surgicalcoder / BlazorInteropGenerator

Generates Blazor -> Javascript strongly typed interop methods.
MIT License
15 stars 2 forks source link

Generator Fails to Parse Regular Expressions #2

Closed JCKortlang closed 1 week ago

JCKortlang commented 5 months ago

Generator fails to generate code when parsing regular expressions.

Specifically... PlotJs source code:

CSC : error CS8785: Generator 'JSInteropGenerator' failed to generate source. It will not contribute to the output and compilation errors may occur as a result. Exception was of type 'ParserException' with message 'Line 5655: Invalid regular expression'.

Problematic code:

    const reCombiner = /[\p{Combining_Mark}\p{Emoji_Modifier}]+/uy;
    const rePictographic = /\p{Extended_Pictographic}/uy;

Full stack trace by reproducing in unit tests.

Esprima.ParserException : Line 5655: Invalid regular expression
   at Esprima.Scanner.ThrowUnexpectedToken(String message)
   at Esprima.Scanner.ParseRegex(String pattern, String flags)
   at Esprima.Scanner.ScanRegExp()
   at Esprima.JavaScriptParser.NextRegexToken()
   at Esprima.JavaScriptParser.ParsePrimaryExpression()
   at Esprima.JavaScriptParser.InheritCoverGrammar[T](Func`1 parseFunction)
   at Esprima.JavaScriptParser.ParseLeftHandSideExpressionAllowCall()
   at Esprima.JavaScriptParser.InheritCoverGrammar[T](Func`1 parseFunction)
   at Esprima.JavaScriptParser.ParseUpdateExpression()
   at Esprima.JavaScriptParser.ParseUnaryExpression()
   at Esprima.JavaScriptParser.InheritCoverGrammar[T](Func`1 parseFunction)
   at Esprima.JavaScriptParser.ParseExponentiationExpression()
   at Esprima.JavaScriptParser.InheritCoverGrammar[T](Func`1 parseFunction)
   at Esprima.JavaScriptParser.ParseBinaryExpression()
   at Esprima.JavaScriptParser.InheritCoverGrammar[T](Func`1 parseFunction)
   at Esprima.JavaScriptParser.ParseConditionalExpression()
   at Esprima.JavaScriptParser.ParseAssignmentExpression()
   at Esprima.JavaScriptParser.IsolateCoverGrammar[T](Func`1 parseFunction)
   at Esprima.JavaScriptParser.ParseLexicalBinding(VariableDeclarationKind kind, Boolean inFor)
   at Esprima.JavaScriptParser.ParseBindingList(VariableDeclarationKind kind, Boolean inFor)
   at Esprima.JavaScriptParser.ParseLexicalDeclaration(Boolean& inFor)
   at Esprima.JavaScriptParser.ParseStatementListItem()
   at Esprima.JavaScriptParser.ParseFunctionSourceElements()
   at Esprima.JavaScriptParser.ParseFunctionExpression()
   at Esprima.JavaScriptParser.ParsePrimaryExpression()
   at Esprima.JavaScriptParser.InheritCoverGrammar[T](Func`1 parseFunction)
   at Esprima.JavaScriptParser.ParseLeftHandSideExpressionAllowCall()
   at Esprima.JavaScriptParser.InheritCoverGrammar[T](Func`1 parseFunction)
   at Esprima.JavaScriptParser.ParseUpdateExpression()
   at Esprima.JavaScriptParser.ParseUnaryExpression()
   at Esprima.JavaScriptParser.InheritCoverGrammar[T](Func`1 parseFunction)
   at Esprima.JavaScriptParser.ParseExponentiationExpression()
   at Esprima.JavaScriptParser.InheritCoverGrammar[T](Func`1 parseFunction)
   at Esprima.JavaScriptParser.ParseBinaryExpression()
   at Esprima.JavaScriptParser.InheritCoverGrammar[T](Func`1 parseFunction)
   at Esprima.JavaScriptParser.ParseConditionalExpression()
   at Esprima.JavaScriptParser.ParseAssignmentExpression()
   at Esprima.JavaScriptParser.InheritCoverGrammar[T](Func`1 parseFunction)
   at Esprima.JavaScriptParser.ParseGroupExpression()
   at Esprima.JavaScriptParser.InheritCoverGrammar[T](Func`1 parseFunction)
   at Esprima.JavaScriptParser.ParsePrimaryExpression()
   at Esprima.JavaScriptParser.InheritCoverGrammar[T](Func`1 parseFunction)
   at Esprima.JavaScriptParser.ParseLeftHandSideExpressionAllowCall()
   at Esprima.JavaScriptParser.InheritCoverGrammar[T](Func`1 parseFunction)
   at Esprima.JavaScriptParser.ParseUpdateExpression()
   at Esprima.JavaScriptParser.ParseUnaryExpression()
   at Esprima.JavaScriptParser.InheritCoverGrammar[T](Func`1 parseFunction)
   at Esprima.JavaScriptParser.ParseExponentiationExpression()
   at Esprima.JavaScriptParser.InheritCoverGrammar[T](Func`1 parseFunction)
   at Esprima.JavaScriptParser.ParseBinaryExpression()
   at Esprima.JavaScriptParser.InheritCoverGrammar[T](Func`1 parseFunction)
   at Esprima.JavaScriptParser.ParseConditionalExpression()
   at Esprima.JavaScriptParser.ParseAssignmentExpression()
   at Esprima.JavaScriptParser.IsolateCoverGrammar[T](Func`1 parseFunction)
   at Esprima.JavaScriptParser.ParseArguments()
   at Esprima.JavaScriptParser.ParseLeftHandSideExpressionAllowCall()
   at Esprima.JavaScriptParser.InheritCoverGrammar[T](Func`1 parseFunction)
   at Esprima.JavaScriptParser.ParseUpdateExpression()
   at Esprima.JavaScriptParser.ParseUnaryExpression()
   at Esprima.JavaScriptParser.InheritCoverGrammar[T](Func`1 parseFunction)
   at Esprima.JavaScriptParser.ParseExponentiationExpression()
   at Esprima.JavaScriptParser.InheritCoverGrammar[T](Func`1 parseFunction)
   at Esprima.JavaScriptParser.ParseBinaryExpression()
   at Esprima.JavaScriptParser.InheritCoverGrammar[T](Func`1 parseFunction)
   at Esprima.JavaScriptParser.ParseConditionalExpression()
   at Esprima.JavaScriptParser.ParseAssignmentExpression()
   at Esprima.JavaScriptParser.IsolateCoverGrammar[T](Func`1 parseFunction)
   at Esprima.JavaScriptParser.ParseExpression()
   at Esprima.JavaScriptParser.ParseExpressionStatement()
   at Esprima.JavaScriptParser.ParseStatement()
   at Esprima.JavaScriptParser.ParseStatementListItem()
   at Esprima.JavaScriptParser.ParseScript(Boolean strict)
   at Jint.Engine.Execute(String source, ParserOptions parserOptions)
   at Jint.Engine.Execute(String source)
   at GoLive.Generator.BlazorInterop.JSInteropGenerator.GenerateSource(Settings config) in /Users/jkortlan/workplace/BlazorInteropGenerator/GoLive.Generator.BlazorInterop/JSInteropGenerator.cs:line 65
   at GoLive.Generator.BlazorInterop.Tests.JsInteropGeneratorTests.Test1() in /Users/jkortlan/workplace/BlazorInteropGenerator/GoLive.Generator.BlazorInterop.Tests/JsInteropGeneratorTests.cs:line 17
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

-----

One or more child tests had errors
  Exception doesn't have a stacktrace
JCKortlang commented 5 months ago

Pulled this package locally and updated the underlying dependencies but the issue persists.

Opened an issue against Jint: https://github.com/sebastienros/jint/issues/1899

surgicalcoder commented 4 months ago

@JCKortlang Thanks for reporting this and the underlying issue, will get this fixed by end of week (currently out of country)

surgicalcoder commented 1 week ago

@JCKortlang Sorry took so long, got massively sidetracked, JInt upgraded to newish version that fixes this issue, v2.0 is out which also changes the way the .json file works, hope it makes sense.