Open AArnott opened 2 days ago
This is closely related to https://github.com/eiriktsarpalis/PolyType/issues/47. The current generation strategy augments witness types with a full-blown implementation of the underlying ITypeShapeProvider
. We could try changing this so that witnesses only receive explicit interface implementations that are stubs pointing to a compilation-wide provider.
One open question is how we source generate for netstandard2.0, assuming we do add support for that target in the future. With IShapeable<T>
and static abstracts not being available, the source generator would need to generate something else in its place.
We could try changing this so that witnesses only receive explicit interface implementations that are stubs pointing to a compilation-wide provider.
True. I don't mind knocking out two bugs at once. But if the other one is far more expensive to fix, you could always just emit a private nested class and make that one instantiable instead of the one that has the attribute on it.
I'll start thinking about the netstandard2.0 problem...
And at the very least, can these members be emitted as internal
rather than subtly contributing public API to the library? The static shapeable method should still be able to access them, right?
Again, this is just emulating the generation strategy used by JsonSerializerContext
. The public properties provide a strongly typed ITypeShape<T>
instance in a way that predates the introduction of IShapeable<T>
. It may or may not be necessary to keep for netstandard2.0 depending on what pattern we decide to use there.
I have a type that starts with this:
The mere presence of the
[GenerateShape<string>]
attribute causes this to be source generated:I already define a (private) default constructor, and I don't want a
public static Default
member either. Why isMemoFormatter
having its API added to in this way?