Repository navigation
Map old symbols to baseline - #86453
Conversation
|
Azure Pipelines: Successfully started running 2 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
|
This PR modifies public API files. Please follow the instructions at https://github.com/dotnet/roslyn/blob/main/docs/contributing/API%20Review%20Process.md for ensuring all public APIs are reviewed before merging. |
There was a problem hiding this comment.
🟡 Changes recommended
The new tests leave closure cleanup after a compilation-only advance untested, so coverage is needed to verify that removed lambdas receive throwing bodies and retained lambdas reuse their metadata handles.
1 open issue
What changed in this PR
This PR addresses Hot Reload failures when the preceding solution snapshot is newer than a project’s emit baseline, as reported in #79898. It maps old symbols to the baseline for metadata lookup while retaining the original symbols for syntax-offset calculations.
Changes:
- Add baseline symbol mapping for deleted and updated members in C# and Visual Basic.
- Add compiler and workspace regression tests for compilation advances without emitted deltas.
- Clarify symbol ownership and make
SemanticEdit.NewSymbolnon-nullable.
| File | Description |
|---|---|
src/Test/PdbUtilities/EditAndContinue/EditAndContinueTest.cs |
Adds a helper to advance compilation without emitting a delta. |
src/Features/Test/EditAndContinue/EditAndContinueWorkspaceServiceTests.cs |
Tests method deletion after a dependency-only update. |
src/Compilers/VisualBasic/Test/Emit/Emit/EditAndContinue/EditAndContinueTests.vb |
Adds Visual Basic coverage for old symbols newer than the baseline. |
src/Compilers/VisualBasic/Portable/Emit/EditAndContinue/VisualBasicDefinitionMap.vb |
Creates Visual Basic matchers targeting the baseline compilation. |
src/Compilers/CSharp/Test/Emit2/Emit/EditAndContinue/EditAndContinueTests.cs |
Adds C# regression coverage with metadata assertions. |
src/Compilers/CSharp/Portable/Emitter/EditAndContinue/CSharpDefinitionMap.cs |
Creates C# matchers targeting the baseline compilation. |
src/Compilers/Core/Portable/PublicAPI.Unshipped.txt |
Records the non-nullable NewSymbol annotation. |
src/Compilers/Core/Portable/Emit/SemanticEdit.cs |
Clarifies compilation ownership and updates NewSymbol nullability. |
src/Compilers/Core/Portable/Emit/EditAndContinue/SymbolMatcher.cs |
Clarifies local names in definition remapping without changing behavior. |
src/Compilers/Core/Portable/Emit/EditAndContinue/SymbolChanges.cs |
Maps deleted and updated old symbols to baseline symbols. |
src/Compilers/Core/Portable/Emit/EditAndContinue/EncVariableSlotAllocator.cs |
Uses the renamed preceding-compilation method field for syntax offsets. |
src/Compilers/Core/Portable/Emit/EditAndContinue/EncMappedMethod.cs |
Renames and documents the method retained for syntax calculations. |
src/Compilers/Core/Portable/Emit/EditAndContinue/EmitBaseline.cs |
Documents accumulated symbol definitions and stable row IDs. |
src/Compilers/Core/Portable/Emit/EditAndContinue/DefinitionMap.cs |
Adds cached baseline-source mapping and clarifies handle-lookup documentation. |
Review effort: Balanced
…or symbol mapping The IDE creates SemanticEdits from the immediately preceding compilation (old) and the current compilation (new). The emit baseline however might be for an older generation than the immediately preceding generation. This occurs when no semantically significant changes are applied to the project while other projects are semantically changed. The entire solution advances to the next snapshot but baselines are emitted only for projects with significant changes. If SemanticEdit.OldSymbol is used by the compiler for syntax offset mapping it is correct to use it as is. If it is stored in various baseline maps or used for symbol mapping the compiler needs to map it to the baseline compilation beforehand.
333fred
left a comment
There was a problem hiding this comment.
Generally LGTM, just a question and a comment
333fred
left a comment
There was a problem hiding this comment.
@dotnet/roslyn-compiler for a second review

Map old symbols specified in SemanticEdit to the baseline when used for symbol mapping
The IDE creates SemanticEdits from the immediately preceding compilation (old) and the current compilation (new). The emit baseline however might be for an older generation than the immediately preceding generation. This occurs when no semantically significant changes are applied to the project while other projects are semantically changed. The entire solution advances to the next snapshot but baselines are emitted only for projects with significant changes.
If SemanticEdit.OldSymbol is used by the compiler for syntax offset mapping it is correct to use it as is.
If it is stored in various baseline maps or used for symbol mapping the compiler needs to map it to the baseline compilation beforehand.
Fixes #79898
Microsoft Reviewers: Open in CodeFlow