IDE0051 false positive for extension referenced from another extension
- Dominant language
- C#
- Stars
- 20.7k
- Forks
- 4.3k
- PR merge metrics
- PR metrics pending
Description
**Version Used**:
VS 18.4.0
**Steps to Reproduce**:
```cs
static class Helpers
{
extension(User _this)
{
public bool IsUsed => _this.Helper();
}
// // warning IDE0051: Private member 'Helpers.Helper' is unused
private static bool Helper(this User _this)
{
return _this != null;
}
}
public class User
{
public void Test()
{
_ = this.IsUsed;
}
}
```
```xml
net10.0
enable
enable
true
preview-All
true
```
**Diagnostic Id**:
[Remove unused private member (IDE0051)](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0051)
**Expected Behavior**:
no reports
**Actual Behavior**:
incorrect diagnostic reported
Contributor guide
Research direction
Start by reproducing the C# example with analyzer diagnostic IDE0051 enabled and confirm that Helper is reported as unused when referenced through the extension member. Trace the IDE0051 analysis for this extension-reference case; done means the sample produces no incorrect diagnostic while unused private members remain reported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100