Skip to content

Conversation

@ysmoradi
Copy link
Member

@ysmoradi ysmoradi commented Nov 26, 2025

closes #11759

Summary by CodeRabbit

  • Infrastructure Updates
    • Enhanced caching serialization with automatic object cloning support for improved performance and data consistency
    • Updated exception handling framework to provide better error management

✏️ Tip: You can customize this high-level summary in your review settings.

@ysmoradi ysmoradi requested a review from Copilot November 26, 2025 13:04
@coderabbitai
Copy link

coderabbitai bot commented Nov 26, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This pull request integrates FusionCache serialization support into the boilerplate by adding a new NuGet package dependency, configuring FusionCache with automatic cloning and a custom SystemTextJson serializer, and updating the KnownException base class from Exception to ApplicationException.

Changes

Cohort / File(s) Summary
Dependency Management
src/Templates/Boilerplate/Bit.Boilerplate/src/Directory.Packages.props, src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Shared/Boilerplate.Server.Shared.csproj
Added central package version for ZiggyCreatures.FusionCache.Serialization.SystemTextJson (v2.4.0) and included corresponding package reference in the shared project.
FusionCache Configuration
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Shared/Extensions/WebApplicationBuilderExtensions.cs
Enhanced FusionCache registration with automatic cloning (EnableAutoClone = true) and configured FusionCacheSystemTextJsonSerializer as the cache serializer. Added using directives for serialization support.
Exception Hierarchy
src/Templates/Boilerplate/Bit.Boilerplate/src/Shared/Exceptions/KnownException.cs
Changed KnownException base class from Exception to ApplicationException.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Review the FusionCache serializer configuration in WebApplicationBuilderExtensions.cs to verify automatic cloning behavior is appropriate for the boilerplate's use cases
  • Verify the KnownException base class change to ApplicationException aligns with exception handling strategy and doesn't break existing catch blocks or exception filtering logic
  • Confirm package version compatibility across dependencies

Poem

🐰 A cache now serializes with care,
Cloning values through the air,
JSON-forged and crystal clear,
While exceptions find new tier,
Boilerplate blooms beyond compare! ✨

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The KnownException base class change from Exception to ApplicationException appears unrelated to the FusionCache serializer objective and may be out of scope. Clarify whether the KnownException change in #11759 is intentional; if not, consider removing it to maintain focus on the FusionCache serialization issue.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses the main objective: implementing auto-clone feature in FusionCache to resolve scale-out issues when switching to Redis.
Linked Issues check ✅ Passed The PR implements the FusionCache serializer configuration with EnableAutoClone=true and FusionCacheSystemTextJsonSerializer, fulfilling the requirement from #11759.

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

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

Copy link

@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 (2)
src/Templates/Boilerplate/Bit.Boilerplate/src/Shared/Exceptions/KnownException.cs (1)

3-3: Reconsider deriving from ApplicationException instead of Exception

Changing KnownException to inherit from ApplicationException is a behavioral change and goes against current .NET design guidance, which generally recommends deriving directly from Exception rather than ApplicationException. Unless you have specific handling/logging that relies on ApplicationException, you may want to keep KnownException : Exception to avoid surprises for consumers that assume the previous hierarchy.

src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Shared/Extensions/WebApplicationBuilderExtensions.cs (1)

17-18: FusionCache auto-clone + SystemTextJson serializer wiring matches the PR goal, with a notable behavior change

The new configuration

services.AddFusionCache()
    .WithOptions(opt => opt.DefaultEntryOptions.EnableAutoClone = true)
    .WithSerializer(new FusionCacheSystemTextJsonSerializer());

correctly enables FusionCache’s auto‑clone feature and provides a System.Text.Json‑based IFusionCacheSerializer, so cached values will be cloned via serialization even when only the in‑memory layer is used—this aligns with the scale‑out/Redis objective. (docs.dndocs.com)

One thing to be aware of: with EnableAutoClone = true as the default, any entries whose value type cannot be (de)serialized by FusionCacheSystemTextJsonSerializer will now start throwing at runtime instead of being cached as raw objects. This may be fine if you only ever put DTOs/POCOs into FusionCache, but it’s worth double‑checking existing usages for non‑JSON‑friendly types.

If you already have centralized JsonSerializerOptions (e.g., for your APIs), consider passing them into FusionCacheSystemTextJsonSerializer so cache serialization behavior stays consistent with the rest of your JSON stack.

Also applies to: 49-52

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 4874691 and fc4e81e.

📒 Files selected for processing (4)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Directory.Packages.props (1 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Shared/Boilerplate.Server.Shared.csproj (1 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Shared/Extensions/WebApplicationBuilderExtensions.cs (2 hunks)
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Shared/Exceptions/KnownException.cs (1 hunks)
⏰ 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). (3)
  • GitHub Check: Agent
  • GitHub Check: CodeQL analysis (csharp)
  • GitHub Check: build Bit.Templates
🔇 Additional comments (2)
src/Templates/Boilerplate/Bit.Boilerplate/src/Directory.Packages.props (1)

135-137: FusionCache serialization package versioning looks consistent

The new ZiggyCreatures.FusionCache.Serialization.SystemTextJson entry at 2.4.0 is aligned with the other FusionCache packages (OutputCaching and OpenTelemetry), so central versioning looks coherent.

Please just confirm this is the intended FusionCache version for your supported target frameworks/environments (e.g., no known regressions in 2.4.0 for net10.0) by checking the package release notes.

src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Shared/Boilerplate.Server.Shared.csproj (1)

32-35: FusionCache package references align with usage in the shared server project

Adding ZiggyCreatures.FusionCache.AspNetCore.OutputCaching and ZiggyCreatures.FusionCache.Serialization.SystemTextJson here matches the extension methods used in WebApplicationBuilderExtensions (AddFusionOutputCache and the SystemTextJson serializer), and the versions are centrally managed alongside the other FusionCache packages.

Please just confirm via a quick build/restore that there are no assembly binding or transitive dependency issues introduced by these additions.

@ysmoradi ysmoradi merged commit 21a7ab3 into bitfoundation:develop Nov 26, 2025
3 checks passed
@ysmoradi ysmoradi deleted the 11759 branch November 26, 2025 13:08
Copy link
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 implements the FusionCache auto-clone feature and adds JSON serialization support to prevent data mutation issues when scaling out to distributed caching (like Redis). The changes ensure that cached objects are properly cloned and serialized for safe use across multiple application instances.

  • Configures FusionCache with auto-clone enabled to prevent shared reference issues
  • Adds SystemTextJson serializer for proper distributed cache serialization
  • Includes unrelated change to exception hierarchy base class

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

File Description
src/Templates/Boilerplate/Bit.Boilerplate/src/Shared/Exceptions/KnownException.cs Changes base class from Exception to ApplicationException (appears unrelated to PR purpose)
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Shared/Extensions/WebApplicationBuilderExtensions.cs Configures FusionCache with auto-clone and SystemTextJson serializer for distributed caching scenarios
src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Shared/Boilerplate.Server.Shared.csproj Adds FusionCache.Serialization.SystemTextJson package reference
src/Templates/Boilerplate/Bit.Boilerplate/src/Directory.Packages.props Defines version 2.4.0 for the new serialization package

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.

bit Boilerplate fusion cache must use serializer even in in-memory store to prevent further scale out issues

1 participant