Conversation
…ntity, LocalPluginContext>` which fails at runtime. This fixes #6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a new analyzer and code fix to prevent a common runtime error when using
RegisterStep<TEntity, TService>withLocalPluginContextas the service type. It adds a Roslyn analyzer that detects this misuse at compile time, provides a code fix to automatically rewrite the call to the correctRegisterPluginStep<TEntity>API, and documents the rule and its rationale. Comprehensive tests are included to ensure correct diagnostic and code fix behavior.Key changes:
Analyzer and Code Fix Implementation
LocalPluginContextAsServiceAnalyzerto report an error (XPC3004) whenRegisterStep<TEntity, LocalPluginContext>is used, preventing a runtime exception due toLocalPluginContextnot being registered in the DI container. [1] [2]LocalPluginContextAsServiceCodeFixProviderto provide an automatic fix that rewritesRegisterStep<TEntity, LocalPluginContext>toRegisterPluginStep<TEntity>.Diagnostics and Rule Documentation
AnalyzerReleases.Unshipped.mdand documented it inREADME.mdand a new rule filerules/XPC3004.md. [1] [2] [3]Testing
LocalPluginContextAsServiceAnalyzerTeststo verify the analyzer and code fix, including positive and negative cases, code fix correctness, and title.These changes help catch a subtle but critical error at compile time, improving developer experience and reliability when migrating or writing plugins with dependency injection.
This fixes #6