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

SA1126: PrefixCallsCorrectly #59

Closed
sharwell opened this issue Nov 18, 2014 · 9 comments
Closed

SA1126: PrefixCallsCorrectly #59

sharwell opened this issue Nov 18, 2014 · 9 comments

Comments

@sharwell
Copy link
Member

http://www.stylecop.com/docs/SA1126.html

@sharwell
Copy link
Member Author

It seems like this diagnostic is not needed now that we are using Roslyn for analysis (its SemanticModel tells us everything we need to know).

@sharwell
Copy link
Member Author

I am planning to close this issue as wontfix because it is so vaguely worded. If we are in agreement on this, any specific functionality originally part of it can be proposed and implemented as part of new well-defined rules.

@vweijsters
Copy link
Contributor

Sounds like a good plan.

As far as I could determine, the following scenarios should still be addressed:

  • Usage of Equals(objA, objB) and ReferenceEquals(objA, objB)
  • A overridden method where the analyzer cannot decide if the developer intended to call the this implementation or the base implementation

@sharwell
Copy link
Member Author

@vweijsters How might those scenarios be addressed?

💭 For the second one, all of our analyzers currently assume that the intended target is the method that was actually called. That seems to be a reasonable assumption for a style checker.

@AArnott
Copy link
Contributor

AArnott commented Jul 18, 2015

Is SA1126 the rule responsible for enforcing folks prefix this. everywhere? If that's the case, that's a valuable rule that I am eager to resume enforcing once StyleCop.Analyzers supports.

It's fantastic for when you write thread-safe code because it makes it abundantly clear whether you're reading or modifying instance state, or calling an instance method that might.

Please, let's support this rule.

@sharwell
Copy link
Member Author

@AArnott That would be SA1101, and it's been available with a code fix since Alpha 3. In this project we actually have the severity for violations set to Error.

@AArnott
Copy link
Contributor

AArnott commented Jul 18, 2015

I see. In that case, I agree with not implementing this diagnostic.

sharwell added a commit to sharwell/StyleCopAnalyzers that referenced this issue Jul 18, 2015
sharwell added a commit to sharwell/StyleCopAnalyzers that referenced this issue Jul 18, 2015
hvanbakel pushed a commit to hvanbakel/StyleCopAnalyzers that referenced this issue Aug 7, 2015
@naamunds
Copy link

naamunds commented Dec 9, 2022

@sharwell - is there currently a rule for enforcing that a reference to a class-level member is prefixed with the class's name? This would be analogous to SA1101, but for static methods and variables, const variables, etc.

For example, if I define class Person with const string JuniorSuffix = "Jr.", I would want to enforce that references to JuniorSuffix within the Person class are written as Person.JuniorSuffix rather than just JuniorSuffix.

@sharwell
Copy link
Member Author

@naamunds I am not aware of any such rule.

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

4 participants