Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/cecil.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJb Evain <jb@evain.net>2021-03-13 04:36:32 +0300
committerGitHub <noreply@github.com>2021-03-13 04:36:32 +0300
commit553506adb74b1edbc12a8fb8cd681dcc93f180cf (patch)
tree1c8c0c1ebfed8a981d781875c25d87c8f32b8678
parent3c4ea3f8f4fcb688194f5f1e501ab01642d4bdf4 (diff)
Fix reading GenericInst constants in portable pdbs (#729)
* Fix reading GenericInst constants in portable pdbs * Add test
-rw-r--r--Mono.Cecil/AssemblyReader.cs2
-rw-r--r--Test/Mono.Cecil.Tests/PortablePdbTests.cs18
-rw-r--r--Test/Resources/assemblies/ReproConstGenericInst.dllbin0 -> 4608 bytes
-rw-r--r--Test/Resources/assemblies/ReproConstGenericInst.pdbbin0 -> 9564 bytes
4 files changed, 19 insertions, 1 deletions
diff --git a/Mono.Cecil/AssemblyReader.cs b/Mono.Cecil/AssemblyReader.cs
index d18a51e..2a59358 100644
--- a/Mono.Cecil/AssemblyReader.cs
+++ b/Mono.Cecil/AssemblyReader.cs
@@ -3013,7 +3013,7 @@ namespace Mono.Cecil {
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);
diff --git a/Test/Mono.Cecil.Tests/PortablePdbTests.cs b/Test/Mono.Cecil.Tests/PortablePdbTests.cs
index fc0516e..b0c1f32 100644
--- a/Test/Mono.Cecil.Tests/PortablePdbTests.cs
+++ b/Test/Mono.Cecil.Tests/PortablePdbTests.cs
@@ -457,6 +457,24 @@ namespace Mono.Cecil.Tests {
}
[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 ()
{
TestModule ("TargetLib.dll", module => {
diff --git a/Test/Resources/assemblies/ReproConstGenericInst.dll b/Test/Resources/assemblies/ReproConstGenericInst.dll
new file mode 100644
index 0000000..4fce084
--- /dev/null
+++ b/Test/Resources/assemblies/ReproConstGenericInst.dll
Binary files differ
diff --git a/Test/Resources/assemblies/ReproConstGenericInst.pdb b/Test/Resources/assemblies/ReproConstGenericInst.pdb
new file mode 100644
index 0000000..7e564b5
--- /dev/null
+++ b/Test/Resources/assemblies/ReproConstGenericInst.pdb
Binary files differ