Skip to content

refactor: align Refit with rxui coding standards and modernize - #2149

Merged
glennawatson merged 11 commits into
mainfrom
glennawatson/standards-aot
Jun 19, 2026
Merged

refactor: align Refit with rxui coding standards and modernize#2149
glennawatson merged 11 commits into
mainfrom
glennawatson/standards-aot

Conversation

@glennawatson

@glennawatson glennawatson commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

Refactor / modernization. Brings Refit in line with the documentation, styling, and structural standards used across the other rxui projects, with supporting modernization and a couple of serializer fixes surfaced along the way.

What is the new behavior?

  • Docs & style: StyleSharp / Roslynator / Sonar analyzers are now a build gate (no NoWarn); XML documentation added throughout; one top-level type per file; consistent layout and naming.
  • Structure: tests live in src/tests, benchmarks in src/benchmarks; AssemblyInfo replaced with csproj-based metadata; shared internal helpers moved to src/Shared (linked source) so production assemblies no longer expose InternalsVisibleTo; per-project refit.props/refit.targets imports removed.
  • Tests: migrated to TUnit native async assertions (the xUnit shim and file-based GlobalUsings are gone). Refit.Tests and Refit.GeneratorTests are now AOT/trim-compatible (IsAotCompatible), with reflection sites annotated and an AOT-safe collection-equality assertion helper.
  • Serializer: SystemTextJsonContentSerializer restores its reflection fallback (it had begun calling GetTypeInfo() unconditionally, which throws for resolver-less options even with reflection enabled). CamelCaseStringEnumConverter is reworked into strongly-typed converters so .NET 11 dictionary-key enum serialization works, while preserving lenient empty-string→null handling for nullable enums.

All tests pass on net8/9/10/11 for both test projects; the full solution builds clean with the analyzers on.

What is the current behavior?

The pre-PR main lacked the rxui-standard analyzer/documentation enforcement and structure, used an xUnit-style assertion shim, was not AOT/trim-clean in the test projects, and shipped a SystemTextJsonContentSerializer that threw NotSupportedException for the default (reflection) serializer path and could not serialize enum dictionary keys on .NET 11.

What might this PR break?

  • Public API: production assemblies no longer declare InternalsVisibleTo (helpers are now per-assembly linked source). The generated public-API surface changed accordingly (snapshots updated).
  • Behavior is otherwise preserved; the serializer changes restore previously-working reflection behavior and add .NET 11 support.

Checklist

  • I have read the Contribute guide
  • Tests have been added or updated (for bug fixes / features)
  • Docs have been added or updated (for bug fixes / features)
  • Changes target the main branch
  • PR title follows Conventional Commits

Additional information

Bring the repository in line with the documentation, styling, and structural
standards used across the other rxui projects, plus supporting modernization.

- docs/style: enforce StyleSharp/Roslynator/Sonar analyzers as a gate (no NoWarn);
  add XML documentation throughout, single top-level type per file, consistent
  layout and naming.
- structure: move tests to src/tests and benchmarks to src/benchmarks; replace
  AssemblyInfo with csproj-based metadata; move shared internal helpers to
  src/Shared (linked source) and drop InternalsVisibleTo from production assemblies;
  remove the per-project refit.props/refit.targets imports.
- test: migrate the suite to TUnit native async assertions (delete the xUnit shim
  and file-based GlobalUsings); make Refit.Tests/Refit.GeneratorTests AOT/trim
  compatible, annotating reflection sites and adding an AOT-safe collection assert.
- fix(serializer): restore the reflection fallback in SystemTextJsonContentSerializer
  (GetTypeInfo threw for resolver-less options) and rework CamelCaseStringEnumConverter
  into strongly-typed converters so .NET 11 dictionary-key enum serialization works,
  preserving lenient empty-string->null for nullable enums.
- Add sonarcloud.yml and codeql.yml calling the shared reactiveui/actions-common reusable workflows (project key reactiveui_refit; randomised CodeQL cron).
- Drop the deprecated productNamespacePrefix input from ci-build.yml (coverage filtering is driven by testconfig.json under MTP) and normalise srcFolder/version floor.
- Consolidate all workflow files under the Solution Items/workflows folder in Refit.slnx and remove the duplicated/backslash entries.
The repo versions via MinVer/git tags; version.json no longer exists.
@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

Delete the checked-in Benchmarks/{netcoreapp3.1,net5.0,net6.0}/*.bat
launchers. They target EOL frameworks and are superseded by
BenchmarkSwitcher + --filter (already wired in Program.cs). The
benchmark classes themselves already follow modern BenchmarkDotNet
conventions ([MemoryDiagnoser], [ShortRunJob], [EventPipeProfiler]).
GetEmbeddedResourceStream in RestServiceIntegrationTests and
MultipartTests used if (x is null) throw blocks; collapse them into
null-coalescing throw expressions to satisfy IDE0270 under the
SonarCloud build's code-style enforcement.
- S6444: pass a 1s match timeout to the legacy (pre-net7) parameter Regex
  to bound execution time (ReDoS hardening).
- S5332: the placeholder BaseUri used only for relative-path combining now
  uses https; its scheme/host are discarded before the request is sent.
- S5766: drop the dead [Serializable] marker from the ApiException family.
  These types have no serialization constructor and hold non-serializable
  members (HttpRequestMessage, response headers, RefitSettings), so
  BinaryFormatter already throws on them; the attribute was non-functional
  and BinaryFormatter is obsolete in modern .NET.

Hotspots cannot be cleared by in-code suppression, so each is resolved by
removing the triggering pattern.
Drop the PublicApiGenerator + Verify snapshot approval test (Refit core
only, net8-11) in favour of Microsoft.CodeAnalysis.PublicApiAnalyzers,
matching the other rxui repos.

- Track the public surface of every shipped library (Refit,
  Refit.HttpClientFactory, Refit.Newtonsoft.Json, Refit.Xml) across all
  10 TFMs via per-TFM PublicAPI/<tfm>/PublicAPI.{Shipped,Unshipped}.txt
  baselines; the analyzer (RS0016/RS0017/RS0037) now fails the build on any
  unbaselined public API change.
- Gate tracking in Directory.Build.props: tests, benchmarks, examples, the
  InterfaceStubGenerator projects, and the AOT smoke app opt out.
- Add tools/generate-publicapi.{sh,ps1} + README to regenerate baselines.
  Refit ships only cross-platform libraries, so every TFM builds on any OS.
- Remove the now-unused PublicApiGenerator package.
The MTP code-coverage config used a non-standard `extensions[].settings`
shape with an unanchored module filter ("Refit(\..+)?"), which matched
nothing against the full module paths on the Windows CI runner — every
*.cobertura.xml came back with empty <packages>, so SonarCloud showed 0%.

- Rewrite src/testconfig.json to the rxui-standard `codeCoverage.Configuration`
  schema. Anchor the module include to the assembly filename
  (".*[\\/]Refit(\..+)?\.dll$") so it matches the shipped Refit libraries on
  any OS while excluding third-party dependencies sitting in the same bin dir
  (verified locally: only Refit, Refit.Newtonsoft.Json, Refit.Xml are scored).
- Exclude generated sources (*.g.cs) and the usual coverage-exempt attributes.
- Add a repo-root codecov.yml matching the other rxui repos.
- Track codecov.yml and testconfig.json under Solution Items.
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@codecov

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.99366% with 369 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.17%. Comparing base (3717256) to head (66f611e).

Files with missing lines Patch % Lines
...y/HttpClientFactoryExtensions.ServiceCollection.cs 20.00% 132 Missing and 12 partials ⚠️
...y/HttpClientFactoryExtensions.HttpClientBuilder.cs 0.00% 108 Missing ⚠️
...c/Refit.HttpClientFactory/HttpClientFactoryCore.cs 54.19% 50 Missing and 10 partials ⚠️
src/InterfaceStubGenerator.Shared/Parser.cs 88.82% 13 Missing and 8 partials ⚠️
...erfaceStubGenerator.Shared/Polyfills/IndexRange.cs 0.00% 7 Missing ⚠️
...c/InterfaceStubGenerator.Shared/Polyfills/Range.cs 0.00% 6 Missing ⚠️
src/InterfaceStubGenerator.Shared/Emitter.cs 96.35% 2 Missing and 3 partials ⚠️
...Newtonsoft.Json/NewtonsoftJsonContentSerializer.cs 87.50% 3 Missing and 2 partials ⚠️
...StubGenerator.Shared/ImmutableEquatableArrayOfT.cs 88.46% 1 Missing and 2 partials ⚠️
...ator.Shared/IncrementalValuesProviderExtensions.cs 83.33% 3 Missing ⚠️
... and 3 more
Additional details and impacted files
@@            Coverage Diff            @@
##           main    #2149       +/-   ##
=========================================
+ Coverage      0   78.17%   +78.17%     
=========================================
  Files         0       97       +97     
  Lines         0     3821     +3821     
  Branches      0      715      +715     
=========================================
+ Hits          0     2987     +2987     
- Misses        0      690      +690     
- Partials      0      144      +144     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@glennawatson
glennawatson merged commit c7c14b4 into main Jun 19, 2026
12 of 13 checks passed
@glennawatson
glennawatson deleted the glennawatson/standards-aot branch June 19, 2026 09:02
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jul 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants