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

Fix S1117 FN: support primary constructors #8251

Merged
merged 7 commits into from
Oct 27, 2023

Conversation

cristian-ambrosini-sonarsource
Copy link
Contributor

Fixes #8131

Copy link
Contributor

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();

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

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

94.3% 94.3% Coverage
0.0% 0.0% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@pavel-mikula-sonarsource pavel-mikula-sonarsource merged commit 388e7f8 into master Oct 27, 2023
@pavel-mikula-sonarsource pavel-mikula-sonarsource deleted the cristian/S1117-FN-fix_8131 branch October 27, 2023 07:03
@cristian-ambrosini-sonarsource
Copy link
Contributor Author

Peach validation: no changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix S1117 FN: support primary constructors
4 participants