Conversation
This enables [GenerateAssertion] extensions targeting concrete array types (e.g., string[]) to work with Assert.That(array), by ensuring the returned assertion type implements IAssertionSource<TItem[]>. Co-authored-by: thomhurst <30480171+thomhurst@users.noreply.github.com>
|
@claude There should be new snapshots for the new test. And can we add a test that calls and uses the generated assertion? |
|
Claude finished @thomhurst's task in 4m 44s —— View job SummaryI've added an end-to-end usage test for the ✅ Completed
❌ Blocked - Requires Manual Steps
What I CreatedNew file: This test file:
The file is committed locally but needs to be pushed. Next Steps (Manual)From the repository root, run these commands: # 1. Pull the latest changes (if needed)
git pull origin copilot/fix-generate-assertion-extension
# 2. Navigate to test directory
cd TUnit.Assertions.SourceGenerator.Tests
# 3. Build and run the ArrayTargetType test to generate snapshots
dotnet build
dotnet test --filter "FullyQualifiedName~ArrayTargetType"
# 4. Accept the generated .received.txt files as .verified.txt
for f in MethodAssertionGeneratorTests.ArrayTargetType*.received.txt; do
mv "$f" "${f%.received.txt}.verified.txt"
done
# 5. Go back to root and run all tests
cd ..
dotnet test
# 6. Stage and commit the snapshot files
git add TUnit.Assertions.SourceGenerator.Tests/*ArrayTargetType*.verified.txt
git commit -m "Accept snapshot files for ArrayTargetType test"
# 7. If I successfully pushed my changes, skip this. Otherwise:
git add TUnit.Assertions.Tests/GeneratedAssertions/ArrayTargetGeneratedAssertionUsageTests.cs
git commit -m "Add end-to-end usage test for ArrayAssertion with GenerateAssertion"
# 8. Push all changes
git push origin copilot/fix-generate-assertion-extensionExpected Snapshot FilesThese files should be generated (one per target framework):
--- | Branch |
|
@copilot There should be new snapshots for the new test. And can we add a test that calls and uses the generated assertion? |
…ource generator - Add .verified.txt snapshot files for ArrayTargetType test across all frameworks - Add GenerateAssertionArrayTests with 3 integration tests that call generated assertions - Fix GetSimpleTypeName to handle IArrayTypeSymbol (string[] -> StringArray) - Fix test assertion to use correct class name (Bool not Boolean) Co-authored-by: thomhurst <30480171+thomhurst@users.noreply.github.com>
Add ArrayAssertion<TItem> to all 4 framework-specific PublicAPI snapshot files. Co-authored-by: thomhurst <30480171+thomhurst@users.noreply.github.com>
Added in 38152b5:
|
The source generator's GetSimpleTypeName change for array types produces different class names (e.g., TArray_IsEmpty_Assertion instead of _IsEmpty_Assertion, T_IsIn_TArray_Assertion instead of T_IsIn__Assertion). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Assert.That(string[])returnsCollectionAssertion<string>(implementingIAssertionSource<IEnumerable<string>>), but[GenerateAssertion]onstring[]generates extension onIAssertionSource<string[]>- type mismatchArrayAssertion<TItem>class extendingCollectionAssertionBase<TItem[], TItem>(implementsIAssertionSource<TItem[]>)Assert.That(TItem[])to returnArrayAssertion<TItem>instead ofCollectionAssertion<TItem>GetSimpleTypeNamein source generator to handle array types (string[]→StringArray).verified.txtfiles forArrayTargetTypetest (all 4 frameworks)TUnit.Assertions.Teststhat call and verify the generated assertionArrayAssertion<TItem>typeOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.