Skip to content

refactor: split ISymbolExtensions into general and Moq-specific files#1037

Merged
rjmurillo merged 3 commits intomainfrom
refactor/979-split-isymbol-extensions
Mar 8, 2026
Merged

refactor: split ISymbolExtensions into general and Moq-specific files#1037
rjmurillo merged 3 commits intomainfrom
refactor/979-split-isymbol-extensions

Conversation

@rjmurillo-bot
Copy link
Copy Markdown
Collaborator

@rjmurillo-bot rjmurillo-bot commented Mar 7, 2026

Summary

Resolves #979. Splits ISymbolExtensions.cs (362 lines) into two cohesive files:

  • ISymbolExtensions.cs (~105 lines) retains general-purpose Roslyn symbol utilities with zero Moq dependencies: IsConstructor, IsInstanceOf (3 overloads), IsOverridable
  • MoqSymbolExtensions.cs (~250 lines) contains all Moq-specific detection methods that depend on MoqKnownSymbols

Methods moved to MoqSymbolExtensions.cs

  • IsMoqSetupMethod, IsMoqSetupAddMethod, IsMoqSetupRemoveMethod, IsMoqEventSetupMethod, IsMoqSetupSequenceMethod
  • IsMoqVerificationMethod
  • IsMoqReturnsMethod, IsMoqThrowsMethod, IsMoqReturnsAsyncMethod, IsMoqThrowsAsyncMethod, IsMoqReturnValueSpecificationMethod
  • IsMoqCallbackMethod, IsMoqRaisesMethod
  • IsTaskOrValueTaskType, IsTaskOrValueResultProperty (both accept MoqKnownSymbols, per code review feedback)
  • Private helpers: IsSetupRaisesMethod, IsConcreteSetupPhraseRaisesMethod, IsCallbackRaisesMethod, IsReturnsRaisesMethod, IsRaiseableMethod, IsGenericResultProperty

Why no call-site changes

Extension methods resolve by namespace, not class name. All consumers already import Moq.Analyzers.Common via GlobalUsings.cs.

Test plan

  • dotnet build passes with 0 errors, 0 warnings
  • dotnet test passes all 2901 tests with 0 failures

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Reorganized internal symbol detection utilities to improve code structure and maintainability, with a reduced public API surface for better encapsulation.

…#979)

Separate Moq-specific symbol detection methods from general-purpose
Roslyn symbol utilities to improve cohesion and discoverability.

Moved to MoqSymbolExtensions.cs:
- All IsMoq* methods (Setup, Verify, Returns, Throws, Callback, Raises)
- IsTaskOrValueTaskType, IsTaskOrValueResultProperty (depend on MoqKnownSymbols)
- IsGenericResultProperty and all Raises private helpers

Kept in ISymbolExtensions.cs:
- IsConstructor, IsInstanceOf (3 overloads), IsOverridable

No call-site changes needed. Extension methods resolve by namespace,
and all consumers already import Moq.Analyzers.Common.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rjmurillo-bot rjmurillo-bot requested a review from rjmurillo as a code owner March 7, 2026 22:37
@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 refactors the symbol extension methods by separating general Roslyn utilities from Moq-specific functionalities. This improves the modularity and maintainability of the codebase by ensuring that files contain only related logic, making it easier to understand and manage dependencies.

Highlights

  • File Split: The large ISymbolExtensions.cs file has been split into two more cohesive files to improve organization and separation of concerns.
  • General Roslyn Extensions: The original ISymbolExtensions.cs now exclusively contains general-purpose Roslyn symbol utilities without any Moq dependencies, such as IsConstructor, IsInstanceOf, and IsOverridable.
  • Moq-Specific Extensions: A new file, MoqSymbolExtensions.cs, has been created to house all Moq-specific detection methods that rely on MoqKnownSymbols, including methods for setup, verification, returns, throws, callbacks, and raises.
  • No Call-Site Changes: The refactoring was performed without requiring any changes to existing call sites, as extension methods resolve by namespace, and all consumers already import the necessary common namespace.
Changelog
  • src/Common/ISymbolExtensions.cs
    • Removed numerous Moq-specific extension methods.
    • Added a XML documentation comment to clarify its general-purpose nature.
  • src/Common/MoqSymbolExtensions.cs
    • Added a new file containing all Moq-specific symbol extension methods previously located in ISymbolExtensions.cs.
    • Included methods for Moq setup, verification, return value specification, callbacks, and event raising.
Activity
  • The pull request author confirmed that dotnet build passes with 0 errors and 0 warnings.
  • The pull request author confirmed that dotnet test passes all 2901 tests with 0 failures.
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 7, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: f2ae1b3b-47c3-4bc1-9e88-bf1f2cbf2c70

📥 Commits

Reviewing files that changed from the base of the PR and between 08986de and 071de6b.

📒 Files selected for processing (2)
  • src/Common/ISymbolExtensions.Moq.cs
  • src/Common/ISymbolExtensions.cs

📝 Walkthrough

Walkthrough

The PR splits ISymbolExtensions into two files: a general-purpose file with core Roslyn utilities and a specialized file containing Moq-specific symbol detection helpers. Visibility of utility methods is reduced to internal, organizing framework-specific detection logic separately from general Roslyn utilities.

