Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix System.Reflection.Emit SetChecksum creating invalid pdb #110097

Merged
merged 2 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading