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

Internal NuGet dependency #6

Open
magol opened this issue May 30, 2021 · 4 comments
Open

Internal NuGet dependency #6

magol opened this issue May 30, 2021 · 4 comments

Comments

@magol
Copy link

magol commented May 30, 2021

Can you please update the code to show how do if the generator is dependent on a NuGet package. I think it is a common scenario.

I have try to use you template to write a generator that is generating code based on a json file using System.Text.Json, but I cannot make it to work.
And how do I add the json file to the tests that you have in the template?

@davidwengier
Copy link
Owner

I can try to take a look, sure.

Did you see the guidance on NuGet dependencies in the cookbook? https://github.com/dotnet/roslyn/blob/main/docs/features/source-generators.cookbook.md#use-functionality-from-nuget-packages

Also since this project was created, there is now testing support for generators via roslyn-sdk which might be easier to use for some scenarios. A good repo example for that would be https://github.com/jmarolf/generator-start

@magol
Copy link
Author

magol commented May 31, 2021

Thanks for your reply.
Yes, I have seen the cookbook, but I still do not get it to work. The cookbook, and many other pages, are focused on creating a NuGet package of the generator. But I'm interested in that, I just want to use it to generate code in another project in the same solution.

I had not seen generator-start before, so it was interesting to review that code. But as soon as I added a dependency to System.Text.Json to that generator, I got the same problem as in my project. So it's obviously something I'm doing wrong.

@Youssef1313
Copy link
Contributor

There is some discussion about that in dotnet/docs#28054.

@tom-englert
Copy link

Here is a sample project that covers the case with NuGet dependencies:
https://github.com/tom-englert/LogMessageGenerator/

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

4 participants