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 S1144: False Positive when private member is only used in a gener… #2320

Merged
merged 1 commit into from
Mar 6, 2019

Conversation

Evangelink
Copy link
Contributor

…ated file

Fix #2312

@ghost ghost assigned Evangelink Mar 6, 2019
@ghost ghost added the Status: Needs Review label Mar 6, 2019
@@ -85,7 +85,7 @@ protected override void Initialize(SonarAnalysisContext context)
// Collect symbols of private members that could potentially be removed
var removableSymbolsCollector = new CSharpRemovableSymbolWalker(c.Compilation.GetSemanticModel);

if (!VisitDeclaringReferences(namedType, removableSymbolsCollector, c.Compilation))
if (!VisitDeclaringReferences(namedType, removableSymbolsCollector, c.Compilation, includeGeneratedFile: false))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to collect the members declared in generated files as we don't want to report about them...

@@ -100,7 +100,7 @@ protected override void Initialize(SonarAnalysisContext context)
c.Compilation.GetSemanticModel,
removableSymbolsCollector.PrivateSymbols.Select(s => s.Name).ToHashSet());

if (!VisitDeclaringReferences(namedType, usageCollector, c.Compilation))
if (!VisitDeclaringReferences(namedType, usageCollector, c.Compilation, includeGeneratedFile: true))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... But we do want to collect the usages of other members even in generated files.

@Evangelink Evangelink merged commit a4160cd into master Mar 6, 2019
@Evangelink Evangelink deleted the ammo/S1144-used-generated branch March 6, 2019 16:44
@ghost ghost removed the Status: Needs Review label Mar 6, 2019
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.

1 participant