Add ResetExceptionDispatchState operator and document exception reuse limitations#2237
Merged
Add ResetExceptionDispatchState operator and document exception reuse limitations#2237
Conversation
…ed path detection in build works on agent
The Windows 2025 agents don't have the 10.0.19041 SDK we had previously been relying on installed but they do have 22621 Also fix build issue that seems to have started with .NET SDK 10 in which the Reverse extension method for Span<char> takes precedence over the LINQ operator.
There was a problem hiding this comment.
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
CaptureExceptionDispatchStateoperator 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.
carmeleve
reviewed
Oct 1, 2025
Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/MaxTest.cs
Show resolved
Hide resolved
carmeleve
reviewed
Oct 1, 2025
Rx.NET/Source/tests/Tests.System.Reactive/Tests/Linq/Observable/MinTest.cs
Show resolved
Hide resolved
carmeleve
approved these changes
Oct 1, 2025
carmeleve
approved these changes
Oct 1, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #2187 illustrates a problem caused by a non-obvious feature of how Rx promotes
OnErrornotifications to real exceptions in mechanisms such asawait.This PR provides two mitgations:
CaptureExceptionDispatchStateoperator that can provide a straightforward way to avoid the problem