diff options
author | Simon Cropp <simon.cropp@gmail.com> | 2020-01-31 20:18:23 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-31 20:18:23 +0300 |
commit | 933575cbd7c9e306439cefcd171785e9f7280c55 (patch) | |
tree | e4ecb029cee05a9a5cd25b25d718b2aade1bf153 | |
parent | 0a2f2944638c13987d8a2318bc34bd64fdac55fd (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.cs | 2 | ||||
-rw-r--r-- | Test/Mono.Cecil.Tests/ImageReadTests.cs | 14 | ||||
-rw-r--r-- | Test/Resources/assemblies/LocallyScopedConstantArray.dll | bin | 0 -> 4096 bytes | |||
-rw-r--r-- | Test/Resources/assemblies/LocallyScopedConstantArray.pdb | bin | 0 -> 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 Binary files differnew file mode 100644 index 0000000..ae5eaf4 --- /dev/null +++ b/Test/Resources/assemblies/LocallyScopedConstantArray.dll diff --git a/Test/Resources/assemblies/LocallyScopedConstantArray.pdb b/Test/Resources/assemblies/LocallyScopedConstantArray.pdb Binary files differnew file mode 100644 index 0000000..eea50b9 --- /dev/null +++ b/Test/Resources/assemblies/LocallyScopedConstantArray.pdb |