fix: update test to expect diagnostic for generic callback type mismatch#1057
fix: update test to expect diagnostic for generic callback type mismatch#1057
Conversation
The analyzer now correctly detects type mismatches in generic Callback<T>() syntax after symbol-based detection was introduced in PR #1030. The previous 'known limitation' test expected no diagnostic, but the analyzer now correctly produces Moq1100. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a previous limitation in the Moq analyzer where the explicit generic Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
✏️ Tip: You can disable in-progress messages and the fortune message in your review settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
|
|
Overall Grade Focus Area: Hygiene |
Security Reliability Complexity Hygiene |
Feedback
- [Async-naming drift]
- Task-returning methods lack the "Async" suffix across tests and likely production; inconsistent naming points to missing enforcement. Centralize the rule in a Roslyn analyzer or editorconfig and autofix to stop naming drift.
- [Tests depend on fragile names]
- Analyzer tests use literal method names, so naming slips cause misleading failures or blind spots. Make tests assert diagnostics via symbol properties or generated code patterns rather than hardcoded names.
- [Tooling blind spots fuel hygiene decay]
- Sporadic style violations show tooling isn't enforcing rules, so small hygiene issues accumulate unnoticed. Enable repo-level analyzers, editorconfig and auto-fix in IDE/CI to detect and correct issues automatically.
Code Review Summary
| Analyzer | Status | Updated (UTC) | Details |
|---|---|---|---|
| C# | Mar 9, 2026 2:07a.m. | Review ↗ |
There was a problem hiding this comment.
Code Review
This pull request correctly updates a test to verify that a previously known limitation with generic callback type validation has been fixed. The test now expects a diagnostic for a type mismatch, which is a good improvement. My review identified that the associated documentation has not been updated to reflect this fix, which could cause confusion for users. This comment has been kept as it does not violate any of the provided rules.
tests/Moq.Analyzers.Test/CallbackSignatureShouldMatchMockedMethodAnalyzerTests.cs
Show resolved
Hide resolved
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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 preferencesFootnotes
|
There was a problem hiding this comment.
Pull request overview
This PR updates a test in CallbackSignatureShouldMatchMockedMethodAnalyzerTests to reflect that the "known limitation" around validating .Callback<T>() with a mismatched generic type argument no longer exists. The test is renamed and updated to expect a Moq1100 diagnostic where the mocked method takes string but the callback uses .Callback<int>().
Changes:
- Renamed
GenericCallbackValidation_CurrentLimitation_IsDocumented→GenericCallbackWithWrongType_ProducesDiagnostic - Updated test expectations from "no diagnostic expected" to
{|Moq1100:wrongTypeParam|}marking the mismatched parameter - Removed the outdated "known limitation" documentation comment and its associated
<remarks>block
tests/Moq.Analyzers.Test/CallbackSignatureShouldMatchMockedMethodAnalyzerTests.cs
Outdated
Show resolved
Hide resolved
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
tests/Moq.Analyzers.Test/CallbackSignatureShouldMatchMockedMethodAnalyzerTests.cs
Outdated
Show resolved
Hide resolved
tests/Moq.Analyzers.Test/CallbackSignatureShouldMatchMockedMethodAnalyzerTests.cs
Outdated
Show resolved
Hide resolved
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
GenericCallbackValidation_CurrentLimitation_IsDocumentedtoGenericCallbackWithWrongType_ProducesDiagnostic.Callback<int>(wrongTypeParam => { })where the mocked method takesstringTest plan
Net80WithOldMoqandNet80WithNewMoqvariants pass locally (2/2 passed)🤖 Generated with Claude Code