Skip to content

Commit 1eb702c

Browse files
authored
Fix NullableAttribute illink test failures (#90449)
When we started building with preview 7 in 5549f72, NullableAttribute in these testcases started to use the attribute definition from the framework, instead of generating it into the code. This broke the `--used-attrs-only` optimization because `skip` assemblies (the default for the framework in these testcases) are treated as if all types in them are kept, for the purposes of the `--used-attrs-only` optimization. (The optimization removes attribute instances unless the attribute type is preserved for some other reason). It's not clear what the intended behavior of `--used-attrs-only` is for `skip` assemblies, and the discussion in dotnet/linker#952 indicates that it's considered experimental, so this fixes the failures by using the `link` action. This represents a more realistic scenario since `skip` is mainly used in testing to avoid linking the framework in every testcase.
1 parent 55c896f commit 1eb702c

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

src/tools/illink/test/Mono.Linker.Tests.Cases/Attributes/OnlyKeepUsed/NullableOnConstraints.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace Mono.Linker.Tests.Cases.Attributes.OnlyKeepUsed
77
{
88
[SetupCSharpCompilerToUse ("csc")]
99
[SetupLinkerArgument ("--used-attrs-only", "true")]
10+
[SetupLinkerTrimMode ("link")]
1011
public class NullableOnConstraints
1112
{
1213
public static void Main ()

src/tools/illink/test/Mono.Linker.Tests.Cases/LinqExpressions/CanPreserveNullableCustomOperators.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ namespace Mono.Linker.Tests.Cases.LinqExpressions
55
{
66
[SetupCompileArgument ("/unsafe")]
77
[SetupLinkerArgument ("--used-attrs-only")]
8+
[SetupLinkerTrimMode ("link")]
89
public class CanPreserveNullableCustomOperators
910
{
1011
public static void Main ()

0 commit comments

Comments
 (0)