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

Implement WarningsNotAsErrors in the new property pages #6971

Merged
merged 1 commit into from
Feb 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the LICENSE.md file in the project root for more information.

using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Threading.Tasks;

namespace Microsoft.VisualStudio.ProjectSystem.Properties
{
[ExportInterceptingPropertyValueProvider("TreatWarningsAsErrors", ExportInterceptingPropertyValueProviderFile.ProjectFile)]
internal sealed class TreatWarningsAsErrorsValueProvider : InterceptingPropertyValueProviderBase
{
private const string WarningsAsErrorsProperty = "WarningsAsErrors";
private const string WarningsNotAsErrorsProperty = "WarningsNotAsErrors";
private readonly ITemporaryPropertyStorage _temporaryPropertyStorage;

[ImportingConstructor]
public TreatWarningsAsErrorsValueProvider(ITemporaryPropertyStorage temporaryPropertyStorage)
{
_temporaryPropertyStorage = temporaryPropertyStorage;
}

public override async Task<string?> OnSetPropertyValueAsync(string propertyName, string unevaluatedPropertyValue, IProjectProperties defaultProperties, IReadOnlyDictionary<string, string>? dimensionalConditions = null)
{
if (StringComparers.PropertyLiteralValues.Equals(unevaluatedPropertyValue, "true"))
{
// When setting this to "true", remove WarningsAsErrors
await defaultProperties.SaveValueIfCurrentlySetAsync(WarningsAsErrorsProperty, _temporaryPropertyStorage);
await defaultProperties.DeletePropertyAsync(WarningsAsErrorsProperty, dimensionalConditions);
await defaultProperties.RestoreValueIfNotCurrentlySetAsync(WarningsNotAsErrorsProperty, _temporaryPropertyStorage);
}
else
{
// When settings this to "false", remove WarningsNotAsErrors
await defaultProperties.SaveValueIfCurrentlySetAsync(WarningsNotAsErrorsProperty, _temporaryPropertyStorage);
await defaultProperties.DeletePropertyAsync(WarningsNotAsErrorsProperty, dimensionalConditions);
await defaultProperties.RestoreValueIfNotCurrentlySetAsync(WarningsAsErrorsProperty, _temporaryPropertyStorage);
}

return await base.OnSetPropertyValueAsync(propertyName, unevaluatedPropertyValue, defaultProperties, dimensionalConditions);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@
DisplayName="Treat warnings as errors"
Description="Used to specify which warnings are treated as errors."
Category="ErrorsAndWarnings" >

<EnumProperty.DataSource>
<DataSource Persistence="ProjectFileWithInterception" />
</EnumProperty.DataSource>

<EnumValue Name="false"
DisplayName="None" />
<EnumValue Name="true"
Expand All @@ -196,7 +201,27 @@
DisplayName="Treat specific warnings as errors"
HelpUrl="https://go.microsoft.com/fwlink/?linkid=2147301"
Description="Treats the specified warnings as errors. Separate multiple warning numbers with a comma (',') or semicolon (';')."
Category="ErrorsAndWarnings" />
Category="ErrorsAndWarnings">
<StringProperty.Metadata>
<NameValuePair Name="DependsOn" Value="Build::TreatWarningsAsErrors" />
<NameValuePair Name="VisibilityCondition">
<NameValuePair.Value>(has-evaluated-value "Build" "TreatWarningsAsErrors" "false")</NameValuePair.Value>
</NameValuePair>
</StringProperty.Metadata>
</StringProperty>

<StringProperty Name="WarningsNotAsErrors"
DisplayName="Exempt specific warnings from being treated as errors"
HelpUrl="https://go.microsoft.com/fwlink/?linkid=2147301"
Description="Exempts the specified warnings from being treated as errors. Separate multiple warning numbers with a comma (',') or semicolon (';')."
Category="ErrorsAndWarnings">
<StringProperty.Metadata>
<NameValuePair Name="DependsOn" Value="Build::TreatWarningsAsErrors" />
<NameValuePair Name="VisibilityCondition">
<NameValuePair.Value>(has-evaluated-value "Build" "TreatWarningsAsErrors" "true")</NameValuePair.Value>
</NameValuePair>
</StringProperty.Metadata>
</StringProperty>

<StringProperty Name="BaseOutputPath"
DisplayName="Base output path"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.