Appending the warning codes to
$(NoWarn);applies the C# default values too.
I found this quite interesting, nice nugget of information.
It seems like a reasonable thing to add into my projects.
But I cannot seem to find any information elsewhere about
$(NoWarn)Can anyone clarify, perhaps add some links to the docs?
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
@rpetrusha can you suggest a link?
-nowarn is documented (for the C# compiler) at https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/nowarn-compiler-option.
Thanks for contacting us. We believe that the question you've raised have been answered. If you still feel a need to continue the discussion, feel free to reopen it and add your comments.
Hi @Rick-Anderson
I can't seem to reopen the issue so I'll add a comment here.
Thanks for the link @rpetrusha but I don't think that page has any information about
$(NoWarn)These are the two specific things I would like some more information about.
Perhaps I should have included a bit more information from the page to explain exactly what I mean.
If you take a look at the Swashbuckle docs page (that I created this issue from) it has an example about adding $(NoWarn) to the <NoWarn> options in the csproj and states:
To suppress warnings project-wide, define a semicolon-delimited list of warning codes to ignore in the project file. Appending the warning codes to $(NoWarn); applies the C# default values too.
<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);1591</NoWarn>
</PropertyGroup>
Any ideas?
cc @scottaddie
Hi @connorads, I think that you may like to see this link that contains a list of c# compile errors:
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/cs0006
Hope this helps you.
Hi @marcominas, thanks for the suggestion but there doesn't seem to be anything on that link, or in the C# Compiler Errors section of the docs, about the two specific things I mentioned _(1. & 2.)_ .... unless I have really got my wires crossed and/or something fairly obvious or apparent is evading me!
If you take a look at the Swashbuckle docs page (that I created this issue from) it has an example about adding $(NoWarn) to the <NoWarn> options in the csproj and states:
To suppress warnings project-wide, define a semicolon-delimited list of warning codes to ignore in the project file. Appending the warning codes to $(NoWarn); applies the C# default values too.
<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);1591</NoWarn>
</PropertyGroup>
The key bits of information are:
<NoWarn>$(NoWarn);1591</NoWarn>
Appending the warning codes to $(NoWarn); applies the C# default values too.
For me this raises further questions that don't seem to be explained in the Swashbuckle docs page, elsewhere in the Microsoft docs, or on the interwebs.
$(NoWarn)? I'm not talking about the general use of _NoWarn_, _No Warn_, -nowarn, /nowarn etc. I mean specifically this $(NoWarn) with the the dollar sign and the brackets (property element?)$(NoWarn) to the <NoWarn> section of the .csproj.In other words:
What happens when you add $(NoWarn) to the <NoWarn> options in the csproj?
Or conversely:
What happens if you don't add $(NoWarn) to the <NoWarn> options in the csproj?
<NoWarn>$(NoWarn);1591</NoWarn>
The default values are here: https://github.com/dotnet/sdk/blob/2eb6c546931b5bcb92cd3128b93932a980553ea1/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.CSharp.props#L16
I'll get this added to the doc.
@BillWagner Anything you want to add to the C# docs regarding NoWarn?
@scottaddie Over time, what I want to add is to provide links from each C# option (like -nowarn) to the corresponding MS Build docs. Not all the options are documented, which is much of the underlying concern.
Thanks @scottaddie and everyone for your help 👌
Most helpful comment
The default values are here: https://github.com/dotnet/sdk/blob/2eb6c546931b5bcb92cd3128b93932a980553ea1/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.CSharp.props#L16
I'll get this added to the doc.