-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Include new warning codes in --notrimwarn and --noaotwarn #105049
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -187,6 +187,7 @@ public enum DiagnosticId | |
_unused_DynamicallyAccessedMembersOnTypeReferencesCompilerGeneratedMemberOnBase = 2120, | ||
RedundantSuppression = 2121, | ||
TypeNameIsNotAssemblyQualified = 2122, | ||
_EndTrimAnalysisWarningsSentinel = 2123, | ||
|
||
// Single-file diagnostic ids. | ||
AvoidAssemblyLocationInSingleFile = 3000, | ||
|
@@ -203,6 +204,7 @@ public enum DiagnosticId | |
GenericRecursionCycle = 3054, | ||
CorrectnessOfAbstractDelegatesCannotBeGuaranteed = 3055, | ||
RequiresDynamicCodeOnStaticConstructor = 3056, | ||
_EndAotAnalysisWarningsSentinel = 3057, | ||
|
||
// Feature guard diagnostic ids. | ||
ReturnValueDoesNotMatchFeatureGuards = 4000, | ||
|
@@ -227,9 +229,9 @@ public static string GetDiagnosticSubcategory (this DiagnosticId diagnosticId) = | |
2103 => MessageSubCategory.TrimAnalysis, | ||
2106 => MessageSubCategory.TrimAnalysis, | ||
2107 => MessageSubCategory.TrimAnalysis, | ||
>= 2109 and <= 2121 => MessageSubCategory.TrimAnalysis, | ||
>= 2109 and <= (int) DiagnosticId._EndTrimAnalysisWarningsSentinel => MessageSubCategory.TrimAnalysis, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Technically this should be just |
||
>= 3050 and <= 3052 => MessageSubCategory.AotAnalysis, | ||
>= 3054 and <= 3055 => MessageSubCategory.AotAnalysis, | ||
>= 3054 and <= (int) DiagnosticId._EndAotAnalysisWarningsSentinel => MessageSubCategory.AotAnalysis, | ||
_ => MessageSubCategory.None, | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// 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; | ||
sbomer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace ILLink.RoslynAnalyzer.Tests | ||
{ | ||
public sealed partial class WarningsTests : LinkerTestBase | ||
{ | ||
|
||
protected override string TestSuiteName => "Warnings"; | ||
|
||
[Fact (Skip = "Analyzers are disabled entirely by SuppressTrimAnalysisWarnings or SuppressAotAnalysisWarnings")] | ||
public Task CanDisableWarningsByCategory () | ||
{ | ||
return RunTest (); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// 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.Diagnostics.CodeAnalysis; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Header? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I started from a copy of an existing test that didn't have a copyright header. A lot of our tests don't - I guess that should be fixed. |
||
using Mono.Linker.Tests.Cases.Expectations.Assertions; | ||
using Mono.Linker.Tests.Cases.Expectations.Metadata; | ||
|
||
namespace Mono.Linker.Tests.Cases.Warnings | ||
{ | ||
[ExpectedNoWarnings] | ||
[SkipKeptItemsValidation] | ||
[SetupLinkerArgument ("--notrimwarn")] | ||
#if NATIVEAOT | ||
[SetupLinkerArgument ("--noaotwarn")] | ||
#endif | ||
public class CanDisableWarningsByCategory | ||
{ | ||
public static void Main () | ||
{ | ||
TestNonQualifiedType (); | ||
RequiresDynamicCodeOnStaticConstructor.Test (); | ||
} | ||
|
||
static void TestNonQualifiedType () | ||
{ | ||
RequireAll ("Mono.Linker.Tests.Cases.Warnings.TypeDoesntExist"); | ||
} | ||
|
||
class RequiresDynamicCodeOnStaticConstructor | ||
{ | ||
class StaticConstructor | ||
{ | ||
[RequiresDynamicCode (nameof (StaticConstructor))] | ||
static StaticConstructor () { } | ||
} | ||
|
||
public static void Test () { | ||
new StaticConstructor (); | ||
} | ||
} | ||
|
||
static void RequireAll ([DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] string s) {} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to not specify the value - AFAIK C# should assign the next (+1) value automatically which would make this work nicely when we add a new one.