Open 0xced opened 1 year ago
In case you generate attributes as public
in lib A and have reference to them in another lib B (or generate as internal
and use reflection).
With this attribute lib A will always have definition of IsExternalInitAttribute
(real or forwarded). Without it, there is a possibility of TypeLoadException
in some edge cases if A and B are updated separately, but I wold say in any sane deploy scheme this should not be a problem. Or maybe I missing something obvious.
Like if you publish lib A ver 1, but in ver 2 change PolySharp settings, so this type is no longer generated.
Lib B is transitive dep of app have dependency on A.v1, and app have direct dep on lib A.v2 -- assembly redirection would kick in and choose A.v2 and lib B will throw TypeLoadException
.
Find a document about the type forwarding, hope it helps https://learn.microsoft.com/en-us/dotnet/standard/assembly/type-forwarding
In #86 you said
Could you please elaborate a little bit more on this? What exact problem does it solve to add
TypeForwardedTo
attributes in target frameworks where the type exists?For example, when multi-targeting
net7.0;net6.0;netstandard2.0
the source generator produces this for .NET 6 and .NET 7 targets:If I add
<PolySharpExcludeTypeForwardedToDeclarations>true</PolySharpExcludeTypeForwardedToDeclarations>
they are not generated and everything seems to work fine. Am I missing something?