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

CQRS handlers name analyzer + code action #608

Merged
merged 13 commits into from
Nov 16, 2023

Conversation

wojtek2288
Copy link
Contributor

No description provided.

return await Renamer.RenameSymbolAsync(
solution,
classSymbol,
new(RenameFile: true),
Copy link
Contributor Author

@wojtek2288 wojtek2288 Nov 8, 2023

Choose a reason for hiding this comment

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

thank god (or roslyn) for this option

@wojtek2288 wojtek2288 force-pushed the feature/cqrs-handlers-name-analyzer branch from e7dbf79 to a7888a9 Compare November 8, 2023 09:37
Copy link
Contributor

@Dragemil Dragemil left a comment

Choose a reason for hiding this comment

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

Will command validators also be handled in a similar way?

@wojtek2288 wojtek2288 changed the base branch from v8.0-preview to task/format-with-csharpier-26 November 8, 2023 11:25
@wojtek2288 wojtek2288 force-pushed the feature/cqrs-handlers-name-analyzer branch from f402ea1 to 91e1b11 Compare November 8, 2023 11:28
Copy link

github-actions bot commented Nov 8, 2023

Test Results

  33 files  ±  0  113 suites  +4   59s ⏱️ -1s
624 tests +13  611 ✔️ +13  13 💤 ±0  0 ±0 
640 runs  +13  620 ✔️ +13  20 💤 ±0  0 ±0 

Results for commit d4f5ad4. ± Comparison against base commit 00a3e79.

This pull request removes 3 and adds 16 tests. Note that renamed tests count towards both.
LeanCode.CodeAnalysis.Tests.CodeActions.FixCancellationTokenNamingActionTests ‑ Does_not_rename_overridden_and_new_methods(keyword: "new")
LeanCode.CodeAnalysis.Tests.CodeActions.FixCancellationTokenNamingActionTests ‑ Does_not_rename_overridden_and_new_methods(keyword: "override")
LeanCode.CodeAnalysis.Tests.CodeActions.FixCancellationTokenNamingActionTests ‑ Renames_CancellationToken_argument_not_following_convention
LeanCode.CodeAnalysis.Tests.Analyzers.EnsureCQRSHandlersFollowNamingConventionTests ‑ CQRS_handlers_following_naming_convention_are_accepted(cqrsType: "command")
LeanCode.CodeAnalysis.Tests.Analyzers.EnsureCQRSHandlersFollowNamingConventionTests ‑ CQRS_handlers_following_naming_convention_are_accepted(cqrsType: "operation")
LeanCode.CodeAnalysis.Tests.Analyzers.EnsureCQRSHandlersFollowNamingConventionTests ‑ CQRS_handlers_following_naming_convention_are_accepted(cqrsType: "query")
LeanCode.CodeAnalysis.Tests.Analyzers.EnsureCQRSHandlersFollowNamingConventionTests ‑ Command_handlers_not_following_naming_convention_are_rejected
LeanCode.CodeAnalysis.Tests.Analyzers.EnsureCQRSHandlersFollowNamingConventionTests ‑ Operation_handlers_not_following_naming_convention_are_rejected
LeanCode.CodeAnalysis.Tests.Analyzers.EnsureCQRSHandlersFollowNamingConventionTests ‑ Query_handlers_not_following_naming_convention_are_rejected
LeanCode.CodeAnalysis.Tests.Analyzers.EnsureValidatorsFollowNamingConventionTests ‑ Validators_following_naming_convention_are_accepted
LeanCode.CodeAnalysis.Tests.Analyzers.EnsureValidatorsFollowNamingConventionTests ‑ Validators_not_following_naming_convention_are_rejected
LeanCode.CodeAnalysis.Tests.CodeActions.FixCQRSHandlerNamingCodeActionTests ‑ Renames_command_handlers_not_following_naming_convention
LeanCode.CodeAnalysis.Tests.CodeActions.FixCQRSHandlerNamingCodeActionTests ‑ Renames_handlers_to_multiple_contracts_not_following_naming_convention
…

♻️ This comment has been updated with latest results.

Copy link

codecov bot commented Nov 8, 2023

Codecov Report

Attention: 15 lines in your changes are missing coverage. Please review.

Comparison is base (3757521) 65.19% compared to head (b8619dc) 66.30%.
Report is 1 commits behind head on v8.0-preview.

❗ Current head b8619dc differs from pull request most recent head d4f5ad4. Consider uploading reports for the commit d4f5ad4 to get more accurate results

Files Patch % Lines
...lyzers/EnsureCQRSHandlersFollowNamingConvention.cs 91.52% 5 Missing and 5 partials ⚠️
...s/EnsureCommandValidatorsFollowNamingConvention.cs 97.82% 0 Missing and 1 partial ⚠️
...ysis/CodeActions/FixCQRSHandlerNamingCodeAction.cs 91.66% 1 Missing ⚠️
...CodeActions/FixCommandValidatorNamingCodeAction.cs 85.71% 1 Missing ⚠️
...ixProviders/FixCQRSHandlerNamingCodeFixProvider.cs 92.30% 1 Missing ⚠️
...viders/FixCommandValidatorNamingCodeFixProvider.cs 88.88% 1 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff                @@
##           v8.0-preview     #608      +/-   ##
================================================
+ Coverage         65.19%   66.30%   +1.11%     
================================================
  Files               211      217       +6     
  Lines              4864     5069     +205     
  Branches            303      322      +19     
================================================
+ Hits               3171     3361     +190     
- Misses             1602     1611       +9     
- Partials             91       97       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@wojtek2288
Copy link
Contributor Author

wojtek2288 commented Nov 8, 2023

@Dragemil We did not discuss adding similar analyzer for command validators but now when you mention it I think it can be added to the backlog. Btw there is already quick action which will add command validator, but in our case we often copy code from other commands so rename might be also useful. cc: @lukaszgarstecki

Base automatically changed from task/format-with-csharpier-26 to v8.0-preview November 8, 2023 13:54
@wojtek2288 wojtek2288 force-pushed the feature/cqrs-handlers-name-analyzer branch from ded6874 to 98498d7 Compare November 8, 2023 13:56
@lukaszgarstecki
Copy link
Member

I'd say a rename + quickfix can also be helpful for CV. The current analyzer tackles only the case when it's missing, I believe having similar validator as for CH, QH and OH would be nice. Will that be a lot of work @wojtek2288 ?

Copy link
Member

@lukaszgarstecki lukaszgarstecki left a comment

Choose a reason for hiding this comment

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

LGTM. I'd say that we can add CV rule and fix in this PR if this is not too much trouble

@wojtek2288 wojtek2288 force-pushed the feature/cqrs-handlers-name-analyzer branch from 9195214 to b8619dc Compare November 16, 2023 13:09
@wojtek2288
Copy link
Contributor Author

Need to wait for #618. As bumping dotnet to 8.0.100 fixes this issue: dotnet/sdk#36434

@wojtek2288 wojtek2288 force-pushed the feature/cqrs-handlers-name-analyzer branch from b8619dc to d4f5ad4 Compare November 16, 2023 15:21
@wojtek2288 wojtek2288 merged commit bae2dea into v8.0-preview Nov 16, 2023
@wojtek2288 wojtek2288 deleted the feature/cqrs-handlers-name-analyzer branch November 16, 2023 15:29
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.

3 participants