Changes

Cohort / File(s) Summary
ISymbolExtensions Refactoring
src/Common/ISymbolExtensions.cs, src/Common/ISymbolExtensions.Moq.cs
Extracted Moq-specific symbol detection methods (IsMoqSetupMethod, IsMoqReturnsMethod, IsMoqRaisesMethod, and 15+ related helpers) into a new partial class file. Reduced visibility of IsConstructor, IsInstanceOf overloads, and IsOverridable from public to internal. Retained general Roslyn utilities in the original file.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested labels

analyzers, housekeeping

Suggested reviewers

  • MattKotsenas
  • rjmurillo
✨ 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 refactor/979-split-isymbol-extensions

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

@deepsource-io
Copy link
Copy Markdown

deepsource-io Bot commented Mar 7, 2026

DeepSource Code Review

We reviewed changes in 08986de...071de6b 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   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
C# Mar 8, 2026 5:43p.m. Review ↗

Comment thread src/Common/ISymbolExtensions.Moq.cs
Comment thread src/Common/ISymbolExtensions.Moq.cs
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 effectively refactors the large ISymbolExtensions.cs file by separating general-purpose Roslyn extension methods from Moq-specific ones into a new MoqSymbolExtensions.cs file. This is a good improvement for code organization and maintainability. The approach of keeping the same namespace to avoid call-site changes is clever. The implementation is a clean move of the existing code. The minor suggestion to improve readability in the new file has been retained as it does not conflict with any established rules.

Comment thread src/Common/ISymbolExtensions.Moq.cs
@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented Mar 7, 2026

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.52% (target: -1.00%) 93.94% (target: 95.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (06b2fe4) 2507 2249 89.71%
Head commit (071de6b) 2537 (+30) 2289 (+40) 90.22% (+0.52%)

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 (#1037) 66 62 93.94%

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

coderabbitai[bot]
coderabbitai Bot previously approved these changes Mar 8, 2026
Comment thread src/Common/MoqSymbolExtensions.cs Outdated
Make ISymbolExtensions a partial class so it can span multiple files.
Rename MoqSymbolExtensions.cs to ISymbolExtensions.Moq.cs following the
C# convention of ClassName.Purpose.cs for partial class files.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
coderabbitai[bot]
coderabbitai Bot previously approved these changes Mar 8, 2026
Comment thread src/Common/ISymbolExtensions.Moq.cs
Comment thread src/Common/ISymbolExtensions.Moq.cs
…sions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai coderabbitai Bot requested review from MattKotsenas and rjmurillo March 8, 2026 17:44
@rjmurillo rjmurillo merged commit dc1a489 into main Mar 8, 2026
28 of 30 checks passed
@rjmurillo rjmurillo deleted the refactor/979-split-isymbol-extensions branch March 8, 2026 17:47
@rjmurillo rjmurillo added this to the vNext milestone Mar 8, 2026
@coderabbitai coderabbitai Bot added housekeeping analyzers Change that impacts an analyzer behavior labels Mar 8, 2026
rjmurillo-bot added a commit that referenced this pull request Mar 8, 2026
…#1037)

## Summary

Resolves #979. Splits `ISymbolExtensions.cs` (362 lines) into two
cohesive files:

- **`ISymbolExtensions.cs`** (~105 lines) retains general-purpose Roslyn
symbol utilities with zero Moq dependencies: `IsConstructor`,
`IsInstanceOf` (3 overloads), `IsOverridable`
- **`MoqSymbolExtensions.cs`** (~250 lines) contains all Moq-specific
detection methods that depend on `MoqKnownSymbols`

### Methods moved to `MoqSymbolExtensions.cs`
- `IsMoqSetupMethod`, `IsMoqSetupAddMethod`, `IsMoqSetupRemoveMethod`,
`IsMoqEventSetupMethod`, `IsMoqSetupSequenceMethod`
- `IsMoqVerificationMethod`
- `IsMoqReturnsMethod`, `IsMoqThrowsMethod`, `IsMoqReturnsAsyncMethod`,
`IsMoqThrowsAsyncMethod`, `IsMoqReturnValueSpecificationMethod`
- `IsMoqCallbackMethod`, `IsMoqRaisesMethod`
- `IsTaskOrValueTaskType`, `IsTaskOrValueResultProperty` (both accept
`MoqKnownSymbols`, per code review feedback)
- Private helpers: `IsSetupRaisesMethod`,
`IsConcreteSetupPhraseRaisesMethod`, `IsCallbackRaisesMethod`,
`IsReturnsRaisesMethod`, `IsRaiseableMethod`, `IsGenericResultProperty`

### Why no call-site changes
Extension methods resolve by namespace, not class name. All consumers
already import `Moq.Analyzers.Common` via `GlobalUsings.cs`.

## Test plan
- [x] `dotnet build` passes with 0 errors, 0 warnings
- [x] `dotnet test` passes all 2901 tests with 0 failures

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Richard Murillo <rjmurillo@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

analyzers Change that impacts an analyzer behavior housekeeping releasable

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: ISymbolExtensions mixes general Roslyn concerns with Moq-specific detection

2 participants