You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been using CollectionAssert for quite some time but when I want to check whether the contents of a ReadOnlyCollection<T> match my expectation a cannot use CollectionAssert because many generic collection interfaces do not inherit from ICollection.
Proposal
Add new generic overloads of all methods to take IReadOnlyCollection<T> or IEnumerable<T> instead of ICollection.
The methods nested in head methods highlighted by white color and any attempts to open them to look inside follows with "you can not move caret to it" or something like this
Once expanded the code is there, and in the code I can navigate to other parts of the class with ctrl+click.
I see no issue on my side.
Please record a gif / video (e.g. via snipping tool that is built-in in Windows) if this did not help, because I don't know what else to look for :)
Those regions look useless now that the classes are split, do you still find them useful Amaury Levé (@Evangelink)? (I have VS set to always expand regions so I don't care either way).
ok, this is something wrong with the project (i've never seen that architecture). Depends on which project me opening i get or errors or unreachable code.
When i did my dll on C# i knew what i should open and run to test my code. I had my own project and couple others with tests. But i cannot find even "the" project =(
try closing the solution, and delete all bin and obj folders. Or open cmdline in the folder where you have solution, and do dotnet clean, followed by dotnet build.
That should show all errors that you have there, if any. This looks like broken cache to me. VS should recover.
I guess I just don't know how to use projects like this. I don't know what to open. There are dozens of projects here. And they're all unhappy with something.
I'm currently working on my own collection and wanted to write tests for it. I was extremely surprised that this tool doesn't implement modern interfaces.
However, I also encountered an issue with element identification. So, I was interested in the outcome of the issue mentioned in the pull request.
The gist of it was that in binary lists, sort-equality doesn't always equal equal-equality. This requires a strict implementation of the Iquatable and IComparable interfaces so that they determine element equality in the same way. Otherwise, this leads to collisions and requires O(MxN) checks within the collision.
Maybe this will help with the issue. I no longer have any desire to delve into the project.
Closing as superseded — the modern Assert.* family added in 4.x already accepts IEnumerable<T> (which is strictly broader than IReadOnlyCollection<T> and ICollection<T>), so no extra CollectionAssert overloads are needed. The recommended replacements are all on Assert itself:
CollectionAssert.*
Modern Assert.* replacement (takes IEnumerable<T>)
All overloads use RFC 012 structured failure messages and apply to any IReadOnlyCollection<T>, custom enumerable, or LINQ query without needing .ToList() / casts.
For the umbrella analyzer guidance pushing users toward these APIs (extension of MSTEST0037), see #8338.
Activity
Haplois commentedon Oct 1, 2021
Hi, thanks for the proposal.
If you're up for it, we are open for community PR's.
daniel-lerch commentedon Nov 18, 2021
Because of some difficulties described in #990, I will not continue to work on this issue and migrate my unit tests to Xunit instead.
10 remaining items
RioMcBoo commentedon Apr 30, 2026
Hi, how can i see the code and do changes? I created fork, but it is only headers inside =(
What the problem with Indentation? I wanted to help
nohwnd commentedon May 4, 2026
RioMcBoo which file are you looking at where there are only headers?
RioMcBoo commentedon May 5, 2026
https://github.com/microsoft/testfx/blob/main/src/TestFramework/TestFramework/Assertions/CollectionAssert.Equality.cs - this one
The methods nested in head methods highlighted by white color and any attempts to open them to look inside follows with "you can not move caret to it" or something like this
nohwnd commentedon May 5, 2026
In those files I see regions.
Once expanded the code is there, and in the code I can navigate to other parts of the class with ctrl+click.
I see no issue on my side.
Please record a gif / video (e.g. via snipping tool that is built-in in Windows) if this did not help, because I don't know what else to look for :)
Those regions look useless now that the classes are split, do you still find them useful Amaury Levé (@Evangelink)? (I have VS set to always expand regions so I don't care either way).
RioMcBoo commentedon May 5, 2026
ok, this is something wrong with the project (i've never seen that architecture). Depends on which project me opening i get or errors or unreachable code.
When i did my dll on C# i knew what i should open and run to test my code. I had my own project and couple others with tests. But i cannot find even "the" project =(
It looks like i am newbie in it
nohwnd commentedon May 5, 2026
try closing the solution, and delete all bin and obj folders. Or open cmdline in the folder where you have solution, and do
dotnet clean, followed bydotnet build.That should show all errors that you have there, if any. This looks like broken cache to me. VS should recover.
RioMcBoo commentedon May 5, 2026
I guess I just don't know how to use projects like this. I don't know what to open. There are dozens of projects here. And they're all unhappy with something.
RioMcBoo commentedon May 5, 2026
I'm currently working on my own collection and wanted to write tests for it. I was extremely surprised that this tool doesn't implement modern interfaces.
However, I also encountered an issue with element identification. So, I was interested in the outcome of the issue mentioned in the pull request.
The gist of it was that in binary lists, sort-equality doesn't always equal equal-equality. This requires a strict implementation of the Iquatable and IComparable interfaces so that they determine element equality in the same way. Otherwise, this leads to collisions and requires O(MxN) checks within the collision.
Maybe this will help with the issue. I no longer have any desire to delve into the project.
Evangelink commentedon May 20, 2026
Closing as superseded — the modern
Assert.*family added in 4.x already acceptsIEnumerable<T>(which is strictly broader thanIReadOnlyCollection<T>andICollection<T>), so no extraCollectionAssertoverloads are needed. The recommended replacements are all onAssertitself:CollectionAssert.*Assert.*replacement (takesIEnumerable<T>)AreEqual(ordered)Assert.AreSequenceEqual<T>(expected, actual)(#8334)AreNotEqual(ordered)Assert.AreNotSequenceEqual<T>(notExpected, actual)(#8334)AreEqual(any order)Assert.AreSequenceEqual<T>(expected, actual, SequenceOrder.InAnyOrder)(#8334)AreEquivalent/ structuralAssert.AreEquivalent<T>/AreNotEquivalent<T>(#8266)ContainsAssert.Contains<T>(item, collection)(#8265)DoesNotContainAssert.DoesNotContain<T>(item, collection)(#8265)AllItemsAreNotNullAssert.AreAllNotNull<T>(collection)(#8237)AllItemsAreUniqueAssert.AreAllDistinct<T>(collection)(#8237)AllItemsAreInstancesOfTypeAssert.AreAllOfType<T>(collection)(#8237)IsSubsetOfAssert.ContainsAll<T>(expected, collection)(#8234)IsNotSubsetOfAssert.DoesNotContainAll<T>(expected, collection)(#8234)Assert.HasCount<T>(n, collection)/IsEmpty/IsNotEmpty(#8262)All overloads use RFC 012 structured failure messages and apply to any
IReadOnlyCollection<T>, custom enumerable, or LINQ query without needing.ToList()/ casts.For the umbrella analyzer guidance pushing users toward these APIs (extension of MSTEST0037), see #8338.
cremor commentedon May 21, 2026
Just to be clear: Those new overloads are not yet released, correct? So the "x" in "4.x" stands for some future version, e.g. maybe 4.3?
Evangelink commentedon May 21, 2026
Yes it will be shipped in 4.3 but I don't have ETA yet.