-
Notifications
You must be signed in to change notification settings - Fork 799
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
src/Compiler/Checking/infos.fs
Outdated
@@ -1562,6 +1579,16 @@ type ILPropInfo = | |||
/// Indicates if the IL property has a 'set' method | |||
member x.HasSetter = Option.isSome x.RawMetadata.SetMethod | |||
|
|||
/// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably shouldn't be here.
tests/FSharp.Compiler.ComponentTests/Interop/RequiredAndInitOnlyProperties.fs
Outdated
Show resolved
Hide resolved
tests/FSharp.Compiler.ComponentTests/Interop/RequiredAndInitOnlyProperties.fs
Show resolved
Hide resolved
Co-authored-by: Petr Pokorny <petr@innit.cz>
tests/FSharp.Compiler.ComponentTests/Interop/RequiredAndInitOnlyProperties.fs
Show resolved
Hide resolved
Co-authored-by: Petr Pokorny <petr@innit.cz>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
set_Prop
is forbidden too.instance.MethodThatReturnsThis(initOnlyProp = 123)
Which will mutate the
instance
CompilerFeatureRequiredAttribute
(Roslyn codegen)