Skip to content

Conversation

Evangelink
Copy link
Member

This moves will allows to introduce the following fluent Assert.That(x).IsYYY pattern

Youssef1313
Youssef1313 previously approved these changes Jun 18, 2025
@Youssef1313 Youssef1313 enabled auto-merge (squash) June 18, 2025 08:18
# Conflicts:
#	src/TestFramework/TestFramework/PublicAPI/PublicAPI.Unshipped.txt
@Youssef1313 Youssef1313 merged commit 0d6c7ff into microsoft:main Jun 18, 2025
8 checks passed
@cagrin
Copy link

cagrin commented Aug 3, 2025

I'm not happy with that change. You can already do Assert.That.IsSomething(x, ...) using an extension method on this Assert. To me, it's not a significant improvement — especially when compared to Shouldly.

@Evangelink
Copy link
Member Author

@cagrin your syntax is a little bit different Assert.That.Contains(x, collection) which is equivalent to Assert.Contains(x, collection) vs Assert.That(collection).Contains(x). Moreoever, we have implemented Assert.That(expression) feature in #5991. We have been thinking about a couple of alternatives for the name but this one felt the more natural.

Looking up to GitHub repos using MSTest That, we saw only handful usage so it felt like it would not be too painful to update`.

How many instances does this change impact on your codebase?

@Evangelink Evangelink deleted the dev/amauryleve/assert-that-instance branch August 4, 2025 04:49
@cagrin
Copy link

cagrin commented Aug 4, 2025

Yes, I agree, the name That will be best for this type of assertion extension. I'm waiting for new methods. I'll try to adapt my extensions to the new Instance name or find another convinient way.

@mdrexel
Copy link

mdrexel commented Aug 6, 2025

Hello, I saw that 3.10.1 had released and went to check the changelog, and I just wanted to chime in that deprecating the .That extension point is very painful... we have tens of thousands of usages via an internal helper library 😢
Screenshot 2025-08-06 143459

@orbitalbits
Copy link

Seconding what @mdrexel just wrote here. We have tens of thousands of uses of the .That extension point. Deprecating this extension is going to incur a very significant negative impact on us. Please reconsider this change.

@Youssef1313
Copy link
Member

Youssef1313 commented Aug 7, 2025

Thanks for the feedback @cagrin, @mdrexel, and @orbitalbits. I reverted for now in #6323, and will be experimenting with having both the Assert.That property and Assert.That(() => ...) methods working using extension members coming in C# 14.

@orbitalbits
Copy link

@Youssef1313 thank you, we appreciate it.

@Evangelink
Copy link
Member Author

Great call @Youssef1313 and thanks everyone for the feedback! If extension methods aren't working we can go back to a different naming like Assert.Subject, Assert.ThatSubject, Assert.Expression ...

@Youssef1313
Copy link
Member

Youssef1313 commented Aug 11, 2025

Great call @Youssef1313 and thanks everyone for the feedback! If extension methods aren't working we can go back to a different naming like Assert.Subject, Assert.ThatSubject, Assert.Expression ...

Either a different name, or with "extension members" (C# 14). Hopefully, VB/F# might follow-up and support it as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants