From e052ab52e44fd2a6564964e47e79929068731916 Mon Sep 17 00:00:00 2001 From: Steve Gilham Date: Thu, 29 Sep 2022 22:59:52 +0100 Subject: [PATCH] Address issue #873 (#874) * 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 --- Mono.Cecil/AssemblyWriter.cs | 1 + Test/Mono.Cecil.Tests/PortablePdbTests.cs | 17 +++++++++++++++++ Test/Resources/assemblies/NullConst.dll | Bin 0 -> 5120 bytes Test/Resources/assemblies/NullConst.pdb | Bin 0 -> 10424 bytes 4 files changed, 18 insertions(+) create mode 100644 Test/Resources/assemblies/NullConst.dll create mode 100644 Test/Resources/assemblies/NullConst.pdb 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 0000000000000000000000000000000000000000..7c58453c4d35c0af1b856daa7406dc807b420217 GIT binary patch literal 5120 zcmeHKeQZ_b8GlYGwI8$tu>=Ow!v(h%=;BqWRo!Nn+3*zbMsxgRYK z{CA5_`+hvn^E=P`Jn!doH{7#}rV&vw%9SfbhtYCs5%smJ38<@Xd9jKPl^tJrSn4{y zuzy5%+R=|pGfX^$4`&LBL$&iT>m|zfhfu7V`XVk=RhQkHVD3v364GgzR6;vN9in;CSFmGwc)heA z^}W(X)RI5heBQVv{x_4(k|E6#{a%^NAE!^~_u%gn+;)n?u0(2vn|oQu;m*>n>1e7cBw5&fI0sd$2N#3NaZvALIdnoo5(h9h1^IfxGL z7xRi!q)T_)!3GL#uo9lZnkkxgT$WVYEyG}%t6Qd{bTX6Kx|UV-d8Vr;8HHKg8y;5U z25WV(YH`nH)UVpZ%w323fNizx(Y&JFN~Ux};1s43Y)^a(CJ+OSGT~r;oXpJAqS4~k+8>J-BxBL$ls0Up=uG3r)onM7v?7gl}E& zebLqizODH#TpIiFL&c58@;e&FK0f)uwly!+4W57dmCf5f+r!Q_8-JRA{PlhNqNnd% z@!Ek{*Uw(Od;YTIm5ayfs!p~4=$W^-A8~@^olk9R-Se-VuLL&V@_z09(%$>us($#+ z!S^bTw!b-J-|8cG&G>BO&*@Ju{5t)eu{GzuHIpt>@A+unnX zmF2R`VJT+2=}z17QV`0ZP><)PJhwlcV$B`nEL2~>`-myKy4hqd91GP?mHY5WGG*wR z?hZKoDr;sYKO>>~DPkYYw=LJ_U^xK?gzB$$S;!+eq?4lPNXA(r!4iGUu{>L2a>UdO zFTt7uQx8T!uFr=4-#^M9g#x(0<@2VmMj^}s&nnAB0DNgMB-X1UvtAyb898&R*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