Skip to content
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

F# compiler option --nowarn does not accept alphanumeric warning codes #3626

Closed
mishra14 opened this issue Sep 22, 2017 · 12 comments · Fixed by #3631
Closed

F# compiler option --nowarn does not accept alphanumeric warning codes #3626

mishra14 opened this issue Sep 22, 2017 · 12 comments · Fixed by #3631

Comments

@mishra14
Copy link

From @mishra14 on September 21, 2017 20:1

Stemming from: NuGet/Home#5913

It seems that F# compiler option --nowarn only accepts integers. Which seems fine based on the description on the docs page.

But the docs also state that the option is equivalent to C# compiler option /nowarn. But the C# compiler option accepts alpha-numeric codes like /nowarn:CS0219

F:\validation\test\addpkg>csc Program.cs /nowarn:NU1603;CS0219
Microsoft (R) Visual C# Compiler version 2.4.0.62025 (a0507c1e)
Copyright (C) Microsoft Corporation. All rights reserved.


F:\validation\test\addpkg>

IMO, either the two should be equivalent or maybe the docs should not state them as equivalent.

Please let me know, if this is not the right place for it or it needs to be in fslang-suggestions.

Copied from original issue: fsharp/fsharp#785

@mishra14
Copy link
Author

From @forki on September 22, 2017 5:43

I tink it should be posted in https://github.com/Microsoft/visualfsharp
/cc @cartermp

@mishra14
Copy link
Author

From @cartermp on September 22, 2017 16:11

Yep, @mishra14 can you repost this on visualfsharp? Thanks!

@KevinRansom
Copy link
Member

KevinRansom commented Sep 22, 2017

Seems like a reasonable suggestions, just out of curiosity: what does the
/nowarn:NU1603; is that a C# warning message?

@KevinRansom
Copy link
Member

KevinRansom commented Sep 22, 2017

@mishra14, @forki

Okay ...

so we won't validate the alpha chars, and we will only not warn for fsxxxx numbers. And I guess we will need to make sure that we keep the arguments as passed and pass them through the compilation ...
There are a bunch of related switches, warnaserror etc ... they should accept the same values.

Does that sound like what we need?.

@mishra14
Copy link
Author

@KevinRansom: NUxxxx warnings are NuGet related warnings which were recently added.

Your description seems about right. The same warning codes should be acceptable in --nowarn and --warnaserror.

@KevinRansom
Copy link
Member

KevinRansom commented Sep 22, 2017

@mishra14 @forki

Yeah ... C# is broken, so I will not make this change in the compiler. I will fix the issue in the targets file or build task, I will just strip out values our compiler doesn't understand we don't understand..

The C# bug:

namespace ConsoleApp10 {
    class Program {
        static void Main(string[] args) {
            int x = 7;
        }
    }
}
```'
**csc Program.cs**

Microsoft (R) Visual C# Compiler version 2.3.2.62019 (b7354608)
Copyright (C) Microsoft Corporation. All rights reserved.

Program.cs(13,17): warning CS0219: The variable 'x' is assigned but its value is never used

**csc Program.cs /nowarn:0219**

Microsoft (R) Visual C# Compiler version 2.3.2.62019 (b7354608)
Copyright (C) Microsoft Corporation. All rights reserved.

now this:
**csc Program.cs /nowarn:cs0219**
Microsoft (R) Visual C# Compiler version 2.3.2.62019 (b7354608)
Copyright (C) Microsoft Corporation. All rights reserved.

Program.cs(13,17): warning CS0219: The variable 'x' is assigned but its value is never used

C# ignores any non numeric value including cs0219. It is a C# bug, and it is very likely it won't get fixed.

@mishra14
Copy link
Author

mishra14 commented Sep 22, 2017

@KevinRansom Thanks for the detailed response.

I have one correction - /nowarn:CS0219 works as expected -

F:\validation\test\addpkg>csc Program.cs  /nowarn:CS0219
Microsoft (R) Visual C# Compiler version 2.4.0.62025 (a0507c1e)
Copyright (C) Microsoft Corporation. All rights reserved.


F:\validation\test\addpkg>csc Program.cs  /nowarn:cs0219
Microsoft (R) Visual C# Compiler version 2.4.0.62025 (a0507c1e)
Copyright (C) Microsoft Corporation. All rights reserved.

Program.cs(9,17): warning CS0219: The variable 'x' is assigned but its value is never used

F:\validation\test\addpkg>

Note that it is case sensitive, so cs0219 is not the same as CS0219.

@forki
Copy link
Contributor

forki commented Sep 23, 2017 via email

@KevinRansom
Copy link
Member

KevinRansom commented Sep 23, 2017

@forki ... it's 6 of one, half a dozen of the other.

Clearly that C# doesn't validate arguments is a bug ... however ... it is convenient that no UI is needed to add the nuget nowarn setting in VS because they can re-use the nowarnings field in the compiler settings.

So I can see it both ways ... anyway ... it is no big deal

@forki
Copy link
Contributor

forki commented Sep 23, 2017 via email

@Pilchie
Copy link
Member

Pilchie commented Sep 25, 2017

For reference, the C# compiler does this because it runs analyzers (which have their own custom error prefixes) and emits the diagnostics from analyzers, and allows suppression with /nowarn and #pragma warning disable.

@Pilchie
Copy link
Member

Pilchie commented Sep 25, 2017

I.e., it's not so much for other exes in the build like NuGet, etc, as it is for other analyzers running within csc.exe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants