This is definitely an approach I hadn't thought of. I like the interface jazz. So you are thinking of using it with the attribute? I'd think you'd use one or the other?
Comments
Log in with your Bluesky account to leave a comment
The attribute is a marker indicating which class realize the interface. to give the developer the option to opt in. And then somehow why factory class is aware of all those types at compile time. But as @flash0ver.bsky.social mentioned works just in certain cases. Analyzer+codefix compliments it.
I know what you mean and could see your point! Still, I couldn’t tell that all source generator scenarios need an analyzer or code fix provider. But definitely if they do, it’d be better off to be in same project.
I seem to never be too sure whether to ship a "ForAttributeWithMetadataName"-Generator with a Diagnostic+CodeFixer when the annotated type is not modified with `partial`, or to just generate the partial declaration anyway and let tooling offer the Refactoring to make to type partial via error CS0260
So funny you bring this up. I struggled with the same thought last night. To partial or not to partial.
I could generate it for you, but how do I know you want me to? I guess the existence of the attribute means you want to opt in and I should likely just make it partial for you ...
Comments
I have had success with it.
I can't imagine shipping source gen without some analysis for the edge cases. I learned this the hard way.
I could generate it for you, but how do I know you want me to? I guess the existence of the attribute means you want to opt in and I should likely just make it partial for you ...