Skip to content

fix: update test to expect diagnostic for generic callback type mismatch#1057

Merged
rjmurillo merged 4 commits intomainfrom
fix/generic-callback-test-regression
Mar 9, 2026
Merged

fix: update test to expect diagnostic for generic callback type mismatch#1057
rjmurillo merged 4 commits intomainfrom
fix/generic-callback-test-regression

Conversation

@rjmurillo
Copy link
Copy Markdown
Owner

Summary

  • Renamed GenericCallbackValidation_CurrentLimitation_IsDocumented to GenericCallbackWithWrongType_ProducesDiagnostic
  • Updated the test to expect Moq1100 diagnostic on .Callback<int>(wrongTypeParam => { }) where the mocked method takes string
  • The "known limitation" no longer exists after PR fix: replace string-based detection with symbol-based detection #1030 introduced symbol-based detection, which correctly resolves generic type arguments

Test plan

  • Both Net80WithOldMoq and Net80WithNewMoq variants pass locally (2/2 passed)
  • CI passes on this branch

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings March 9, 2026 01:54
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 Callback<T>() syntax with incorrect type parameters was not properly validated. Leveraging symbol-based detection introduced in a prior PR, the analyzer can now accurately identify these type mismatches. The changes update an existing test to verify that the analyzer correctly produces the expected Moq1100 diagnostic for such scenarios, enhancing the robustness of type checking for Moq callbacks.

Highlights

  • Test Renaming: Renamed the test method GenericCallbackValidation_CurrentLimitation_IsDocumented to GenericCallbackWithWrongType_ProducesDiagnostic to accurately reflect its updated purpose.
  • Diagnostic Expectation: Updated the test to now expect a Moq1100 diagnostic when .Callback<int>(wrongTypeParam => { }) is used with a mocked method expecting a string parameter, indicating a type mismatch.
  • Limitation Resolution: Confirmed that a previous 'known limitation' regarding generic callback validation no longer exists, as symbol-based detection introduced in PR fix: replace string-based detection with symbol-based detection #1030 now correctly resolves generic type arguments.
Changelog
  • tests/Moq.Analyzers.Test/CallbackSignatureShouldMatchMockedMethodAnalyzerTests.cs
    • Renamed the test method GenericCallbackValidation_CurrentLimitation_IsDocumented to GenericCallbackWithWrongType_ProducesDiagnostic.
    • Updated the test's documentation comments to reflect the new diagnostic expectation and the resolution of the previous limitation.
    • Modified the test case to expect a Moq1100 diagnostic for a type mismatch in Callback<int>() where the mocked method expects a string.
    • Removed outdated comments that described the previous known limitation.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 9, 2026

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8fe68f6c-b970-48f5-b64c-3838788eb582

📥 Commits

Reviewing files that changed from the base of the PR and between a974999 and 5d56135.

📒 Files selected for processing (2)
  • docs/rules/Moq1100.md
  • tests/Moq.Analyzers.Test/CallbackSignatureShouldMatchMockedMethodAnalyzerTests.cs
 _________________________________________________________
< Your config has more knobs than a 2004 Honda dashboard. >
 ---------------------------------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ

✏️ Tip: You can disable in-progress messages and the fortune message in your review settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/generic-callback-test-regression

Comment @coderabbitai help to get the list of available commands and usage tips.

@deepsource-io
Copy link
Copy Markdown

deepsource-io bot commented Mar 9, 2026

DeepSource Code Review

We reviewed changes in a974999...2de610c on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

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 ↗

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
coderabbitai[bot]
coderabbitai bot previously approved these changes Mar 9, 2026
@codacy-production
Copy link
Copy Markdown

codacy-production bot commented Mar 9, 2026

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for a9749991 (target: 95.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (a974999) Report Missing Report Missing Report Missing
Head commit (2de610c) 2554 2295 89.86%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#1057) 0 0 ∅ (not applicable)

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Footnotes

  1. Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_IsDocumentedGenericCallbackWithWrongType_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

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rjmurillo rjmurillo merged commit 93e725c into main Mar 9, 2026
41 of 42 checks passed
@rjmurillo rjmurillo deleted the fix/generic-callback-test-regression branch March 9, 2026 15:34
@rjmurillo rjmurillo added this to the vNext milestone Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants