Skip to content

Comments

docs: Add XML documentation to top-level classes#16

Merged
DrBarnabus merged 2 commits intomainfrom
top-level-xmldoc
Jun 29, 2025
Merged

docs: Add XML documentation to top-level classes#16
DrBarnabus merged 2 commits intomainfrom
top-level-xmldoc

Conversation

@DrBarnabus
Copy link
Owner

@DrBarnabus DrBarnabus commented Jun 29, 2025

Summary by CodeRabbit

  • New Features

    • Introduced new setup methods for configuring mocked methods and properties, including support for property getters, setters, and automatic property behaviour.
    • Added generic type matchers for flexible mock setups, covering unconstrained, reference type, value type, and assignable type scenarios.
  • Documentation

    • Added comprehensive XML documentation to all public methods, properties, and interfaces in the mocking framework, improving clarity and usage guidance for argument matchers, call count constraints, verification methods, generic matchers, and mimic instance management.

@DrBarnabus
Copy link
Owner Author

@coderabbitai full review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 29, 2025

✅ Actions performed

Full review triggered.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 29, 2025

Walkthrough

This update introduces extensive XML documentation comments across the Mimic mocking framework's public APIs, clarifying usage, behaviour, and constraints for users and maintainers. It also adds new setup methods to the Mimic<T> class, enabling more expressive configuration of method and property behaviours in mocks. No functional or logic changes are present except for the new setup methods.

Changes

File(s) Change Summary
src/Mimic/Arg.cs Added XML documentation comments to all public methods and nested classes in Arg.
src/Mimic/CallCount.cs Added XML documentation to the CallCount struct and all its public static and instance methods.
src/Mimic/Generic.cs Introduced new Generic class with four generic matcher types, each with XML documentation.
src/Mimic/IGenericMatcher.cs Added comprehensive XML documentation to the IGenericMatcher interface and its method.
src/Mimic/IMimicked`1.cs Added XML documentation to the IMimicked<T> interface and its property.
src/Mimic/Mimic`1.Setup.cs Added new public setup methods for configuring mocks in Mimic<T>, all with XML documentation.
src/Mimic/Mimic`1.VerifyReceived.cs Added XML documentation to all public verification methods in Mimic<T>.
src/Mimic/Mimic`1.cs Added XML documentation to public/internal members, constructors, and methods of Mimic<T>.

Sequence Diagram(s)

sequenceDiagram
    participant Test as Test Code
    participant Mimic as Mimic<T>
    participant MockObj as Mocked Object

    Test->>Mimic: Setup(expression)
    Mimic-->>Test: Returns setup interface

    Test->>Mimic: SetupGet/SetupSet/SetupProperty(...)
    Mimic-->>Test: Returns setup interface or self

    Test->>Mimic: VerifyReceived(expression, ...)
    Mimic-->>Test: Throws if verification fails

    Test->>MockObj: Calls method/property
    MockObj-->>Mimic: Records invocation
Loading

Poem

In the warren of code, comments now bloom,
With XML petals dispelling the gloom.
Setup and verify, with clarity bright,
Each method explained, every usage in sight.
New matchers hop in, generic and spry—
This rabbit approves with a twinkle in eye!
🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4a30169 and d3f1f9b.

📒 Files selected for processing (1)
  • src/Mimic/Mimic1.Setup.cs` (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Mimic/Mimic`1.Setup.cs
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: Test (macos-latest, net9.0)
  • GitHub Check: Test (ubuntu-latest, net9.0)
  • GitHub Check: Test (ubuntu-latest, net8.0)
  • GitHub Check: Test (macos-latest, net8.0)
  • GitHub Check: Package (ubuntu-latest)
  • GitHub Check: Package (macos-latest)
  • GitHub Check: Analyze (csharp)
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov
Copy link

codecov bot commented Jun 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.24%. Comparing base (0d7661e) to head (d3f1f9b).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #16      +/-   ##
==========================================
- Coverage   92.38%   92.24%   -0.15%     
==========================================
  Files          64       64              
  Lines        2115     2115              
  Branches      365      365              
==========================================
- Hits         1954     1951       -3     
- Misses         84       86       +2     
- Partials       77       78       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/Mimic/Mimic`1.Setup.cs (1)

79-79: Fix typo in XML documentation.

There's a typographical error in the documentation.

-    /// Sets up a property setter on the mocked object to be configured with behaviours, with stronglytyped property support.
+    /// Sets up a property setter on the mocked object to be configured with behaviours, with strongly-typed property support.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0d7661e and 4a30169.

📒 Files selected for processing (8)
  • src/Mimic/Arg.cs (1 hunks)
  • src/Mimic/CallCount.cs (3 hunks)
  • src/Mimic/Generic.cs (1 hunks)
  • src/Mimic/IGenericMatcher.cs (1 hunks)
  • src/Mimic/IMimicked1.cs` (1 hunks)
  • src/Mimic/Mimic1.Setup.cs` (5 hunks)
  • src/Mimic/Mimic1.VerifyReceived.cs` (2 hunks)
  • src/Mimic/Mimic1.cs` (4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/Mimic/Mimic`1.VerifyReceived.cs (9)
src/Mimic.UnitTests/MimicTests.VerifyReceived.cs (1)
  • VerifyReceived (8-874)
src/Mimic/IMimic.cs (1)
  • VerifyReceived (15-15)
src/Mimic/Setup/Fluent/SequenceSetupBase.cs (1)
  • Expected (173-173)
src/Mimic/Setup/Fluent/SetupBase.cs (3)
  • Expected (286-286)
  • SetupBase (3-289)
  • SetupBase (5-10)
src/Mimic/Fluent/IExpected.cs (1)
  • Expected (7-7)
src/Mimic/Setup/SetupBase.cs (2)
  • SetupBase (5-85)
  • SetupBase (23-28)
src/Mimic/Setup/SetupCollection.cs (1)
  • SetupBase (25-44)
src/Mimic/Expressions/SetterExpressionConstructor.cs (3)
  • Expression (7-39)
  • Expression (47-128)
  • T (41-45)
src/Mimic/CallCount.cs (10)
  • CallCount (13-18)
  • CallCount (24-24)
  • CallCount (32-36)
  • CallCount (44-48)
  • CallCount (54-54)
  • CallCount (63-67)
  • CallCount (76-82)
  • CallCount (90-94)
  • CallCount (100-100)
  • CallCount (106-106)
🔇 Additional comments (17)
src/Mimic/IMimicked`1.cs (1)

3-6: Excellent documentation for the interface and property.

The XML documentation clearly explains the interface's purpose and the generic constraint. The property documentation effectively describes what the Mimic property provides and its role in controlling mock behaviour.

Also applies to: 12-17

src/Mimic/CallCount.cs (3)

3-5: Well-written class-level documentation.

The documentation clearly explains the purpose of the CallCount struct as a constraint for verifying method invocation counts.


20-23: Comprehensive documentation for all factory methods.

Each static factory method is thoroughly documented with clear descriptions of parameters, return values, and exception conditions. The documentation helps users understand the different call count constraint options available.

Also applies to: 26-31, 38-43, 50-53, 56-62, 69-75, 84-89, 96-99, 102-105


108-112: Clear documentation for the Validate method.

The documentation accurately describes the method's purpose and parameters, making it clear how to use this method for validation.

src/Mimic/Arg.cs (3)

7-9: Clear class-level documentation.

The documentation succinctly explains the purpose of the Arg class in providing argument matchers for mock setups and verifications.


13-17: Comprehensive method documentation with excellent remarks.

Each method is thoroughly documented with clear descriptions, parameter details, and helpful remarks about generic matcher limitations. The documentation provides valuable guidance for users choosing between different overloads.

Also applies to: 22-26, 31-40, 48-58, 66-75, 83-89, 93-98, 102-109, 112-118, 121-127, 130-137, 140-146


149-157: Appropriate documentation for the nested Ref class.

The documentation clearly explains the purpose of the Ref class for reference argument matching in ref parameters.

src/Mimic/IGenericMatcher.cs (2)

3-55: Outstanding interface documentation with excellent examples.

The documentation provides comprehensive coverage of the interface's purpose, usage scenarios, and practical examples. The inclusion of custom matcher examples and integration with built-in Generic matchers is particularly helpful for developers.


59-81: Thorough method documentation with practical examples.

The Matches method documentation clearly explains its purpose, parameters, return value, and includes a practical implementation example. The remarks about performance considerations are valuable.

src/Mimic/Generic.cs (5)

3-7: Clear class-level documentation.

The documentation effectively explains the purpose of the Generic class and its relationship with the Arg class for flexible type matching.


11-25: Excellent documentation for AnyType matcher.

The documentation clearly explains the unrestricted nature of this matcher and provides a helpful usage example. The method documentation is concise and accurate.

Also applies to: 28-33


36-49: Comprehensive documentation for AnyReferenceType matcher.

The documentation effectively explains reference type constraints and provides good examples. The comparison to generic type constraints with class is particularly helpful.

Also applies to: 52-57


60-77: Outstanding documentation for AssignableFromType matcher.

The documentation thoroughly explains inheritance-based matching with excellent examples demonstrating both interface and inheritance scenarios. The generic type parameter is well-documented.

Also applies to: 80-85


88-101: Clear documentation for AnyValueType matcher.

The documentation effectively explains value type constraints and provides appropriate examples. The comparison to generic type constraints with struct is helpful for understanding.

Also applies to: 104-109

src/Mimic/Mimic`1.Setup.cs (1)

