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

SA1649 broken for generic delegate types #3468

Closed
rdeago opened this issue Mar 5, 2022 · 2 comments · Fixed by #3485
Closed

SA1649 broken for generic delegate types #3468

rdeago opened this issue Mar 5, 2022 · 2 comments · Fixed by #3485

Comments

@rdeago
Copy link

rdeago commented Mar 5, 2022

A file containing this code:

namespace MyProgram;

public delegate void Foo<T>(T arg);

should be called "Foo`1.cs" (assuming fileNamingConvention = "metadata" in stylecop.json). Yet SA1649 (File name should match first type name) is triggered unless the file name is "Foo.cs".

Things start going downhill fast if you have multiple Foo<> delegates:

namespace MyProgram;

public delegate void Foo<T>(T arg);

public delegate void Foo<T1,T2>(T1 arg1, T2 arg2);

Now the two delegate types cannot be in two separate files, as they should both be names "Foo.cs". However, keeping them both in "Foo.cs" triggers SA1402 (File may only contain a single type).

The possible workarounds are pretty obvious (either disable SA1402 in "Foo.cs", or disable SA1649 in all "Foo`{n}.cs" files) but this behavior of SA1649 still looks like a bug to me.

@sharwell sharwell added the bug label Mar 7, 2022
@bjornhellander
Copy link
Contributor

Unable to reproduce on master. Probably fixed in #3485.

@rdeago
Copy link
Author

rdeago commented Apr 27, 2022

Thanks. I'll wait for the next beta to test and confirm.

@sharwell sharwell added this to the 1.2-beta.next milestone Apr 27, 2022
@sharwell sharwell added the fixed label Apr 27, 2022
@sharwell sharwell linked a pull request Apr 27, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants