Skip to content

refactor(cache): make the size provider a field, since that is what it is - #175

Closed
cosmin-staicu wants to merge 1 commit into
mainfrom
chore/size-provider-field
Closed

refactor(cache): make the size provider a field, since that is what it is#175
cosmin-staicu wants to merge 1 commit into
mainfrom
chore/size-provider-field

Conversation

@cosmin-staicu

Copy link
Copy Markdown
Member

MemoryCacheSetter.SizeProvider was a get-only private property holding a value resolved once from the options:

private ICacheEntrySizeProvider SizeProvider { get; } = memoryCacheOptions.SizeProvider ?? new DefaultCacheEntrySizeProvider();

No computation, no interception, nothing a property buys over a field. It is now _sizeProvider, declared with the other fields — which also keeps it out of the property block that the ordering rules group together.

Came out of counting property accessibilities across src while sizing up the StyleCop ordering rules: 398 properties, of which exactly four are private. The other three earn it — RedisStreamHealthMaintainer.Database, RedisStreamSubjectWriter.ContinueLoop and RedisConnector.ConnectionMultiplexer all compute on every read, which is what a private property is for. This was the only one holding state.

IMemoryCacheOptions.SizeProvider, the public option it reads from, is untouched.

Build clean, full suite green: 1704 on net10, 1683 on net8.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NsPw6MZHPGmpbo6WDuLzF1

…t is

SizeProvider was a get-only private property holding a value resolved
once from the options. That is a readonly field wearing a property's
clothes: no computation, no interception, nothing a property buys. It
now sits with the other fields as _sizeProvider, which also keeps it out
of the property block that the ordering rules group.

The three other private properties in the library stay as they are:
Database, ContinueLoop and ConnectionMultiplexer all compute on each
read, which is what a private property is for.

IMemoryCacheOptions.SizeProvider, the public option this reads from, is
untouched.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NsPw6MZHPGmpbo6WDuLzF1
Signed-off-by: Cosmin Staicu <cosmin.staicu@uipath.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The change is a behavior-preserving refactor with a straightforward substitution and no observable functional impact.

Pull request overview

This PR refactors MemoryCacheSetter to store the resolved ICacheEntrySizeProvider as a private readonly field instead of a get-only private property, aligning the implementation with its actual behavior (stateful, resolved once) and avoiding unnecessary “property” semantics.

Changes:

  • Replace private ICacheEntrySizeProvider SizeProvider { get; } = ... with private readonly ICacheEntrySizeProvider _sizeProvider = ....
  • Update the SetSize(...) call site to use _sizeProvider.
File summaries
File Description
src/UiPath.Caching/MemoryCacheSetter.cs Convert size-provider from private get-only property to private readonly field and update usage accordingly.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@sonarqubecloud

Copy link
Copy Markdown

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.

2 participants