10-137: Excellent XML documentation coverage.

The comprehensive XML documentation for all setup methods provides clear guidance on usage, parameters, return types, and exceptions. The method implementations include proper validation and follow consistent patterns.

src/Mimic/Mimic`1.cs (1)

20-129: Comprehensive and accurate XML documentation.

The XML documentation accurately describes the behaviour of all class members, including:

  • Clear property descriptions with behaviour details
  • Constructor documentation explaining strict mode functionality
  • Method documentation with proper parameter and exception details
  • Consistent formatting and terminology throughout
src/Mimic/Mimic`1.VerifyReceived.cs (1)

8-208: Excellent documentation for verification methods.

The XML documentation provides comprehensive coverage of all verification methods with:

  • Clear descriptions of verification behaviour
  • Consistent parameter documentation across overloads
  • Proper exception documentation matching actual thrown exceptions
  • Well-documented generic type parameters
  • Consistent formatting and terminology

This greatly improves the API usability for developers using the Mimic framework.

@DrBarnabus
Copy link
Owner Author

@coderabbitai Please implement the documentation change you suggested for strongly-typed

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 29, 2025

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

I need to search the codebase to understand the context of the "strongly-typed" documentation change I previously suggested. Let me examine the relevant files.


🏁 Script executed:

#!/bin/bash
# Search for references to "strongly-typed" or "strongly typed" in the codebase
rg -i "strongly.typed" -A 2 -B 2

# Also search for "strong" to catch variations
rg -i "strong" -A 2 -B 2

# Examine the Arg.cs file which mentions strongly typed overloads
cat src/Mimic/Arg.cs

Length of output: 15329


@DrBarnabus I can see the issue! There's a typo in the SetupSet method documentation in src/Mimic/Mimic1.Setup.cs` where "stronglytyped" should be "strongly typed" (missing space). Let me implement this fix.

Task: Fix "strongly typed" documentation typo

  • Fix the typo in the SetupSet method XML documentation where "stronglytyped" should be "strongly typed"

⏳ Preparing changes...

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 29, 2025

A summary of the changes CodeRabbit can apply:

  • Correct the typo by adding a missing space in "strongly typed" within the SetupSet method documentation in the file src/Mimic/Mimic`1.Setup.cs.
  • Created local commit - (🔄 Check again to try again)

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 29, 2025

Creating a commit in the current branch to apply the edits...

The changes have been committed to the current branch. Commit ID: d3f1f9b4cf2031d7527eecc2185c7387f51accf3

@DrBarnabus DrBarnabus merged commit 3ceff21 into main Jun 29, 2025
18 checks passed
@DrBarnabus DrBarnabus deleted the top-level-xmldoc branch June 29, 2025 16:02
@DrBarnabus DrBarnabus added the documentation Improvements or additions to documentation label Aug 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant