Aspnetcore.docs: "Appending the warning codes to $(NoWarn); applies the C# default values too."

Created on 27 Nov 2018  Â·  11Comments  Â·  Source: dotnet/AspNetCore.Docs

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

  1. The use of $(NoWarn)
  2. What the "default C# NoWarn values" are

Can anyone clarify, perhaps add some links to the docs?


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

P2 Source - Docs.ms

Most helpful comment

All 11 comments

@rpetrusha can you suggest a link?

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

  1. The use of $(NoWarn)
  2. What the "default C# NoWarn values" are

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.

  1. How/why/where/when to use $(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?)
  2. What are the aforementioned "default C# NoWarn values"? Which according to the Swashbuckle docs page are being applied when you add $(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>

@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 👌

Was this page helpful?
0 / 5 - 0 ratings