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 want to write another source generator while following along this guide :) And since I have wanted to replace our reflection-based NewType converter with a source-generated one I thought a general new type generator would be fun.
What features should it have?
Off the top of my head:
generate a JSON converter (and point to it via the [JsonConverter] attribute)
replace the record's ToString() implementation with a more tuple-like representation
so instead of DisplayName { Value = test } we should get DisplayName(test).
delegate comparable operators <=, >=, > and <.
delegate interface implementations? this one seems like a lot of hassle (especially for things like IComparable where other is an object that we need to "unpack" the value first before delegating).
Maybe we start with a list of known interfaces (e.g. IComparable<T>, IComparable) first.
I think it's also OK to restrict the source generator to sealed class record / record structs with primary constructors for now.
The text was updated successfully, but these errors were encountered:
I want to write another source generator while following along this guide :) And since I have wanted to replace our reflection-based NewType converter with a source-generated one I thought a general new type generator would be fun.
What features should it have?
Off the top of my head:
[JsonConverter]
attribute)ToString()
implementation with a more tuple-like representationso instead of
DisplayName { Value = test }
we should getDisplayName(test)
.<=
,>=
,>
and<
.IComparable
whereother
is an object that we need to "unpack" the value first before delegating).Maybe we start with a list of known interfaces (e.g.
IComparable<T>
,IComparable
) first.I think it's also OK to restrict the source generator to
sealed class record
/record struct
s with primary constructors for now.The text was updated successfully, but these errors were encountered: