dotnet / dotnet/linker

Analyzer: If type is used as a generic argument to a new constrain RUC on default .ctor should be reported

Open
#2,117 0 comments 0 reactions 0 assignees View on GitHub
area-Linker: Diagnostic
Dominant language
C#
Stars
392
Forks
128
Avg merge
2d 10h
Merged PRs (30d)
2

Description

```C#
void Test ()
{
// IL2026 Foo
Method();
}

class ResultType {
[RequiresUnreferencedCode("Foo")]
public ResultType() { }
}

static void Method () where T : new() { }
```

If a type is used in a generic parameter which has the new constraint, then trimmer must assume its default .ctor is going to be called. If that .ctor has a RUC annotation a warning should be reported.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.