Skip to content

RUC should suppress warnings about generics from type #108523

Closed

Description

@sbomer

RUC on type silences warnings for code in members of the type, including generics warnings for methods.
But it doesn't silence warnings about generics on the type itself:

    class RequireAll<[DAM(DAMT.All)] T> {}
    
    [RUC("C<T>")]
    class C<T> : RequireAll<T> {} // IL2091 'T' generic argument does not satisfy 'DynamicallyAccessedMemberTypes.All' 

I believe RUC on type should silence this warning. I can't think of a way to do something unsafe with typeof(C<>) that wouldn't cause warnings elsewhere.

Activity

  1. sbomer commented on Dec 1, 2022

    @sbomer
    MemberAuthor

    Similar for fields:

        class G<[DAM(DAMT.PublicMethods)] T> {}
    
        [RUC("")]
        class CInst<T> {
            public static G<T> field; // IL2091
    
            public G<T> instField; // IL2091
        }
    
        [RequiresUnreferencedCode("")]
        public static void Test() {
            var f = new CInst<int>().instField;
            var g = CInst<int>.field;
        }

    I think these cases should not warn.

  2. transferred this issue fromdotnet/linkeron Oct 3, 2024
  3. added
    area-Tools-ILLink.NET linker development as well as trimming analyzers
    on Oct 3, 2024
  4. added this to the 10.0.0 milestone on Oct 3, 2024
  5. dotnet-policy-service commented on Oct 3, 2024

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas
    See info in area-owners.md if you want to be subscribed.

  6. dotnet-policy-service commented on Oct 3, 2024

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @agocke, @sbomer, @vitek-karas
    See info in area-owners.md if you want to be subscribed.

  7. dotnet-policy-service commented on Oct 3, 2024

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas
    See info in area-owners.md if you want to be subscribed.

  8. dotnet-policy-service commented on Oct 3, 2024

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @agocke, @sbomer, @vitek-karas
    See info in area-owners.md if you want to be subscribed.

  9. modified the milestones: 10.0.0, Future on Jun 10, 2025
  10. sbomer commented on Aug 13, 2025

    @sbomer
    MemberAuthor

    The field cases should be fixed by #118708 since ILLink will no longer produce generic warnings on fields (instead they will show up at the field accesses).

  11. added a commit that references this issue on Aug 14, 2026
    63666de
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-Tools-ILLink.NET linker development as well as trimming analyzers

    Type

    No type

    Projects

    • Status
      No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions