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 S3264: FP when using add/remove syntax #1229

Merged
merged 2 commits into from
Mar 20, 2018
Merged

Fix S3264: FP when using add/remove syntax #1229

merged 2 commits into from
Mar 20, 2018

Conversation

valhristov
Copy link
Contributor

@valhristov valhristov commented Mar 14, 2018

Removed the check for EventDeclarationSyntax as it cannot be invoked. One can only invoke EventFieldDeclarationSyntax but checking whether the event declaration is using the correct field is a different rule IMO. S3237 will report if the value of the accessor is not used (e.g. if you don't assign an event field).

Refactored the implementation a bit to make it more functional and somewhat easier to understand.

Fix #1219
Fix #1123

var removableEvents = removableDeclarationCollector.GetRemovableDeclarations(
ImmutableHashSet.Create(SyntaxKind.EventDeclaration), maxAccessibility);
var removableEventFields = removableDeclarationCollector.GetRemovableFieldLikeDeclarations(
ImmutableHashSet.Create(SyntaxKind.EventFieldDeclaration), maxAccessibility);
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 found that ImmutableHashSet is a bit slower than HashSet before, hence I switched to HashSet.


protected void OnEvent1()
{
PublicEvent += (s, o) => { }; // Need to use the event to be able to trigger issues
Copy link
Contributor Author

Choose a reason for hiding this comment

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

IF the event declaration is not used we don't report, hence we need this line.

Copy link
Contributor

Choose a reason for hiding this comment

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

If that's not used do you know if we have another rule triggering (like unused member or something like that)? I actually think we should always report because this rule is about dead code so not subscribing + not raising = issue.

WDYT?

@valhristov valhristov changed the base branch from master to dev March 14, 2018 15:51

protected void OnEvent1()
{
PublicEvent += (s, o) => { }; // Need to use the event to be able to trigger issues
Copy link
Contributor

Choose a reason for hiding this comment

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

If that's not used do you know if we have another rule triggering (like unused member or something like that)? I actually think we should always report because this rule is about dead code so not subscribing + not raising = issue.

WDYT?

@valhristov
Copy link
Contributor Author

valhristov commented Mar 19, 2018

@Evangelink, the unused member will raise issue when the event is not used. I would not increase the scope of the tickets, we could rather create a new ticket to update the rule.

@valhristov valhristov merged commit f4df640 into dev Mar 20, 2018
@ghost ghost removed the Status: Needs Review label Mar 20, 2018
@valhristov valhristov deleted the s3264 branch March 20, 2018 10:37
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.

2 participants