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

RUC should suppress warnings about generics from type #3142

Open
Tracked by #101149
sbomer opened this issue Nov 29, 2022 · 1 comment
Open
Tracked by #101149

RUC should suppress warnings about generics from type #3142

sbomer opened this issue Nov 29, 2022 · 1 comment

Comments

@sbomer
Copy link
Member

sbomer commented Nov 29, 2022

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.

@sbomer
Copy link
Member Author

sbomer commented Dec 1, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant