Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ILLink rooting assemblies with forwarded types #99592

Open
kotlarmilos opened this issue Mar 12, 2024 · 3 comments
Open

ILLink rooting assemblies with forwarded types #99592

kotlarmilos opened this issue Mar 12, 2024 · 3 comments
Assignees
Labels
area-Tools-ILLink .NET linker development as well as trimming analyzers disabled-test The test is disabled in source code against the issue os-ios Apple iOS
Milestone

Comments

@kotlarmilos
Copy link
Member

Description

Rooting input assemblies is not enough when trimming with ILLinker forwarded types. It is required to root all forwarded assemblies as well.

Test case:

[Theory]
[InlineData("mscorlib")]
[InlineData("System.Threading.Overlapped")]
public static void ShimsHaveOnlyTypeForwards(string assemblyName)
{
    Assembly assembly = Assembly.Load(assemblyName);

    Assert.Empty(assembly.GetTypes());
    Assert.Empty(assembly.GetManifestResourceNames());
    Assert.NotEmpty(assembly.GetForwardedTypes());
}
@kotlarmilos kotlarmilos added disabled-test The test is disabled in source code against the issue os-ios Apple iOS area-Tools-ILLink .NET linker development as well as trimming analyzers labels Mar 12, 2024
@kotlarmilos kotlarmilos added this to the Future milestone Mar 12, 2024
@vitek-karas
Copy link
Member

The product behavior is by design here - I think the test case in question just needs special consideration if running as "Trimmed" - or maybe we should just disable it. The things it's doing are specifically against what trimming/AOT supports, so not supporting this test case in that setup seems OK to me.

@filipnavara
Copy link
Member

I had problem with this behavior in production so maybe there should be some additional consideration on how to handle this. My scenario involved System.Windows.Forms / System.Drawing and the type forwarders there. There are serialized resources that depend on the forwarders being kept after trimming (eg. resource references System.Windows.Forms.Padding and the real type is System.Windows.Forms.Primitives.Padding). I realize that this is currently an unsupported scenario, but I still think that some consideration should be given to it and how to handle it (eg. optional switch to keep the type forwarders in specific assembly).

@kotlarmilos
Copy link
Member Author

kotlarmilos commented Mar 12, 2024

I think the test case in question just needs special consideration if running as "Trimmed" - or maybe we should just disable it.

We can skip the test if trimming is enabled.

My scenario involved System.Windows.Forms / System.Drawing and the type forwarders there. There are serialized resources that depend on the forwarders being kept after trimming (eg. resource references System.Windows.Forms.Padding and the real type is System.Windows.Forms.Primitives.Padding). I realize that this is currently an unsupported scenario, but I still think that some consideration should be given to it and how to handle it (eg. optional switch to keep the type forwarders in specific assembly).

I agree that adding an ILLInk warning message or an optional switch could be beneficial. Currently, it may be unclear to customers what has happened and how to resolve the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Tools-ILLink .NET linker development as well as trimming analyzers disabled-test The test is disabled in source code against the issue os-ios Apple iOS
Projects
Status: No status
Development

No branches or pull requests

4 participants