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

Default namespace for item templates #154

Merged

Conversation

Mrxx99
Copy link
Contributor

@Mrxx99 Mrxx99 commented Jan 6, 2023

This infers the root namespace of the project (by default the name of the project) an item template is added to and uses this for the item template when no one is specified with the --namespace flag. It also does not give an error if the item template is created outside of a project.

This sadly only works for C#.

Maybe in future this could be improved to include also the folder structure, e.g "AvaloniaApplication.Views" but that would require changes in the template SDK.

@grokys grokys requested a review from Takoooooo January 10, 2023 11:14
@Takoooooo
Copy link
Contributor

LGTM,thanks for doing that!
But may you share the documentation you were using to implement that just to make sure we will have resources to maintain that later

@Takoooooo Takoooooo merged commit fada2e5 into AvaloniaUI:master Jan 10, 2023
@Mrxx99
Copy link
Contributor Author

Mrxx99 commented Jan 10, 2023

@Takoooooo Here is the documentation:

https://github.com/dotnet/templating/wiki/Binding-and-project-context-evaluation

Here there is also binding to a namespace for VS mentioned but I did not use that because a) VS does not support item templates yet and b) it does not work for CLI, so I would have to add another fallback block besides another parameter which would bloat the template.json (more than half of the file would be about namespaces :D). I hope in future the bind:namespace can be used from CLI as well respecting also the folder path in the project

@Mrxx99 Mrxx99 deleted the feature/item-template-root-namespace branch January 11, 2023 18:50
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