-
Notifications
You must be signed in to change notification settings - Fork 794
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
Add support for C# Experimental
attribute
#18253
base: main
Are you sure you want to change the base?
Conversation
❗ Release notes required
|
Experimental
attributeExperimental
attribute
@@ -1795,7 +1794,7 @@ type Exception with | |||
if s <> "" then | |||
os.AppendString(Obsolete2E().Format s) | |||
|
|||
| Experimental(s, _) -> os.AppendString(ExperimentalE().Format s) | |||
| Experimental(message = s) -> os.AppendString(ExperimentalE().Format s) |
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.
I propose the message includes the added properties if they were present even in plain (text output) build results.
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.
Especially the ID might be something useful for searching with.
The url would be better a clicklable, but at least plaintext for command line builds is IMO also beneficial.
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.
Experimental
attribute does not have a message property for now. It seems that will be added in the next mayor version to match the obsolete attribute See.
dotnet/runtime#108216
But I think we can handle this so it will work when it is available for us.
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.
Regarding the DiagnosticId
We have 2 options:
- Use the provided id from the attribute
[Experimental(diagnosticId: "MY001")]
as a error number which potentially might collide with existing error numbers. - Use 57 like we do in F# but that will defeat the purpose of the
diagnosticId
I guess the problem is to report the experimental as error number 57 and then show a diagnostic id was part the error text which will be confusing ?
@@ -78,6 +78,17 @@ module ExtendedData = | |||
/// Represents the URL format of the diagnostic | |||
member this.UrlFormat: string = urlFormat | |||
|
|||
/// Additional data for diagnostics about experimental attributes. | |||
[<Class; Experimental("This FCS API is experimental and subject to change.")>] | |||
type ExperimentalExtendedData |
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.
Are non-nullable strings the correct signature?
Is there a particular reason for representing missing attribute with an empty string here?
(Is it e.g. what the attribute does when e.g. scanned via reflection at runtime ? )
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.
Will have to check
@@ -133,6 +133,8 @@ exception DiagnosticWithSuggestions of number: int * message: string * range: ra | |||
/// A diagnostic that is raised when enabled manually, or by default with a language feature | |||
exception DiagnosticEnabledWithLanguageFeature of number: int * message: string * range: range * enabledByLangFeature: bool | |||
|
|||
exception ObsoleteDiagnostic of isError: bool * diagnosticId: string * message: string * urlFormat: string * range: range |
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.
Like for Experimental, are we representing absence of information via ""
because this is what the attribute does in C# or when extracted at runtime?
Is there some reason this is insufficient? https://github.com/dotnet/fsharp/blob/main/src/FSharp.Core/prim-types.fs#L265 |
Description
Fixes #18198
Checklist