Skip to content

Using only a static method generates warnings from the ctor #68660

@LakshanF

Description

@LakshanF

The below code currently generates warnings for both RUC and RDC even though the user is only accessing the static method

using System;
using System.Diagnostics.CodeAnalysis;

public class Program
{
    static void Main(string[] args)
    {
        Derived.D_Method();
    }
}

public class Base
{
    [RequiresDynamicCode("RDC")]
    [RequiresUnreferencedCode("RUC")]
    public Base() { }
}

public class Derived : Base
{
    public static void D_Method() { }
}
ILC: Trim analysis warning IL2026: Derived.Derived(): Using member 'Base.Base()' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. RUC.
ILC: AOT analysis warning IL3050: Derived.Derived(): Using member 'Base.Base()' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. RDC.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

No status

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions