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

Add rendered C# templates to compilation source when using NTypewriter.SourceGenerator #75

Merged
merged 2 commits into from
Apr 26, 2023

Conversation

amdavie
Copy link
Contributor

@amdavie amdavie commented Apr 25, 2023

Regarding #74

This small change adds rendered templates to the compilation source (instead of file system) if the render path has a .cs extension and is within the project directory (that the source generator is running for). For all other templates, the rendering behavior remains the same. This still allows a project to generate .cs files to the file system if they are not within the project.

A limitation is that filenames must be unique for rendered .cs templates because the source generator needs a unique name. This is unlikely to be an issue for most people.

Usage:
{{ Save output "PartialClass.g.cs" }} - adds the rendered template to compilation source

{{ Save output "../Path/Outside/Project/SomethingElse.g.cs" }} - renders template to file system (existing behavior) because resulting path is not within the project where source generator is running

@NeVeSpl NeVeSpl merged commit b2f43fc into NeVeSpl:master Apr 26, 2023
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

Successfully merging this pull request may close these issues.

2 participants