Okno
Compilation issue with source generator
Hello there, I am building a mapper source generator to learn Csharp. I am now testing it in a real project.
Unfortunately using it as a dependency seems to trigger the following compilation error:
I have looked up this error code but I am really unsure what could be done to diagnose this.
For reference the source generator repo is here: https://github.com/oknozor/CartographeAutomatique/tree/main
Any advice on how to troubleshot this would be appreciated.
27 replies
Source generator unable to resolve external type
I am writing a source generator to learn csharp and I stubbled into something strange.
Here is the
IncrementalValueProvider
in my source generator:
It generate mapping code for a class A to a class B and is used like so:
Everything work as expected as long as the attribute parameter (here
typeof(Point3))) is accessible in the current package.
If the typeof attribute parameter lives in an external package the
PopulateTyypeMapping method is never called by the
IncrementalValueProvider`. I think I understand that the compiler is unable to resolve the class so it skip the attribute, but it's very puzzling that there is no error message or warning emitted at compile time.
Am I missing something or is there a way to make this work without changing the attribute parameter to something else ?24 replies