dotnet / fsharp

The F# compiler, F# core library, F# language service, and F# tooling integration for Visual Studio
https://dotnet.microsoft.com/languages/fsharp
MIT License
3.91k stars 785 forks source link

Nullness - Consider supporting Nullable shorthand for TreatWarningsAsErrors #17524

Open BoundedChenn31 opened 2 months ago

BoundedChenn31 commented 2 months ago

Is your feature request related to a problem? Please describe.

In C# it's possible to convert all nullable-related warnings to errors using <WarningsAsErrors>nullable</WarningsAsErrors>. From docs: The set of all nullability warnings can be specified with the Nullable shorthand.

So in line with https://github.com/dotnet/fsharp/pull/17486 it would be nice to have WAE behaviour as well.

Describe the solution you'd like

Support <WarningsAsErrors>nullable</WarningsAsErrors>

Describe alternatives you've considered

Just use specific warning numbers or even true.

Additional context

.

T-Gro commented 2 months ago

So the nullable would be a shorthand for putting in all nullness-related errors, on top of the option for specifying error codes individually.

Do I understand it right?

vzarytovskii commented 2 months ago

So the nullable would be a shorthand for putting in all nullness-related errors, on top of the option for specifying error codes individually.

Do I understand it right?

Yeah, I think that's what C# does currently.

BoundedChenn31 commented 2 months ago

So the nullable would be a shorthand for putting in all nullness-related errors, on top of the option for specifying error codes individually.

Do I understand it right?

Yes, not sure about implementation details (csc also supports /warnaserror:nullable option, so maybe it's handled completely by roslyn) but it definitely behaves like that and recommended as a solution:

SO: How to treat ALL C# 8 nullable reference warnings as errors? Roslyn 1: Provide single option to treat nullable issues as errors not warnings Roslyn 2: Proposal: Add switch for treating nullable-related warnings as errors

abonie commented 1 month ago

It's done, reopen if you still see it with F# 9

T-Gro commented 1 month ago

This was not done, this proposal is about a syntactical shorthand for doing warningsAsErrors for all nullable-related warnings. (as opposed to listing individual error codes)

vzarytovskii commented 1 month ago

I thought that we did it already for some reason