You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The library has its own Contract.Requires(...) and Contract.Assume(...) helpers, left over as part of the migration away from the legacy .NET Frameworks Code Contracts (RIP). The .NET base class library (BCL) now provides equivalent (and more idiomatic) ThrowIfNull and ThrowIf guards directly on exception types, and C# 14 closes the one remaining gap. This allows us to retire the custom helper in favor of the modern, standard pattern. While this is mostly invisible to consumers, a handful of validation errors will become more precisely typed as part of this.
Tasks
Add InvalidOperationExceptionThrowIf() and ThrowIfNull() extension guards (the BCL doesn't cover this)
Add matching ThrowIf*() guards to each custom exception type (InvalidKeyException, TopicNotFoundException, &c.)
Migrate key-validation calls from TopicFactory.ValidateKey() to the new InvalidKeyException guards
Migrate the 150+ null-check call sites from Contract.Requires<>() to BCL ?? throw guards
Migrate the remaining generic-exception call sites (ArgumentOutOfRangeException, ArgumentException, &c.)
Evaluate and convert the 20+ boolean Contract.Requires() sites to ThrowIf(...) (these require care)
The condition inverts, as the old helper throws on false; ThrowIf() throws on true
Delete Contract.cs, its test file, and the Microsoft.VisualStudio.Validation package dependency
Activity