dotnet / dotnet/linker

Trimming analyzer misses some IL2070;IL2091 warnings from publishing

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

Description

Spotted by @tannergooding when compiling [ComputeSharp](https://github.com/Sergio0694/ComputeSharp) with trimming.

> **NOTE:** to repro, use the .slnf file, as that works with `dotnet build` (it doesn't have some UWP/WinUI 3 projects).

## Overview

Publishing with trimming results in a few errors like this:

> "C:\Users\tagoo\source\repos\ComputeSharp\src\ComputeSharp\Graphics\Helpers\TypeInfo{T}.cs(29,41): error IL2070: 'this' argum
ent does not satisfy 'DynamicallyAccessedMemberTypes.PublicFields', 'DynamicallyAccessedMemberTypes.NonPublicFields' in call t
o 'System.Type.GetFields(BindingFlags)'. The parameter 'type' of method 'ComputeSharp.Graphics.Helpers.TypeInfo.ChecksIsDou
bleOrContainsDoubles(Type)' does not have matching annotations. The source value must declare at least the same requirements a
s those declared on the target location it is assigned to. [C:\Users\tagoo\source\repos\ComputeSharp\src\ComputeSharp\ComputeS
harp.csproj]"

They seem to come from [TypeInfo](https://github.com/Sergio0694/ComputeSharp/blob/76a83967dcd9b11964fe4ef3e49ac42afbad85f5/src/ComputeSharp/Graphics/Helpers/TypeInfo%7BT%7D.cs#L10), which does lack annotations. I reckon this should have been spotted by the trimmer analyzer though, no? That's enabled in the whole project. To repro, just clone the repo, open the `.slnf` file and `dotnet build`.

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.