Uh oh!
There was an error while loading. Please reload this page.
Optimize non-generic collection count assertions - #10575
Conversation
Use ICollection.Count for non-generic HasCount and IsEmpty calls while preserving fallback, null, message, and telemetry behavior. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Optimizes non-generic count assertions by using ICollection.Count while preserving fallback behavior and telemetry.
Changes:
- Adds the
ICollectionfast path. - Adds unit tests for counting, failures, nulls, and enumeration.
- Verifies telemetry cardinality in acceptance tests.
Show a summary per file
| File | Description |
|---|---|
src/TestFramework/TestFramework/Assertions/Assert.HasCount.cs | Implements the optimized count path. |
test/UnitTests/TestFramework.UnitTests/Assertions/AssertTests.Items.cs | Covers optimized and fallback behavior. |
test/IntegrationTests/MSTest.Acceptance.IntegrationTests/TelemetryTests.cs | Validates assertion telemetry counts. |
Review details
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 3/3 changed files
- Comments generated: 0
- Review effort level: Balanced
🧵 Parallel-safety audit — PR #10575Nothing audited here touches process-global state, shared filesystem paths, or Changes reviewed:
No Audited Re-run with
|
🧪 Expert test review — PR #10575This PR adds a non-generic
No high-confidence actionable findings — every reviewed test asserts meaningful, mutation-sensitive behavior with tight diagnostics (custom This advisory comment was generated automatically. Grades are heuristic
|
Uh oh!
There was an error while loading. Please reload this page.
Summary
ICollection.Countfor non-genericAssert.HasCountandAssert.IsEmptycalls instead of enumerating throughCast<object>()IEnumerablefallback, null exception ordering, failure messages, and one telemetry event per assertion callPerformance
Release microbenchmark of the isolated count path over 1,000 elements (median of five 200,000-iteration samples):
ICollection(ArrayList)IEnumerableThe fallback result is effectively unchanged; the collection path becomes O(1) and allocation-free.
Validation
Assert.HasCountand oneAssert.IsEmptyeventCloses#10573