You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
System:
System: Tested on Arch Linux x64
Kernel: 5.5.11-arch1-1
DotNet Version: 3.1.103
AsmResolver Branch: v4
Summary
The ModuleDefinition class already provides functionality to automatically create a global static constructor with the method GetOrCreateStaticConstructor() .
However, this only works, if the type is already present, otherwise GetModuleType() returns null.
Run the code, and observe that AsmResolver throws a NullReferenceException exception, because GetModuleType() just returns null, if the type is not present:
public TypeDefinition GetModuleType()=> TopLevelTypes.Count >0? TopLevelTypes[0]:null;
See: ModuleDefinition.cs (L.596)
Suggestion:
Either modify GetModuleType() to GetOrCreateModuleType(), or add a second method with that functionality.
If there is already a shortcut to create a static module type constructor, there should also be a shortcut to create the global module type itself, if not present.
The text was updated successfully, but these errors were encountered:
System:
System: Tested on Arch Linux x64
Kernel: 5.5.11-arch1-1
DotNet Version: 3.1.103
AsmResolver Branch: v4
Summary
The ModuleDefinition class already provides functionality to automatically create a global static constructor with the method
GetOrCreateStaticConstructor()
.However, this only works, if the type is already present, otherwise
GetModuleType()
returnsnull
.Steps to reproduce:
GetModuleType()
just returnsnull
, if the type is not present:See: ModuleDefinition.cs (L.596)
Suggestion:
Either modify GetModuleType() to GetOrCreateModuleType(), or add a second method with that functionality.
If there is already a shortcut to create a static module type constructor, there should also be a shortcut to create the global module type itself, if not present.
The text was updated successfully, but these errors were encountered: