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

Add notes for NativeAOT specific warnings in ExpectedWarningAttributes #103657

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
Expand Up @@ -39,10 +39,10 @@ public static void WithLocalFunctionInner ()
LocalWithWarning ();
}

// NativeAOT behavioral difference
[UnexpectedWarning ("IL2026", Tool.NativeAot, "https://github.com/dotnet/runtime/issues/85161")]
// Analyzer doesn't implement constant propagation and branch removal, so it reaches this code
// NativeAOT behavioral difference:
// https://github.com/dotnet/runtime/issues/85161
[ExpectedWarning ("IL2026", Tool.Analyzer | Tool.NativeAot, "")]
[ExpectedWarning ("IL2026", Tool.Analyzer, "Analyzer cannot remove branch")]
void LocalWithWarning ()
{
// No warning
Expand All @@ -61,10 +61,10 @@ public static void WithLocalFunction ()
LocalWithWarning ();
}

// NativeAOT behavioral difference
[ExpectedWarning ("IL2026", Tool.NativeAot, "https://github.com/dotnet/runtime/issues/85161")]
// Analyzer doesn't implement constant propagation and branch removal, so it reaches this code
// NativeAOT behavioral difference:
// https://github.com/dotnet/runtime/issues/85161
[ExpectedWarning ("IL2026", Tool.Analyzer | Tool.NativeAot, "")]
[ExpectedWarning ("IL2026", Tool.Analyzer, "Analyzer cannot remove branch")]
void LocalWithWarning ()
{
Requires ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Mono.Linker.Tests.Cases.Extensibility
[ExpectedNoWarnings]
public class CustomWarningUsage
{
[ExpectedWarning ("IL2026", "--RUCMethod--", Tool.Analyzer, "")]
[ExpectedWarning ("IL2026", "--RUCMethod--", Tool.Analyzer, "Analyzer doesn't have access to trim time flags")]
public static void Main ()
{
new KnownTypeThatShouldWarn ();
Expand All @@ -29,4 +29,4 @@ public class KnownTypeThatShouldWarn
[RequiresUnreferencedCode ("--RUCMethod--")]
static void RUCMethod () { }
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public static void Main ()
}

[ExpectedWarning ("IL2026", "Message for --RequiresWithMessageOnly--.")]
[ExpectedWarning ("IL3002", "Message for --RequiresWithMessageOnly--.", Tool.Analyzer | Tool.NativeAot, "")]
[ExpectedWarning ("IL3050", "Message for --RequiresWithMessageOnly--.", Tool.Analyzer | Tool.NativeAot, "")]
[ExpectedWarning ("IL3002", "Message for --RequiresWithMessageOnly--.", Tool.Analyzer | Tool.NativeAot, "NativeAOT Specific Warning")]
[ExpectedWarning ("IL3050", "Message for --RequiresWithMessageOnly--.", Tool.Analyzer | Tool.NativeAot, "NativeAOT Specific Warning")]
static void TestRequiresWithMessageOnlyOnMethod ()
{
RequiresWithMessageOnly ();
Expand All @@ -43,8 +43,8 @@ static void RequiresWithMessageOnly ()
}

[ExpectedWarning ("IL2026", "Message for --RequiresWithMessageAndUrl--.", "https://helpurl")]
[ExpectedWarning ("IL3002", "Message for --RequiresWithMessageAndUrl--.", "https://helpurl", Tool.Analyzer | Tool.NativeAot, "")]
[ExpectedWarning ("IL3050", "Message for --RequiresWithMessageAndUrl--.", "https://helpurl", Tool.Analyzer | Tool.NativeAot, "")]
[ExpectedWarning ("IL3002", "Message for --RequiresWithMessageAndUrl--.", "https://helpurl", Tool.Analyzer | Tool.NativeAot, "NativeAOT Specific Warning")]
[ExpectedWarning ("IL3050", "Message for --RequiresWithMessageAndUrl--.", "https://helpurl", Tool.Analyzer | Tool.NativeAot, "NativeAOT Specific Warning")]
static void TestRequiresWithMessageAndUrlOnMethod ()
{
RequiresWithMessageAndUrl ();
Expand All @@ -58,8 +58,8 @@ static void RequiresWithMessageAndUrl ()
}

[ExpectedWarning ("IL2026", "Message for --ConstructorRequires--.")]
[ExpectedWarning ("IL3002", "Message for --ConstructorRequires--.", Tool.Analyzer | Tool.NativeAot, "")]
[ExpectedWarning ("IL3050", "Message for --ConstructorRequires--.", Tool.Analyzer | Tool.NativeAot, "")]
[ExpectedWarning ("IL3002", "Message for --ConstructorRequires--.", Tool.Analyzer | Tool.NativeAot, "NativeAOT Specific Warning")]
[ExpectedWarning ("IL3050", "Message for --ConstructorRequires--.", Tool.Analyzer | Tool.NativeAot, "NativeAOT Specific Warning")]
static void TestRequiresOnConstructor ()
{
new ConstructorRequires ();
Expand All @@ -77,10 +77,10 @@ public ConstructorRequires ()

[ExpectedWarning ("IL2026", "Message for --getter PropertyRequires--.")]
[ExpectedWarning ("IL2026", "Message for --setter PropertyRequires--.")]
[ExpectedWarning ("IL3002", "Message for --getter PropertyRequires--.", Tool.Analyzer | Tool.NativeAot, "")]
[ExpectedWarning ("IL3002", "Message for --setter PropertyRequires--.", Tool.Analyzer | Tool.NativeAot, "")]
[ExpectedWarning ("IL3050", "Message for --getter PropertyRequires--.", Tool.Analyzer | Tool.NativeAot, "")]
[ExpectedWarning ("IL3050", "Message for --setter PropertyRequires--.", Tool.Analyzer | Tool.NativeAot, "")]
[ExpectedWarning ("IL3002", "Message for --getter PropertyRequires--.", Tool.Analyzer | Tool.NativeAot, "NativeAOT Specific Warning")]
[ExpectedWarning ("IL3002", "Message for --setter PropertyRequires--.", Tool.Analyzer | Tool.NativeAot, "NativeAOT Specific Warning")]
[ExpectedWarning ("IL3050", "Message for --getter PropertyRequires--.", Tool.Analyzer | Tool.NativeAot, "NativeAOT Specific Warning")]
[ExpectedWarning ("IL3050", "Message for --setter PropertyRequires--.", Tool.Analyzer | Tool.NativeAot, "NativeAOT Specific Warning")]
static void TestRequiresOnPropertyGetterAndSetter ()
{
_ = PropertyRequires;
Expand All @@ -107,8 +107,8 @@ static void WarningMessageWithoutEndingPeriod ()
}

[ExpectedWarning ("IL2026", "Adds a trailing period to this message.")]
[ExpectedWarning ("IL3002", "Adds a trailing period to this message.", Tool.Analyzer | Tool.NativeAot, "")]
[ExpectedWarning ("IL3050", "Adds a trailing period to this message.", Tool.Analyzer | Tool.NativeAot, "")]
[ExpectedWarning ("IL3002", "Adds a trailing period to this message.", Tool.Analyzer | Tool.NativeAot, "NativeAOT Specific Warning")]
[ExpectedWarning ("IL3050", "Adds a trailing period to this message.", Tool.Analyzer | Tool.NativeAot, "NativeAOT Specific Warning")]
static void TestThatTrailingPeriodIsAddedToMessage ()
{
WarningMessageWithoutEndingPeriod ();
Expand All @@ -123,8 +123,8 @@ static void WarningMessageEndsWithPeriod ()

[LogDoesNotContain ("Does not add a period to this message..")]
[ExpectedWarning ("IL2026", "Does not add a period to this message.")]
[ExpectedWarning ("IL3002", "Does not add a period to this message.", Tool.Analyzer | Tool.NativeAot, "")]
[ExpectedWarning ("IL3050", "Does not add a period to this message.", Tool.Analyzer | Tool.NativeAot, "")]
[ExpectedWarning ("IL3002", "Does not add a period to this message.", Tool.Analyzer | Tool.NativeAot, "NativeAOT Specific Warning")]
[ExpectedWarning ("IL3050", "Does not add a period to this message.", Tool.Analyzer | Tool.NativeAot, "NativeAOT Specific Warning")]
static void TestThatTrailingPeriodIsNotDuplicatedInWarningMessage ()
{
WarningMessageEndsWithPeriod ();
Expand Down Expand Up @@ -188,8 +188,8 @@ public static void GenericTypeWithStaticMethodWhichRequires () { }
}

[ExpectedWarning ("IL2026", "--GenericTypeWithStaticMethodWhichRequires--")]
[ExpectedWarning ("IL3002", "--GenericTypeWithStaticMethodWhichRequires--", Tool.Analyzer | Tool.NativeAot, "")]
[ExpectedWarning ("IL3050", "--GenericTypeWithStaticMethodWhichRequires--", Tool.Analyzer | Tool.NativeAot, "")]
[ExpectedWarning ("IL3002", "--GenericTypeWithStaticMethodWhichRequires--", Tool.Analyzer | Tool.NativeAot, "NativeAOT Specific Warning")]
[ExpectedWarning ("IL3050", "--GenericTypeWithStaticMethodWhichRequires--", Tool.Analyzer | Tool.NativeAot, "NativeAOT Specific Warning")]
public static void GenericTypeWithStaticMethodViaLdftn ()
{
var _ = new Action (GenericWithStaticMethod<TestType>.GenericTypeWithStaticMethodWhichRequires);
Expand All @@ -215,8 +215,8 @@ static void Requires () { }
[RequiresAssemblyFiles ("--PropertyRequires--")]
static int PropertyRequires { get; set; }

[ExpectedWarning ("IL3002", "--PropertyRequires--", Tool.Analyzer | Tool.NativeAot, "")]
[ExpectedWarning ("IL3002", "--PropertyRequires--", Tool.Analyzer | Tool.NativeAot, "")]
[ExpectedWarning ("IL3002", "--PropertyRequires--", Tool.Analyzer | Tool.NativeAot, "NativeAOT Specific Warning")]
[ExpectedWarning ("IL3002", "--PropertyRequires--", Tool.Analyzer | Tool.NativeAot, "NativeAOT Specific Warning")]
static void TestProperty ()
{
var a = PropertyRequires;
Expand All @@ -226,11 +226,11 @@ static void TestProperty ()
[RequiresAssemblyFiles ("--EventRequires--")]
static event EventHandler EventRequires;

[ExpectedWarning ("IL3002", "--EventRequires--", Tool.Analyzer | Tool.NativeAot, "")]
[ExpectedWarning ("IL3002", "--EventRequires--", Tool.Analyzer | Tool.NativeAot, "")]
[ExpectedWarning ("IL3002", "--EventRequires--", Tool.Analyzer | Tool.NativeAot, "NativeAOT Specific Warning")]
[ExpectedWarning ("IL3002", "--EventRequires--", Tool.Analyzer | Tool.NativeAot, "NativeAOT Specific Warning")]
[ExpectedWarning ("IL2026", "--RequiresOnEventLambda--")]
[ExpectedWarning ("IL3002", "--RequiresOnEventLambda--", Tool.Analyzer | Tool.NativeAot, "")]
[ExpectedWarning ("IL3050", "--RequiresOnEventLambda--", Tool.Analyzer | Tool.NativeAot, "")]
[ExpectedWarning ("IL3002", "--RequiresOnEventLambda--", Tool.Analyzer | Tool.NativeAot, "NativeAOT Specific Warning")]
[ExpectedWarning ("IL3050", "--RequiresOnEventLambda--", Tool.Analyzer | Tool.NativeAot, "NativeAOT Specific Warning")]
static void TestEvent ()
{
EventRequires += (object sender, EventArgs e) => throw new NotImplementedException ();
Expand All @@ -244,7 +244,7 @@ static void TestEvent ()
EventRequires (null, null); // no warning on invocation
}

[ExpectedWarning("IL3002", "--Requires--", Tool.Analyzer | Tool.NativeAot, "")]
[ExpectedWarning("IL3002", "--Requires--", Tool.Analyzer | Tool.NativeAot, "NativeAOT Specific Warning")]
public static void Test()
{
Requires ();
Expand All @@ -258,7 +258,7 @@ class DynamicCodeOnly
[RequiresDynamicCode ("--Requires--")]
static void Requires () { }

[ExpectedWarning ("IL3050", "--Requires--", Tool.Analyzer | Tool.NativeAot, "")]
[ExpectedWarning ("IL3050", "--Requires--", Tool.Analyzer | Tool.NativeAot, "NativeAOT Specific Warning")]
public static void Test ()
{
Requires ();
Expand Down
Loading
Loading