-
Notifications
You must be signed in to change notification settings - Fork 269
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 MSTEST0036 is shown for cases where no shadowing happens #3881
Conversation
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.
We have another FP when the methods are private (add the same private method in current and base and you will see a false positive).
@@ -112,7 +112,8 @@ private static bool IsMemberShadowing(ISymbol member, ISymbol baseMember) | |||
} | |||
|
|||
// Compare methods | |||
if (member is IMethodSymbol methodSymbol && baseMember is IMethodSymbol baseMethodSymbol) | |||
if (member is IMethodSymbol methodSymbol && baseMember is IMethodSymbol baseMethodSymbol && methodSymbol.IsGenericMethod == baseMethodSymbol.IsGenericMethod | |||
&& !(methodSymbol.DeclaredAccessibility == Accessibility.Private && baseMethodSymbol.DeclaredAccessibility == Accessibility.Private)) |
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.
It also can't be shadowing if only one of the methods is private, or can it?
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 right, I find the syntax confusing but @engyebrahim added the not before the parenthesis so the and clause becomes a or :)
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.
- private and private:
!(true && true) = false
(ok) - public and public:
!(false && false) = true
(ok) - private and public:
!(true && false) = true
(not ok, is not shadowing)
And I think the visibility check also needs to happen in the "Compare properties" section below.
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.
Oh yeah good point, I overlooked last case. @engyebrahim can you please add more tests and probably fix the remaining broken part?
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.
fix: #3824