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.
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 rule to explicitly pick MockBehavior #226
Add rule to explicitly pick MockBehavior #226
Changes from all commits
82ac176
e4262de
12d7d8b
b9a4556
4992005
1c0ade3
4f6a565
4f8b41f
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Clarify Suppression of 'ECS0900' Warning
The suppression of the
ECS0900
warning for minimizing boxing and unboxing is noted. Consider providing a comment explaining why this suppression is necessary to aid future maintainability.Apply this diff to add an explanatory comment:
#pragma warning disable ECS0900 // Minimize boxing and unboxing +// Suppressing this warning because the LINQ query does not significantly impact performance in this context. ImmutableArray<IMethodSymbol> ofMethods = mockTypes
📝 Committable suggestion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Handle Explicit Behaviors Specified via Variables or Expressions
The current implementation checks for mock behaviors specified directly as field references. Consider extending the analysis to handle scenarios where the mock behavior is provided via variables, method calls, or expressions to avoid false positives.
For example, if a mock behavior is assigned to a variable and then passed as an argument, the analyzer may incorrectly report a diagnostic. Enhancing the logic to perform a more comprehensive analysis of the argument values can improve accuracy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Provide More Specific Diagnostic Location
When reporting the diagnostic, consider pinpointing the location of the default mock behavior argument rather than the entire object creation syntax. This will help developers identify the exact issue more efficiently.
Apply this diff to report the diagnostic at the specific argument location:
📝 Committable suggestion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Unified Argument Analysis across Methods
The argument analysis logic in
AnalyzeInvocation
mirrors that inAnalyzeNewObject
. Consider refactoring this repetitive code into a shared method to enhance maintainability and reduce duplication.Extract the argument analysis into a helper method:
Then update the methods: