feat: update AsShouldBeUsedOnlyForInterfaceAnalyzer metadata for better diagnostics#668
feat: update AsShouldBeUsedOnlyForInterfaceAnalyzer metadata for better diagnostics#668
Conversation
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferences |
…sted Co-authored-by: rjmurillo <6811113+rjmurillo@users.noreply.github.com>
|
Reviewer note: I'm A/B against #669 |
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Join our Discord community for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the AsShouldBeUsedOnlyForInterfaceAnalyzer by improving diagnostic messaging and updating categorization. The analyzer now provides more specific error messages that include the actual problematic type name, making it easier for developers to identify and fix issues.
Key Changes
- Enhanced diagnostic message format to include the specific type name that's causing the error
- Changed diagnostic category from "Moq" to "Usage" for better classification
- Added Usage category to the DiagnosticCategory class
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/Common/DiagnosticCategory.cs |
Added new "Usage" category constant |
src/Analyzers/AsShouldBeUsedOnlyForInterfaceAnalyzer.cs |
Updated diagnostic metadata with format string message, description, and category change; modified analysis to pass type name |
src/Analyzers/AnalyzerReleases.Unshipped.md |
Added release tracking entry for category change |
| { | ||
| private static readonly LocalizableString Title = "Moq: Invalid As type parameter"; | ||
| private static readonly LocalizableString Message = "Mock.As() should take interfaces only"; | ||
| private static readonly LocalizableString Message = "Mock.As() should take interfaces only, but '{0}' is not an interface"; |
There was a problem hiding this comment.
[nitpick] The description ends with a period while the message format string doesn't. For consistency, either both should have periods or neither should.
| private static readonly LocalizableString Message = "Mock.As() should take interfaces only, but '{0}' is not an interface"; | |
| private static readonly LocalizableString Message = "Mock.As() should take interfaces only, but '{0}' is not an interface."; |
This PR updates the metadata for
AsShouldBeUsedOnlyForInterfaceAnalyzerto provide more informative diagnostics and better categorization.Changes Made
Enhanced Diagnostic Messaging
Category Improvement
DiagnosticCategoryto include the new Usage constantExample Output Improvement
Before:
After:
The enhanced message clearly identifies which specific type is problematic, making it easier for developers to understand and fix the issue.
Validation
Fixes #648.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.