Skip to content

refactor: order type members, and enforce it - #176

Merged
cosmin-staicu merged 1 commit into
mainfrom
chore/analyzer-member-order
Sep 11, 2026
Merged

refactor: order type members, and enforce it#176
cosmin-staicu merged 1 commit into
mainfrom
chore/analyzer-member-order

Conversation

@cosmin-staicu

@cosmin-staicu cosmin-staicu commented Sep 10, 2026

Copy link
Copy Markdown
Member

Members are laid out the way the ordering rules ask, and the rules are on so it stays that way. The build now reports no warnings at all, on either CI job — main reports 38.

How to review this: 189 files, but almost all of it is mechanical — member moves, argument line breaks, trailing commas and braces, each driven by a named rule. The parts worth actual attention are .editorconfig, stylecop.json, Directory.Build.props and the four "by hand" files listed below.

What is now enforced

.editorconfig already carried a curated StyleCop block, so this joins it rather than replacing it — worth knowing when reading the diff. StyleCop.Analyzers is now referenced, and every one of its eight categories is none except OrderingRules, with rules named individually where a category cannot reach them. Without that the package reports about 5,000 warnings.

  • The OrderingRules category — order by kind, by access, constants first, readonly first, using directives alphabetical. The category rather than a list of ids, because it costs 28 more violations and no maintenance.
  • SA1204 (static before instance) and SA1208 (System usings first) had to be named explicitly. Both were already none further up the file, and a specific id beats a category, so the category alone would not have applied them. SA1208 was free — the tree was already clean against it. SA1200 stays none: it wants using directives inside the namespace, and this repo puts them above the file-scoped namespace.
  • SA1402, scoped to src — one top-level type per file on the shipped surface. topLevelTypes in stylecop.json widens it past its default of class alone. Four files held nine extra types and are now thirteen. Outside src it is none, not suggestion: tests, samples and benchmarks keep small helper types beside what uses them, and leaving it at suggestion only meant 33 standing Sonar issues for 17 files nobody intends to split.
  • SA1649 was already none and stays there. It doesn't recognise the OfT suffix used for generic types, so it would ask to rename CacheOfT.cs, ICacheOfT.cs and five siblings to Cache{T}.cs.
  • SX1309 stays at warning, where the file already had it. The alternative to SA1309, it wants every field to begin with an underscore, which is this repo's convention — SA1309, which asks the opposite, is none. It belongs to no StyleCop category, so switching the categories off does not reach it. This one caught me out: referencing the package is what makes it report, and enabling it surfaced 20 warnings main does not have, which my first greps (filtered to SA1*/IDE0040) missed. The five fields are fixed rather than the rule silenced.
  • IDE0040 was configured but at severity silent, so it never reported. It's a warning now, which is the rule as asked: a class member always states its accessibility, an interface member never repeats the public it already has. 25 interface members carried a redundant public; two class members had none at all. Removing public from an interface member changes no API — PublicAPI.Shipped.txt is untouched.

The formatting rules that were reporting to Sonar

Five rules sat at suggestion, so they never failed a build but SonarCloud imported all 248 of them. Four are fixed and promoted to warning so they cannot drift back:

Rule Sites How
SA1117 parameters on one line or one each 129 Roslyn pass; the first argument stays on the invocation line, so no lambda body needed re-indenting (SA1116 and SA1118 are none)
SA1413 trailing comma in multi-line initializers 116 Roslyn pass, 2 by hand
SA1503 braces not omitted 40 csharp_prefer_braces raised from silent to warning, then dotnet format style
SA1300 element begins upper-case 17 13 lowercase local functions renamed, plus 4 snake_case test methods brought to the repo's Upper_then_snake. Local variables named generator were left alone — lowercase is correct there

The fifth is SA1402, above.

How the members were moved

Neither dotnet format nor the Roslynator CLI can drive StyleCop's fixer for the ordering rules — both answer that no code fix was found, and Roslynator lists the diagnostics as unfixable. Rider's own layout engine ranks constants and statics above accessibility, which pushes SA1202 up rather than down.

So a Roslyn pass did it: parse, sort each type's members by StyleCop's default elementOrder (kind → accessibility → const → static → readonly), write the tree back — which carries each member's doc comments and blank lines with it, rather than matching them by text.

Three rules kept it safe:

  1. The sort is stable, so anything the comparer calls equal keeps the order the author chose.
  2. A field whose initializer reads a sibling member, or this, is pinned where it is — C# runs field initializers in textual order, so moving one can change behaviour. A field built from literals, constants and other types moves freely.
  3. A file containing #region or #if is refused outright. Those directives are trivia on the members around them, and a sort can carry one away from its partner and change what compiles.

Settled by hand

Rule 2 and rule 3 leave work behind by design. Each of these is the safety net working, not failing:

  • MemoryCacheFactoryTests and RedisSetCacheTests — field blocks moved as units, so Before/After keep reading Deadline and the set-cache options keep reading their const.
  • GenerationDepthBehavior — an interface declared below a class, which is a file-level ordering the pass doesn't do.
  • UiPathBufferDistributedCacheTests — the whole file is one conditional block, so its directives were lifted, the members sorted, and the directives restored.
  • DistributedCacheRedisIntegrationTests — an inner block held both a public test and a private nested helper, which cannot satisfy kind order and access order as one unit. It is two blocks now.

Also here

S4136 had been reporting eight non-adjacent overload groups on every build, and #164 proposed switching the rule off. Measuring first said otherwise: every one of the eight groups is of uniform accessibility, five are split by a single private XCoreAsync sitting between the public overloads it serves, and moving that helper below the group is what SA1202 asks for anyway. The two rules agree rather than conflict, so the rule is satisfied instead of suppressed.

The last 11 warnings on the Sonar-wrapped build, all pre-existing on main, are gone too — no suppressions added:

  • S8969 ×5 wanted a null-forgiving ! removed. Removing it broke the build with CS8604 on all five: _context.Topic is a RedisKey and @event.Id a RedisValue, non-nullable structs whose implicit conversion to string is nullable. Sonar reads the operand, Roslyn reads the conversion result, and both are right about different things. .ToString() drops the ! and the CS8604 together.
  • S2699 ×6 were tests asserting implicitly, by "does not throw" or by a WaitAsync timeout. Each now states what its name claims: the second Dispose does not throw, the 1000 concurrent subscriptions all survive, no worker faults, StreamCreateConsumerGroupAsync is actually reached, and the fetch loop is not faulted after BUSYGROUP or an unexpected create failure.

KeyMasker.IsMasking carried two <summary> tags, having absorbed ShouldMask's when it was inserted above it in #165. ShouldMask has its documentation back; it's the only place in src with that mistake.

Verification

  • CI: 0 warnings on build-windows and 0 on build-linux, against 38 on main. SonarCloud gate passes with 0 open issues, down from 248.
  • build-windows now builds with -warnaserror, so none of this can drift back. TreatWarningsAsErrors stays false in Directory.Build.props — a local build still compiles while you work. The gate rides on the Windows job alone: build-linux builds under the SonarScanner, whose analyzer package this repo does not pin, so a new Sonar rule would fail the build rather than report it. The analyzers that are pinned run identically on both jobs, so gating one catches the same drift.
  • Both suites unchanged against main: 1704 on net10, 1683 on net8. For the conditional files that count is the check: a [Fact] carried out of a NET9_0_OR_GREATER block would raise the net8 total, one carried in would lower it. Neither moved.
  • #if/#endif pairs balanced in both files that have them.
  • Packed nuspec unchanged.

An earlier revision of this branch had reverted all four files of #172 back to their pre-#172 state, dropping $(MEVersion10) and the three PackageVersionFloorTests guards with it. Restored from main; the only change left in Directory.Packages.props is the one StyleCop.Analyzers line this PR needs. The test totals above are what caught it.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NsPw6MZHPGmpbo6WDuLzF1

@cosmin-staicu
cosmin-staicu requested a lite review from Copilot September 10, 2026 15:47
@github-actions github-actions Bot added the needs-cla-review A maintainer should assess whether a signed CLA is required (see CONTRIBUTING.md) label Sep 10, 2026
@github-actions

Copy link
Copy Markdown

🔎 Maintainer heads-up: automated triage flagged this PR as potentially material, so it may need a signed CLA in addition to the DCO sign-off.

Strong signals

  • adds dependency: StyleCop.Analyzers

Other signals

  • large production change (+2105 lines under src/)

