-
Notifications
You must be signed in to change notification settings - Fork 14
Description
I had a discussion way earlier, where someone stated, that one source generator cannot see the content of another's source generator. I think that's here the case.
Is there even a way to detect that? If so it would make sense to skip/exclude those attribute-annotations whose origin is "source generator". I mean if you can see that attribute usage and PolyType is able to track it, maybe it also can check the attributes of the attribute, and check for EmbeddedAttribute? Would it feasable to assume that every Attribute annotated by EmbeddedAttribute is considerable to be skipped/excluded?
I just thought I create an issue. Maybe this is a resolvable problem? But maybe this is rather out of scope.
Edit: I investigated the problem. I was partially wrong. It seems, that usages (e.g. attributes) of generated code is correctly introspected by PolyType.
To elaborate the problem: I have the following project structure:
project A <--referencing-- project B <--referencing-- project C
Project A has installed PolyType.
Project B AND project C has installed another source generator with PrivateAssets="all" that generates public attributes annotated with EmbeddedAttribute.
- project A uses GenerateShape on a type it owns.
- PolyType then generates for each reachable type a TypeShape, also when reachable types are outside of project A.
- PolyType may then face attributes whose origin is "source generator" and those are annotated by EmbeddedAttribute.
Because project A has not installed the "another source generator", the generated code of PolyType states that the attribute in question is not resolvable due to ambiguity since the it is present (public visibility) in project B and project C.
The solution is either:
- to also install the "another source generator" in project A. Then Roslyn's EmbeddedAttribute functionality kicks in, and PolyType now correctly resolves to the attribute in question generated by project A or
- remove PrivateAsset="all" of "another source generator" in either project B or project C to let the source generator flow upwards.
Note: Not sure why PrivateAssets="all" in project B does not keep project C without PrivateAsset=all from flowing upwards to project A.
I think you can close the issue. But yay, PolyType just works with attribute annotations whose attributes are coming from source generators.