Skip to content

Commit

Permalink
Address issue #873 (#874)
Browse files Browse the repository at this point in the history
* Address issue #873

* Be explicit as to what we support writing

* Use normal test infrastructure

* Restore writing primitives

* Restore style

* Can't verify .net core assembly

Co-authored-by: Jb Evain <jb@evain.net>
  • Loading branch information
SteveGilham and jbevain authored Sep 29, 2022
1 parent 92f32da commit e052ab5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions Mono.Cecil/AssemblyWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
17 changes: 17 additions & 0 deletions Test/Mono.Cecil.Tests/PortablePdbTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
{
Expand Down
Binary file added Test/Resources/assemblies/NullConst.dll
Binary file not shown.
Binary file added Test/Resources/assemblies/NullConst.pdb
Binary file not shown.

0 comments on commit e052ab5

Please sign in to comment.