This is advisory only — the bot does not decide. Please judge against the CLA criteria (material, product-critical, patent-sensitive, corporate contributor, broad commercial use). Note that thresholds can be gamed by splitting PRs, so use your judgement.

  • If a CLA is needed → add the cla-required label (a contributor comment with signing steps is posted automatically).
  • If it is not needed → replace needs-cla-review with cla-not-required so later pushes don't re-flag it.

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.

🟡 Changes recommended

It contains a couple of objective mismatches between documentation/PR description and the enforced analyzer/package-floor behavior that should be corrected for maintainability and accurate review context.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Refactors the repository to comply with (and enforce) consistent C# member ordering and accessibility-modifier rules, primarily by enabling specific analyzers and mechanically reordering members across types.

Changes:

  • Enable and configure StyleCop/IDE analyzer rules (OrderingRules, SA1402 under src, IDE0040 severity) and add StyleCop settings.
  • Mechanical reordering of members across src/, tests/, samples/, and benchmarks/ to eliminate ordering/accessibility diagnostics.
  • Adjust central package-version floors and add StyleCop.Analyzers as a centrally-managed dependency.
File summaries
File Description
.editorconfig Enables IDE0040 as warning and configures StyleCop categories/rules.
.github/dependabot.yml Updates Dependabot guidance comments for the new floor strategy.
Directory.Build.props Adds StyleCop analyzer package reference + links stylecop.json.
Directory.Packages.props Updates per-TFM floors and adds central StyleCop.Analyzers version.
stylecop.json Adds StyleCop settings (notably topLevelTypes for SA1402).
src/UiPath.Caching/CacheEntryFactory.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching/CacheMemoryMonitor.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching/Config/CachingBuilder.cs Registers options validator and reorders members.
src/UiPath.Caching/Config/RedisCollectionExtensions.cs Reorders extension methods.
src/UiPath.Caching/Config/ServiceCollectionExtensions.cs Member reordering (also reserves Redis keyspaces).
src/UiPath.Caching/InMemoryCacheProvider.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching/InMemoryRedisCacheProvider.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching/IMultilayerCacheOptions.cs Removes redundant public modifiers and reorders members.
src/UiPath.Caching/ICacheOptions.cs Removes redundant public modifiers and reorders members.
src/UiPath.Caching/ICacheEntryOptions.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching/Logging/AlwaysMaskKeyMaskingPolicy.cs Extracted type into its own file for SA1402.
src/UiPath.Caching/Logging/IKeyMaskingPolicy.cs Extracts nested types; member ordering cleanup.
src/UiPath.Caching/Logging/KeyMasker.cs Member reordering and doc-comment cleanup.
src/UiPath.Caching/Logging/LoggedKey.cs Removes extra top-level type (moved out for SA1402).
src/UiPath.Caching/Logging/LoggedKeys.cs New dedicated file for LoggedKeys type (SA1402).
src/UiPath.Caching/Logging/MaskingContext.cs Extracted type into its own file for SA1402.
src/UiPath.Caching/Logging/NullKeyMaskingPolicy.cs Extracted type into its own file for SA1402.
src/UiPath.Caching/Metrics.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching/MemoryCacheSetter.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching/RehydrationCoordinator.cs Member reordering (helper methods/constants).
src/UiPath.Caching/Broadcast/ChangeToken.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching/Broadcast/EventDispatcher.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching/Broadcast/KeyedSubject.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching/Broadcast/Redis/RedisPubSubSubjectWriter.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching/Broadcast/Redis/RedisPubSubTopic.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching/Broadcast/Redis/RedisPubSubTopicProvider.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching/Broadcast/Redis/RedisStreamHealthMaintainer.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching/Broadcast/Redis/RedisStreamNotifyChannel.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching/Broadcast/Redis/RedisStreamsTopic.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching/Broadcast/Redis/RedisStreamsTopicProvider.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching/Broadcast/Redis/RedisStreamSubjectWriter.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching/Broadcast/Redis/RedisTopicProviderBase.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching/Broadcast/Redis/StreamConstants.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching/Locking/RedisDistributedLock.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching/Redis/ClusterConfigurationReader.cs Extracted type into its own file for SA1402.
src/UiPath.Caching/Redis/ClusterMembership.cs Extracted type into its own file for SA1402.
src/UiPath.Caching/Redis/ClusterTopologyReader.cs Removes extra top-level types (moved out for SA1402).
src/UiPath.Caching/Redis/ConnectionStateMonitor.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching/Redis/IProfiledCommandProcessor.cs Removes redundant public modifier and reorders members.
src/UiPath.Caching/Redis/IProfilingSessionCommandReader.cs Removes redundant public modifier and reorders members.
src/UiPath.Caching/Redis/IReservedRedisKeyspace.cs Adds reserved-keyspace contract used for validation.
src/UiPath.Caching/Redis/PrefixRedisKeyStrategy.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching/Redis/ProfiledCommandExtensions.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching/Redis/RedisCacheProvider.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching/Redis/RedisPlannedMaintenance.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching/Redis/RedisProfiler.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching/Redis/ReservedRedisKeyspaceExtensions.cs Adds reservation/validation helpers for keyspaces.
src/UiPath.Caching/Redis/ReservedRedisKeyspaceValidator.cs Adds early options validation for reserved keyspaces.
src/UiPath.Caching/Redis/StreamId.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching.Queue/InMemoryQueueCacheProvider.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching.Queue/InMemoryRedisQueueCacheProvider.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching.Queue/MemorySetCache.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching.Queue/MultilayerSetCache.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching.Queue/RedisQueueCacheProvider.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching.Queue/RedisSetCache.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching.Polly/GlobalUsings.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching.CloudEvents/CacheCloudEventWrapper.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching.Azure/AzureEntraConnectionConfigurator.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching.Azure/AzureEntraCredentialFactory.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching.Azure/UiPath.Caching.Azure.csproj Updates Microsoft.Extensions.Options VersionOverride.
src/UiPath.Caching.Abstractions/CacheKey.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching.Abstractions/CacheOfT.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching.Abstractions/ICacheChangeToken.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching.Abstractions/ICacheEntry.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching.Abstractions/NullCache.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching.Abstractions/NullHashCache.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching.Abstractions/Config/ICachePolicyFactory.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching.Abstractions/Config/NullCachePolicyFactory.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching.Abstractions/Telemetry/ICachingTelemetryProvider.cs Removes redundant public modifier and reorders members.
src/UiPath.Caching.Abstractions/Telemetry/TelemetryOperation.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching.Abstractions/Broadcast/IChangeTokenFactory.cs Removes redundant public modifier and reorders members.
src/UiPath.Caching.Abstractions/Broadcast/ITopic.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching.Abstractions/Broadcast/NullCacheChangeToken.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching.Abstractions/Broadcast/NullCacheEventFactory.cs Member reordering to satisfy ordering rules.
src/UiPath.Caching.Abstractions/Broadcast/TopicKey.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/Azure/AzureEntraConnectionConfiguratorTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/BatchGetOrAddTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/Broadcast/ChangeTokenTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/Broadcast/ConnectionStateMonitorTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/Broadcast/KeyedSubjectTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/Broadcast/RedisPubSubSubjectWriterTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/Broadcast/RedisPubSubTopicTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/Broadcast/RedisStreamSubjectWriterTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/CacheExpirationTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/CacheOfTBatchGetOrAddTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/CancelationTokenCacheTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/Distributed/DistributedCacheEndToEndTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/Distributed/UiPathBufferDistributedCacheTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/Fakes/DictionaryCache.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/GenerationDepthBehavior.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/InMemorySetCacheTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/LegacySerializerWireCompatTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/Logging/KeyMaskingTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/Logging/MaskedLogSiteTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/Locking/AsyncKeyedLocalLockTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/Locking/CacheOptionsLockValidatorTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/Locking/MultilayerCacheBatchGetOrAddLockTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/Locking/MultilayerCacheGetOrAddLockTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/Locking/MultilayerCacheLockCrossOptionsValidatorTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/Locking/MultilayerHashCacheGetOrAddLockTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/Locking/RedisDistributedLockTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/MemoryCacheFactoryTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/MultilayerCacheBatchGetOrAddTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/MultilayerCacheBatchRehydrateTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/MultilayerCachePerNameLockTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/MultilayerCacheRehydrateTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/MultilayerCacheTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/MultilayerCacheTryAddTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/MultilayerHashCacheRehydrateTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/MultilayerHashCacheTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/MultilayerSetCacheTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/OpenTelemetry/OpenTelemetryCachingTelemetryProviderTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/PackageVersionFloorTests.cs Updates tests guarding central package floors.
tests/UiPath.Caching.Tests/PropagateCacheNullValuesFromMultilayerTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/RawByteSerializerProxyTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/Redis/RedisCacheTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/Redis/RedisCacheTryAddTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/Redis/RedisConfigurationOptionsProviderFactoryTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/Redis/RedisConnectionConfiguratorTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/Redis/RedisConnectionWarmupTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/Redis/RedisConnectorIntegrationTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/Redis/RedisConnectorTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/Redis/RedisHashCacheTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/Redis/RedisPlannedMaintenanceIntegrationTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/Redis/RedisSetCacheTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/RehydrationCoordinatorTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/ResiliencePipelineFactoryTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/ResiliencePipelineProviderTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/SetCacheProviderTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/SystemJsonByteSerializerProxyTests.cs Member reordering to satisfy ordering rules.
tests/UiPath.Caching.Tests/TestCacheEntry.cs Member reordering to satisfy ordering rules.
benchmarks/UiPath.Caching.Benchmarks/CacheBenchmark.cs Member reordering to satisfy ordering rules.
benchmarks/UiPath.Caching.Benchmarks/SerializerBenchmark.cs Member reordering to satisfy ordering rules.
benchmarks/UiPath.Caching.Benchmarks/StreamNotifyDoorbellHarness.cs Member reordering to satisfy ordering rules.
samples/UiPath.Caching.Sample.ServiceDefaults/Extensions.cs Member reordering to satisfy ordering rules.
Review details
  • Files reviewed: 154/154 changed files
  • Comments generated: 2
  • Review effort level: Lite

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

