Options for handler style settable via .editorconfig#7681
Options for handler style settable via .editorconfig#7681DavidBoike wants to merge 2 commits intomasterfrom
Conversation
…ntions to determine which fixers are available
|
@copilot This feature is potentially incomplete. By controlling which code fixes can be used, it only suggests the NServiceBus handler style for new message handlers as they're being written, but does nothing to help a project maintainer enforce a handler style for handlers that already exist or that a developer types up manually. Could you please raise a PR on top of this PR to add an additional analyzer to enforce this if the .editorconfig file contains the
|
|
@DavidBoike I've opened a new pull request, #7682, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
Closing, as I'm not sold that this is the way to go about this, plus it's not 100% not necessary and could be added later in a minor. |
This pull request introduces a new
nservicebus_handler_styleoption with values of eitherIHandleMessagesorConventionsto the.editorconfigfile that control which fixers are allowed to scaffold an NServiceBus message handler when the[Handler]attribute is applied to a class:When either of these options is set in .editorconfig, it determines the preferred organization for NServiceBus message handlers within the codebase. This centralized configuration allows project maintainers to suggest a consistent handler structure across the codebase, streamlining code reviews and onboarding for contributors.
Because
.editorconfigfiles are hierarchical, project maintainers can control which styles are preferred in different parts of the codebase, if there are differences.No setting (default)
When no setting is used, both fixers are available:
Implement IHandleMessages<MyMessage>Add convention-based Handle(MyMessage, ...)IHandleMessages only
When the
.editorconfigfile contains:nservicebus_handler_style = IHandleMessagesThen only the
Implement IHandleMessages<MyMessage>code fix is available.Conventions only
When the
.editorconfigfile containsnservicebus_handler_style = ConventionsDetails
IHandleMessagesorConventions) is case insensitive.Then only the
Add convention-based Handle(MyMessage, ...)code fix is available.