Skip to content

Commit

Permalink
Fix document checksums in emitted pdbs (#110205)
Browse files Browse the repository at this point in the history
Co-authored-by: Tim Jones <[email protected]>
  • Loading branch information
github-actions[bot] and tgjones authored Dec 17, 2024
1 parent 43515e5 commit 2690c5f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ private DocumentHandle AddDocument(string url, Guid language, Guid hashAlgorithm
_pdbBuilder.AddDocument(
name: _pdbBuilder.GetOrAddDocumentName(url),
hashAlgorithm: hashAlgorithm == default ? default : _pdbBuilder.GetOrAddGuid(hashAlgorithm),
hash: hash == null ? default : _metadataBuilder.GetOrAddBlob(hash),
hash: hash == null ? default : _pdbBuilder.GetOrAddBlob(hash),
language: language == default ? default : _pdbBuilder.GetOrAddGuid(language));

private void FillMemberReferences(ILGeneratorImpl il)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ private static void ValidatePDB(MethodBuilder method, MethodBuilder entryPoint,
Document doc = reader.GetDocument(docEnumerator.Current);
Assert.Equal("MySourceFile.cs", reader.GetString(doc.Name));
Assert.Equal(SymLanguageType.CSharp, reader.GetGuid(doc.Language));
Assert.Equal(default, reader.GetGuid(doc.HashAlgorithm));
Assert.Equal(new Guid("8829d00f-11b8-4213-878b-770e8597ac16"), reader.GetGuid(doc.HashAlgorithm));
Assert.Equal("06CBAB3A501306FDD9176A00A83E5BB92EA4D7863CFD666355743527CF99EDC6", Convert.ToHexString(reader.GetBlobBytes(doc.Hash)));
Assert.False(docEnumerator.MoveNext());

MethodDebugInformation mdi1 = reader.GetMethodDebugInformation(MetadataTokens.MethodDebugInformationHandle(method.MetadataToken));
Expand Down Expand Up @@ -147,6 +148,7 @@ private static MetadataBuilder GenerateAssemblyAndMetadata(out MethodBuilder met
ModuleBuilder mb = ab.DefineDynamicModule("MyModule2");
TypeBuilder tb = mb.DefineType("MyType", TypeAttributes.Public | TypeAttributes.Class);
ISymbolDocumentWriter srcdoc = mb.DefineDocument("MySourceFile.cs", SymLanguageType.CSharp);
srcdoc.SetCheckSum(new Guid("8829d00f-11b8-4213-878b-770e8597ac16"), Convert.FromHexString("06CBAB3A501306FDD9176A00A83E5BB92EA4D7863CFD666355743527CF99EDC6"));
method = tb.DefineMethod("SumMethod", MethodAttributes.Public | MethodAttributes.Static, typeof(int), [typeof(int), typeof(int)]);
ILGenerator il1 = method.GetILGenerator();
LocalBuilder local = il1.DeclareLocal(typeof(int));
Expand Down

0 comments on commit 2690c5f

Please sign in to comment.