Skip to content

Comments

build: Add PublicAPI Analyzer#19

Merged
DrBarnabus merged 1 commit intomainfrom
public-api-analyzer
Aug 8, 2025
Merged

build: Add PublicAPI Analyzer#19
DrBarnabus merged 1 commit intomainfrom
public-api-analyzer

Conversation

@DrBarnabus
Copy link
Owner

@DrBarnabus DrBarnabus commented Aug 8, 2025

Enables the Microsoft.CodeAnalysis.PublicApiAnalyzers analyzer to help identify and avoid breaking changes.

All current APIs have been documented as "Shipped".

Summary by CodeRabbit

  • New Features

    • Introduced a comprehensive public API specification for the Mimic library, detailing all available types, interfaces, methods, and properties for advanced mocking, setup, and verification scenarios.
  • Chores

    • Added the Microsoft.CodeAnalysis.PublicApiAnalyzers package for enhanced API analysis.
    • Enabled nullable reference types in the API surface.
    • Updated package lock and project files to reflect new analyser dependency.

Enables the `Microsoft.CodeAnalysis.PublicApiAnalyzers` analyzer to help
identify and avoid breaking changes.

All current APIs have been documented as "Shipped".
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 8, 2025

Walkthrough

A new dependency on Microsoft.CodeAnalysis.PublicApiAnalyzers (v4.14.0) has been introduced and centrally managed. The Mimic project now references this analyser, and associated lock files are updated. A comprehensive public API specification file for Mimic has been added, and nullable reference types are enabled for the unshipped API.

Changes

Cohort / File(s) Change Summary
Central Package Management
src/Directory.Packages.props
Added Microsoft.CodeAnalysis.PublicApiAnalyzers v4.14.0 to the analyzers item group for central package version management.
Project Reference and Lock File
src/Mimic/Mimic.csproj, src/Mimic/packages.lock.json
Added a project reference to Microsoft.CodeAnalysis.PublicApiAnalyzers in Mimic.csproj, including all relevant assets and marking as private. Updated packages.lock.json to reflect the new dependency for net8.0.
Public API Documentation
src/Mimic/PublicAPI.Shipped.txt
Introduced a detailed public API specification file for the Mimic library, enumerating all public types, interfaces, methods, properties, operators, and extension methods. This documents the complete public API surface for users.
Nullable Reference Types Directive
src/Mimic/PublicAPI.Unshipped.txt
Enabled nullable reference types by adding #nullable enable at the top of the unshipped API file. No other content changes were made.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

In the warren, code grows neat and wise,
With analyzers sharp as a rabbit’s eyes.
The API’s mapped, each method and class,
Nullable warnings enabled—nothing will pass!
Dependencies locked, the garden secure,
Mimic’s public face is polished and pure.
🐇✨

Note

🔌 MCP (Model Context Protocol) integration is now available in Early Access!

Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch public-api-analyzer

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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.
  • 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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate unit tests to generate unit tests for 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.

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 (4)
src/Directory.Packages.props (1)

15-17: Prefer centralising PrivateAssets to avoid per-project duplication

You already centralise PrivateAssets for JetBrains.Annotations. Do the same for the PublicApiAnalyzers to keep things consistent and simplify project files.

-        <PackageVersion Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="4.14.0" />
+        <PackageVersion Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="4.14.0" PrivateAssets="All" />

If you make this change, you can drop the PrivateAssets node from Mimic.csproj for this package.

src/Mimic/Mimic.csproj (2)

14-17: PrivateAssets looks correct; IncludeAssets is redundant noise

For analyser-only packages, the IncludeAssets value is the default and can be omitted. Keeping only PrivateAssets keeps the file lean.

-        <PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers">
-            <PrivateAssets>all</PrivateAssets>
-            <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
-        </PackageReference>
+        <PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers">
+            <PrivateAssets>all</PrivateAssets>
+        </PackageReference>

If you adopt central PrivateAssets in Directory.Packages.props (as suggested), you can reduce this to a self-closing reference:

<PackageReference Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" />

11-22: Optional: enforce RS00xx as errors via .editorconfig for stronger API stability

