Skip to content
This repository was archived by the owner on Sep 25, 2026. It is now read-only.
This repository was archived by the owner on Sep 25, 2026. It is now read-only.

Type forwarder handling needs cleanup #1740

Closed

Description

@sbomer

The type forwarder logic needs cleanup. A few problem areas:

See also some TODOs in the code:
https://github.com/mono/linker/blob/7a095faf3925689f2a3450da1a76fdd79a070de9/src/linker/Linker.Steps/MarkStep.cs#L1183-L1185

@marek-safar suggested getting rid of --keep-facades. I think this is OK since we don't set this or have a public option for it in the SDK, but we should still keep type forwards when they are referenced dynamically. We also need to consider how a future "copyoriginal" action would handle references to type forwarders (see #1669 (comment)). My suggestion is to emit an error in this case, and add support for it in the future if it proves necessary. One challenge is the fact that resolving a typeref through cecil will transparently dereference through the type forwarder without giving the calling code an opportunity to make a decision about the exported type.

I propose we:

  • Get rid of --keep-facades
  • Don't mark exported type forwards that just happen to point to a marked type
  • Mark type forwards that are resolved dynamically
  • Keep all marked type forwards

Activity

  1. marek-safar commented on Jan 13, 2021

    @marek-safar
    Contributor

    I think this option is not needed anymore. My understanding is that it was added for netcore (in #12) presumably someone needed it for libraries like trimming.

    It'd be great if we could also ensure that any Assembly.Load to facade assembly also keeps the assembly even if has only type forwarders. This is the only useful workaround like scenario I can think of now for the option.

  2. added this to the .NET 6.0 milestone on Jan 13, 2021
  3. added 2 commits that reference this issue on Jan 25, 2021
    6697d87
    add8328
  4. vitek-karas commented on Sep 16, 2022

    @vitek-karas
    Member

    MarkStep marks exported types that point to marked types, regardless of whether that type was actually referenced through the forwarder:

    I think this is already fixed - we reworked exported types handling and all of this was completely changed

    The rest of this issue still seems valid unfortunately.

    @sbomer, @jtschuster for additional comments

  5. sbomer commented on Sep 16, 2022

    @sbomer
    MemberAuthor

    The DynamicDependency issue and the TODO in MarkEntireAssembly was also fixed in #1941. I believe the only remaining item is to get rid of --keep-facades.

  6. self-assigned this
    on Sep 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions