Test templates fixes#4043
Conversation
|
I tried: diff --git a/src/Aspire.ProjectTemplates/templates/aspire-starter/AspireStarterApplication.1.Tests/WebTests.cs b/src/Aspire.ProjectTemplates/templates/aspire-starter/AspireStarterApplication.1.Tests/WebTests.cs
index a0a114dde..bf183ff63 100644
--- a/src/Aspire.ProjectTemplates/templates/aspire-starter/AspireStarterApplication.1.Tests/WebTests.cs
+++ b/src/Aspire.ProjectTemplates/templates/aspire-starter/AspireStarterApplication.1.Tests/WebTests.cs
@@ -17,7 +17,7 @@ public class WebTests
public async Task GetWebResourceRootReturnsOkStatusCode()
{
// Arrange
- var appHost = await DistributedApplicationTestingBuilder.CreateAsync<Projects.AspireStarterApplication._1_AppHost>();
+ var appHost = await DistributedApplicationTestingBuilder.CreateAsync<Projects.AspireStarterApplication__1_AppHost>();
await using var app = await appHost.BuildAsync();
await app.StartAsync();.. essentially use to the .. which fixes #4025 . For #4024, the targets need to be updated to handle the case of But there is yet another case, .. and the relevant lines: <ProjectReference Include="../aspire 龦唉丂荳◎℉㐁&ᠭᠤ སྲིད خەل ꌠ ᥕ᧞.ApiService/aspire 龦唉丂荳◎℉㐁&ᠭᠤ སྲིད خەل ꌠ ᥕ᧞.ApiService.csproj" />
<ProjectReference Include="../aspire 龦唉丂荳◎℉㐁&ᠭᠤ སྲིད خەل ꌠ ᥕ᧞.Web/aspire 龦唉丂荳◎℉㐁&ᠭᠤ སྲིད خەل ꌠ ᥕ᧞.Web.csproj" />.. |
|
Hmm so the template engine's default form transform doesn't auto-XML-encode in .csproj files? Wouldn't all other templates that have project references based on the name have the same issue too then? |
Yeah. I can't even create a @joeloff is there an existing way to get a xml-encoded transformation of the string in the template? If I remove the And this is because the code we generate is: public class aspire_ UNs% !94-$_frQ_.D_ _U_AppHost
{
private aspire_ UNs% !94-$_frQ_.D_ _U_AppHost() { }
public static string ProjectPath => """/private/tmp/test/aspire UNs% !94-$ frQ .D U/aspire UNs% !94-$ frQ .D U.AppHost""";
}.. and this is what the template engine used: var apiService = builder.AddProject<Projects.aspire_龦唉丂荳___㐁ᠭᠤ_སྲིད_خەل_ꌠ_ᥕ__ApiService>("apiservice"); |
|
In my source, the value {
...
"symbols": {
"example": {
"type": "parameter",
"dataType": "string",
"replaces": "\"Hi there\"",
"forms": {
"global": [ "encode" ]
}
}
},
"forms": {
"encode": {
"identifier": "xmlEncode"
}
}
} |
diff --git a/src/Aspire.ProjectTemplates/templates/aspire-starter/.template.config/template.json b/src/Aspire.ProjectTemplates/templates/aspire-starter/.template.config/template.json
index 652ddb0dd..67d70c756 100644
--- a/src/Aspire.ProjectTemplates/templates/aspire-starter/.template.config/template.json
+++ b/src/Aspire.ProjectTemplates/templates/aspire-starter/.template.config/template.json
@@ -344,6 +344,13 @@
"datatype": "bool",
"defaultValue": "false",
"description": "Whether to turn off HTTPS."
+ },
+ "XmlEncodedProjectName": {
+ "type": "derived",
+ "datatype": "string",
+ "replaces": "XmlEncodedProjectName",
+ "valueSource": "name",
+ "valueTransform": "xmlEncode"
}
},
"primaryOutputs": [
diff --git a/src/Aspire.ProjectTemplates/templates/aspire-starter/AspireStarterApplication.1.ApiService/AspireStarterApplication.1.ApiService.csproj b/src/Aspire.ProjectTemplates/templates/aspire-starter/AspireS>
index f7812db4b..3b56d6e4b 100644
--- a/src/Aspire.ProjectTemplates/templates/aspire-starter/AspireStarterApplication.1.ApiService/AspireStarterApplication.1.ApiService.csproj
+++ b/src/Aspire.ProjectTemplates/templates/aspire-starter/AspireStarterApplication.1.ApiService/AspireStarterApplication.1.ApiService.csproj
@@ -7,7 +7,7 @@
</PropertyGroup>
<ItemGroup>
- <ProjectReference Include="..\AspireStarterApplication.1.ServiceDefaults\AspireStarterApplication.1.ServiceDefaults.csproj" />
+ <ProjectReference Include="..\XmlEncodedProjectName.ServiceDefaults\XmlEncodedProjectName.ServiceDefaults.csproj" />
</ItemGroup>
</Project>
diff --git a/src/Aspire.ProjectTemplates/templates/aspire-starter/AspireStarterApplication.1.AppHost/AspireStarterApplication.1.AppHost.csproj b/src/Aspire.ProjectTemplates/templates/aspire-starter/AspireStarter>
index 4652b02ef..40434d256 100644
--- a/src/Aspire.ProjectTemplates/templates/aspire-starter/AspireStarterApplication.1.AppHost/AspireStarterApplication.1.AppHost.csproj
+++ b/src/Aspire.ProjectTemplates/templates/aspire-starter/AspireStarterApplication.1.AppHost/AspireStarterApplication.1.AppHost.csproj
@@ -10,8 +10,8 @@
</PropertyGroup>
<ItemGroup>
- <ProjectReference Include="..\AspireStarterApplication.1.ApiService\AspireStarterApplication.1.ApiService.csproj" />
- <ProjectReference Include="..\AspireStarterApplication.1.Web\AspireStarterApplication.1.Web.csproj" />
+ <ProjectReference Include="..\XmlEncodedProjectName.ApiService\XmlEncodedProjectName.ApiService.csproj" />
+ <ProjectReference Include="..\XmlEncodedProjectName.Web\XmlEncodedProjectName.Web.csproj" />
</ItemGroup>
<ItemGroup>.. this results in a fixed: |
|
@radical I tried applying your suggested change locally and ran into issues with the .sln file not working apparently. All the paths and names look correct, but I get the sense this might never have worked properly in any template judging from how much of the logging doesn't even seem to support the unicode chars: |
|
Maybe we can skip the case where the name has characters needing to be xml encoded for now. But other than that we should get unicode chars working, right? |
|
@radical I'm not sure we fully understand exactly what's supported though, e.g. that example you gave results in C# errors: |
|
Starter template works with this on macOS: https://gist.github.com/radical/840d12dcf55ca52d867ed8cb2aeafa34
|
|
It has scope for cleanup of course :D |
|
@radical are you saying it works with something like |
|
In my tests I didn't use But I did try https://gist.github.com/radical/fa68b403ddfa165b725a1fc42901ab69 (Also, the new property is something that we can probably remove by doing similar transformation as yours for the project name) |
|
Hmm I'm trying to figure out what I'm missing in my changes so far then. We definitely don't want a property in the generated project file, so any idea what I should change to get it working? |
|
@radical can you share all the files from the project created with your changes? I'm a bit confused how yours is working as mine seems to be producing the files I expect (names and content) but I then hit C# errors and the solution saying the projects don't exist, but if I copy the path of the projects in the .sln file and do a |
|
I haven't tried this on windows yet, btw. |
|
Nevermind, 7zip works |
|
@radical Based on what we just figured out I'm marking this ready for review as it does fix the issues logged and it seems Windows doesn't support project names with unicode chars anyway. |
interesting! fyi, I'm pushing my changes to #3270 but it has workload tests also. The templates relevant changes are in
Fair enough. I'll try on windows too, and see if anything is doable but all that can be in separate PR anyway. |
Not for this PR, but I think |
|
I tried the changes here with the workload tests, and they passed. |
Fixes #4056
ed1250c to
0e8c88b
Compare
|
Thank you for being patient, @DamianEdwards! |



This appears to fix #4025For #4024 I think the targets change I make here fixes that but I haven't fully verified that as it's a bit trickier to do so locally.Fixes #4025
Fixes #4024
Fixes #4056
Fixes #3981
Microsoft Reviewers: Open in CodeFlow