diff options
author | Marek Safar <marek.safar@gmail.com> | 2017-04-04 09:53:27 +0300 |
---|---|---|
committer | Marek Safar <marek.safar@gmail.com> | 2017-04-04 09:53:27 +0300 |
commit | 5f93431f2d699e9b090a5a14db5941a18b1e171b (patch) | |
tree | 61b4002d7818cde7449309502319fe950c93721a | |
parent | 4cbf4a8d42cffb460d6394250dad8d81ae411693 (diff) | |
parent | 473362bb224afafee47d93895665028deb4c77aa (diff) |
Merge remote-tracking branch 'upstream/master'
-rw-r--r-- | Mono.Cecil/AssemblyReader.cs | 4 | ||||
-rw-r--r-- | Mono.Cecil/AssemblyWriter.cs | 1 | ||||
-rw-r--r-- | Mono.Cecil/ModuleDefinition.cs | 19 | ||||
-rw-r--r-- | Test/Mono.Cecil.Tests/PortablePdbTests.cs | 16 | ||||
-rw-r--r-- | Test/Resources/assemblies/xattr.dll | bin | 0 -> 3584 bytes | |||
-rw-r--r-- | Test/Resources/assemblies/xattr.pdb | bin | 0 -> 420 bytes |
6 files changed, 24 insertions, 16 deletions
diff --git a/Mono.Cecil/AssemblyReader.cs b/Mono.Cecil/AssemblyReader.cs index 43926c0..654bf48 100644 --- a/Mono.Cecil/AssemblyReader.cs +++ b/Mono.Cecil/AssemblyReader.cs @@ -2986,13 +2986,13 @@ namespace Mono.Cecil { value = Encoding.Unicode.GetString (bytes, 0, bytes.Length); } else value = null; - } else if (type.etype == ElementType.Object) { - value = null; } else if (type.IsTypeOf ("System", "Decimal")) { var b = signature.ReadByte (); 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) { + value = null; } else value = signature.ReadConstantSignature (type.etype); diff --git a/Mono.Cecil/AssemblyWriter.cs b/Mono.Cecil/AssemblyWriter.cs index 1bd8efb..a44a5a1 100644 --- a/Mono.Cecil/AssemblyWriter.cs +++ b/Mono.Cecil/AssemblyWriter.cs @@ -2152,6 +2152,7 @@ namespace Mono.Cecil { case ElementType.SzArray: case ElementType.Class: case ElementType.Object: + case ElementType.None: case ElementType.Var: case ElementType.MVar: signature.WriteInt32 (0); diff --git a/Mono.Cecil/ModuleDefinition.cs b/Mono.Cecil/ModuleDefinition.cs index 42ae73c..1dd9a8c 100644 --- a/Mono.Cecil/ModuleDefinition.cs +++ b/Mono.Cecil/ModuleDefinition.cs @@ -995,19 +995,7 @@ namespace Mono.Cecil { public ImageDebugHeader GetDebugHeader () { - if (!HasDebugHeader) - throw new InvalidOperationException (); - - return Image.DebugHeader; - } - - void ProcessDebugHeader () - { - if (!HasDebugHeader) - return; - - if (!symbol_reader.ProcessDebugHeader (GetDebugHeader ())) - throw new InvalidOperationException (); + return Image.DebugHeader ?? new ImageDebugHeader (); } #if !READ_ONLY @@ -1084,7 +1072,10 @@ namespace Mono.Cecil { symbol_reader = reader; - ProcessDebugHeader (); + if (!symbol_reader.ProcessDebugHeader (GetDebugHeader ())) { + symbol_reader = null; + throw new InvalidOperationException (); + } if (HasImage && ReadingMode == ReadingMode.Immediate) { var immediate_reader = new ImmediateModuleReader (Image); diff --git a/Test/Mono.Cecil.Tests/PortablePdbTests.cs b/Test/Mono.Cecil.Tests/PortablePdbTests.cs index 107b537..1b4c5ec 100644 --- a/Test/Mono.Cecil.Tests/PortablePdbTests.cs +++ b/Test/Mono.Cecil.Tests/PortablePdbTests.cs @@ -388,6 +388,22 @@ namespace Mono.Cecil.Tests { } [Test] + public void NullClassConstant () + { + TestModule ("xattr.dll", module => { + var type = module.GetType ("Library"); + var method = type.GetMethod ("NullXAttributeConstant"); + var symbol = method.DebugInformation; + + Assert.IsNotNull (symbol); + Assert.AreEqual(1, symbol.Scope.Constants.Count); + + var a = symbol.Scope.Constants [0]; + Assert.AreEqual ("a", a.Name); + }, symbolReaderProvider: typeof (PortablePdbReaderProvider), symbolWriterProvider: typeof (PortablePdbWriterProvider)); + } + + [Test] public void PortablePdbLineInfo () { TestModule ("line.exe", module => { diff --git a/Test/Resources/assemblies/xattr.dll b/Test/Resources/assemblies/xattr.dll Binary files differnew file mode 100644 index 0000000..3691397 --- /dev/null +++ b/Test/Resources/assemblies/xattr.dll diff --git a/Test/Resources/assemblies/xattr.pdb b/Test/Resources/assemblies/xattr.pdb Binary files differnew file mode 100644 index 0000000..42d203b --- /dev/null +++ b/Test/Resources/assemblies/xattr.pdb |