diff --git a/Mono.Cecil/AssemblyWriter.cs b/Mono.Cecil/AssemblyWriter.cs index 9972c12ed..df8afdcc8 100644 --- a/Mono.Cecil/AssemblyWriter.cs +++ b/Mono.Cecil/AssemblyWriter.cs @@ -2192,6 +2192,7 @@ SignatureWriter GetConstantSignature (ElementType type, object value) case ElementType.None: case ElementType.Var: case ElementType.MVar: + case ElementType.GenericInst: signature.WriteInt32 (0); break; case ElementType.String: diff --git a/Test/Mono.Cecil.Tests/PortablePdbTests.cs b/Test/Mono.Cecil.Tests/PortablePdbTests.cs index 3aa0ffce8..a89f79d83 100644 --- a/Test/Mono.Cecil.Tests/PortablePdbTests.cs +++ b/Test/Mono.Cecil.Tests/PortablePdbTests.cs @@ -453,6 +453,23 @@ public void NullClassConstant () }, symbolReaderProvider: typeof (PortablePdbReaderProvider), symbolWriterProvider: typeof (PortablePdbWriterProvider)); } + [Test] + public void NullGenericInstConstant () + { + TestModule ("NullConst.dll", module => { + var type = module.GetType ("NullConst.Program"); + var method = type.GetMethod ("MakeConst"); + var symbol = method.DebugInformation; + + Assert.IsNotNull (symbol); + Assert.AreEqual (1, symbol.Scope.Constants.Count); + + var a = symbol.Scope.Constants [0]; + Assert.AreEqual ("thing", a.Name); + Assert.AreEqual (null, a.Value); + }, verify: false, symbolReaderProvider: typeof (PortablePdbReaderProvider), symbolWriterProvider: typeof (PortablePdbWriterProvider)); + } + [Test] public void InvalidConstantRecord () { diff --git a/Test/Resources/assemblies/NullConst.dll b/Test/Resources/assemblies/NullConst.dll new file mode 100644 index 000000000..7c58453c4 Binary files /dev/null and b/Test/Resources/assemblies/NullConst.dll differ diff --git a/Test/Resources/assemblies/NullConst.pdb b/Test/Resources/assemblies/NullConst.pdb new file mode 100644 index 000000000..e70f2c2f9 Binary files /dev/null and b/Test/Resources/assemblies/NullConst.pdb differ