Skip to content

Trim analyzer misses base constructors with trim annotations #106796

@Sergio0694

Description

@Sergio0694

Description

Found this while testing the new upcoming release of the MVVM Toolkit. It seems the trim analyzer doesn't flag base constructors that are annotated with some trim annotation, so you only see the issue on publish, which of course is not ideal.

Reproduction Steps

B b = new(); // No warnings here either

abstract class A
{
    [RequiresUnreferencedCode("blah")]
    public A()
    {
    }
}

// No warnings here
class B : A
{
}

Expected behavior

Not sure if the warning should be on the B declaration or on the new() expression, but I assume it should be somewhere 😅

Actual behavior

No warnings at all from the analyzer.

Regression?

No, tried on both .NET 8 and .NET 9, same issue.

Configuration

  • .NET 8.0.400
  • .NET 9.0.100-preview.7.24407.12

cc. @MichalStrehovsky

Metadata

Metadata

Assignees

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