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 reading GenericInst constants in portable pdbs #729

Merged
merged 2 commits into from
Mar 13, 2021
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
2 changes: 1 addition & 1 deletion Mono.Cecil/AssemblyReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3013,7 +3013,7 @@ ConstantDebugInformation ReadLocalConstant (uint rid)
value = new decimal (signature.ReadInt32 (), signature.ReadInt32 (), signature.ReadInt32 (), (b & 0x80) != 0, (byte) (b & 0x7f));
} else if (type.IsTypeOf ("System", "DateTime")) {
value = new DateTime (signature.ReadInt64());
} else if (type.etype == ElementType.Object || type.etype == ElementType.None || type.etype == ElementType.Class || type.etype == ElementType.Array) {
} else if (type.etype == ElementType.Object || type.etype == ElementType.None || type.etype == ElementType.Class || type.etype == ElementType.Array || type.etype == ElementType.GenericInst) {
value = null;
} else
value = signature.ReadConstantSignature (type.etype);
Expand Down
18 changes: 18 additions & 0 deletions Test/Mono.Cecil.Tests/PortablePdbTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,24 @@ public void InvalidConstantRecord ()
}
}

[Test]
public void GenericInstConstantRecord ()
{
using (var module = GetResourceModule ("ReproConstGenericInst.dll", new ReaderParameters { SymbolReaderProvider = new PortablePdbReaderProvider () })) {
var type = module.GetType ("ReproConstGenericInst.Program");
var method = type.GetMethod ("Main");
var symbol = method.DebugInformation;

Assert.IsNotNull (symbol);
Assert.AreEqual (1, symbol.Scope.Constants.Count);

var list = symbol.Scope.Constants [0];
Assert.AreEqual ("list", list.Name);

Assert.AreEqual ("System.Collections.Generic.List`1<System.String>", list.ConstantType.FullName);
}
}

[Test]
public void SourceLink ()
{
Expand Down
Binary file not shown.
Binary file not shown.