diff options
author | Matt Ward <matt.ward@microsoft.com> | 2020-01-02 16:53:27 +0300 |
---|---|---|
committer | Matt Ward <matt.ward@microsoft.com> | 2020-01-02 16:53:27 +0300 |
commit | 0990511ae1b7a4bcfada1ea2a376e7e16bfd92b2 (patch) | |
tree | 04cdd85babb49a4029bd6ee1f58b8c757d07f76a /main | |
parent | 9161a9aa6a9c8cea7aa732444e5b72190b1d2701 (diff) |
[C#] NoWarn in project should override rulesets
NoWarn settings for suppressing warnings was not overridding the
configuration defined in the ruleset. This was incorrect based on the
Visual Studio on Windows behaviour.
Diffstat (limited to 'main')
4 files changed, 11 insertions, 2 deletions
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Project/CSharpCompilerParameters.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Project/CSharpCompilerParameters.cs index 8c4ba7d7d8..965dd89dd2 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Project/CSharpCompilerParameters.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Project/CSharpCompilerParameters.cs @@ -192,8 +192,6 @@ namespace MonoDevelop.CSharp.Project Dictionary<string, ReportDiagnostic> GetSpecificDiagnosticOptions () { var result = new Dictionary<string, ReportDiagnostic> (); - foreach (var warning in GetSuppressedWarnings ()) - result [warning] = ReportDiagnostic.Suppress; var globalRuleSet = IdeApp.TypeSystemService.RuleSetManager.GetGlobalRuleSet (); if (globalRuleSet != null) { @@ -204,6 +202,11 @@ namespace MonoDevelop.CSharp.Project if (ruleSet != null) { AddSpecificDiagnosticOptions (result, ruleSet); } + + foreach (var warning in GetSuppressedWarnings ()) { + result [warning] = ReportDiagnostic.Suppress; + } + return result; } diff --git a/main/tests/MonoDevelop.CSharpBinding.Tests/MonoDevelop.CSharpBinding/CustomProjectRuleSetTests.cs b/main/tests/MonoDevelop.CSharpBinding.Tests/MonoDevelop.CSharpBinding/CustomProjectRuleSetTests.cs index 31e6b87168..263b5883d9 100644 --- a/main/tests/MonoDevelop.CSharpBinding.Tests/MonoDevelop.CSharpBinding/CustomProjectRuleSetTests.cs +++ b/main/tests/MonoDevelop.CSharpBinding.Tests/MonoDevelop.CSharpBinding/CustomProjectRuleSetTests.cs @@ -79,6 +79,9 @@ namespace MonoDevelop.CSharpBinding.Tests // Global ruleset option which is not overridden by project ruleset. Assert.AreEqual (ReportDiagnostic.Error, diagnosticOptions ["SA1003"]); + + // NoWarn set in project file directly should override project ruleset. + Assert.AreEqual (ReportDiagnostic.Suppress, diagnosticOptions ["SA1600"]); } } } diff --git a/main/tests/test-projects/ruleset/custom.ruleset b/main/tests/test-projects/ruleset/custom.ruleset index 6411b72e21..0d7baaab51 100644 --- a/main/tests/test-projects/ruleset/custom.ruleset +++ b/main/tests/test-projects/ruleset/custom.ruleset @@ -4,5 +4,7 @@ <Rule Id="SA1000" Action="Error" /> <Rule Id="SA1001" Action="Warning" /> <Rule Id="SA1002" Action="None" /> + <!-- Rule SA1003 defined in global ruleset --> + <Rule Id="SA1600" Action="Error" /> </Rules> </RuleSet>
\ No newline at end of file diff --git a/main/tests/test-projects/ruleset/ruleset.csproj b/main/tests/test-projects/ruleset/ruleset.csproj index 7b266eaccb..b4779cd891 100644 --- a/main/tests/test-projects/ruleset/ruleset.csproj +++ b/main/tests/test-projects/ruleset/ruleset.csproj @@ -9,6 +9,7 @@ <AssemblyName>ruleset</AssemblyName> <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> <CodeAnalysisRuleSet>custom.ruleset</CodeAnalysisRuleSet> + <NoWarn>SA1600</NoWarn> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> |