dotnet / dotnet/roslyn

Unexpected/misleading IDE diagnostics for a user defined assignment operator usage

Open
#78,280 0 comments 0 reactions 0 assignees View on GitHub
Area-IDE Bug Feature-UserDefinedCompoundAssignmentOperators IDE-CodeStyle
Dominant language
C#
Stars
20.7k
Forks
4.3k
PR merge metrics
PR metrics pending

Description

```
class Program
{
static void Main()
{
var c1 = new C1();
c1++; // IDE0059 Unnecessary assignment of a value to 'c1'

var c2 = new C1();
c2 -= 1; // IDE0059 Unnecessary assignment of a value to 'c2'
}
}

class C1
{
public void operator ++()
{
}

public void operator -=(int i)
{
}
}
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the C# snippet and investigating the IDE0059 diagnostic for the user-defined ++ and -= operators. Trace the analyzer entry point and existing diagnostic tests, then add a regression test showing that these operator usages no longer receive the misleading unnecessary-assignment warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
compilers, devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.