From 951e37fa19f66b7bf9423af0d648ad4f3477b9b2 Mon Sep 17 00:00:00 2001 From: belivo Date: Sat, 20 Jun 2020 16:10:54 -0400 Subject: [PATCH] support typeof in attribute parameters --- spec/csharp/ClassInsideNamespace.cs | 2 +- src/RegExHelper.ts | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/spec/csharp/ClassInsideNamespace.cs b/spec/csharp/ClassInsideNamespace.cs index cd74e6d..cad9c70 100644 --- a/spec/csharp/ClassInsideNamespace.cs +++ b/spec/csharp/ClassInsideNamespace.cs @@ -3,7 +3,7 @@ namespace MyNamespace { [SomeAttribute] - [SomeAttributeWithParameters(MyName = "Foo", 28, Framework.Blah)] + [SomeAttributeWithParameters(MyName = "Foo", 28, Framework.Blah, typeof(BlahBlah))] abstract class MyPoco where WithGenerics : new() { public string[] Name { get; set; } diff --git a/src/RegExHelper.ts b/src/RegExHelper.ts index eb45dfc..016addb 100644 --- a/src/RegExHelper.ts +++ b/src/RegExHelper.ts @@ -47,6 +47,10 @@ return this.wrapInGroup(capture, false, "'" + this.wrapInGroup(false, false, "\\\\?.") + "'"); } + public getTypeOfRegex(capture: boolean) { + return this.wrapInGroup(capture, false, "typeof" + this.wrapInGroup(false, true, this.getMethodParametersWrapperRegex(false, false))); + } + public getLiteralRegex(capture: boolean) { return this.wrapInGroup(capture, true, this.getLiteralNumberRegex(false) + "{1}?|" + @@ -289,7 +293,8 @@ var result = ""; result += this.wrapInGroup(false, true, this.getNameRegex(captureName) + "=") + "??"; - result += this.getLiteralRegex(captureValue); + result += this.getLiteralRegex(captureValue) + "|"; + result += this.getTypeOfRegex(captureValue); return this.wrapInGroup(capture, true, result); }