-
-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue: Using escaped strings is not working correctly #163
Comments
Hey, I got this issue again but only for backslashes, when switching from the NuGet package
(https://www.nuget.org/packages/wilx.System.Linq.Dynamic.Core/)
I think the later one should be used? Error:
Console app code to reproduce: using System;
using System.Linq;
using System.Linq.Dynamic.Core;
namespace Test
{
class Program
{
static void Main(string[] args)
{
var strings = new[] { "test \\ string" }.AsQueryable();
var count = strings.Count("ToString().Contains('\\')");
//var count = strings.Count(s => s.ToString().Contains('\\'));
Console.WriteLine("Elements found (should be 1): " + count);
Console.ReadKey();
}
}
} |
As a workaround you can use: |
Thank you for the answer, this worked for me in the given example. At a different point we use an input string to filter out elements, so it would be quite complicated to get it to work that way, having multiple inputs for each argument in the string predicate, as well as that filter string containing the arguments. Is there a plan to fix this in the future? Thank you for your help! |
I see your point, it seems that the parsing code in this library is different regarding escaping. I'll take a look if I can find and fix the logic. |
@hypetsch and @SolidWhiteSven https://www.myget.org/feed/system-linq-dynamic-core/package/nuget/System.Linq.Dynamic.Core |
Hey @StefH, I've added the prerelease package with version 1.0.13-ci-11244 to the solution, but sadly I still get the 'Unterminated string literal' exception. I also thought the changes were only in the mentioned 11242 version, but that one also throws the error for this code: using System;
using System.Linq;
using System.Linq.Dynamic.Core;
namespace Test
{
class Program
{
static void Main(string[] args)
{
var strings = new[] { "test \\ string" }.AsQueryable();
var count = strings.Count("Contains('\\')");
Console.WriteLine("Elements found (should be 1): " + count);
Console.ReadKey();
}
}
} |
You are correct, this test does not work. I've to double check the code again... |
@SolidWhiteSven |
@StefH Works like a charm, thank you! |
@hypetsch Can you also do some tests please? |
@StefH, thanks for your work. Just did a quick test: the test case |
@hypetsch string expectedLeftValue = "Property1.IndexOf(\"\\\\\")"; Which means (to my knowledge):
|
Sorry, think you are right. |
Thank you both for your help ! I will close this issue and merge the PR; in some time, I'll create a new official NuGet. |
In issue #65 some issues regarding the usage of escaped strings have been fixed. I am currently facing another issue in combination with escaped characters (backslashes and quotation marks).
TextParser.cs
seems to not handle those scenarios correctly.I have been able to reproduce the issue in unit tests:
I think the issue is that the current implementation assumes that it is always a full string (starting and ending with an escaped quotation mark) and not only a single escaped character.
Edit: Updated unit tests code
The text was updated successfully, but these errors were encountered: