Fix NullableAttribute illink test failures (#90680)
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Wed, 16 Aug 2023 18:44:08 +0000 (12:44 -0600)
committerGitHub <noreply@github.com>
Wed, 16 Aug 2023 18:44:08 +0000 (12:44 -0600)
commitdbb6f4569a2a1056d010f11fc38512476ebf6033
treee6b5720e2c116f8d1dfa3fd7494b56bac9f3ea38
parent243a5aea6983e8a36abbabd14d4f95bf8123ce5b
Fix NullableAttribute illink test failures (#90680)

When we started building with preview 7 in
5549f72da3b3cea9e74bb81cfbb0f2d27731fc42, 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
https://github.com/dotnet/linker/issues/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.

Co-authored-by: Sven Boemer <sbomer@gmail.com>
src/tools/illink/test/Mono.Linker.Tests.Cases/Attributes/OnlyKeepUsed/NullableOnConstraints.cs
src/tools/illink/test/Mono.Linker.Tests.Cases/LinqExpressions/CanPreserveNullableCustomOperators.cs