Comment thread Directory.Packages.props Outdated
Comment thread Directory.Build.props Outdated

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.

🟡 Changes recommended

Core ordering rules remain disabled, while unrelated dependency downgrades and removed floor safeguards introduce operational regressions.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (2)

Directory.Build.props:48

  • This comment contradicts the configuration it documents: .editorconfig:495 enables the OrderingRules category, while SA1402 is the single file-per-type rule enabled under src. Please describe the analyzer scope accurately so future maintainers do not disable a rule set that is intentionally active.
  <!-- StyleCop is here for two rules only: the file-per-type pair. Everything else it ships,
       including the ordering rules, is switched off by category in .editorconfig. -->

Directory.Packages.props:26

  • Placing the net8 floor before the net10 floor reintroduces the Dependabot failure this file previously guarded against: for duplicate package IDs, its patch update can target the first (now net8) declaration. The PR also removes TheNet10FloorIsDeclaredFirst, so CI no longer detects this. Keep the net10 group first and retain the order test.
  <ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
  • Files reviewed: 154/154 changed files
  • Comments generated: 3
  • Review effort level: Balanced

Comment thread .editorconfig
Comment thread Directory.Packages.props Outdated
Comment thread src/UiPath.Caching.Azure/UiPath.Caching.Azure.csproj Outdated
alinahornet
alinahornet previously approved these changes Sep 10, 2026

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 implementation is mechanically consistent and behavior-preserving; only minor analyzer-policy wording discrepancies remain.

