Skip to content

ILLink rooting assemblies with forwarded types #99592

Closed as not planned
Closed as not planned

Description

@kotlarmilos

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());
}

Activity

  1. added
    disabled-test
    os-ios
    area-Tools-ILLink
    on Mar 12, 2024
  2. added this to the Future milestone on Mar 12, 2024
  3. vitek-karas commented on Mar 12, 2024

    @vitek-karas
    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.

  4. filipnavara commented on Mar 12, 2024

    @filipnavara
    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).

  5. kotlarmilos commented on Mar 12, 2024

    @kotlarmilos
    MemberAuthor

    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.

  6. removed their assignment
    on May 21, 2025
  7. locked and limited conversation to collaborators on Jul 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-Tools-ILLinkdisabled-testos-ios

Type

No type

Projects

  • Status
    No status

Relationships

None yet

Development

No branches or pull requests

Issue actions