-
Notifications
You must be signed in to change notification settings - Fork 510
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
SA1204 incorrectly reported when private static method follows non-private instance method #1123
Comments
I'm not sure I agree with this evaluation. What does the original StyleCop report for the code above? |
No ordering rules are reported for the above. (Of course, there are multiple layout rule violations, and complaints about missing modifiers.) The methods without access modifiers are treated as |
Looking through the documentation proper checks should be in the order of element type, access level , const/static, then readonly. I've got this out of order on both 1202 and 1204. |
That sounds good. OK if I leave you to work out what needs to change then @Noryoko? |
Sure thing. Thanks for all the testing! |
@oatkins Can you confirm the order below?
|
Not quite. It seems that constants are treated as fields, just ones that sort above
Otherwise I think your list is correct. |
I'm torn when it comes to properties/methods, but for fields I just completely disagree with that ordering. I always want to see all constants, then all static, then all instance. Aside from StyleCop doing that in the past, do you see any advantage to interleaving them like this? Also it makes no sense for |
For initial implementation I think we should follow StyleCop. Perhaps we can add configurable ordering rules in the future. |
Yep, this will be interesting for sure. Changing this issue to 🐛 now that we know the expected order. Thanks for the detailed feedback @oatkins. |
@sharwell I'm fairly resigned to not always agreeing with the SC rules on the basis that having a standard (even one I might take issue with occasionally) is better than having none at all. And I do believe that—since there is a sizable established user base for SC—it is best to maintain the SC behaviour unless it's clearly a bug. I did notice the same thing as you regarding |
btw, I did triple-check after reading your comments. If I move all the constants to the top of the class I definitely do introduce SC warnings. |
The following code should not report SA1204, but actually reports it multiple times:
I think that the following changes would fix the code:
HandleMemberList()
method, each time the access level changes or each time the "syntax kind" changes,previousMemberStatic
should be reset totrue
.I'm close to a fix for this.
The text was updated successfully, but these errors were encountered: