Feature: Support format parameters with string interpolation
Describe the feature
Just a small quality of life improvement.
Steps to reproduce
Having this ValueObject
[ValueObject<DateTime>]
public partial struct MyDate;
When used with string interpolation the ToString Method of MyDate doesn't accept the string format parameter and so the format isn't applied
var date = MyDate.From(DateTime.Now);
string text = $"This doesn't work: {date:o}";
Workaround
Casting the ValueObject to it's primitive type can be used as workaround. But is very error prone, as there is no error thrown in the frist example:
var date = MyDate.From(DateTime.Now);
string text = $"This does work: {(DateTime)date:o}";
Work needed
So I guess this feature request is about forwarding the parameters of ToString to the primitive type correctly.
DateTime has 4 sets of parameters for ToString
The source gen would need to lookup the ToString variants and generate wrappers.
Hi, thanks for the feedback. It should hoist ToString overloads from the primitive that it wraps. I'll check the config required and let you know
Actually, it's string comparison that is hoisted.
I think this would make an excellent addition, thanks again for the feedback!
@Khaos66 - this has now been released in 5.0.5-beta.2 Thanks for the feedback!