dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.44k stars 4.76k forks source link

Trim analyzer should warn on unnecessary DynamicallyAccessedMembers #109802

Open sbomer opened 1 week ago

sbomer commented 1 week ago

Context: https://github.com/dotnet/runtime/pull/109772#issuecomment-2474856235

It would be nice if the analyzer could warn on DynamicallyAccessedMembers annotations that preserve more than is necessary. This would be hard to do when a Type "escapes" to an annotated field, but sounds reasonable at least when the dataflow only involves annotated method parameters.

This would help move away from DynamicallyAccessedMembers.All annotations to the less broad annotations added for https://github.com/dotnet/runtime/issues/88512.

dotnet-policy-service[bot] commented 1 week ago

Tagging subscribers to this area: @agocke, @sbomer, @vitek-karas See info in area-owners.md if you want to be subscribed.