Review details
  • Files reviewed: 191/191 changed files
  • Comments generated: 3
  • Review effort level: Balanced

Comment thread .editorconfig Outdated
Comment thread .editorconfig
Comment thread .editorconfig

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.

🟡 Changes recommended

Three unconsumed generated SA1201 report files containing machine-specific paths should be removed before approval.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 191/191 changed files
  • Comments generated: 3
  • Review effort level: Balanced

Comment thread sa1201_files.txt Outdated
Comment thread sa1201_remaining_unique.txt Outdated
Comment thread sa1201_unique.txt Outdated
@cosmin-staicu
cosmin-staicu force-pushed the chore/analyzer-member-order branch from 3cb177c to db8d2e8 Compare September 11, 2026 04:49
@cosmin-staicu
cosmin-staicu requested a balanced review from Copilot September 11, 2026 04:49

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 analyzer-driven changes preserve behavior and are comprehensively verified; only a minor stale tooling comment remains.

Review details
  • Files reviewed: 188/188 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread .editorconfig Outdated

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.

🟡 Changes recommended

The diagnostics intended to prevent ordering drift are warnings, but neither project configuration nor CI fails on warnings.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 188/188 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread .editorconfig

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.

🟡 Changes recommended

The moved SER007 pragma now suppresses unrelated code beyond the intended helper, weakening the warning-enforcement boundary.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 189/189 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Members are laid out the way the ordering rules ask, and the rules are
on so it stays that way. The build reports no warnings at all: every
SA1201, SA1202, SA1203, SA1204, SA1210, SA1214 and IDE0040 is gone, and
S4136 with them.

What is enforced

.editorconfig already carried a curated StyleCop block, so this joins it
rather than replacing it. StyleCop.Analyzers is now referenced, and every
one of its eight categories is none except OrderingRules, with the rules
we want named individually where a category cannot reach them. Without
that the package reports around five thousand warnings.

- The OrderingRules category: order by kind, by access, constants first,
  readonly first, using directives alphabetical. The category rather
  than a list of ids, because it costs 28 more violations and no
  maintenance.
- SA1204, static before instance, was already none further up the file.
  A specific id beats a category, so the category alone would not have
  applied it; it is named explicitly. SA1200 and SA1208, on using
  directive placement, stay none as they were.
- SA1402, scoped to src: one top-level type per file on the shipped
  surface. topLevelTypes in stylecop.json widens it past its default of
  class alone. Four files held nine extra types and are now thirteen.
  Tests and samples keep small helper types next to what uses them.
- SA1649 was already none and stays there: it does not recognise the OfT
  suffix this repo uses for generic types, so it would rename
  CacheOfT.cs and six siblings to Cache{T}.cs.
- SX1309, the alternative to SA1309, wants every field to begin with an
  underscore. It belongs to no StyleCop category, so switching the
  categories off does not reach it; the SX family is named off
  explicitly. SA1309 is already off above for the opposite reason.
- IDE0040 was configured but silent. It is a warning now: a class member
  always states its accessibility, an interface member never repeats the
  public it already has. 25 interface members carried a redundant public
  and two class members had none.

How the members were moved

Neither dotnet format nor the Roslynator CLI can drive StyleCop's fixer
for the ordering rules — both answer that no code fix was found — and
Rider's layout engine ranks constants and statics above accessibility,
which pushes SA1202 up rather than down. So a Roslyn pass did it: parse,
sort each type's members by StyleCop's default elementOrder, write the
tree back, which carries each member's doc comments and blank lines with
it.

Three rules kept it safe. The sort is stable, so anything the comparer
calls equal keeps the order the author chose. A field whose initializer
reads a sibling member, or this, is pinned where it is, because C# runs
field initializers in textual order. And a file containing #region or
#if is refused outright, since those directives are trivia on the
members around them and a sort can carry one away from its partner.

That left seven conditional-compilation files and six other places to
settle by hand: three field blocks moved as units so their initializers
keep reading what they read, an interface that sat below a class in its
file, and the two buffer tests whose nested helper lives beside the
tests that use it.

Also here

S4136 had been reporting eight non-adjacent overload groups on every
build, and #164 proposed turning the rule off. Measuring first said
otherwise: every group is of uniform accessibility, five are split by a
single private Core helper sitting between the public overloads it
serves, and moving that helper below the group is what SA1202 asks for
anyway. The two rules agree rather than conflict.

KeyMasker.IsMasking carried two summary tags, having taken ShouldMask's
when it was inserted above it. ShouldMask has its documentation back.

Verification

The reordering is a move and nothing else, which the diff shows: the
insertions and deletions match. Both suites are unchanged at 1701 on
net10 and 1680 on net8 — the count is the check that matters for the
conditional files, because a test carried out of a NET9_0_OR_GREATER
block would raise the net8 total and one carried in would lower it. #if
pairs stay balanced. The packed nuspec 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.

🔵 Needs a closer look

The 189-file mechanical rewrite is coherent and no specific defect was found, but its breadth warrants final human review.

Review details
  • Files reviewed: 189/189 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@sonarqubecloud

Copy link
Copy Markdown

@cosmin-staicu
cosmin-staicu merged commit 8708d1c into main Sep 11, 2026
11 checks passed
@cosmin-staicu
cosmin-staicu deleted the chore/analyzer-member-order branch September 11, 2026 06:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-cla-review A maintainer should assess whether a signed CLA is required (see CONTRIBUTING.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants