-
-
Notifications
You must be signed in to change notification settings - Fork 106
fix(assertions): update HasSingleItem to return the single item when awaited #3428
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
Conversation
|
Claude finished @thomhurst's task —— View job Code Review CompletedReviewing PR #3428: "fix(assertions): update HasSingleItem to return the single item when awaited" Review Checklist:
Code Quality & Implementation✅ Excellent Implementation: The solution follows the established pattern used by Key Strengths:
Technical AnalysisCore Changes Review:// Lines 541-554 in CollectionAssertions.cs
public new System.Runtime.CompilerServices.TaskAwaiter<TItem> GetAwaiter()
{
return ExecuteAndReturnItemAsync().GetAwaiter();
}
private async Task<TItem> ExecuteAndReturnItemAsync()
{
await AssertAsync(); // Execute validation first
return _singleItem!; // Return the captured item
}✅ Thread Safety: The Test Coverage Assessment:The new
Performance Considerations✅ Minimal Overhead: The implementation adds negligible performance cost Security & Safety✅ No Security Concerns: Pure assertion logic with no external dependencies Adherence to TUnit Guidelines✅ Dual-Mode Compatible: Works identically in both source-generated and reflection modes Potential ImprovementsMinor Suggestion: Consider adding XML documentation example showing both usage patterns: /// <example>
/// // Chain with .And
/// await Assert.That(list).HasSingleItem().And.ContainsOnly(x => x > 0);
///
/// // Await to get the item
/// var item = await Assert.That(list).HasSingleItem();
/// await Assert.That(item).IsEqualTo(expectedValue);
/// </example>Final Assessment✅ APPROVED - This is a well-implemented enhancement that:
The implementation demonstrates excellent understanding of the TUnit architecture and C# async patterns. No bugs or issues identified. |
…erence for collections
|
Claude finished @thomhurst's task —— View job Code Review CompletedReviewing PR #3428: "fix(assertions): update HasSingleItem to return the single item when awaited" Review Checklist:
Code Quality & Implementation✅ Excellent Implementation: The solution follows the established pattern used by Key Strengths:
Technical AnalysisCore Changes Review:// Lines 541-554 in CollectionAssertions.cs
public new System.Runtime.CompilerServices.TaskAwaiter<TItem> GetAwaiter()
{
return ExecuteAndReturnItemAsync().GetAwaiter();
}
private async Task<TItem> ExecuteAndReturnItemAsync()
{
await AssertAsync(); // Execute validation first
return _singleItem!; // Return the captured item
}✅ Thread Safety: The Test Coverage Assessment:The new
Performance Considerations✅ Minimal Overhead: The implementation adds negligible performance cost Security & Safety✅ No Security Concerns: Pure assertion logic with no external dependencies Adherence to TUnit Guidelines✅ Dual-Mode Compatible: Works identically in both source-generated and reflection modes Potential ImprovementsMinor Suggestion: Consider adding XML documentation example showing both usage patterns: /// <example>
/// // Chain with .And
/// await Assert.That(list).HasSingleItem().And.ContainsOnly(x => x > 0);
///
/// // Await to get the item
/// var item = await Assert.That(list).HasSingleItem();
/// await Assert.That(item).IsEqualTo(expectedValue);
/// </example>Final Assessment✅ APPROVED - This is a well-implemented enhancement that:
The implementation demonstrates excellent understanding of the TUnit architecture and C# async patterns. No bugs or issues identified. |
Fixes #3420