-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Preserve all InternalsVisibleTo attributes in ILLink Trimmer
Removes previous special handling to only keep IVT attributes for assemblies that were resolvable and marked at link time. This behaviour could cause a noticeable difference in behaviour at runtime without emitting any trim analysis warnings while providing no mechanism to retain the attributes. The removal of these attributes provides only a neglible size reduction. Fixes #92582
- Loading branch information
Showing
4 changed files
with
42 additions
and
55 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
8 changes: 8 additions & 0 deletions
8
src/tools/illink/test/Mono.Linker.Tests.Cases/Attributes/Dependencies/IVTUnused_Lib.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,8 @@ | ||
#if IVT | ||
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo ("missing")] | ||
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo ("test-with-key, PublicKey=00240000")] | ||
#endif | ||
|
||
namespace Mono.Linker.Tests.Cases.Attributes.Dependencies; | ||
|
||
public class IVTUnusedLib; |
20 changes: 9 additions & 11 deletions
20
src/tools/illink/test/Mono.Linker.Tests.Cases/Attributes/IVTUnused.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 |
---|---|---|
@@ -1,20 +1,18 @@ | ||
using System.Runtime.CompilerServices; | ||
using Mono.Linker.Tests.Cases.Attributes.Dependencies; | ||
using Mono.Linker.Tests.Cases.Expectations.Assertions; | ||
using Mono.Linker.Tests.Cases.Expectations.Metadata; | ||
|
||
#if IVT | ||
[assembly: InternalsVisibleTo ("missing")] | ||
[assembly: InternalsVisibleTo ("test-with-key, PublicKey=00240000")] | ||
namespace Mono.Linker.Tests.Cases.Attributes; | ||
|
||
#endif | ||
|
||
namespace Mono.Linker.Tests.Cases.Attributes | ||
[SetupCompileBefore ("lib.dll", ["Dependencies/IVTUnused_Lib.cs"], defines: ["IVT"])] | ||
[KeptAssembly ("lib.dll")] | ||
[KeptTypeInAssembly ("lib.dll", typeof(IVTUnusedLib))] | ||
[KeptAttributeInAssembly ("lib.dll", typeof (InternalsVisibleToAttribute))] | ||
class IVTUnused | ||
{ | ||
[Define ("IVT")] | ||
class IVTUnused | ||
static void Main () | ||
{ | ||
static void Main () | ||
{ | ||
} | ||
_ = new IVTUnusedLib (); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...ink/test/Mono.Linker.Tests.Cases/Attributes/IVTUnusedKeptWhenKeepingUsedAttributesOnly.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,20 @@ | ||
using System.Runtime.CompilerServices; | ||
using Mono.Linker.Tests.Cases.Attributes.Dependencies; | ||
using Mono.Linker.Tests.Cases.Expectations.Assertions; | ||
using Mono.Linker.Tests.Cases.Expectations.Metadata; | ||
|
||
namespace Mono.Linker.Tests.Cases.Attributes; | ||
|
||
[SetupCompileBefore ("lib.dll", ["Dependencies/IVTUnused_Lib.cs"], defines: ["IVT"])] | ||
[KeptAssembly ("lib.dll")] | ||
[KeptTypeInAssembly ("lib.dll", typeof(IVTUnusedLib))] | ||
[KeptAttributeInAssembly ("lib.dll", typeof (InternalsVisibleToAttribute))] | ||
|
||
[SetupLinkerArgument("--used-attrs-only", "true")] | ||
class IVTUnusedKeptWhenKeepingUsedAttributesOnly | ||
{ | ||
static void Main () | ||
{ | ||
_ = new IVTUnusedLib (); | ||
} | ||
} |