TUnit icon indicating copy to clipboard operation
TUnit copied to clipboard

Move assertion extensions to properties with C#13 type extensions

Open thomhurst opened this issue 1 year ago • 3 comments

thomhurst avatar Jul 03 '24 11:07 thomhurst

Example: DateTimeExtensions.cs

For DateTime =>

public static extension DateTime
{
    private static readonly string? DateFormat = "yyyy/MM/dd";
    private static readonly string? LongTimeFormatWithMilliseconds = "hh:mm:ss.ffff tt";
    private static readonly string? LongDateTimeFormatWithMilliseconds = $"{DateFormat} {LongTimeFormatWithMilliseconds}";

    public string ToLongStringWithMilliseconds => this.ToString(LongDateTimeFormatWithMilliseconds);
}

Is this the pattern you are looking for @thomhurst ?

SaileshBK avatar Sep 21 '24 16:09 SaileshBK

@SaileshBK Yeah that's along the lines of what I wanted to trial, but I heard it got delayed and isn't going to make it into C#13

thomhurst avatar Sep 21 '24 16:09 thomhurst

I will keep an eye on the feature itself, I am really excited about the C# 13 Type extensions as well. How about I work on this and slowly start migrating all the assertion extensions and make PR for it @thomhurst :)?

SaileshBK avatar Sep 21 '24 16:09 SaileshBK