diff --git a/packages/aws-cdk/lib/init-templates/app/csharp/src/%name.PascalCased%/Program.template.cs b/packages/aws-cdk/lib/init-templates/app/csharp/src/%name.PascalCased%/Program.template.cs index 7099783ef9eac..0079f4418d1d0 100644 --- a/packages/aws-cdk/lib/init-templates/app/csharp/src/%name.PascalCased%/Program.template.cs +++ b/packages/aws-cdk/lib/init-templates/app/csharp/src/%name.PascalCased%/Program.template.cs @@ -3,14 +3,14 @@ using System.Collections.Generic; using System.Linq; -namespace %name.PascalCased% +namespace %PascalNameSpace% { sealed class Program { public static void Main(string[] args) { var app = new App(); - new %name.PascalCased%Stack(app, "%stackname%", new StackProps + new %name.PascalCased%Stack(app, "%stackname%", new %PascalStackProps% { // If you don't specify 'env', this stack will be environment-agnostic. // Account/Region-dependent features and context lookups will not work, diff --git a/packages/aws-cdk/lib/init.ts b/packages/aws-cdk/lib/init.ts index 60c5173e04611..cbbcc940eae4f 100644 --- a/packages/aws-cdk/lib/init.ts +++ b/packages/aws-cdk/lib/init.ts @@ -173,6 +173,8 @@ export class InitTemplate { } return template.replace(/%name%/g, project.name) .replace(/%stackname%/, project.stackName ?? '%name.PascalCased%Stack') + .replace(/%PascalNameSpace%/, project.stackName ? camelCase(project.stackName + 'Stack', { pascalCase: true }) : '%name.PascalCased%') + .replace(/%PascalStackProps%/, project.stackName ? (camelCase(project.stackName, { pascalCase: true }) + 'StackProps') : 'StackProps') .replace(/%name\.camelCased%/g, camelCase(project.name)) .replace(/%name\.PascalCased%/g, camelCase(project.name, { pascalCase: true })) .replace(/%cdk-version%/g, cdkVersion) diff --git a/packages/aws-cdk/test/commands/migrate.test.ts b/packages/aws-cdk/test/commands/migrate.test.ts index 9453030af9dcd..50eed4c20d9a1 100644 --- a/packages/aws-cdk/test/commands/migrate.test.ts +++ b/packages/aws-cdk/test/commands/migrate.test.ts @@ -177,7 +177,7 @@ describe('Migrate Function Tests', () => { // Replaced stack file is referenced correctly in app file const app = fs.readFileSync(path.join(workDir, 'GoodCSharp', 'src', 'GoodCSharp', 'Program.cs'), 'utf8').split('\n'); expect(app.map(line => line.match('namespace GoodCSharp')).filter(line => line).length).toEqual(1); - expect(app.map(line => line.match(/ new GoodCSharpStack\(app, "GoodCSharp", new StackProps/)).filter(line => line).length).toEqual(1); + expect(app.map(line => line.match(/ new GoodCSharpStack\(app, "GoodCSharp", new GoodCSharpStackProps/)).filter(line => line).length).toEqual(1); // Replaced stack file is correctly generated const replacedStack = fs.readFileSync(path.join(workDir, 'GoodCSharp', 'src', 'GoodCSharp', 'GoodCSharpStack.cs'), 'utf8');