fix: Resolve JS proxy namespace mismatch for multi-segment company names#24877
fix: Resolve JS proxy namespace mismatch for multi-segment company names#24877
Conversation
When generating a project with a company name containing dots (e.g., 'Demo.App.QoL'), the template replacement was incorrectly camelCasing the company name as 'demo.App' instead of 'demo.app'. This was because SolutionRenamer used ToCamelCase() on the entire string rather than on each dot-separated segment individually. The runtime JS proxy generator (JQueryProxyScriptGenerator.CamelCaseWithNamespace) applies camelCase to each segment, causing a mismatch. Added ToCamelCaseWithNamespace() helper to match runtime behavior.
There was a problem hiding this comment.
Pull request overview
This PR fixes a critical bug where projects with multi-segment company names (e.g., Demo.App.QoL) caused runtime JavaScript errors due to namespace mismatches between template generation and runtime proxy script generation.
Changes:
- Added
ToCamelCaseWithNamespace()helper method that transforms each dot-separated segment individually (e.g., "Demo.App" → "demo.app") - Updated template replacement logic to use the new method for both company name and project name transformations
- Added
System.Linqimport for theSelect()method used in the new helper
| private static string ToCamelCaseWithNamespace(string name) | ||
| { | ||
| if (name.Contains('.')) | ||
| { | ||
| return name.Split('.').Select(n => n.ToCamelCase()).JoinAsString("."); | ||
| } | ||
|
|
||
| return name.ToCamelCase(); | ||
| } |
There was a problem hiding this comment.
Consider adding unit tests for the new ToCamelCaseWithNamespace method to verify it correctly handles multi-segment namespaces (e.g., "Demo.App.QoL" → "demo.app.qoL"). This would prevent regressions and document the expected behavior. The test could be added to a new SolutionRenamer_Tests class in the Volo.Abp.Cli.Core.Tests project, following the pattern of other test classes in that project.
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
Co-authored-by: enisn <[email protected]>
Add unit tests for ToCamelCaseWithNamespace method
|
|
Summary
When generating a project with a company name containing dots (e.g.,
Demo.App.QoL), the template replacement was incorrectly camelCasing the company name asdemo.Appinstead ofdemo.app.Root Cause
Template replacement (
SolutionRenamer): UsedToCamelCase()on the entire company/project name string, which only lowercases the first character of the whole string."Demo.App".ToCamelCase()→"demo.App"Runtime proxy (
JQueryProxyScriptGenerator.CamelCaseWithNamespace): AppliesToCamelCase()to each dot-separated segment individually."Demo.App"→"demo.app"This mismatch causes a runtime error:
Cannot read properties of undefined (reading 'someProperty')when the generated JavaScript tries to access a namespace that doesn't exist.Fix
Added
ToCamelCaseWithNamespace()helper method inSolutionRenamer.csthat mirrors the runtime proxy's behavior - splitting by.and camelCasing each segment.Affected Areas
app-nolayerstemplate (MVC, Blazor, etc.)apptemplate (Web, Web.Host)microservicetemplates.services.or.controllers.patternFiles Changed
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/SolutionRenamer.cs