Skip to content
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

Introduce interpolated string handler overloads for assertions #4476

Open
wants to merge 46 commits into
base: main
Choose a base branch
from

Conversation

Youssef1313
Copy link
Member

@Youssef1313 Youssef1313 commented Dec 30, 2024

Fixes #4273

@Youssef1313 Youssef1313 marked this pull request as ready for review December 30, 2024 18:02
@Youssef1313 Youssef1313 requested a review from Copilot December 30, 2024 18:03
Copy link
Member

@Evangelink Evangelink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please apply the various suggestions on AreEqual globally?

@Youssef1313 Youssef1313 requested a review from Evangelink January 2, 2025 09:10
@Youssef1313
Copy link
Member Author

Thanks for the review @Evangelink. Those comments were really very helpful and revealed some important issues.


public void AppendLiteral(string value) => _builder!.Append(value);

public void AppendFormatted<T>(T value) => AppendFormatted(value, format: null);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should be adding AppendFormatted(string?) overload. This should be resolved before merging.

Copy link
Member

@Evangelink Evangelink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work. I didn't review every single test added but I assume you have used the same pattern everywhere so LGTM

@@ -80,6 +432,12 @@ public static void AreEqual<T>(T? expected, T? actual, IEqualityComparer<T>? com
public static void AreEqual<T>(T? expected, T? actual, string? message)
=> AreEqual(expected, actual, null, message, null);

/// <inheritdoc cref="AreEqual{T}(IEquatable{T}?, IEquatable{T}?, string?)" />
#pragma warning disable IDE0060 // Remove unused parameter - https://github.com/dotnet/roslyn/issues/76578
public static void AreEqual<T>(T? expected, T? actual, [InterpolatedStringHandlerArgument(nameof(expected), nameof(actual))] ref AssertAreEqualInterpolatedStringHandler<T> message)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if runtime calls this parameter message, I would prefer handler or builder like in the example.

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

Successfully merging this pull request may close these issues.

Add interpolated string handler overloads for Assert methods
2 participants