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

Add note on WarningsAsErrors #81451

Merged
merged 1 commit into from
Feb 1, 2023
Merged

Conversation

MichalStrehovsky
Copy link
Member

@ghost
Copy link

ghost commented Feb 1, 2023

Tagging subscribers to this area: @dotnet/area-meta
See info in area-owners.md if you want to be subscribed.

Issue Details

Cc @ivdiazsa

Author: MichalStrehovsky
Assignees: MichalStrehovsky
Labels:

area-Meta

Milestone: -


## Warnings as Errors

The repo build treats warnings as errors. Dealing with warnings when you're in the middle of making changes can be annoying (e.g. unused variable that you plan to use later). To disable treating warnings as errors, set the `WarningsAsErrors` environment variable to `false` before building. This variable will be respected by both the `build.sh`/`build.cmd` root build scripts and builds done with `dotnet build` or Visual Studio. Some people may prefer setting this environment variable globally in their machine settings.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Internal and public alike, environment variables naming convention in the repo is

DOTNET_TREAT_WARNING_AS_ERROR=false or =0

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sets an MSBuild property that is documented to be named like this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed the TreatWarningsAsErrors is checked here:
https://github.com/dotnet/runtime/pull/81402/files#diff-0eee3e18fdac60b29b08c403d130ff9badcadeb22e2e8f01b1ddd34fdeb59ef0R270

This confused me as to what environment variable name we should be using: TreatWarningsAsErrors, or WarningsAsErrors?

From what I understood (https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/errors-warnings), TreatWarningsAsErrors is intended to be a boolean, whereas WarningsAsErrors is the list of diagnostic ids to upgrade from warnings to errors.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sigh, yeah, it's TreatWarningsAsErrors. I'll fix it.

@MichalStrehovsky MichalStrehovsky merged commit 9459ac6 into main Feb 1, 2023
@MichalStrehovsky MichalStrehovsky deleted the MichalStrehovsky-patch-1 branch February 1, 2023 08:23
@ivdiazsa
Copy link
Member

ivdiazsa commented Feb 1, 2023

Thanks for adding this @MichalStrehovsky! The note looks very much on point.

@ghost ghost locked as resolved and limited conversation to collaborators Mar 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants