-
Notifications
You must be signed in to change notification settings - Fork 231
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 S1117 FN: support primary constructors #8251
Conversation
analyzers/src/SonarAnalyzer.CSharp/Rules/VariableShadowsField.cs
Outdated
Show resolved
Hide resolved
analyzers/src/SonarAnalyzer.CSharp/Rules/VariableShadowsField.cs
Outdated
Show resolved
Hide resolved
analyzers/src/SonarAnalyzer.CSharp/Rules/VariableShadowsField.cs
Outdated
Show resolved
Hide resolved
analyzers/src/SonarAnalyzer.CSharp/Rules/VariableShadowsField.cs
Outdated
Show resolved
Hide resolved
analyzers/tests/SonarAnalyzer.UnitTest/TestCases/VariableShadowsField.CSharp12.cs
Outdated
Show resolved
Hide resolved
analyzers/tests/SonarAnalyzer.UnitTest/TestCases/VariableShadowsField.CSharp12.cs
Show resolved
Hide resolved
analyzers/src/SonarAnalyzer.CSharp/Rules/VariableShadowsField.cs
Outdated
Show resolved
Hide resolved
analyzers/src/SonarAnalyzer.CSharp/Rules/VariableShadowsField.cs
Outdated
Show resolved
Hide resolved
analyzers/src/SonarAnalyzer.CSharp/Rules/VariableShadowsField.cs
Outdated
Show resolved
Hide resolved
analyzers/tests/SonarAnalyzer.UnitTest/TestCases/VariableShadowsField.CSharp12.cs
Show resolved
Hide resolved
dda3c12
to
c23a507
Compare
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.
LGTM. Some follow-up issues/PRs are needed. See the new comments for details.
{ | ||
var members = context.ContainingSymbol.ContainingType.GetMembers(); | ||
var primaryConstructorParameters = members.FirstOrDefault(x => x.IsPrimaryConstructor())?.GetParameters(); | ||
var fieldsAndProperties = members.Where(x => x is IPropertySymbol or IFieldSymbol).ToList(); |
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.
I think we missed an SemanticModel.IsAccessible check here:
- Private fields/properties are accessible from within the declaring type but not derived types
- protected/public fields/properties are accessible from the declaring and derived types.
Just add a comment about this in #8260
Kudos, SonarCloud Quality Gate passed! |
SonarCloud Quality Gate failed. 0 Bugs 94.3% Coverage Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
Peach validation: no changes |
Fixes #8131