dotnet / dotnet/linker

Bad warning message for assignement to annotated parameter

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

Description

```csharp
[return: DAM(DAMT.PublicFields)]
public static Type GetFields() => throw null;

static void TestParams([DAM(DAMT.PublicMethods)] Type t = null)
{
t = GetFields (); // warning
}
```

```
Trim analysis warning IL2072: Program.TestParams2(Type): 't' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicMethods' in call to 'Program.TestParams(Type)'. The return value of method 'Program.GetFields()' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.
```

The warning says that the problem is in "in call to 'Program.TestParams(Type)" which is incorrect. The other warnings where an annotated value flows to an annotated parameter have the same problem.

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.