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
The F#-compiled IL lacks the IsReadOnlyAttribute and the modreq at the property declaration. C# views it as a read-write property. We can't do anything about the latter, but let's try to apply the attribute ourselves (we shouldn't have):
What if the IsReadOnlyAttribute does not exist (like in .NET Standard 2.0 or .NET Framework)? Roslyn generates an internal attribute type and emits that when needed. F#'s compiler tries to find it from anywhere within the assembly's references (even from internal attribute types with the same name), and if it doesn't find it, it doesn't emit it at all. Manually defining an IsReadOnlyAttribute type in the same assembly is ignored.
The bug is reproduced with .NET SDK 5.0.100. inrefs in interface methods are properly compiled like C#.
The text was updated successfully, but these errors were encountered:
Consider this simple F# interface:
The equivalent C# interface is this:
The F# snippet's property is compiled to the following IL:
And the C#'s is compiled to this:
The F#-compiled IL lacks the
IsReadOnlyAttribute
and themodreq
at the property declaration. C# views it as a read-write property. We can't do anything about the latter, but let's try to apply the attribute ourselves (we shouldn't have):And now let's use this interface from C#:
If fails with a mysterious
[CS0570] 'I.Property' is not supported by the language
in the fifth line.Two things stood out:
IsReadOnlyAttribute
and themodreq
at the interface's property. Both should be automatically added. Looks like the fixes in Emitting IsReadOnlyAttribute on return arguments of type inref<_> #10022 were not covering all cases.IsReadOnlyAttribute
does not exist (like in .NET Standard 2.0 or .NET Framework)? Roslyn generates an internal attribute type and emits that when needed. F#'s compiler tries to find it from anywhere within the assembly's references (even from internal attribute types with the same name), and if it doesn't find it, it doesn't emit it at all. Manually defining anIsReadOnlyAttribute
type in the same assembly is ignored.The bug is reproduced with .NET SDK 5.0.100.
inref
s in interface methods are properly compiled like C#.The text was updated successfully, but these errors were encountered: