I have a C# application that uses reflection to enumerate an object's fields:
foreach (FieldInfo field in t.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)
This works just fine, except when I try to produce a single .exe
file with ahead of time compilation, in which case no fields are returned.
I understand that .NET native can strip the metadata required for reflection to work, but haven't been able to find a straight answer to what to do to fix this issue.
So how can I get the fields to appear when using .NET native? I am using Visual Studio 2022.