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 test for invalid trim annotations in top-level method #103182

Merged
merged 1 commit into from
Jun 12, 2024
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
Expand Up @@ -13,5 +13,11 @@ public Task BasicDataFlow ()
{
return RunTest ();
}

[Fact]
public Task InvalidAnnotations ()
{
return RunTest ();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -338,13 +338,13 @@ static void RequirePublicFields (
{
}

[ExpectedWarning ("IL2077", Tool.Analyzer, "https://github.com/dotnet/runtime/issues/101211")]
[UnexpectedWarning ("IL2077", Tool.Analyzer, "https://github.com/dotnet/runtime/issues/101211")]
static void TestFlowOutOfField ()
{
RequirePublicFields (unsupportedTypeInstance);
}

[ExpectedWarning ("IL2074", Tool.Analyzer, "https://github.com/dotnet/runtime/issues/101211")]
[UnexpectedWarning ("IL2074", Tool.Analyzer, "https://github.com/dotnet/runtime/issues/101211")]
public static void Test () {
var t = GetUnsupportedTypeInstance ();
unsupportedTypeInstance = t;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ class UnsupportedType ()
static UnsupportedType GetUnsupportedTypeInstance () => null;

[ExpectedWarning ("IL2098", nameof (UnsupportedType))]
[ExpectedWarning ("IL2067", Tool.Analyzer, "https://github.com/dotnet/runtime/issues/101211")]
[UnexpectedWarning ("IL2067", Tool.Analyzer, "https://github.com/dotnet/runtime/issues/101211")]
static void RequirePublicMethods (
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)]
UnsupportedType unsupportedTypeInstance)
Expand All @@ -259,7 +259,7 @@ static void RequirePublicFields (
{
}

[ExpectedWarning ("IL2072", Tool.Analyzer, "https://github.com/dotnet/runtime/issues/101211")]
[UnexpectedWarning ("IL2072", Tool.Analyzer, "https://github.com/dotnet/runtime/issues/101211")]
public static void Test () {
var t = GetUnsupportedTypeInstance ();
RequirePublicMethods (t);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ static void TestMethodReturnValue () {
RequirePublicFields (t);
}

[ExpectedWarning ("IL2072", Tool.Analyzer, "https://github.com/dotnet/runtime/issues/101211")]
[UnexpectedWarning ("IL2072", Tool.Analyzer, "https://github.com/dotnet/runtime/issues/101211")]
static void TestCtorReturnValue () {
var t = new UnsupportedType ();
RequirePublicFields (t);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ static void RequirePublicFields (
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)]
UnsupportedType unsupportedTypeInstance) { }

[ExpectedWarning ("IL2075", nameof (UnsupportedType), nameof (UnsupportedType.GetMethod), Tool.Analyzer, "https://github.com/dotnet/runtime/issues/101211")]
[UnexpectedWarning ("IL2075", nameof (UnsupportedType), nameof (UnsupportedType.GetMethod), Tool.Analyzer, "https://github.com/dotnet/runtime/issues/101211")]
static void TestMethodThisParameter () {
var t = GetUnsupportedTypeInstance ();
t.GetMethod ("foo");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<Project Sdk="Microsoft.NET.Sdk" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// 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;
using Mono.Linker.Tests.Cases.Expectations.Assertions;

[assembly: ExpectedNoWarnings]

Test ();

[UnexpectedWarning ("IL2072", Tool.Analyzer, "https://github.com/dotnet/runtime/issues/101211")]
[Kept]
static void Test () {
RequireAll (GetUnsupportedType ());
}

[ExpectedWarning ("IL2098", Tool.Trimmer | Tool.NativeAot, "https://github.com/dotnet/runtime/issues/101215")]
[Kept]
static void RequireAll(
[KeptAttributeAttribute (typeof (DynamicallyAccessedMembersAttribute))]
[DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.All)] UnsupportedType f) {}

[Kept]
static UnsupportedType GetUnsupportedType () => new UnsupportedType ();

[Kept]
[KeptMember (".ctor()")]
class UnsupportedType {}
Loading