Since the goal is preventing breaking changes, consider pinning Public API analyser rules to error in .editorconfig so CI fails on API drift.

Example .editorconfig entries:

dotnet_diagnostic.RS0016.severity = error
dotnet_diagnostic.RS0017.severity = error
dotnet_diagnostic.RS0026.severity = error
dotnet_diagnostic.RS0027.severity = error
src/Mimic/PublicAPI.Shipped.txt (1)

3-278: Baseline looks comprehensive; adopt a clear workflow for updates

The shipped API list is extensive and appears coherent for a first baseline. To keep it healthy:

  • Add new/changed APIs to PublicAPI.Unshipped.txt during development, then move to Shipped at release.
  • Keep PublicApiAnalyzers enabled in CI with RS00xx as errors to catch accidental changes.

If you want, I can draft a contributor guide snippet that documents this workflow.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e619024 and f79a20a.

📒 Files selected for processing (5)
  • src/Directory.Packages.props (1 hunks)
  • src/Mimic/Mimic.csproj (1 hunks)
  • src/Mimic/PublicAPI.Shipped.txt (1 hunks)
  • src/Mimic/PublicAPI.Unshipped.txt (1 hunks)
  • src/Mimic/packages.lock.json (1 hunks)
🧰 Additional context used
🪛 LanguageTool
src/Mimic/PublicAPI.Shipped.txt

[style] ~6-~6: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...TValue> Mimic.CallCount Mimic.CallCount.CallCount() -> void Mimic.CallCount.Equals(Mimic....

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[duplication] ~11-~11: Possible typo: you repeated a word.
Context: ...ception.MimicException(Mimic.Exceptions.Reason reason, string? message) -> void Mimic.Excepti...

(ENGLISH_WORD_REPEAT_RULE)


[duplication] ~12-~12: Possible typo: you repeated a word.
Context: ...ception.MimicException(Mimic.Exceptions.Reason reason, string? message, System.Exception? inn...

(ENGLISH_WORD_REPEAT_RULE)


[style] ~103-~103: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...> Mimic.IMimicked.Mimic.get -> Mimic.Mimic<T!>! Mimic.IProceed Mimic.IProceed.Proc...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~103-~103: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...micked.Mimic.get -> Mimic.Mimic<T!>! Mimic.IProceed Mimic.IProceed.Proceed() -> Mi...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~170-~170: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...Mimic.Mimic() -> void Mimic.Mimic.Mimic(bool strict) -> void Mimic.Mimic.Nam...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~177-~177: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...lProperties() -> Mimic.Mimic<T!>! Mimic.Mimic.SetupGet(System.Linq.Expr...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~179-~179: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...(TProperty?)) -> Mimic.Mimic<T!>! Mimic.Mimic.SetupSet(System.Action<T!>! setterEx...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[duplication] ~186-~186: Possible typo: you repeated a word.
Context: ...unc<T!, TProperty>!>! expression, Mimic.CallCount callCount) -> void Mimic.Mimic.VerifyGetReceiv...

(ENGLISH_WORD_REPEAT_RULE)


[duplication] ~187-~187: Possible typo: you repeated a word.
Context: ...unc<T!, TProperty>!>! expression, Mimic.CallCount callCount, string! failureMessage) -> void Mimic....

(ENGLISH_WORD_REPEAT_RULE)


[duplication] ~191-~191: Possible typo: you repeated a word.
Context: ...<System.Action<T!>!>! expression, Mimic.CallCount callCount) -> void Mimic.Mimic.VerifyReceived(...

(ENGLISH_WORD_REPEAT_RULE)


[duplication] ~192-~192: Possible typo: you repeated a word.
Context: ...<System.Action<T!>!>! expression, Mimic.CallCount callCount, string! failureMessage) -> void Mimic....

(ENGLISH_WORD_REPEAT_RULE)


[duplication] ~195-~195: Possible typo: you repeated a word.
Context: ....Func<T!, TResult>!>! expression, Mimic.CallCount callCount) -> void Mimic.Mimic.VerifyReceived<...

(ENGLISH_WORD_REPEAT_RULE)


[duplication] ~196-~196: Possible typo: you repeated a word.
Context: ....Func<T!, TResult>!>! expression, Mimic.CallCount callCount, string! failureMessage) -> void Mimic....

