question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Crash reading fields of type with local method and dynamic local

See original GitHub issue

If you have a dynamic local inside a local method, cecil crashes reading the fields of the compiler generated type.

Expected output of repro project

F:/Unity/dev/TestGround/DyanmicAndLocalMethodRepro/DyanmicAndLocalMethodRepro/bin/Debug/DyanmicAndLocalMethodRepro.exe
DyanmicAndLocalMethodRepro.Program/DynamicInNormalMethod
DyanmicAndLocalMethodRepro.Program/DynamicInNormalMethod/<>o__1`2
System.Runtime.CompilerServices.CallSite`1<System.Func`4<System.Runtime.CompilerServices.CallSite,System.Object,System.Object,System.Object>> DyanmicAndLocalMethodRepro.Program/DynamicInNormalMethod/<>o__1`2::<>p__0
System.Runtime.CompilerServices.CallSite`1<System.Func`3<System.Runtime.CompilerServices.CallSite,System.Object,System.Boolean>> DyanmicAndLocalMethodRepro.Program/DynamicInNormalMethod/<>o__1`2::<>p__1
System.Runtime.CompilerServices.CallSite`1<System.Func`3<System.Runtime.CompilerServices.CallSite,System.Object,T2>> DyanmicAndLocalMethodRepro.Program/DynamicInNormalMethod/<>o__1`2::<>p__2
DyanmicAndLocalMethodRepro.Program/NoDynamicLocalMethod
DyanmicAndLocalMethodRepro.Program/DynamicInsideLocalMethod
DyanmicAndLocalMethodRepro.Program/DynamicInsideLocalMethod/<>o__0

Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
   at Mono.Cecil.SignatureReader.GetGenericParameter(GenericParameterType type, UInt32 var)
   at Mono.Cecil.SignatureReader.ReadTypeSignature(ElementType etype)
   at Mono.Cecil.SignatureReader.ReadGenericInstanceSignature(IGenericParameterProvider provider, IGenericInstance instance, UInt32 arity)
   at Mono.Cecil.SignatureReader.ReadTypeSignature(ElementType etype)
   at Mono.Cecil.SignatureReader.ReadGenericInstanceSignature(IGenericParameterProvider provider, IGenericInstance instance, UInt32 arity)
   at Mono.Cecil.SignatureReader.ReadTypeSignature(ElementType etype)
   at Mono.Cecil.MetadataReader.ReadFieldType(UInt32 signature)
   at Mono.Cecil.MetadataReader.ReadField(UInt32 field_rid, Collection`1 fields)
   at Mono.Cecil.MetadataReader.ReadFields(TypeDefinition type)
   at Mono.Cecil.TypeDefinition.<>c.<get_Fields>b__47_0(TypeDefinition type, MetadataReader reader)
   at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TRet& variable, TItem item, Func`3 read)
   at Mono.Cecil.TypeDefinition.get_Fields()
   at DyanmicAndLocalMethodRepro.Program.IterateAllFields(TypeDefinition type) in F:\Unity\dev\TestGround\DyanmicAndLocalMethodRepro\DyanmicAndLocalMethodRepro\Program.cs:line 30
   at DyanmicAndLocalMethodRepro.Program.IterateAllFields(TypeDefinition type) in F:\Unity\dev\TestGround\DyanmicAndLocalMethodRepro\DyanmicAndLocalMethodRepro\Program.cs:line 33
   at DyanmicAndLocalMethodRepro.Program.Main(String[] args) in F:\Unity\dev\TestGround\DyanmicAndLocalMethodRepro\DyanmicAndLocalMethodRepro\Program.cs:line 23

DyanmicAndLocalMethodRepro.zip

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jbevaincommented, Feb 25, 2020

Why are you doing this to me Mike?

0reactions
jbevaincommented, Mar 6, 2020

Closing this then.

Read more comments on GitHub >

github_iconTop Results From Across the Web

C# reusable function to dump current value of local variables
The short answer is: you can't get the values of the local ... want to have the method have to know the specific...
Read more >
Customize your Firebase Crashlytics crash reports
This guide describes how to customize your crash reports using the Firebase Crashlytics SDK. By default, Crashlytics automatically collects crash reports ...
Read more >
5.1.8 Server System Variables
Some variables are read-only, and their values are determined by the system environment, by how MySQL is installed on the system, or possibly...
Read more >
Server System Variables - MariaDB Knowledge Base
Variables that can be changed at runtime are described as "Dynamic" below, ... Data Type: enumerated; Default Value: DEFAULT; Valid Values: DEFAULT ...
Read more >
Express Tutorial Part 3: Using a Database (with Mongoose)
In this article, we've learned a bit about databases and ORMs on Node/Express, and a lot about how Mongoose schema and models are...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found