Skip to content

Commit

Permalink
Fix NullableAttribute illink test failures (#90449)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sbomer committed Aug 15, 2023
1 parent 55c896f commit 1eb702c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace Mono.Linker.Tests.Cases.Attributes.OnlyKeepUsed
{
[SetupCSharpCompilerToUse ("csc")]
[SetupLinkerArgument ("--used-attrs-only", "true")]
[SetupLinkerTrimMode ("link")]
public class NullableOnConstraints
{
public static void Main ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace Mono.Linker.Tests.Cases.LinqExpressions
{
[SetupCompileArgument ("/unsafe")]
[SetupLinkerArgument ("--used-attrs-only")]
[SetupLinkerTrimMode ("link")]
public class CanPreserveNullableCustomOperators
{
public static void Main ()
Expand Down

0 comments on commit 1eb702c

Please sign in to comment.