C# Analyzer: Don't warn about required CancellationToken if [EditorBrowsable(Never)]
- Dominant language
- C#
- Stars
- 135
- Forks
- 260
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 143
Description
Imagine we have an API in v1 that looks like
```C#
public Response GimmeFoo(string id, CancellationToken cancellationToken = default);
```
and we want to add a new parameter. We'd version that by changing to
```C#
[EditorBrowsable(EditorBrowsableState.Never)]
public Response GimmeFoo(string id, CancellationToken cancellationToken);
public Response GimmeFoo(string id, int size = 10, CancellationToken cancellationToken = default);
```
Unfortunately the analyzer complains about the old API with `Client method should have cancellationToken as the last optional parameter (both name and it being optional matters)`.
We should relax the optional requirement for `CancellationToken`s when `[EditorBrowsable(Never)]` has been applied to an API.
Contributor guide
Research direction
Start by locating the C# analyzer rule that emits the quoted cancellationToken diagnostic and inspect how EditorBrowsable(Never) is represented. The change is done when an API hidden with EditorBrowsable(Never) no longer triggers the optional-token warning, while the existing warning remains for visible APIs.
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
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100