refactor: order type members, and enforce it - #176
Conversation
|
🔎 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
Other signals
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.
|
There was a problem hiding this comment.
🟡 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/, andbenchmarks/to eliminate ordering/accessibility diagnostics. - Adjust central package-version floors and add
StyleCop.Analyzersas 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.
There was a problem hiding this comment.
🟡 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:495enables the OrderingRules category, while SA1402 is the single file-per-type rule enabled undersrc. 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
a5ca6ad to
8bcda4e
Compare
8bcda4e to
3cb177c
Compare
There was a problem hiding this comment.
🟡 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
3cb177c to
db8d2e8
Compare
db8d2e8 to
1b4e36c
Compare
There was a problem hiding this comment.
🟡 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
1b4e36c to
453fb7c
Compare
There was a problem hiding this comment.
🟡 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>
453fb7c to
ce49be8
Compare
|



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 —
mainreports 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.propsand the four "by hand" files listed below.What is now enforced
.editorconfigalready carried a curated StyleCop block, so this joins it rather than replacing it — worth knowing when reading the diff.StyleCop.Analyzersis now referenced, and every one of its eight categories isnoneexceptOrderingRules, with rules named individually where a category cannot reach them. Without that the package reports about 5,000 warnings.OrderingRulescategory — 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.nonefurther 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 staysnone: it wants using directives inside the namespace, and this repo puts them above the file-scoped namespace.src— one top-level type per file on the shipped surface.topLevelTypesinstylecop.jsonwidens it past its default ofclassalone. Four files held nine extra types and are now thirteen. Outsidesrcit isnone, notsuggestion: tests, samples and benchmarks keep small helper types beside what uses them, and leaving it atsuggestiononly meant 33 standing Sonar issues for 17 files nobody intends to split.noneand stays there. It doesn't recognise theOfTsuffix used for generic types, so it would ask to renameCacheOfT.cs,ICacheOfT.csand five siblings toCache{T}.cs.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, isnone. 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 warningsmaindoes not have, which my first greps (filtered toSA1*/IDE0040) missed. The five fields are fixed rather than the rule silenced.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 thepublicit already has. 25 interface members carried a redundantpublic; two class members had none at all. Removingpublicfrom an interface member changes no API —PublicAPI.Shipped.txtis 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 towarningso they cannot drift back:none)csharp_prefer_bracesraised fromsilenttowarning, thendotnet format styleUpper_then_snake. Local variables namedgeneratorwere left alone — lowercase is correct thereThe fifth is SA1402, above.
How the members were moved
Neither
dotnet formatnor 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:
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.#regionor#ifis 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:
MemoryCacheFactoryTestsandRedisSetCacheTests— field blocks moved as units, soBefore/Afterkeep readingDeadlineand 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 XCoreAsyncsitting 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:!removed. Removing it broke the build withCS8604on all five:_context.Topicis aRedisKeyand@event.IdaRedisValue, non-nullable structs whose implicit conversion tostringis nullable. Sonar reads the operand, Roslyn reads the conversion result, and both are right about different things..ToString()drops the!and theCS8604together.WaitAsynctimeout. Each now states what its name claims: the secondDisposedoes not throw, the 1000 concurrent subscriptions all survive, no worker faults,StreamCreateConsumerGroupAsyncis actually reached, and the fetch loop is not faulted after BUSYGROUP or an unexpected create failure.KeyMasker.IsMaskingcarried two<summary>tags, having absorbedShouldMask's when it was inserted above it in #165.ShouldMaskhas its documentation back; it's the only place insrcwith that mistake.Verification
main. SonarCloud gate passes with 0 open issues, down from 248.-warnaserror, so none of this can drift back.TreatWarningsAsErrorsstaysfalseinDirectory.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.main: 1704 on net10, 1683 on net8. For the conditional files that count is the check: a[Fact]carried out of aNET9_0_OR_GREATERblock would raise the net8 total, one carried in would lower it. Neither moved.#if/#endifpairs balanced in both files that have them.An earlier revision of this branch had reverted all four files of #172 back to their pre-#172 state, dropping
$(MEVersion10)and the threePackageVersionFloorTestsguards with it. Restored frommain; the only change left inDirectory.Packages.propsis the oneStyleCop.Analyzersline this PR needs. The test totals above are what caught it.🤖 Generated with Claude Code
https://claude.ai/code/session_01NsPw6MZHPGmpbo6WDuLzF1