Skip to content

Map old symbols to baseline - #86453

Merged
tmat merged 3 commits into
dotnet:mainfrom
tmat:empty-updates
Nov 20, 2026
Merged

tmat merged 3 commits into
dotnet:mainfrom
tmat:empty-updates

Conversation

@tmat

@tmat tmat commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

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

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service dotnet-policy-service Bot added VSCode Needs API Review Needs to be reviewed by the API review council labels Nov 13, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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.

@tmat
tmat marked this pull request as ready for review November 13, 2026 03:14
@tmat
tmat requested review from a team as code owners November 13, 2026 03:14
Copilot AI balanced review requested due to automatic review settings November 13, 2026 03:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.NewSymbol non-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.
Copilot AI balanced review requested due to automatic review settings November 13, 2026 03:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the Edit and Continue baseline symbol-mapping change.

1 open issue

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 13, 2026 16:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the Hot Reload baseline-mapping changes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@333fred 333fred left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally LGTM, just a question and a comment

@333fred 333fred left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dotnet/roslyn-compiler for a second review

@tmat
tmat merged commit ff887ba into dotnet:main Nov 20, 2026
26 checks passed
@dotnet-policy-service dotnet-policy-service Bot added this to the Next milestone Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Compilers Needs API Review Needs to be reviewed by the API review council VSCode

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HR fails when requesting an intermediate empty update

4 participants