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:
authorSimon Cropp <simon.cropp@gmail.com>2020-01-31 20:18:23 +0300
committerGitHub <noreply@github.com>2020-01-31 20:18:23 +0300
commit933575cbd7c9e306439cefcd171785e9f7280c55 (patch)
treee4ecb029cee05a9a5cd25b25d718b2aade1bf153
parent0a2f2944638c13987d8a2318bc34bd64fdac55fd (diff)
Fix locally scoped constant array (#644)
* add failing test for LocallyScopedConstantArray * add LocallyScopedConstantArray target assembly * ElementType.Array should be treated the same as object in ReadLocalConstant * assert constant is null * Style fixes Co-authored-by: Jb Evain <jb@evain.net>
-rw-r--r--Mono.Cecil/AssemblyReader.cs2
-rw-r--r--Test/Mono.Cecil.Tests/ImageReadTests.cs14
-rw-r--r--Test/Resources/assemblies/LocallyScopedConstantArray.dllbin0 -> 4096 bytes
-rw-r--r--Test/Resources/assemblies/LocallyScopedConstantArray.pdbbin0 -> 700 bytes
4 files changed, 15 insertions, 1 deletions
diff --git a/Mono.Cecil/AssemblyReader.cs b/Mono.Cecil/AssemblyReader.cs
index b648463..224d8a8 100644
--- a/Mono.Cecil/AssemblyReader.cs
+++ b/Mono.Cecil/AssemblyReader.cs
@@ -3017,7 +3017,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) {
+ } else if (type.etype == ElementType.Object || type.etype == ElementType.None || type.etype == ElementType.Class || type.etype == ElementType.Array) {
value = null;
} else
value = signature.ReadConstantSignature (type.etype);
diff --git a/Test/Mono.Cecil.Tests/ImageReadTests.cs b/Test/Mono.Cecil.Tests/ImageReadTests.cs
index fa5562e..de7a2cc 100644
--- a/Test/Mono.Cecil.Tests/ImageReadTests.cs
+++ b/Test/Mono.Cecil.Tests/ImageReadTests.cs
@@ -208,6 +208,20 @@ namespace Mono.Cecil.Tests {
}
[Test]
+ public void LocallyScopedConstantArray ()
+ {
+ TestModule ("LocallyScopedConstantArray.dll", module => {
+ Assert.IsTrue (module.HasDebugHeader);
+ var method = module.Types
+ .Single (x => x.Name == "TestClass")
+ .Methods
+ .Single (x => x.Name == "TestMethod");
+ var debugInformation = method.DebugInformation;
+ Assert.IsNull (debugInformation.Scope.Constants.Single ().Value);
+ }, symbolReaderProvider: typeof (PortablePdbReaderProvider), symbolWriterProvider: typeof (PortablePdbWriterProvider));
+ }
+
+ [Test]
public void ExternalPdbDeterministicAssembly ()
{
TestModule ("ExternalPdbDeterministic.dll", module => {
diff --git a/Test/Resources/assemblies/LocallyScopedConstantArray.dll b/Test/Resources/assemblies/LocallyScopedConstantArray.dll
new file mode 100644
index 0000000..ae5eaf4
--- /dev/null
+++ b/Test/Resources/assemblies/LocallyScopedConstantArray.dll
Binary files differ
diff --git a/Test/Resources/assemblies/LocallyScopedConstantArray.pdb b/Test/Resources/assemblies/LocallyScopedConstantArray.pdb
new file mode 100644
index 0000000..eea50b9
--- /dev/null
+++ b/Test/Resources/assemblies/LocallyScopedConstantArray.pdb
Binary files differ