From 936db48063d3017d1d85bf6e87c1d6dc679a2897 Mon Sep 17 00:00:00 2001 From: Beisi Zhou Date: Fri, 2 Jun 2023 14:47:18 +0800 Subject: [PATCH 1/2] Fix double quote in string pattern --- powershell/llcsharp/schema/string.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/powershell/llcsharp/schema/string.ts b/powershell/llcsharp/schema/string.ts index 0bb2229d97..05c86caa09 100644 --- a/powershell/llcsharp/schema/string.ts +++ b/powershell/llcsharp/schema/string.ts @@ -200,11 +200,11 @@ ${this.validateEnum(eventListener, property)} return `await ${eventListener}.AssertMaximumLength(${nameof(property.value)},${property},${len});`; } private validateRegex(eventListener: Variable, property: Variable): string { - const pattern = (this.schema).pattern; + const pattern = (this.schema).pattern?.replace('"', '""'); if (!pattern) { return ''; } - return `await ${eventListener}.AssertRegEx(${nameof(property.value)},${property},@"${pattern}");`; + return `await ${eventListener}.AssertRegEx(${nameof(property.value)}, ${property}, @"${pattern}");`; } private validateEnum(eventListener: Variable, property: Variable): string { if (this.schema.type !== SchemaType.SealedChoice && this.schema.type != SchemaType.Choice) { From dc0af6de7dbfebe5ed3b255ea63f9a0b1d84cabb Mon Sep 17 00:00:00 2001 From: Beisi Zhou Date: Wed, 7 Jun 2023 09:40:43 +0800 Subject: [PATCH 2/2] Update powershell/llcsharp/schema/string.ts --- powershell/llcsharp/schema/string.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/powershell/llcsharp/schema/string.ts b/powershell/llcsharp/schema/string.ts index 05c86caa09..25a31927a0 100644 --- a/powershell/llcsharp/schema/string.ts +++ b/powershell/llcsharp/schema/string.ts @@ -200,7 +200,7 @@ ${this.validateEnum(eventListener, property)} return `await ${eventListener}.AssertMaximumLength(${nameof(property.value)},${property},${len});`; } private validateRegex(eventListener: Variable, property: Variable): string { - const pattern = (this.schema).pattern?.replace('"', '""'); + const pattern = (this.schema).pattern?.replace(/"/g,'""'); if (!pattern) { return ''; }