-
Notifications
You must be signed in to change notification settings - Fork 227
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 FP: Should not mark template-method implementations #9692
Comments
Seems related to #4918, but I think that one was focussed on the raising items on |
The false positive disappeared again at some point after building. Now that I think of it, the S1144 was raised in code, but not the build log. |
Hello @Xilconic, I am not able to reproduce your issue with the given reproducer. Could you please take a look and fix it so I can take a deeper look at it? Thanks, |
Sorry, I took some shortcuts with writing the reproduction example from memory, based on what I was observing in my actual project. I rewrote the provided example: public class Repro()
{
public void SomeMethod()
{
var x = new SomeClass();
string theName = x.Name;
var y = x.DeepClone();
string theOtherName = y.Name;
}
}
public abstract class SomeClassDefiningTemplateMethods
{
public abstract string Name { get; } // Template property
public abstract SomeClassDefiningTemplateMethods DeepClone(); // Template method
}
public class SomeClass : SomeClassDefiningTemplateMethods
{
public override string Name => "FooBar"; // Currently being flagged with `S1144: Remove the unused private property 'Name'.`
public override SomeClassDefiningTemplateMethods DeepClone() // Currently being flagged with `S1144: Remove the unused private method 'DeepClone'.`
{
return new SomeClass();
}
} However it might not prove useful to you, as this particular sample does not raise the S1144 false positive I originally experienced in my original project 😞 Shall we close this issue? And in case I manage to reproduce it again, I'll create a new issue (or reopen this one)? |
Description
S1144 is being raised unexpectedly for template-method implementations.
Repro steps
Expected behavior
S1144 should not be raised by SonarAnalyzer.CSharp
Actual behavior
For template method, raised:
S1144: Remove the unused private method 'DeepClone'.
For template property, raises:
S1144: Remove the unused private property 'Distribution'.
Also the message incorrectly states these are
private
methods/properties, while they actually arepublic
.Known workarounds
Ignore S1144 with #pragma's around method/property overrides.
Related information
The text was updated successfully, but these errors were encountered: