-
Notifications
You must be signed in to change notification settings - Fork 21
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
Relax hash directives (#token
) to take values other than strings, and formalize their syntax
#1368
Comments
Note that the #load
"filea.fsx"
"fileb.fsx" Should similar be allowed with |
Should diagnostic number prefixes other than C# supports the pragma warning disable IDE0059 // Unnecessary assignment of a value
i = 5;
#pragma warning restore IDE0059 // Unnecessary assignment of a value #pragma warning disable CA1831 // Use AsSpan or AsMemory instead of Range-based indexers when appropriate
ReadOnlySpan<char> slice = str[1..3];
#pragma warning restore CA1831 // Use AsSpan or AsMemory instead of Range-based indexers when appropriate |
@brianrourkeboll, they already are allowed (it's just that And the disable/restore cycle is a linked issue, which we should tackle separately (I linked #278 in the original message). |
@smoothdeveloper, good point, but the multiline feature is already allowed for |
The parser knows nothing about any specific directives, except for SOURCE_DIRECTORY | SOURCE_LINE| SOURCE_FILE. I had no intent to teach the parser about the specific directives, although that may be a way to go. The current valid format is:
This change alters it to:
TBH: |
@brianrourkeboll, we could and perhaps should pass the Nuget nowarns through to the nuget package manager. We currently don't. |
@dsyme there seems to be some consensus here and @KevinRansom already worked on an implementation. This does not change existing behavior of anything, only allows a little more syntax with hash directives. Would agree to this change? I'll create the (small) RFC for this, to further Kevin's PR. |
Yes this is fine, agreed it makes sense |
I propose we allow hash directives to take integers, floats, and (long) identifiers, so we can write
#time on
and#nowarn 1234
. At the same time, this syntax is not prescriptive in the F# spec, I propose to formalize it so we can reason about it.The existing way of approaching this problem in F# is: write
#time "on"
or#nowarn "1234"
.Pros and Cons
The advantages of making this adjustment to F# are
We can now simplify the use of, and expand the scope of allowed types for existing directives. This allows tokens like
#nowarn
to take not only a number, but alsoFS1104
as input, which is the form in which warnings are output. It is also the form that's accepted already on the commandline.Formalizing the syntax helps to reason about it, and makes it easier to add new directives or expand on existing ones.
Before:
After:
The disadvantages of making this adjustment to F# are
None that I can think of.
Extra information
Please note that this change does not intend to change the behavior of these constructs. It merely allows more freedom with the syntax of the arguments, and formalizes the syntax of the status quo.
Estimated cost (XS, S, M, L, XL, XXL): XS
This work has already been started (see dotnet/fsharp#17206). @dsyme, if that PR is accepted, could you do the honors and mark this approved so that we can create an RFC for this?
Related suggestions:
Affidavit (please submit!)
Please tick these items by placing a cross in the box:
Please tick all that apply:
For Readers
If you would like to see this issue implemented, please click the 👍 emoji on this issue. These counts are used to generally order the suggestions by engagement.
The text was updated successfully, but these errors were encountered: