Created attachment 25105 [details]
This is a feature request from C# 7.2 Roslyn which has this new "optimization" which breaks peverify. They are aware of it but consider this to be peverify bug/limitation.
With following code
public enum Type
readonly Type type;
public override string ToString ()
return type.ToString ();
public static void Main ()
attached .exe is generated with 2.6 csc and peverify fails with
Not Verifiable: Cannot take the address of a init-only field at 0x0002
Is there a spec of that change? This sample is not enough to figure out what the new behavior is.
I am not really sure but I asked at https://github.com/dotnet/roslyn/issues/22485
I guess the easiest workaround would be to check for IsReadOnlyAttribute attribute on a struct and alter the checks based on that