Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bogus RS0026: Do not add multiple public overloads with optional parameters #6757

Open
tmat opened this issue Jan 17, 2017 · 4 comments
Open

Comments

@tmat
Copy link
Member

tmat commented Jan 17, 2017

The Roslyn analyzer reports bogus errors RS0026.

For example for completely sound public APIs:

public static Script<T> Create<T>(string code, ScriptOptions options = null, Type globalsType = null, InteractiveAssemblyLoader assemblyLoader = null)
public static Script<T> Create<T>(Stream code, ScriptOptions options = null, Type globalsType = null, InteractiveAssemblyLoader assemblyLoader = null)

We already have 10 suppressions of this in the code base. Seems like the analyzer should be fixed to not flag valid overloads.

@tmat tmat changed the title Bogus RS0026 // Do not add multiple public overloads with optional parameters Bogus RS0026: Do not add multiple public overloads with optional parameters Jan 17, 2017
@tmat
Copy link
Member Author

tmat commented Jan 17, 2017

@filipw FYI

@tmat
Copy link
Member Author

tmat commented Jan 19, 2017

@jaredpar

@mavasani
Copy link
Contributor

This analyzer diagnostic was added to enforce: https://github.com/dotnet/roslyn/blob/master/docs/Adding%20Optional%20Parameters%20in%20Public%20API.md

See section DO NOT add multiple overloads with optional parameters. Also tagging @agocke @jaredpar, who have contributed to this document.

@jinujoseph jinujoseph added this to the milestone Apr 27, 2017
@jinujoseph jinujoseph modified the milestone: May 18, 2017
@jinujoseph jinujoseph added this to the milestone Oct 31, 2017
@kzu
Copy link

kzu commented Jul 10, 2023

Another case where this analyzer is bogus IMO:

Task ExecuteAsync(IAsyncCommand command, CancellationToken cancellation = default);
Task<TResult> ExecuteAsync<TResult>(IAsyncCommand<TResult> command, CancellationToken cancellation = default);

The analyzer thinks both are overloads of each other, where one is generic and the other isn't. I wouldn't expect this case to be flagged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants