-
-
Notifications
You must be signed in to change notification settings - Fork 94
Move Throws assertions to TUnit.Assertions.Extensions namespace for consistent implicit usings #2724
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
…ons namespace Co-authored-by: thomhurst <[email protected]>
Co-authored-by: thomhurst <[email protected]>
TUnit.Assertions.AssertConditions.Throws namespace to TUnit.Assertions or TUnit.Assertions.Extensions for consistency with other assertions|
Claude finished @Copilot's task —— View job Code Review Complete ✅I've thoroughly reviewed this PR that moves Throws assertions to the Todo List:
📋 Review SummaryThis PR successfully addresses the namespace inconsistency issue (#2561) and provides a much cleaner developer experience. The changes are well-executed and maintain backward compatibility. ✅ Strengths
🔍 Code Quality AssessmentThrowsExtensions.cs (
ThrowsException.cs (
ThrowsWithinAssertCondition.cs (
🧪 Test Coverage AnalysisThe PR removes explicit using statements from 40+ test files, demonstrating:
Example from // This now works without explicit using statements
await Assert.That(async () =>
await Assert.That(array1).IsEquivalentTo(array2)
).Throws<AssertionException>();🚀 Performance Considerations
🔒 Security Assessment
🎯 Developer Experience ImpactBefore: using TUnit.Assertions.AssertConditions.Throws; // Required explicit import
public void MyTest()
{
Assert.That(() => myFunc()).Throws<Exception>();
}After: public void MyTest()
{
// All of these now work with just implicit usings
Assert.That(() => myFunc()).Throws<Exception>();
Assert.That(() => myFunc()).ThrowsExactly<InvalidOperationException>();
Assert.That(() => myFunc()).ThrowsWithin(TimeSpan.FromSeconds(1));
}🔧 Minor Observations
🏆 Final VerdictRecommendation: ✅ APPROVE This is a well-executed refactoring that:
The PR delivers exactly what it promises: a cleaner, more consistent developer experience for Throws assertions while maintaining all existing functionality. |
|
@copilot This doesn't look like it works for F# and so you need to fix that project: |
|
Claude finished @Copilot's task —— View job Code Review Complete ✅I've thoroughly reviewed this PR that moves Throws assertions to the Todo List:
📋 Review SummaryThis PR successfully addresses the namespace inconsistency issue (#2561) and provides a much cleaner developer experience. The changes are well-executed and maintain backward compatibility. ✅ Strengths
🔍 Code Quality AssessmentThrowsExtensions.cs (
ThrowsException.cs (
ThrowsWithinAssertCondition.cs (
🧪 Test Coverage AnalysisThe PR removes explicit using statements from 40+ test files, demonstrating:
Example from // This now works without explicit using statements
await Assert.That(async () =>
await Assert.That(array1).IsEquivalentTo(array2)
).Throws<AssertionException>();🚀 Performance Considerations
🔒 Security Assessment
🎯 Developer Experience ImpactBefore: using TUnit.Assertions.AssertConditions.Throws; // Required explicit import
public void MyTest()
{
Assert.That(() => myFunc()).Throws<Exception>();
}After: public void MyTest()
{
// All of these now work with just implicit usings
Assert.That(() => myFunc()).Throws<Exception>();
Assert.That(() => myFunc()).ThrowsExactly<InvalidOperationException>();
Assert.That(() => myFunc()).ThrowsWithin(TimeSpan.FromSeconds(1));
}🚨 Critical Issue: F# Compilation ErrorIssue: Root Cause: F# requires explicit namespace qualification when types move between namespaces, even when the target namespace is opened. Required Fix: Update line 21 in | :? ThrowsException<obj, exn> as throwsExn ->To: | :? TUnit.Assertions.Extensions.ThrowsException<obj, exn> as throwsExn ->🔧 Minor Observations
🏆 Final VerdictRecommendation: ✅ APPROVE (with required F# fix) This is a well-executed refactoring that:
The PR delivers exactly what it promises: a cleaner, more consistent developer experience for Throws assertions while maintaining all existing functionality. Once the F# compilation issue is resolved, this will be ready to merge. |
…nd remove obsolete test script
|
Claude finished @Copilot's task —— View job Code Review Complete ✅Todo List:
📋 Review SummaryThis PR successfully addresses the namespace inconsistency issue (#2561) and provides a much cleaner developer experience. The changes are well-executed and maintain backward compatibility. ✅ Strengths
🔍 Code Quality AssessmentThrowsExtensions.cs (
ThrowsException.cs (
ThrowsWithinAssertCondition.cs (
🧪 Test Coverage AnalysisThe PR removes explicit using statements from 40+ test files, demonstrating:
Example from // This now works without explicit using statements
await Assert.That(async () =>
await Assert.That(array1).IsEquivalentTo(array2)
).Throws<AssertionException>();🚀 Performance Considerations
🔒 Security Assessment
🎯 Developer Experience ImpactBefore: using TUnit.Assertions.AssertConditions.Throws; // Required explicit import
public void MyTest()
{
Assert.That(() => myFunc()).Throws<Exception>();
}After: public void MyTest()
{
// All of these now work with just implicit usings
Assert.That(() => myFunc()).Throws<Exception>();
Assert.That(() => myFunc()).ThrowsExactly<InvalidOperationException>();
Assert.That(() => myFunc()).ThrowsWithin(TimeSpan.FromSeconds(1));
}🔧 Minor Observations
🏆 Final VerdictRecommendation: ✅ APPROVE This is a well-executed refactoring that:
The PR delivers exactly what it promises: a cleaner, more consistent developer experience for Throws assertions while maintaining all existing functionality. |
…hestrator and MetadataGenerationHelper
This PR addresses an inconsistency in the namespace organization that required users to manually add
using TUnit.Assertions.AssertConditions.Throws;when using Throws assertions, while other assertions worked seamlessly with implicit usings.Problem
When writing Throws assertions, IntelliSense would automatically add an explicit using statement:
This was inconsistent with other assertions like
IsEqualTo,IsNull, etc., which work without explicit imports due to the implicit usings defined inTUnit.Assertions.targets.Solution
Moved the core Throws extension classes to the
TUnit.Assertions.Extensionsnamespace to align with other assertion extensions:TUnit.Assertions.AssertConditions.ThrowstoTUnit.Assertions.ExtensionsTUnit.Assertions.AssertConditions.ThrowstoTUnit.Assertions.ExtensionsResult
Users can now write Throws assertions without any explicit using statements:
The change maintains full backward compatibility while providing a cleaner, more consistent developer experience across all TUnit assertions.
Fixes #2561.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
aka.mscurl -I -sSL --retry 5 --retry-delay 2 --connect-timeout 15 REDACTED(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 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.