Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A way to cut off shape generation at certain points #85

Open
AArnott opened this issue Dec 14, 2024 · 4 comments
Open

A way to cut off shape generation at certain points #85

AArnott opened this issue Dec 14, 2024 · 4 comments

Comments

@AArnott
Copy link
Contributor

AArnott commented Dec 14, 2024

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?

@eiriktsarpalis
Copy link
Owner

Does using PropertyShapeAttribute.Ignore prevent generation of the nested type?

@AArnott
Copy link
Contributor Author

AArnott commented Dec 14, 2024

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.

@eiriktsarpalis
Copy link
Owner

On the type with the custom converter itself, you could try applying the new TypeShapeAttribute with TypeShapeKind set to None.

@AArnott
Copy link
Contributor Author

AArnott commented Dec 15, 2024

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants