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

Enable NoWarn Fixes #4421 #5671

Merged
merged 8 commits into from
Oct 2, 2020
Merged

Enable NoWarn Fixes #4421 #5671

merged 8 commits into from
Oct 2, 2020

Conversation

Forgind
Copy link
Member

@Forgind Forgind commented Aug 21, 2020

Fixes #4421

Currently not in a change wave, so will have to update that when it's available.

Fixes dotnet#4421

Currently not behind a warning wave, so will have to update that when it's available.
@benvillalobos
Copy link
Member

Wait, why would NoWarn have similar behavior to MSBuildTreatWarningsAsErrors? From the discussion, wasn't it supposed to be similar to MSBuildWarningsAsMessages?

@Forgind
Copy link
Member Author

Forgind commented Aug 21, 2020

You're right; will fix. 😄

@@ -1278,6 +1278,15 @@ private void ConfigureWarningsAsErrorsAndMessages()
}

ISet<string> warningsAsMessages = ParseWarningCodes(project.GetPropertyValue(MSBuildConstants.WarningsAsMessages));
ISet<string> noWarn = ParseWarningCodes(project.GetPropertyValue(MSBuildConstants.NoWarn));
Copy link
Member

Choose a reason for hiding this comment

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

Why do this in code instead of in common.targets?

Copy link
Member Author

Choose a reason for hiding this comment

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

I can move it there instead. When I was look for where I want to make a change, I sometimes forget to include .targets files in the search.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, after change waves come in, will there be an easy way to read in an environment variable and use it to determine whether a property should be reset?

Copy link
Member Author

Choose a reason for hiding this comment

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

Especially keeping in mind that it would have to consider if the user disabled an earlier change wave.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, we will need change wave observation in properties. Not via environment variable but explicit change-wave checks.

@marcpopMSFT marcpopMSFT added this to the MSBuild 16.8 milestone Aug 29, 2020
src/Tasks/Microsoft.Common.CurrentVersion.targets Outdated Show resolved Hide resolved
@@ -611,6 +611,11 @@ Copyright (C) Microsoft Corporation. All rights reserved.
<ContinueOnError Condition="'$(ContinueOnError)' == ''">false</ContinueOnError>
</PropertyGroup>

<!-- Users familiar with how some other repos work try to use NoWarn with MSBuild in place of MSBuildWarningsAsMessages. -->
<PropertyGroup Condition="'$(MSBuildWarningsAsMessages)'=='' And $(MSBuildChangeWaveVersion) != '' And $([MSBuild]::VersionGreaterThanOrEquals('$(MSBuildChangeWaveVersion)', '16.8'))">
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<PropertyGroup Condition="'$(MSBuildWarningsAsMessages)'=='' And $(MSBuildChangeWaveVersion) != '' And $([MSBuild]::VersionGreaterThanOrEquals('$(MSBuildChangeWaveVersion)', '16.8'))">
<PropertyGroup Condition="'$(MSBuildWarningsAsMessages)'=='' And $([MSBuild]::VersionGreaterThanOrEquals('$(MSBuildChangeWaveVersion)', '16.8'))">

MSBuildChangeWaveVersion is guaranteed to have a proper value, so this check isn't necessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's true whether or not the user specifies a value? And does that also get pulled in for random tests?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, each project will have MSBuildChangeWaveVersion set as a reserved property. If unset, it currently defaults to 999.999.

And does that also get pulled in for random tests?
I'm not sure what you mean?

Copy link
Member Author

Choose a reason for hiding this comment

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

I added that because unit tests failed without it. Unit tests often don't have a proper project/run a proper build, and I haven't checked whether these particular tests do or don't. Is that a problem?

Copy link
Member

Choose a reason for hiding this comment

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

This is actually a great point and something that'll have to be added to the docs. I had to make sure to build using a ProjectCollection so that the reserved properties would be set at all. Tests that need to build should be done similar to this:

                string projectFile = @"
                    <Project>
                        <Target Name='HelloWorld' Condition=""'$(MSBUILDCHANGEWAVEVERSION)' == '999.999' and $([MSBuild]::VersionLessThan('" + featureWave + @"', '$(MSBUILDCHANGEWAVEVERSION)'))"">
                            <Message Text='Hello World!'/>
                        </Target>
                    </Project>";

                TransientTestFile file = env.CreateFile("proj.csproj", projectFile);

                ProjectCollection collection = new ProjectCollection();
                MockLogger log = new MockLogger();
                collection.RegisterLogger(log);

                collection.LoadProject(file.Path).Build().ShouldBeTrue();

Are there a significant amount of tests that fail here?

Co-authored-by: Ben Villalobos <bevillal@microsoft.com>
@Forgind Forgind merged commit aac76a2 into dotnet:master Oct 2, 2020
@Forgind Forgind deleted the nowarn branch October 2, 2020 21:31
sujitnayak pushed a commit to NikolaMilosavljevic/msbuild that referenced this pull request Oct 12, 2020
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 this pull request may close these issues.

Support NoWarn as MSBuildWarningsAsMessages
4 participants