Skip to content

Add [Serializable] and serialization constructor to ConcurrentObserverCallsException#127

Merged
ChrisPulman merged 2 commits intoCP_UpdatePackagesfrom
copilot/sub-pr-126
Feb 28, 2026
Merged

Add [Serializable] and serialization constructor to ConcurrentObserverCallsException#127
ChrisPulman merged 2 commits intoCP_UpdatePackagesfrom
copilot/sub-pr-126

Conversation

Copy link
Contributor

Copilot AI commented Feb 28, 2026

Custom exception types targeting .NET Framework (net462/net472/net481) must be marked [Serializable] and include a protected serialization constructor to satisfy the standard Exception pattern and avoid analyzer warnings.

Changes

  • [Serializable] — Added to ConcurrentObserverCallsException class declaration
  • Serialization constructor — Added protected ConcurrentObserverCallsException(SerializationInfo, StreamingContext) gated behind #if NETFRAMEWORK since BinaryFormatter-based serialization is only relevant on .NET Framework; not needed (and obsolete) on modern .NET
  • Conditional usingusing System.Runtime.Serialization; scoped to #if NETFRAMEWORK to avoid pulling in the namespace on modern TFMs
[Serializable]
public class ConcurrentObserverCallsException : Exception
{
    // existing constructors...

#if NETFRAMEWORK
    protected ConcurrentObserverCallsException(SerializationInfo info, StreamingContext context)
        : base(info, context) { }
#endif
}

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…entObserverCallsException

Co-authored-by: ChrisPulman <4910015+ChrisPulman@users.noreply.github.com>
Copilot AI changed the title [WIP] Update async library based on review feedback Add [Serializable] and serialization constructor to ConcurrentObserverCallsException Feb 28, 2026
@ChrisPulman ChrisPulman marked this pull request as ready for review February 28, 2026 13:17
@ChrisPulman ChrisPulman merged commit ccb417d into CP_UpdatePackages Feb 28, 2026
@ChrisPulman ChrisPulman deleted the copilot/sub-pr-126 branch February 28, 2026 13:18
ChrisPulman added a commit that referenced this pull request Feb 28, 2026
* Bump packages; fix async test subscriptions

Update package versions in Directory.Packages.props (Polyfill -> 9.12.0, Microsoft.NET.Test.Sdk -> 18.3.0, TUnit -> 1.17.54, Verify.TUnit -> 31.13.2, Microsoft.Testing.Extensions.CodeCoverage -> 18.5.1, etc.) and remove some older test package entries.

Refactor ReactiveExtensionsTests to reliably track and await async subscription handlers: replace inline async Subscribe callbacks with a tasks list and a local HandleAsync wrapper that disposes the sync token in a finally block, then await Task.WhenAll(tasks) to avoid race conditions and flakiness in the tests.

* Add scheduler support to SyncTimer and tests

Change SyncTimer to key timers by both TimeSpan and IScheduler, add an overload SyncTimer(TimeSpan, IScheduler) and keep a fallback to Scheduler.Default. Validate scheduler is non-null and create the underlying Observable.Timer with the provided scheduler so timers can be shared per scheduler. Update tests to use TestScheduler (pass it into SyncTimer and OnErrorRetry), and replace async wait helpers with scheduler.AdvanceBy to make timing deterministic.

* Modernize async library and test fixes

Apply modern C# updates and various test fixes across the async library. Highlights:
- Update .github documentation target frameworks and add RCS1047 to NoWarn in Directory.Build.props.
- Bump copyright years from 2019-2025 to 2019-2026 in many source files.
- Add conditional ArgumentNullException.ThrowIfNull / ThrowIfLessThan checks for .NET 8+ and use Lock on newer frameworks where appropriate to improve null-safety and reliability.
- Expand ConcurrentObserverCallsException into a full exception class with standard constructors.
- Minor API/implementation cleanups: suppress CA2000 where needed, simplify nullable/collection initializations, expression-bodied test methods, additional disposals in tests, and other small refactors to reduce analyzer warnings and improve robustness.

* Add ArgumentExceptionHelper and centralize null checks

Introduce Internal/ArgumentExceptionHelper with ThrowIfNull and ThrowIfNullOrEmpty helpers and replace scattered NET8/legacy null-check conditionals across the Async and Reactive extensions with calls to ArgumentExceptionHelper.ThrowIfNull. This centralizes argument validation (removing many #if NET8_0_OR_GREATER blocks), streamlines a few checks (e.g. Timeout and WaitForCondition), and reduces duplication across numerous operator/subject/observable implementations.

* Add [Serializable] and serialization constructor to ConcurrentObserverCallsException (#127)

* Initial plan

* Add [Serializable] attribute and serialization constructor to ConcurrentObserverCallsException

Co-authored-by: ChrisPulman <4910015+ChrisPulman@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: ChrisPulman <4910015+ChrisPulman@users.noreply.github.com>

* Move RCS1047 suppression to .editorconfig

Set dotnet_diagnostic.RCS1047.severity = none in .editorconfig and remove RCS1047 from the NoWarn list in src/Directory.Build.props. This centralizes the analyzer configuration in .editorconfig and avoids duplicate suppression in MSBuild.

* Fix WhenOnDisposeAsyncSourceFails_ThenCallbackInvoked to actually assert callback invocation (#128)

* Initial plan

* Add disposeCallbackInvoked flag assertion in WhenOnDisposeAsyncSourceFails_ThenCallbackInvoked test

Co-authored-by: ChrisPulman <4910015+ChrisPulman@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: ChrisPulman <4910015+ChrisPulman@users.noreply.github.com>

---------

Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: ChrisPulman <4910015+ChrisPulman@users.noreply.github.com>
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