(ENGLISH_WORD_REPEAT_RULE)


[duplication] ~199-~199: Possible typo: you repeated a word.
Context: ...tem.Action<T!>! setterExpression, Mimic.CallCount callCount) -> void Mimic.Mimic.VerifySetReceiv...

(ENGLISH_WORD_REPEAT_RULE)


[duplication] ~200-~200: Possible typo: you repeated a word.
Context: ...tem.Action<T!>! setterExpression, Mimic.CallCount callCount, string! failureMessage) -> void Mimic....

(ENGLISH_WORD_REPEAT_RULE)


[grammar] ~218-~218: This sentence seems to be incomplete. Insert a noun before ‘Is’ to make the sentence complete.
Context: ...>! comparer) -> TValue static Mimic.Arg.Is(System.Linq.Expressions.Express...

(MISSING_SUBJECT)


[grammar] ~219-~219: This sentence seems to be incomplete. Insert a noun before ‘Is’ to make the sentence complete.
Context: ...l>!>! match) -> TValue static Mimic.Arg.Is(System.Linq.Expressions.Express...

(MISSING_SUBJECT)


[grammar] ~220-~220: This sentence seems to be incomplete. Insert a noun before ‘Is’ to make the sentence complete.
Context: ...l>!>! match) -> TValue static Mimic.Arg.Is(TValue value) -> TValue static ...

(MISSING_SUBJECT)


[grammar] ~221-~221: This sentence seems to be incomplete. Insert a noun before ‘Is’ to make the sentence complete.
Context: ...Value value) -> TValue static Mimic.Arg.Is(TValue value, System.Collection...

(MISSING_SUBJECT)


[style] ~235-~235: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...tatic Mimic.CallCount.operator !=(Mimic.CallCount left, Mimic.CallCount right) -> bool st...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~235-~235: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...operator !=(Mimic.CallCount left, Mimic.CallCount right) -> bool static Mimic.CallCount.o...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~236-~236: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...tatic Mimic.CallCount.operator ==(Mimic.CallCount left, Mimic.CallCount right) -> bool st...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~236-~236: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...operator ==(Mimic.CallCount left, Mimic.CallCount right) -> bool static Mimic.DelayableEx...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~277-~277: Using many exclamation marks might seem excessive (in this case: 420 exclamation marks for a text that’s 30875 characters long)
Context: ..., TResult value) -> Mimic.IReturnsResult!

(EN_EXCESSIVE_EXCLAMATION)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: Test (macos-latest, net9.0)
  • GitHub Check: Test (macos-latest, net8.0)
  • GitHub Check: Test (windows-latest, net8.0)
  • GitHub Check: Test (ubuntu-latest, net9.0)
  • GitHub Check: Test (windows-latest, net9.0)
  • GitHub Check: Package (macos-latest)
  • GitHub Check: Package (windows-latest)
  • GitHub Check: Analyze (csharp)
🔇 Additional comments (3)
src/Mimic/PublicAPI.Unshipped.txt (1)

1-1: Good: nullability context enabled for unshipped API

This is the recommended directive for PublicAPI files when tracking nullability. No further action needed.

src/Mimic/packages.lock.json (1)

26-31: Lock entry for PublicApiAnalyzers is consistent with the csproj

Requested/resolved versions and content hash look sane. No action needed.

src/Mimic/PublicAPI.Shipped.txt (1)

1-2: Good: nullability context enabled for shipped API baseline

This ensures the analyser tracks nullability annotations for your released surface.

@codecov
Copy link

codecov bot commented Aug 8, 2025

Codecov Report

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

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #19   +/-   ##
=======================================
  Coverage   92.30%   92.30%           
=======================================
  Files          64       64           
  Lines        2117     2117           
  Branches      365      365           
=======================================
  Hits         1954     1954           
  Misses         85       85           
  Partials       78       78           

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

@DrBarnabus DrBarnabus merged commit 87c0f51 into main Aug 8, 2025
18 checks passed
@DrBarnabus DrBarnabus deleted the public-api-analyzer branch August 8, 2025 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant