dotnet / dotnet/roslyn

Improve CS0201 (ERR_IllegalStatement) codefix to suggest adding discard so that Action overload is picked

Open
#77,324 1 comment 0 reactions 0 assignees View on GitHub
Area-Analyzers untriaged
Dominant language
C#
Stars
20.7k
Forks
4.3k
PR merge metrics
PR metrics pending

Description

> The `_ =` discard is not super obvious from the current lightbulb fixes for cs0201, it suggests changing the return type of the test method.
>
> Is it possible to specifically add code fix for that case?
>
> ![Image](https://github.com/user-attachments/assets/73d661be-7104-4537-a139-49300521ee53)

_Originally posted by @nohwnd in [#5112](https://github.com/microsoft/testfx/issues/5112#issuecomment-2678198152)_

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the CS0201 (ERR_IllegalStatement) lightbulb scenario described in the issue and inspect the existing code fixes offered for it. The work is complete when the relevant case suggests adding a discard so the Action overload is selected instead of suggesting a test-method return-type change.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
compilers, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.