From a0a2dc8ff0367c1acabb4c373f71c9ef1a6b6121 Mon Sep 17 00:00:00 2001 From: Jeremi Kurdek <59935235+jkurdek@users.noreply.github.com> Date: Tue, 9 Aug 2022 13:26:21 +0200 Subject: Fixed IL2121 single warn issue (#2953) --- src/ILLink.Shared/DiagnosticId.cs | 2 +- .../Warnings.WarningSuppressionTests.g.cs | 6 +++++ .../DetectRedundantSuppressionsSingleWarn.cs | 29 ++++++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/DetectRedundantSuppressionsSingleWarn.cs diff --git a/src/ILLink.Shared/DiagnosticId.cs b/src/ILLink.Shared/DiagnosticId.cs index bcc967af1..2f5787070 100644 --- a/src/ILLink.Shared/DiagnosticId.cs +++ b/src/ILLink.Shared/DiagnosticId.cs @@ -222,7 +222,7 @@ namespace ILLink.Shared 2103 => MessageSubCategory.TrimAnalysis, 2106 => MessageSubCategory.TrimAnalysis, 2107 => MessageSubCategory.TrimAnalysis, - >= 2109 and <= 2120 => MessageSubCategory.TrimAnalysis, + >= 2109 and <= 2121 => MessageSubCategory.TrimAnalysis, >= 3050 and <= 3052 => MessageSubCategory.AotAnalysis, >= 3054 and <= 3055 => MessageSubCategory.AotAnalysis, _ => MessageSubCategory.None, diff --git a/test/ILLink.RoslynAnalyzer.Tests/generated/ILLink.RoslynAnalyzer.Tests.Generator/ILLink.RoslynAnalyzer.Tests.TestCaseGenerator/Warnings.WarningSuppressionTests.g.cs b/test/ILLink.RoslynAnalyzer.Tests/generated/ILLink.RoslynAnalyzer.Tests.Generator/ILLink.RoslynAnalyzer.Tests.TestCaseGenerator/Warnings.WarningSuppressionTests.g.cs index 62b51050b..116fd8239 100644 --- a/test/ILLink.RoslynAnalyzer.Tests/generated/ILLink.RoslynAnalyzer.Tests.Generator/ILLink.RoslynAnalyzer.Tests.TestCaseGenerator/Warnings.WarningSuppressionTests.g.cs +++ b/test/ILLink.RoslynAnalyzer.Tests/generated/ILLink.RoslynAnalyzer.Tests.Generator/ILLink.RoslynAnalyzer.Tests.TestCaseGenerator/Warnings.WarningSuppressionTests.g.cs @@ -55,6 +55,12 @@ namespace ILLink.RoslynAnalyzer.Tests.Warnings return RunTest (allowMissingWarnings: true); } + [Fact] + public Task DetectRedundantSuppressionsSingleWarn () + { + return RunTest (allowMissingWarnings: true); + } + [Fact] public Task SuppressWarningsInAssembly () { diff --git a/test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/DetectRedundantSuppressionsSingleWarn.cs b/test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/DetectRedundantSuppressionsSingleWarn.cs new file mode 100644 index 000000000..4ba1a6149 --- /dev/null +++ b/test/Mono.Linker.Tests.Cases/Warnings/WarningSuppression/DetectRedundantSuppressionsSingleWarn.cs @@ -0,0 +1,29 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.Diagnostics.CodeAnalysis; +using Mono.Linker.Tests.Cases.Expectations.Assertions; +using Mono.Linker.Tests.Cases.Expectations.Metadata; + + +namespace Mono.Linker.Tests.Cases.Warnings.WarningSuppression +{ + [SkipKeptItemsValidation] + [SetupLinkerArgument ("--singlewarn")] + [LogContains ("warning IL2104: Assembly 'test' produced trim warnings")] + [LogDoesNotContain ("IL2121")] + class DetectRedundantSuppressionsSingleWarn + { + public static void Main () + { + TrimmerCompatibleMethod (); + } + + [UnconditionalSuppressMessage ("test", "IL2072")] + public static string TrimmerCompatibleMethod () + { + return "test"; + } + } +} -- cgit v1.2.3