Skip to content

Update project templates to work with safe characters#2368

Merged
Eilon merged 9 commits intomainfrom
eilon/fix-template-safe-names
Sep 3, 2021
Merged

Update project templates to work with safe characters#2368
Eilon merged 9 commits intomainfrom
eilon/fix-template-safe-names

Conversation

@Eilon
Copy link
Contributor

@Eilon Eilon commented Sep 2, 2021

Fixes #2176

To learn more about the seemingly-odd MauiApp.1 and MauiApp._1 stuff you'll now see, read here: https://github.com/dotnet/templating/wiki/Naming-and-default-value-forms

TL;DR: The template engine is clever enough to understand different substitution patterns (rather than just blanket search & replace), so if you follow certain conventions, the template engine will use the correct substitution you need for cases where there are restricted character sets, such as C# namespaces and class names.

@vlada-shubina - I've also tagged you here as a reviewer because it seems like you're the expert on this. Thank you in advance if you're able to review this!

Copy link
Member

@jonathanpeppers jonathanpeppers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now when I use this template in VS 2022, it does:

image

Is that going to have a .1 in the name now? So the picture would show MauiApp.4?

@Eilon
Copy link
Contributor Author

Eilon commented Sep 2, 2021

I'd also like to note: While this change moves away from the concept of "Runnable templates" because it's now using default names that are invalid (e.g. MauiApp.1), these templates were never actually runnable anyway due to all kinds of references and versions and various things that weren't set by default.

@Eilon
Copy link
Contributor Author

Eilon commented Sep 2, 2021

@jonathanpeppers good question and I think the answer is that it's unchanged from before because we still set "defaultName": "MauiApp1" in the template.json files (you can't see them by default in this PR because I didn't change them, but you can "expand" the diff to see it).

@Eilon
Copy link
Contributor Author

Eilon commented Sep 2, 2021

Also, I tested locally with a silly name in the form of Biz Box-123 to get both spaces and invalid characters, and it all worked fine (as best I could tell!).

@Eilon
Copy link
Contributor Author

Eilon commented Sep 2, 2021

And... I also meant to update the template test to use a silly name, so I'll get that figured out and push an update in a few moments.

Copy link
Member

@jonathanpeppers jonathanpeppers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, one thing that would be great is to put a weird character in the name here:

StartProcess(dn, $"new {template} -o ./templatesTest/{name}");

Then we'd have CI verifying this keeps working.

@Eilon
Copy link
Contributor Author

Eilon commented Sep 2, 2021

Yup, that's what I will do, once I can get it to run locally (it seems I always have something out of date!).

@Eilon
Copy link
Contributor Author

Eilon commented Sep 2, 2021

Looks like there was a bug in cake 1.0.0 where binlogs with spaces in them weren't escaped (cake-build/cake#2559), but that's been fixed. I've updated to Cake 1.2.0... let's see how that goes...!

@Pakon2543

This comment has been minimized.

@Eilon Eilon mentioned this pull request Sep 2, 2021
@Eilon
Copy link
Contributor Author

Eilon commented Sep 2, 2021

And of course it turns out we don't have Cake 1.2.0 on our internal feeds, so I've reverted to Cake 1.0.0 and manually quoted all binlog names. I logged #2372 to update Cake and revert my binlog quote fix.

@Pakon2543

This comment has been minimized.

@Eilon
Copy link
Contributor Author

Eilon commented Sep 2, 2021

Hi @Pakon2543 , can we help you with something? I'm not sure I understand the various comments/reviews you've put on several MAUI items...

Copy link
Member

@vlada-shubina vlada-shubina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, thank you!

Eilon and others added 2 commits September 3, 2021 09:06
Co-authored-by: Jonathan Dick <jodick@microsoft.com>
Co-authored-by: Jonathan Dick <jodick@microsoft.com>
@Eilon
Copy link
Contributor Author

Eilon commented Sep 3, 2021

@Redth the CI looks happy now, just need an approval.

@vlada-shubina thank you for the review!

rookiejava added a commit to rookiejava/maui that referenced this pull request Feb 25, 2022
- Update project templates to work with safe characters (dotnet#2368)
rookiejava added a commit to rookiejava/maui that referenced this pull request Feb 28, 2022
- Update project templates to work with safe characters (dotnet#2368)
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 2, 2022
- Update project templates to work with safe characters (dotnet#2368)
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 2, 2022
- Update project templates to work with safe characters (dotnet#2368)
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 3, 2022
- Update project templates to work with safe characters (dotnet#2368)
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 4, 2022
- Update project templates to work with safe characters (dotnet#2368)
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 7, 2022
- Update project templates to work with safe characters (dotnet#2368)
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 8, 2022
- Update project templates to work with safe characters (dotnet#2368)
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 8, 2022
- Update project templates to work with safe characters (dotnet#2368)
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 9, 2022
- Update project templates to work with safe characters (dotnet#2368)
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 10, 2022
- Update project templates to work with safe characters (dotnet#2368)
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 10, 2022
- Update project templates to work with safe characters (dotnet#2368)
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 10, 2022
- Update project templates to work with safe characters (dotnet#2368)
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 10, 2022
- Update project templates to work with safe characters (dotnet#2368)
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 11, 2022
- Update project templates to work with safe characters (dotnet#2368)
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 14, 2022
- Update project templates to work with safe characters (dotnet#2368)
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 14, 2022
- Update project templates to work with safe characters (dotnet#2368)
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 15, 2022
- Update project templates to work with safe characters (dotnet#2368)
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 16, 2022
- Update project templates to work with safe characters (dotnet#2368)
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 18, 2022
- Update project templates to work with safe characters (dotnet#2368)
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 21, 2022
- Update project templates to work with safe characters (dotnet#2368)
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 22, 2022
- Update project templates to work with safe characters (dotnet#2368)
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 22, 2022
- Update project templates to work with safe characters (dotnet#2368)
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 22, 2022
- Update project templates to work with safe characters (dotnet#2368)
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 23, 2022
- Update project templates to work with safe characters (dotnet#2368)
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 24, 2022
- Update project templates to work with safe characters (dotnet#2368)
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 25, 2022
- Update project templates to work with safe characters (dotnet#2368)
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 28, 2022
- Update project templates to work with safe characters (dotnet#2368)
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 28, 2022
- Update project templates to work with safe characters (dotnet#2368)
rookiejava added a commit to rookiejava/maui that referenced this pull request Mar 31, 2022
- Update project templates to work with safe characters (dotnet#2368)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-templates Project templates, Item Templates for Blazor and MAUI fixed-in-6.0.101-preview.10 Look for this fix in 6.0.101-preview.10!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Source name in templates should be safe for default form replacements

6 participants