-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ILLink: Avoid warning for RUC field rooted as part of a root assembly (…
…#108498) Similar to #81864, fields in a RUC class are producing trim analysis warnings in the OOB trim step (the mentioned issue was specific to library mode, but it's also a problem for the normal root assembly mode). This extends the fix from #84620 to avoid producing warnings for fields that are marked just because an assembly was rooted. Arguably rooting an assembly _should_ warn about rooted RUC members, but that's not the case today for RUC methods, so this makes the behavior consistent for fields. --------- Co-authored-by: Jackson Schuster <[email protected]>
- Loading branch information
1 parent
e183f70
commit e67f230
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...tools/illink/test/Mono.Linker.Tests.Cases/RequiresCapability/RequiresInRootAllAssembly.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// 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.RequiresCapability | ||
{ | ||
[SetupLinkerArgument ("-a", "test.exe", "all")] | ||
|
||
[SkipKeptItemsValidation] | ||
[ExpectedNoWarnings] | ||
public class RequiresInRootAllAssembly | ||
{ | ||
public static void Main () | ||
{ | ||
} | ||
|
||
[RequiresDynamicCode ("--MethodWhichRequires--")] | ||
public static void MethodWhichRequires () { } | ||
|
||
[RequiresDynamicCode ("--InstanceMethodWhichRequires--")] | ||
public void InstanceMethodWhichRequires () { } | ||
|
||
public sealed class ClassWithDAMAnnotatedMembers | ||
{ | ||
public static void Method ([DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)] Type type) { } | ||
|
||
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] | ||
public static Type Field; | ||
} | ||
|
||
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] | ||
public sealed class ClassWithDAMAnnotation | ||
{ | ||
public void Method () { } | ||
} | ||
|
||
[RequiresUnreferencedCode ("--ClassWithRequires--")] | ||
public sealed class ClassWithRequires | ||
{ | ||
public static int Field; | ||
|
||
internal static int InternalField; | ||
|
||
private static int PrivateField; | ||
|
||
public static void Method () { } | ||
|
||
public void InstanceMethod () { } | ||
|
||
public static int Property { get; set; } | ||
|
||
public static event EventHandler PropertyChanged; | ||
} | ||
} | ||
} |