Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,12 @@
"valueTransform": "vectorStoreIndexNameTransform",
"replaces": "data-ChatWithCustomData-CSharp.Web-"
},
"aspireClassNameReplacer": {
"type": "derived",
"valueSource": "name",
"valueTransform": "aspireClassName_Formatting",
"replaces": "ChatWithCustomData_CSharp_Web_AspireClassName"
},
"webProjectNamespaceAdjuster": {
"type": "generated",
"generator": "switch",
Expand All @@ -524,6 +530,33 @@
}
},
"forms": {
"aspireClassName_ReplaceInvalidChars_DigitDots": {
"identifier": "replace",
"pattern": "((?<=\\.)|^)(?=\\d)",
"replacement": "_",
"description": "Insert underscore before digits at start or after a dot"
},
"aspireClassName_ReplaceInvalidChars_NonWords": {
"identifier": "replace",
"pattern": "\\W",
"replacement": "_",
"description": "Replace non-word characters with underscore"
},
"aspireClassName_AppendWeb": {
"identifier": "replace",
"pattern": "^(.*)$",
"replacement": "$1_Web",
"description": "Append _Web to the project name"
},
"aspireClassName_Formatting": {
"identifier": "chain",
"steps": [
"aspireClassName_ReplaceInvalidChars_DigitDots",
"aspireClassName_ReplaceInvalidChars_NonWords",
"aspireClassName_AppendWeb"
],
"description": "Normalize and add _Web suffix"
},
Comment thread
ViveliDuCh marked this conversation as resolved.
Outdated
"vectorStoreIndexNameTransform": {
"identifier": "chain",
"steps": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
#else // UseLocalVectorStore
#endif

var webApp = builder.AddProject<Projects.ChatWithCustomData_CSharp_Web>("aichatweb-app");
var webApp = builder.AddProject<Projects.ChatWithCustomData_CSharp_Web_AspireClassName>("aichatweb-app");
#if (IsOllama) // AI SERVICE PROVIDER REFERENCES
webApp
.WithReference(chat)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,28 @@ public async Task CreateRestoreAndBuild_AspireTemplate(params string[] args)
await Fixture.BuildProjectAsync(project);
}

/// <summary>
/// Tests build for various project name formats, including dots and other
/// separators, to trigger the class name normalization bug described
/// in https://github.com/dotnet/extensions/issues/6811
/// This runs for all provider combinations with --aspire true and different
/// project names to ensure the bug is caught in all scenarios.
/// </summary>
[Theory]
[MemberData(nameof(GetProjectNameVariants))]
public async Task CreateRestoreAndBuild_ProjectNameVariants(string provider, string projectName)
{
var project = await Fixture.CreateProjectAsync(
templateName: "aichatweb",
projectName: projectName,
args: new[] { "--aspire", $"--provider={provider}" });

project.StartupProjectRelativePath = $"{projectName}.AppHost";

await Fixture.RestoreProjectAsync(project);
await Fixture.BuildProjectAsync(project);
}
Comment thread
ViveliDuCh marked this conversation as resolved.

private static readonly (string name, string[] values)[] _templateOptions = [
("--provider", ["azureopenai", "githubmodels", "ollama", "openai"]),
("--vector-store", ["azureaisearch", "local", "qdrant"]),
Expand Down Expand Up @@ -158,4 +180,26 @@ private static IEnumerable<string[]> GetAllPossibleOptions(ReadOnlyMemory<(strin
}
}
}

public static IEnumerable<object[]> GetProjectNameVariants()
{
foreach (string provider in new[] { "ollama", "openai", "azureopenai", "githubmodels" })
{
foreach (string projectName in new[]
{
"dot.name",
"project.123",
"space name",
"mix.ed-dash_name 123",
".1My.Projec-",
"1Project123",
"11double",
"1",
"nomatch"
Comment thread
ViveliDuCh marked this conversation as resolved.
Outdated
})
{
yield return new object[] { provider, projectName };
}
}
}
}
Loading