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

Explicit interface implementation triggers access level error #3881

Open
marcospgp opened this issue Aug 3, 2024 · 3 comments
Open

Explicit interface implementation triggers access level error #3881

marcospgp opened this issue Aug 3, 2024 · 3 comments

Comments

@marcospgp
Copy link
Contributor

Ran into this today using stylecop.analyzers.1.1.118:

image

@bjornhellander
Copy link
Contributor

And why do you think this is a bug? #1179 (comment)

@sharwell
Copy link
Member

sharwell commented Aug 14, 2024

It's not quite clear what the issue being reported is (primarily because SA1202 involves the relation between two different members, but only one member is shown). Explicit interface implementations were treated as public by StyleCop Classic. StyleCop Analyzers intentionally preserved this behavior.

During the creation of this project, the default behavior was always to follow StyleCop Classic (for ease of migration for existing users) unless a change was warranted. If the intended behavior was unclear due to ambiguity or omissions in the old documentation, our preference was to preserve the implementation behavior and clarify the documentation. We tried to only change behavior in cases where rules were found to be in direct conflict with each other, or were largely/fundamentally incompatible with explicit guidance being given by the language team. In those cases, we tried to document the differences in Known Changes.

@marcospgp
Copy link
Contributor Author

since interfaces can only define public abstract methods, it makes sense to assume an explicit interface implementation will always be public - even if it is only accessible by casting an instance to the interface type

is there any chance the error message could be updated to include this information? or as a fallback, the documentation?

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

No branches or pull requests

3 participants