-
-
Couldn't load subscription status.
- Fork 94
Enhance Assertion source generation for easier extensibility #3356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
- Implemented MethodAssertionGenerator to create assertion classes and extension methods from methods decorated with [GenerateAssertion]. - Added support for various return types: bool, AssertionResult, Task<bool>, and Task<AssertionResult>. - Created tests for boolean methods, assertion result methods, and async methods to validate generated assertions. - Introduced [AssertionFrom] attribute to generate assertions from existing methods in libraries or user code. - Updated documentation to include usage examples and best practices for using source generator assertions.
… update generated assertions for async methods
- Updated `AssertionMethodGenerator` to conditionally add async support based on return type. - Removed deprecated assertions for `Assembly`, `CancellationToken`, `Char`, and `DateTime` in favor of source-generated assertions. - Migrated assertions like `IsCollectible`, `IsDynamic`, `IsFullyTrusted`, and others to `AssemblyAssertionExtensions.cs`. - Consolidated `CancellationToken` assertions into `CancellationTokenAssertionExtensions.cs`. - Removed `CharSpecializedAssertions.cs` and replaced with `CharAssertionExtensions.cs` for static method assertions. - Moved `DateTime` assertions to `DateTimeMethodAssertions.cs` with source-generated attributes. - Refactored `Encoding` assertions into `EncodingPropertyAssertions.cs` for property-based checks. - Consolidated string assertions into `StringStaticMethodAssertions.cs` for static method checks. - Updated `AssertionExtensions.cs` to reflect the removal of old assertion methods and added notes for migrated assertions.
…c handling, remove legacy boolean assertions, and add source-generated extensions for boolean and DayOfWeek assertions.
…ding, and HttpStatusCode types
…, Exception, and StringBuilder types; remove legacy assertion classes.
…ellationToken types; consolidate and remove legacy assertion classes.
…ead, TimeSpan, Type, and Uri types; implement various assertions for each type.
…se nameof for member references
…Time, and Encoding types; consolidate and remove legacy assertion classes.
…ss, Lazy<T>, Process, and Version types; implement various assertions for each type.
…d TimeZoneInfo types; implement various assertions for each type.
…, FileInfo, TimeOnly, and WeakReference types; implement various assertions for each type.
…, Array, DateOnly, TimeOnly, Index, Range, TimeZoneInfo, and WeakReference types; implement various assertions for each type.
… references; add Stream assertion tests.
- Implemented GuidAssertionTests to verify empty and non-empty GUIDs. - Created LazyAssertionTests to check if Lazy<T> values are created or not. - Added StringBuilderAssertionTests to assert on empty and non-empty StringBuilder instances and their capacity. - Developed TaskAssertionTests to validate task states including completion, cancellation, and faulting. - Introduced TimeSpanAssertionTests to assert on TimeSpan values for zero, positive, negative, and non-negative checks.
…er IntelliSense support - Added [EditorBrowsable(EditorBrowsableState.Never)] attribute to various assertion methods across multiple extension classes including Array, Assembly, Boolean, CancellationToken, CultureInfo, DateOnly, DateTime, DateTimeOffset, DayOfWeek, DirectoryInfo, Encoding, Exception, FileInfo, Guid, HttpStatusCode, Lazy, Range, Stream, StringBuilder, TimeOnly, TimeSpan, and Version. - This change helps to hide these methods from IntelliSense, making the public API cleaner and focusing on the most relevant methods for users.
…nd update documentation for IntelliSense clarity
…generated methods
…P address, process, thread, and type scenarios
- Implemented RangeAssertionTests to validate range indices and boundaries. - Added StreamAssertionTests to check stream capabilities like reading, writing, and seeking. - Created StringBuilderAssertionTests to assert on StringBuilder properties such as emptiness and capacity. - Developed TaskAssertionTests to verify task states including completion, cancellation, and faulting. - Introduced ThreadAssertionTests to check thread properties like alive status and background state. - Added TimeOnlyAssertionTests to validate TimeOnly properties such as midnight and noon. - Implemented TimeSpanAssertionTests to assert on TimeSpan characteristics like zero, positive, and negative values. - Created TimeZoneInfoAssertionTests to check daylight saving time support and IANA ID presence. - Developed TypeAssertionTests to validate various type characteristics including class, interface, and generics. - Added UriAssertionTests to assert on URI properties such as absolute, file, and loopback. - Implemented VersionAssertionTests to check version properties like major version and build number. - Created WeakReferenceAssertionTests to validate weak reference behavior and resurrection tracking.
- Implement tests for Thread, TimeOnly, TimeSpan, and TimeZoneInfo assertion generators. - Add comprehensive tests for Type assertion generators, covering various type checks. - Introduce tests for Uri, Version, and WeakReference assertion generators. - Ensure each test verifies the generation of corresponding assertion extension methods.
…r type dependency
… prefixes for consistency
This was referenced Oct 20, 2025
This was referenced Oct 28, 2025
Open
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.
No description provided.