Area-IDEConcept-Continuous ImprovementFeature - IDE0051help wanted
仓库指标
- 星标
- (20,414 个星标)
- PR 合并指标
- (平均合并 6天 17小时) (30 天内合并 256 个 PR)
描述
Version Used: 3.9.0-1.20480.1+b3c3f4875957e51526000898673291d11708d35b
Steps to Reproduce:
using System;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
class Program
{
static void Main() => new Program().Bar();
[DynamicDependency("Foo")]
private void Bar() => typeof(Program).GetMethod("Foo", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(this, null);
private void Foo() => Console.WriteLine("Hello");
}
Expected Behavior: .NET 5 adds new attributes that enable dependencies not obvious in the code, e.g. those via reflection, to be used for dead code elimination tools like https://github.com/mono/linker to better understand such dependencies. IDE0051 is such a tool and should ideally respect these attributes, such that in this example, IDE0051 doesn't fire.
Actual Behavior:
IDE0051 fires and suggests deleting the "unused" method:

cc: @eerhardt, @nickcraver