-
Notifications
You must be signed in to change notification settings - Fork 24
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Save function is misleading #105
Comments
I have created a fork in hope to get the requires changes done. But it seems a split is only possible with heavy refactoring or introducing new APIs / deprecating old ones. My approach would be to deprecate certain APIs and introduce more flexible ones. I think the steps would be
What do you think? |
I would prefer to add a flag |
Hi there,
first things first, this project is fantastic. It is sooo much easier to use than writing your own source generator with all the tweaks needed to get it right. 馃憣
So, back to the actual issue I think is worth addressing. When I saw the save function showcased in some samples I thought, oh, really nice, now I don't need to emit, copy / move things around in csproj to get the generated files in the project. I took it to a test and generated some TypeScript code quick and efficently into the project. After a while I came back to generate some C# code in another project and all of a sudden no file was saved anymore. Same setup, almost same template code, except it was C# code. After almost giving up on it I decided to look at the source code and there I found a little detail that makes the Save function a "add source to compilation" function. So, you need to use a different extension to save C# code to a file. Bummer.
My current setup looks like this:
Foobar.cs.nt
Example.csproj
Another option is to use EmitCompilerGeneratedFiles, but this can result in "path to long" issues and csproj configuration is also more complex.
How can we get rid of the second temporary save? I think something like adding a new function
AddSource
that does the same checks likeSave
will do and bring some clarity. Then I would need to calland since Save would then actually write a file I can remove all that csproj magic from the project.
What do you think?
The text was updated successfully, but these errors were encountered: