A way to cut off shape generation at certain points
Opened this issue · 4 comments
I was reviewing the generated code from [GenerateShape]
, and found several classes to support types that don't get automatically serialized. I believe it's because certain properties are typed with types that I don't expect to be automatically serializable (at least not in an optimal representation) so I have custom converters for them. But the type shape remains in the generated form, needlessly bloating the software. (Will unused type shapes be trimmed?)
I wonder if we should have an attribute that I can apply to types or properties that reference those types to hint to the source generation system that it should not follow this type reference path any further.
Thoughts?
Does using PropertyShapeAttribute.Ignore prevent generation of the nested type?
Yes, that works. Though that also removes the property from its declaring type's shape, so it won't be serialized even by my custom converter.
On the type with the custom converter itself, you could try applying the new TypeShapeAttribute with TypeShapeKind set to None.
In my cases, I don't declare the type that I don't want the shape for. (e.g. Stream, cryptography keys, etc.)
This isn't a blocking issue, so feel free to Won't Fix. It's more an observation about some downside, but the 'fix' may be worse...