Init-only & required properties support#13490
Conversation
|
I will need to add one more language feature, and hide init-only checking under it, so F#6 continues to allow current behaviour. |
WIP Init-only & required properties support|
This is ready for a first wave of reviews. |
|
That is okay, C# compiler cannot find the attribute in the net472 runtime, it's known, i will fix it. Quote from Jared:
|
|
@dsyme Addressed all comments except 1 (not entirely sure whether we should warn user when they place |
|
We may want to retarget this feature to 17.4, and update sdk to .NET7-preview, since it will be much easier to test runtime features without the need of adding attributes ourselves. |
|
Added attributes to unsupported ones, compiler will produce a warning for them if used in F# code. |
|
|
||
| /// Indidcates whether IL property has an init-only setter (i.e. has the `System.Runtime.CompilerServices.IsExternalInit` modifer) | ||
| member x.IsSetterInitOnly = | ||
| assert x.HasSetter |
There was a problem hiding this comment.
This probably shouldn't be here.
Co-authored-by: Petr Pokorny <[email protected]>
dsyme
left a comment
There was a problem hiding this comment.
A couple of small changes needed
|
@vzarytovskii A couple of small changes needed - Please feel free to clear my review after you've addressed them, no 2nd review needed |
| | Some ([ILAttribElem.String (Some msg); ILAttribElem.Bool isError ], _) when not isByrefLikeTyconRef -> | ||
| if isError then | ||
| if g.langVersion.SupportsFeature(LanguageFeature.RequiredPropertiesSupport) then | ||
| CheckCompilerFeatureRequiredAttribute g cattrs msg m |
There was a problem hiding this comment.
Does this attribute always come together with Obsolete?
If not, then this path is not going to be executed when there's no Obsolete attribute.
set_Propis forbidden too.instance.MethodThatReturnsThis(initOnlyProp = 123)Which will mutate the
instanceCompilerFeatureRequiredAttribute(Roslyn codegen)