Skip to content

Fix Hot Reload checksum mismatch for files without UTF-8 BOM#81480

Closed
noiseonwires wants to merge 1 commit intodotnet:mainfrom
noiseonwires:pdb_matchin_hash_bom_fix
Closed

Fix Hot Reload checksum mismatch for files without UTF-8 BOM#81480
noiseonwires wants to merge 1 commit intodotnet:mainfrom
noiseonwires:pdb_matchin_hash_bom_fix

Conversation

@noiseonwires
Copy link

When validating source files against PDB checksums during Hot Reload, try multiple UTF-8 encoding configurations without BOM to find a matching checksum.

This fixes ENC1008 errors that occur when files are created without a BOM (e.g., by VS Code) but Roslyn
assumes UTF-8 with BOM for checksum calculation (AzDO#2067885).

Please see my comment in roslyn/src/Features/Core/Portable/EditAndContinue/CommittedSolution.cs that explains how it happens.

See also: #63583

@noiseonwires noiseonwires requested a review from a team as a code owner November 28, 2025 20:24
@dotnet-policy-service dotnet-policy-service bot added Community The pull request was submitted by a contributor who is not a Microsoft employee. VSCode labels Nov 28, 2025
@noiseonwires
Copy link
Author

@tmat could you please take a look?

// So by default it always calculates the checksum as BOM is present,
// and if the file is saved without BOM, it will not match the baseline checksum in PDB.
// In case if the current file is saved without BOM, it will cause the whole project marked is stale.
// This is a workaround to handle this specific scenario.
Copy link
Member

Choose a reason for hiding this comment

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

It seems like the core of the issue is in LSP server. I'd rather push on getting fix there. This workaround does not address other encodings people might use.

Copy link
Author

@noiseonwires noiseonwires Dec 4, 2025

Choose a reason for hiding this comment

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

So far, here Roslyn supports only UTF-8.

LSP protocol (and types like DidOpenTextDocumentParams) doesn't have encoding data (already discussed in #63583), so this will probably require much more massive work to be done.

Here we can apply the fallback if we see that checksum check failed. TBH I don't have any clear picture of how we can do something similar in LanguageServer (until we get encoding data from IDE, that will require also updating LSP clients in IDEs).

@tmat
Copy link
Member

tmat commented Jan 8, 2026

Superseded by #81933

@tmat tmat closed this Jan 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-IDE Community The pull request was submitted by a contributor who is not a Microsoft employee. VSCode

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants