SergeyTeplyakov / ObjectLayoutInspector

A tool that helps to see an internal structure of the CLR types at runtime
MIT License
678 stars 38 forks source link

Spn<T>/byref-like types support #31

Open controlflow opened 4 years ago

controlflow commented 4 years ago

Unfortunately, byref-like types cannot be used as type arguments...

System.TypeLoadException: The generic type 'SizeComputer`1' was used with an invalid instantiation in assembly 'ObjectLayoutInspector, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
   at System.RuntimeType.MakeGenericType(Type[] instantiation)
   at ObjectLayoutInspector.InspectorHelper.GetSizeOfValueTypeInstance(Type type)
   at ObjectLayoutInspector.InspectorHelper.GetSize(Type type)
   at ObjectLayoutInspector.TypeLayout.<GetLayout>g__DoGetLayout|24_0(<>c__DisplayClass24_0& )
   at ObjectLayoutInspector.TypeLayout.GetLayout(Type type, TypeLayoutCache cache, Boolean includePaddings)

I guess you can emit the "same" type without byref flag...

dzmitry-lahoda commented 4 years ago

is UnsafeLayout also fails?