You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Removing polymorphic command serialization and replacing with explicit method parameter could break existing code that relies on the polymorphic behavior. Validate that all command types are properly handled with the new approach.
The new generic ExecuteCommandAsync methods need validation to ensure type constraints between TCommand and TResult are properly enforced to prevent runtime errors.
The change to use TCommand type for serialization instead of base Command type needs verification that all command types serialize correctly with the new approach.
✅ Add type constraint for safetySuggestion Impact:The commit implemented the suggested type constraint by adding 'where TCommand : Command' to the generic method signature
The generic SendAsJsonAsync method should include a constraint to ensure T is a Command type to maintain type safety and prevent invalid command objects from being sent.
-Task SendAsJsonAsync<T>(T command, JsonSerializerContext jsonSerializerContext, CancellationToken cancellationToken);+Task SendAsJsonAsync<T>(T command, JsonSerializerContext jsonSerializerContext, CancellationToken cancellationToken) where T : Command;
Apply this suggestion
Suggestion importance[1-10]: 8
Why: Adding a type constraint to ensure T is a Command type is a critical safety improvement that prevents runtime errors by enforcing proper type checking at compile time. This is especially important as the PR changes the signature from a concrete Command type to a generic T.
8
Learned best practice
Add null validation check for required constructor parameters to prevent NullReferenceException
The Command constructor should validate that the @params parameter is not null since it's required for command execution. Add ArgumentNullException.ThrowIfNull() check at the start of the constructor.
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
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.
User description
Simplify declaration of commands.
Motivation and Context
Improves AOT.
Types of changes
Checklist
PR Type
Enhancement
Description
Refactored
Commandclass to remove polymorphism and simplify structure.Updated BiDi modules to use generic
ExecuteCommandAsyncfor better type safety.Added explicit
methodparameter to all command classes for improved serialization.Enhanced JSON serialization context to include all command types explicitly.
Changes walkthrough 📝
15 files
Refactored `ExecuteCommandAsync` to use generics.Removed polymorphic attributes and added `method` parameter.Updated JSON serialization context to include all commands.Updated `SendAsJsonAsync` to use generics.Refactored `SendAsJsonAsync` to handle generic command types.Updated `ExecuteCommandAsync` calls to use generics.Added explicit `method` parameter to `CloseCommand`.Added explicit `method` parameter to `CreateUserContextCommand`.Added explicit `method` parameter to `GetUserContextsCommand`.Added explicit `method` parameter to `RemoveUserContextCommand`.Updated `ExecuteCommandAsync` calls to use generics.Added explicit `method` parameter to `CreateCommand`.Updated `ExecuteCommandAsync` calls to use generics.Updated `ExecuteCommandAsync` calls to use generics.Updated `ExecuteCommandAsync` calls to use generics.36 files