Skip to content

Conversation

@idg10
Copy link
Collaborator

@idg10 idg10 commented Sep 26, 2025

Issue #2187 illustrates a problem caused by a non-obvious feature of how Rx promotes OnError notifications to real exceptions in mechanisms such as await.

This PR provides two mitgations:

  1. it documents the limitations, so that developers can have some way of knowing that there might be a problem
  2. it provides a new CaptureExceptionDispatchState operator that can provide a straightforward way to avoid the problem

@idg10 idg10 marked this pull request as ready for review October 1, 2025 08:07
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new CaptureExceptionDispatchState operator and comprehensive documentation to address exception reuse limitations in Rx.NET, specifically the issue where exception stack traces accumulate when the same exception instance is rethrown multiple times.

  • Adds the CaptureExceptionDispatchState operator to reset exception dispatch state by performing a throw/catch cycle
  • Documents the exception reuse problem and provides clear guidelines for developers
  • Updates build configuration to use newer Windows SDK versions and build images

Reviewed Changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated no comments.

Show a summary per file
File Description
azure-pipelines.rx.yml Updates build to use windows-2025 image and removes outdated TargetPlatformSdkPath override
Rx.NET/tools/HomoIcon/app.config Adds .NET Framework 4.8 configuration file
Rx.NET/tools/HomoIcon/HomoIcon.csproj Upgrades project to .NET Framework 4.8 and MSBuild 12.0
Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/ThrowTest.cs Adds System.Threading.Tasks using directive and removes trailing whitespace
Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/MinTest.cs Fixes LINQ compilation issues by adding AsEnumerable() calls
Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/MaxTest.cs Fixes LINQ compilation issues by adding AsEnumerable() calls
Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/CaptureExceptionDispatchStateTest.cs Adds comprehensive tests for the new operator
Rx.NET/Source/tests/Tests.System.Reactive.ApiApprovals/Api/ApiApprovalTests.Core.verified.cs Updates API approval tests to include the new operator
Rx.NET/Source/src/System.Reactive/System.Reactive.csproj Updates Windows SDK reference to version 10.0.26100.0
Rx.NET/Source/src/System.Reactive/Linq/QueryLanguage.Single.cs Implements the core CaptureExceptionDispatchState operator logic
Rx.NET/Source/src/System.Reactive/Linq/Qbservable.Generated.cs Adds queryable support and fixes documentation comments
Rx.NET/Source/src/System.Reactive/Linq/Observable/CaptureExceptionDispatchState.cs Implements the operator's core functionality with detailed comments
Rx.NET/Source/src/System.Reactive/Linq/Observable.Single.cs Adds public API extension method with documentation
Rx.NET/Source/src/System.Reactive/Linq/IQueryLanguage.cs Adds interface definition for the new operator
Rx.NET/Source/src/System.Reactive.Observable.Aliases/System.Reactive.Observable.Aliases.csproj Updates Windows SDK reference to version 10.0.26100.0
Rx.NET/Documentation/adr/0004-onerror-to-throw.md Comprehensive documentation of exception reuse rules and limitations
Rx.NET/Documentation/adr/0003-uap-targets.md Updates documentation to reflect new Windows SDK version
Rx.NET/Documentation/ReleaseHistory/Rx.v6.md Documents the new operator in release notes
Comments suppressed due to low confidence (3)

Rx.NET/Source/src/System.Reactive/Linq/Qbservable.Generated.cs:1

  • The documentation changes appear to be inconsistent. The first two methods now describe 'enumerable sequence' but the third describes 'observable sequence'. These should be consistent - verify which is correct for each overload.
/*

Rx.NET/Source/src/System.Reactive/Linq/Qbservable.Generated.cs:1

  • The documentation changes appear to be inconsistent. The first two methods now describe 'enumerable sequence' but the third describes 'observable sequence'. These should be consistent - verify which is correct for each overload.
/*

Rx.NET/Source/src/System.Reactive/Linq/Qbservable.Generated.cs:1

  • The documentation changes appear to be inconsistent. The first two methods now describe 'enumerable sequence' but the third describes 'observable sequence'. These should be consistent - verify which is correct for each overload.
/*

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@idg10 idg10 changed the title Add CaptureExceptionDispatchState operator and document exception reuse limitations Add ResetExceptionDispatchState operator and document exception reuse limitations Oct 1, 2025
@idg10 idg10 merged commit 1ffbcad into main Oct 1, 2025
7 checks passed
@idg10 idg10 deleted the feature/2187-capture-exception-dispatch branch October 1, 2025 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants