# How to debug Elements Mono.Cecil.SignatureWriter.WriteTypeSignature

**URL:** https://talk.remobjects.com/t/how-to-debug-elements-mono-cecil-signaturewriter-writetypesignature/26950
**Category:** Fire
**Tags:** silver
**Created:** [July 19, 2022, 1:33am UTC](https://talk.remobjects.com/t/how-to-debug-elements-mono-cecil-signaturewriter-writetypesignature/26950 "2022-07-19T01:33:21Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![hggz](https://talk.remobjects.com/user_avatar/talk.remobjects.com/hggz/32/15674_2.png) [@hggz](https://talk.remobjects.com/u/hggz)
#### Post date: [July 19, 2022, 1:33am UTC](https://talk.remobjects.com/t/how-to-debug-elements-mono-cecil-signaturewriter-writetypesignature/26950/1 "2022-07-19T01:33:21Z")

</div>

So after finally getting the bandwidth, I’m proceeding on the great journey to migrate my infrastructure to a unified state that leverages silver for mono platforms. One such piece of this is generous with it’s usages of generics and Its one of the corner stones of my infrastructure.

I have it compiling on all platforms but its failing at the last stage of compilation with silver. I’m getting an error that only appears in the build stage:

```auto
E: Error while generating executable: System.ArgumentNullException: Value cannot be null.
  at Mono.Cecil.SignatureWriter.WriteTypeSignature (Mono.Cecil.TypeReference type) [0x00004] in <6dcf4a273260406485a54d4b20324388>:0 
  at Mono.Cecil.SignatureWriter.WriteGenericInstanceSignature (Mono.Cecil.IGenericInstance instance) [0x00022] in <6dcf4a273260406485a54d4b20324388>:0 
  at Mono.Cecil.MetadataBuilder.GetMethodSpecSignature (Mono.Cecil.MethodSpecification method_spec) [0x00027] in <6dcf4a273260406485a54d4b20324388>:0 
  at Mono.Cecil.MetadataBuilder.CreateMethodSpecRow (Mono.Cecil.MethodSpecification method_spec) [0x00017] in <6dcf4a273260406485a54d4b20324388>:0 
  at Mono.Cecil.MetadataBuilder.GetMethodSpecToken (Mono.Cecil.MethodSpecification method_spec) [0x00000] in <6dcf4a273260406485a54d4b20324388>:0 
  at Mono.Cecil.MetadataBuilder.LookupToken (Mono.Cecil.IMetadataTokenProvider provider) [0x000ba] in <6dcf4a273260406485a54d4b20324388>:0 
  at Mono.Cecil.Cil.CodeWriter.WriteOperand (Mono.Cecil.Cil.Instruction instruction) [0x00287] in <6dcf4a273260406485a54d4b20324388>:0 
  at Mono.Cecil.Cil.CodeWriter.WriteInstructions () [0x00030] in <6dcf4a273260406485a54d4b20324388>:0 
  at Mono.Cecil.Cil.CodeWriter.WriteResolvedMethodBody (Mono.Cecil.MethodDefinition method) [0x0002e] in <6dcf4a273260406485a54d4b20324388>:0 
  at Mono.Cecil.Cil.CodeWriter.WriteMethodBody (Mono.Cecil.MethodDefinition method) [0x0002c] in <6dcf4a273260406485a54d4b20324388>:0 
  at Mono.Cecil.MetadataBuilder.AddMethod (Mono.Cecil.MethodDefinition method) [0x00013] in <6dcf4a273260406485a54d4b20324388>:0 
  at Mono.Cecil.MetadataBuilder.AddMethods (Mono.Cecil.TypeDefinition type) [0x00013] in <6dcf4a273260406485a54d4b20324388>:0 
  at Mono.Cecil.MetadataBuilder.AddType (Mono.Cecil.TypeDefinition type) [0x000a7] in <6dcf4a273260406485a54d4b20324388>:0 
  at Mono.Cecil.MetadataBuilder.AddTypes () [0x00018] in <6dcf4a273260406485a54d4b20324388>:0 
  at Mono.Cecil.MetadataBuilder.BuildTypes () [0x00017] in <6dcf4a273260406485a54d4b20324388>:0 
  at Mono.Cecil.MetadataBuilder.BuildModule () [0x000a2] in <6dcf4a273260406485a54d4b20324388>:0 
  at Mono.Cecil.MetadataBuilder.BuildMetadata () [0x00000] in <6dcf4a273260406485a54d4b20324388>:0 
  at Mono.Cecil.ModuleWriter.BuildMetadata (Mono.Cecil.ModuleDefinition module, Mono.Cecil.MetadataBuilder metadata) [0x0000b] in <6dcf4a273260406485a54d4b20324388>:0 
  at Mono.Cecil.ModuleWriter.Write (Mono.Cecil.ModuleDefinition module, Mono.Disposable`1[T] stream, Mono.Cecil.WriterParameters parameters) [0x00106] in <6dcf4a273260406485a54d4b20324388>:0 
  at Mono.Cecil.ModuleWriter.WriteModule (Mono.Cecil.ModuleDefinition module, Mono.Disposable`1[T] stream, Mono.Cecil.WriterParameters parameters) [0x00002] in <6dcf4a273260406485a54d4b20324388>:0 
  at Mono.Cecil.ModuleDefinition.Write (System.String fileName, Mono.Cecil.WriterParameters parameters) [0x00017] in <6dcf4a273260406485a54d4b20324388>:0 
  at E.b (System.IO.Stream a) [0x001c3] in <c1b9d202b83345148b1cda18390f3c99>:0 

```

Before diving too deep into assessing any work arounds I wanted to see if I could reach out here first. Any tips on how to debug this other than to start trying to clear out and adjust some of my generic members until I find the culprit?

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [July 19, 2022, 10:02am UTC](https://talk.remobjects.com/t/how-to-debug-elements-mono-cecil-signaturewriter-writetypesignature/26950/2 "2022-07-19T10:02:44Z")

</div>

That’s a compiler bug, by definition. Can we see the/a project that shows this? thanx!

---

<div class="post-metadata">

### Author: ![hggz](https://talk.remobjects.com/user_avatar/talk.remobjects.com/hggz/32/15674_2.png) [@hggz](https://talk.remobjects.com/u/hggz)
#### Post date: [July 19, 2022, 5:01pm UTC](https://talk.remobjects.com/t/how-to-debug-elements-mono-cecil-signaturewriter-writetypesignature/26950/3 "2022-07-19T17:01:01Z")

</div>

@mh here’s a sample project I made to illustrate these issues. I was going to try to work around it and try to rewrite the problem area but if you guys can identify the bug and fix it that would also work!

The Elements project is located under the `Backends/RemObjects/Warbler` directory. The Problem sources are located in the `Sources/Warbler/Modules/Core/` directory.

This does compile fine on other platforms and doesn’t report any errors in the Fire editor until the final build stage.

[RemObjectGenericTest.zip](https://talk.remobjects.com/uploads/short-url/tfZU5XRSIwbUkFGzOFeeiaDicp6.zip) (823.7 KB)

For what it’s worth, the problem code is probably around the EventEmitter code. I did notice I had to extract certain inner classes that were embedded in there, outside, for me to resolve some errors being reported. Cheers!

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [July 19, 2022, 5:03pm UTC](https://talk.remobjects.com/t/how-to-debug-elements-mono-cecil-signaturewriter-writetypesignature/26950/4 "2022-07-19T17:03:08Z")

</div>

> [@hggz](#):
>
> [RemObjectGenericTest.zip](https://talk.remobjects.com/uploads/short-url/tfZU5XRSIwbUkFGzOFeeiaDicp6.zip) (823.7 KB)
> 
> For what it’s worth, the problem code is probably around the EventEmitter code. I did notice I had to extract certain inner classes that were embedded in there, outside, for me to resolve some errors being reported. Cheers!

Reproduced, thanx!

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [July 19, 2022, 5:04pm UTC](https://talk.remobjects.com/t/how-to-debug-elements-mono-cecil-signaturewriter-writetypesignature/26950/5 "2022-07-19T17:04:02Z")

</div>

Logged as [bugs://E26014](https://www.remobjects.com/portal/bugs/?id=E26014).

---

<div class="post-metadata">

### Author: ![hggz](https://talk.remobjects.com/user_avatar/talk.remobjects.com/hggz/32/15674_2.png) [@hggz](https://talk.remobjects.com/u/hggz)
#### Post date: [July 19, 2022, 6:23pm UTC](https://talk.remobjects.com/t/how-to-debug-elements-mono-cecil-signaturewriter-writetypesignature/26950/6 "2022-07-19T18:23:27Z")

</div>

The bug is definitely in the `SingleEventEmitter` source file - extension mapping function - line 46

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [July 19, 2022, 6:45pm UTC](https://talk.remobjects.com/t/how-to-debug-elements-mono-cecil-signaturewriter-writetypesignature/26950/7 "2022-07-19T18:45:04Z")

</div>

> [@hggz](#):
>
> The bug is definitely in the `SingleEventEmitter` source file - extension mapping function

Thanx, thats definitely helps. That said i’m sure the team will have this narrowed down quickly once its being debugged.

---

<div class="post-metadata">

### Author: ![hggz](https://talk.remobjects.com/user_avatar/talk.remobjects.com/hggz/32/15674_2.png) [@hggz](https://talk.remobjects.com/u/hggz)
#### Post date: [July 19, 2022, 7:03pm UTC](https://talk.remobjects.com/t/how-to-debug-elements-mono-cecil-signaturewriter-writetypesignature/26950/8 "2022-07-19T19:03:49Z")

</div>

At first glance my tests seem to pass without that subscribe call thats breaking…I’ll do a bit more testing but I wonder if its even necessary to account for this type of edge case. Do with it as you guys please 🙂

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [July 19, 2022, 7:34pm UTC](https://talk.remobjects.com/t/how-to-debug-elements-mono-cecil-signaturewriter-writetypesignature/26950/9 "2022-07-19T19:34:43Z")

</div>

[bugs://E26014](https://www.remobjects.com/portal/bugs/?id=E26014) was closed as fixed.

---

<div class="post-metadata">

### Author: ![hggz](https://talk.remobjects.com/user_avatar/talk.remobjects.com/hggz/32/15674_2.png) [@hggz](https://talk.remobjects.com/u/hggz)
#### Post date: [July 19, 2022, 8:35pm UTC](https://talk.remobjects.com/t/how-to-debug-elements-mono-cecil-signaturewriter-writetypesignature/26950/10 "2022-07-19T20:35:52Z")

</div>

Definitely needed this bit to avoid more involved side effects. I’m seeing what I can do in the interim unless the resolution fixes it

---

<div class="post-metadata">

### Author: ![mh](https://talk.remobjects.com/user_avatar/talk.remobjects.com/mh/32/18050_2.png) [@mh](https://talk.remobjects.com/u/mh)
#### Post date: [July 19, 2022, 9:08pm UTC](https://talk.remobjects.com/t/how-to-debug-elements-mono-cecil-signaturewriter-writetypesignature/26950/11 "2022-07-19T21:08:58Z")

</div>

i can get you a new build tomorrow.

---

<div class="post-metadata">

### Author: ![hggz](https://talk.remobjects.com/user_avatar/talk.remobjects.com/hggz/32/15674_2.png) [@hggz](https://talk.remobjects.com/u/hggz)
#### Post date: [July 19, 2022, 9:31pm UTC](https://talk.remobjects.com/t/how-to-debug-elements-mono-cecil-signaturewriter-writetypesignature/26950/12 "2022-07-19T21:31:55Z")

</div>

Thank you, there is no rush. I got it working by representing the listener block as an explicit closure instead of an inlined function declaration.
