You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cannot output the string "\]", throws error Unrecognized escape sequence in literal: \]. No way of escaping #200
What is the current result?
Error thrown: Unrecognized escape sequence in literal: \]
What is the expected result?
should be string 1, 2, {x} \]
Please post full exception details if applicable (message, stacktrace, inner exceptions)
StackTrace at SmartFormat.Core.Parsing.LiteralText.ConvertCharacterLiteralsToUnicode()
at SmartFormat.Core.Parsing.LiteralText.ToString()
at SmartFormat.SmartFormatter.Format(FormattingInfo formattingInfo)
at SmartFormat.SmartFormatter.Format(FormatDetails formatDetails, Format format, Object current)
at SmartFormat.SmartFormatter.Format(IFormatProvider provider, String format, Object[] args)
at SmartFormat.SmartFormatter.Format(String format, Object[] args)
at SmartFormat.Smart.Format(String format, Object arg0)
at UserQuery.DoStuff.test_escape_reserved_chars() in C:\Users\raxp\AppData\Local\Temp\LINQPad6\_wwimbzqr\inaqdk\LINQPadQuery:line 16
at UserQuery.Main() in C:\Users\raxp\AppData\Local\Temp\LINQPad6\_wwimbzqr\inaqdk\LINQPadQuery:line 4
at LINQPad.ExecutionModel.ClrQueryRunner.Run()
at LINQPad.ExecutionModel.Server.RunQuery(QueryRunner runner)
Did you find a workaround? yes/no
no
Is there a version in which it worked?
only tried latest
Can you help us by writing an unit test?
Sure I will submit one
changed the title [-]Cannot output the string "\]", throws error Unrecognized escape sequence in literal: \]. No way of escaping[/-][+]Cannot output the string "\]", throws error `Unrecognized escape sequence in literal: \].` No way of escaping[/+]on Sep 8, 2021
changed the title [-]Cannot output the string "\]", throws error `Unrecognized escape sequence in literal: \].` No way of escaping[/-][+]Cannot output the string "`\]`", throws error `Unrecognized escape sequence in literal: \].` No way of escaping[/+]on Sep 8, 2021
Thanks for pointing this out. It is a know limitation of v2.x versions and one of the reasons for the next major release. The current version on NuGet is 3.0.0-alpha.2 which includes a fix also for escaping of literals and format options (e.g. for RegEx). Please give it a try. Any other feedback is welcome, too.
Regarding your sample code, for [ there is no need to escape in literals, neither in v2.7.0 nor in v3.0.0. It's only required in Placeholders.
Activity
[-]Cannot output the string "\]", throws error Unrecognized escape sequence in literal: \]. No way of escaping[/-][+]Cannot output the string "\]", throws error `Unrecognized escape sequence in literal: \].` No way of escaping[/+][-]Cannot output the string "\]", throws error `Unrecognized escape sequence in literal: \].` No way of escaping[/-][+]Cannot output the string "`\]`", throws error `Unrecognized escape sequence in literal: \].` No way of escaping[/+]axunonb commentedon Sep 8, 2021
Thanks for pointing this out. It is a know limitation of v2.x versions and one of the reasons for the next major release. The current version on NuGet is 3.0.0-alpha.2 which includes a fix also for escaping of literals and format options (e.g. for RegEx). Please give it a try. Any other feedback is welcome, too.
Regarding your sample code, for
[there is no need to escape in literals, neither in v2.7.0 nor in v3.0.0. It's only required inPlaceholders.axunonb commentedon Sep 11, 2021
@raxuser100 Should we close this issue?