-
Notifications
You must be signed in to change notification settings - Fork 237
Fix S1144: Nested type constructor accessibility is wrong in the rule message #9108
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
Fix S1144: Nested type constructor accessibility is wrong in the rule message #9108
Conversation
Tim-Pohlmann
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely done!
| public void UnusedPrivateMember_NonPrivateConstructorInPrivateClass(string accessModifier, string expectedMessage) => | ||
| builder.AddSnippet($$$""" | ||
| public class Some | ||
| { | ||
| private class Foo // Noncompliant | ||
| { | ||
| {{{accessModifier}}} Foo() // Noncompliant {{{{{expectedMessage}}}}} | ||
| { | ||
| var a = 1; | ||
| } | ||
| } | ||
| } | ||
| """).Verify(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indentation can be improved.
| public void UnusedPrivateMember_NonPrivateConstructorInPrivateClass(string accessModifier, string expectedMessage) => | |
| builder.AddSnippet($$$""" | |
| public class Some | |
| { | |
| private class Foo // Noncompliant | |
| { | |
| {{{accessModifier}}} Foo() // Noncompliant {{{{{expectedMessage}}}}} | |
| { | |
| var a = 1; | |
| } | |
| } | |
| } | |
| """).Verify(); | |
| public void UnusedPrivateMember_NonPrivateConstructorInPrivateClass(string accessModifier, string expectedMessage) => | |
| builder.AddSnippet($$$""" | |
| public class Some | |
| { | |
| private class Foo // Noncompliant | |
| { | |
| {{{accessModifier}}} Foo() // Noncompliant {{{{{expectedMessage}}}}} | |
| { | |
| var a = 1; | |
| } | |
| } | |
| } | |
| """).Verify(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the test classes:
UnusedPrivateMemberTest.Constructors.csUnusedPrivateMemberTest.Fields.csUnusedPrivateMemberTest.Methods.csUnusedPrivateMemberTest.Properties.csUnusedPrivateMemberTest.Types.cs
are following this indentation, I don't like it either, but I like it even less refactoring all the above :D.
Given this context, are you ok with merging as is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are three options:
- Leave as is
- Refactor everything
- Clean as you code
I'd go with 3, but if you think it's too much of a sore on the eye, sticking with 1 is also fine.
|
Ah... one of my comments did not make it from my brain to the keyboard: |
| internal class MyClass | ||
| { | ||
| protected MyClass() // Compliant | ||
| { | ||
| var a = 1; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good test! I actually meant one with a private constructor (should be Noncompliant with a slightly different message).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The message will be the same (the default) as the first DataRow in UnusedPrivateMember_NonPrivateConstructorInPrivateClass: Remove the unused private constructor 'blabla'.
I'll add this as well anyway 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are absolutely right, of course. Still a good case to test!
|
|




Fixes #7774