-
Notifications
You must be signed in to change notification settings - Fork 345
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
Add Roslyn analyzer for actor registration #1441
Open
ngruson
wants to merge
7
commits into
dapr:master
Choose a base branch
from
ngruson:1426-ng-analyzer-actor
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains 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
- Introduced `Dapr.Actors` package reference (v1.15.0-rc01). - Added `Microsoft.CodeAnalysis.CSharp.Analyzer.Testing` package reference (v1.1.2). - Created `Dapr.Actors.Analyzers` and `Dapr.Actors.Analyzers.Test` projects. - Implemented `ActorRegistrationAnalyzer` to warn about unregistered actors. - Developed `ActorRegistrationCodeFixProvider` to suggest actor registration. - Added unit tests for both the analyzer and code fix provider. - Updated documentation for analyzer releases. - Enhanced test project with necessary references and utility methods. Signed-off-by: Nils Gruson <[email protected]>
Renamed `ActorRegistrationAnalyzer` to `ActorAnalyzer` and enhanced it to analyze JSON serialization options for actors. Updated the code fix provider to `ActorJsonSerializationCodeFixProvider` to enable JSON serialization when not set. Introduced new diagnostic `DAPR0002` for interoperability with non-.NET actors. Updated project references and added tests for the new functionality while improving code structure and readability. Signed-off-by: Nils Gruson <[email protected]>
Introduce a new diagnostic rule (DAPR0003) that warns users to call `app.MapActorsHandlers` for Dapr actors. Implemented in the `ActorAnalyzer` class with a corresponding code fix provider (`MapActorsHandlersCodeFixProvider`) to automatically add the call when needed. Updated `SupportedDiagnostics` to include DAPR0003 and added the `AnalyzeMapActorsHandlers` method for syntax tree analysis. Introduced `FindInvocation` to locate method calls in the syntax tree. Added tests in `ActorAnalyzerTests` and `MapActorsHandlersCodeFixProviderTests` to validate the new functionality, covering various scenarios. Updated `Utilities` and `VerifyAnalyzer` classes to include necessary assembly references for compatibility across .NET versions. Made minor adjustments to existing code and tests for consistency. Signed-off-by: Nils Gruson <[email protected]>
…otnet-sdk into 1426-ng-analyzer-actor
Simplify handling of createBuilderInvocation and buildInvocation by removing unnecessary nested checks. Improve code readability with clearer conditional blocks. Ensure the document is returned with the modified syntax root after changes. Signed-off-by: Nils Gruson <[email protected]>
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.
Description
This PR adds a Roslyn analyzer that checks if actors are registered properly.
For every actor in the project, the analyzer checks if there's a corresponding
RegisterActor
call in the application setup.If there's no
AddActors
call yet, it will add it as well. The analyzer will look forWebApplication.CreateBuilder
and adds the actor registration directly below it.Dapr.Actors
package reference.Microsoft.CodeAnalysis.CSharp.Analyzer.Testing
package reference (v1.1.2).Dapr.Actors.Analyzers
andDapr.Actors.Analyzers.Test
projects.ActorRegistrationAnalyzer
to warn about unregistered actors.ActorRegistrationCodeFixProvider
to suggest actor registration.Issue reference
This PR belongs to issue #1426.
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list: