Skip to content

fix: harden R3 bridge generator emission#105

Merged
ChrisPulman merged 2 commits into
mainfrom
CP_fix-r3-bridge-generator-refit-2176
Jun 28, 2026
Merged

fix: harden R3 bridge generator emission#105
ChrisPulman merged 2 commits into
mainfrom
CP_fix-r3-bridge-generator-refit-2176

Conversation

@ChrisPulman

@ChrisPulman ChrisPulman commented Jun 28, 2026

Copy link
Copy Markdown
Member

What kind of change does this PR introduce?

Bug fix and regression test coverage for the R3 bridge source generator.

What is the new behavior?

  • R3 bridge sources are emitted only when the consumer compilation has the complete R3 shape used by the generated code: R3.Observable<T>, R3.Observer<T>, and R3.Result.
  • The R3 generated marker behavior is covered by a project-reference-style regression test to prevent PrimitivesR3BridgeGeneratedAttribute from becoming a public cross-assembly conflict again.
  • Incomplete R3-shaped compilations no longer get sync or async bridge source emitted.

What is the current behavior?

  • Refit issue Refit 12 with PrimitivesR3BridgeGeneratedAttribute issues.... refit#2176 reports CS0436 when a public generated PrimitivesR3BridgeGeneratedAttribute appears in both a referenced assembly and the consuming project.
  • The async R3 bridge emission guard only checked for R3.Observable<T> and async primitives, even though the generated code also referenced R3.Observer<T> and R3.Result.

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

Addresses reactiveui/refit#2176.

Validation:

  • dotnet test tests/ReactiveUI.Primitives.Tests/ReactiveUI.Primitives.Tests.csproj -- --treenode-filter "/*/*/R3BridgeGeneratorTests/*" passed 16 tests across net8.0, net9.0, net10.0, and net11.0.
  • dotnet test tests/ReactiveUI.Primitives.Async.Tests/ReactiveUI.Primitives.Async.Tests.csproj -- --treenode-filter "/*/*/AsyncBridgeGeneratorContractTests/*" passed 8 tests across net8.0, net9.0, net10.0, and net11.0.
  • TUnit MCP coverage summary reported ReactiveUI.Primitives.R3Bridge.Generator at 63/63 covered lines in existing Cobertura data.

Tighten ReactiveUI.Primitives.R3Bridge.Generator so R3 bridge sources are emitted only when the complete R3 observable, observer, and result shapes are visible.

Add regression coverage for reactiveui/refit#2176 by compiling a generated library and generated consumer in a project-reference-style scenario, verifying the generated marker attribute remains internal and does not produce CS0436.

Add regression coverage for incomplete R3 shapes so sync and async bridge sources are skipped instead of emitting code that references unavailable R3 types.

Validation: dotnet test tests/ReactiveUI.Primitives.Tests/ReactiveUI.Primitives.Tests.csproj -- --treenode-filter "/*/*/R3BridgeGeneratorTests/*"; dotnet test tests/ReactiveUI.Primitives.Async.Tests/ReactiveUI.Primitives.Async.Tests.csproj -- --treenode-filter "/*/*/AsyncBridgeGeneratorContractTests/*".
@ChrisPulman ChrisPulman marked this pull request as ready for review June 28, 2026 11:00
@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Jun 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.93%. Comparing base (c7bc03f) to head (605e962).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #105      +/-   ##
==========================================
- Coverage   90.93%   90.93%   -0.01%     
==========================================
  Files         651      651              
  Lines       20464    20467       +3     
  Branches     2454     2455       +1     
==========================================
+ Hits        18609    18611       +2     
  Misses       1486     1486              
- Partials      369      370       +1     

☔ 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.

@ChrisPulman ChrisPulman merged commit d40dad2 into main Jun 28, 2026
13 checks passed
@ChrisPulman ChrisPulman deleted the CP_fix-r3-bridge-generator-refit-2176 branch June 28, 2026 21:22
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