Comments (11)
from system.linq.dynamic.core.
ok, got it.
When I run these tests using 1.3.10:
[Theory]
[InlineData("\"{\\\"PropertyA\\\":\\\"abc\\\"}\"", "{\"PropertyA\":\"abc\"}")]
[InlineData("\"{\\\"PropertyA\\\":\\\" \\\"}\"", "{\"PropertyA\":\" \"}")]
[InlineData("\"{\\\"PropertyA\\\":\\\"\\\"}\"", "{\"PropertyA\":\"\"}")]
[InlineData("\"{\\\\\\\"PropertyA\\\\\\\":\\\\\\\"\\\\\\\"}\"", "{\\\"PropertyA\\\":\\\"\\\"}")]
public void GivenJsonString_WhenParseLambda_ThenShouldOutputEscapedJson(
string jsonString,
string expectedResult)
{
var actualResult = DynamicExpressionParser
.ParseLambda(typeof(object), jsonString)
.Compile()
.DynamicInvoke();
Assert.Equal(
expectedResult,
actualResult?.ToString()
);
}
They fail as originally described:
Then when I run the same tests using 1.3.11-preview-01
All pass!
Thank you very much for your quick fix, I'll look out for 1.3.11
from system.linq.dynamic.core.
from system.linq.dynamic.core.
BTW I'm using System.Linq.Dynamic.Core
v1.3.10
from system.linq.dynamic.core.
@brettwinters
Can you please test preview version 1.3.11-preview-01?
From: https://www.myget.org/F/system-linq-dynamic-core/api/v3/index.json
from system.linq.dynamic.core.
Hi @StefH - I'm having some trouble using myget. Sorry about this but would you mind publishing to nuget? otherwise please could you point me to a online c# ide so I can write some tests?
from system.linq.dynamic.core.
This page describes how to use myget:
https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions
from system.linq.dynamic.core.
@brettwinters
Some advice is needed.
I did introduce a new config enum like below to make sure that this solution is now the default, but if users want to use the old parsing, they can configure it.
Do you think it's a good naming?
namespace System.Linq.Dynamic.Core.Config;
/// <summary>
/// Defines the types of string literal parsing that can be performed.
/// </summary>
public enum StringLiteralParsingType : byte
{
/// <summary>
/// Represents the default string literal parsing type. Double quotes should be escaped using the default escaping.
/// E.G. var expression = "StaticHelper.Filter(\"UserName == \\\"x\\\"\")";
///
/// [Default]
/// </summary>
Default = 0,
/// <summary>
/// Represents a string literal parsing type where a double quotes should be escaped by two double quotes.
/// E.G. var expression = "StaticHelper.Filter(\"UserName == "\"\"x\"\"\")";
/// </summary>
EscapeDoubleQuoteByTwoDoubleQuotes = 1
}
from system.linq.dynamic.core.
Hi @StefH - escaping and unescaping serialised strings get really confusing quickly haha
The rule I think is that each pair of backslashes \\
turns into a single backslash \
and \"
turns into "
right? so combining, like this \\\"
turns into \"
(i.e. " when deserialised again into memory).
So \"UserName == \\\"x\\\"\"
-> "UserName == \"x\""
(i.e. UserName == "x" in memory)
But the EscapeDoubleQuoteByTwoDoubleQuotes
\"UserName == "\"\"x\"\"\"
-> "UserName == "x""
(i.e. UserName == x" in memory) which to me looks wrong so I'd call it "Legacy" with an [Obsolete] attribute but I'm not sure who depends on this behaviour...
from system.linq.dynamic.core.
wait I just confused myself. You're right \"UserName == "\"\"x\"\"\"
-> UserName == "x"
- it's totally correct and valid since it's another method of escaping: Escape with backslash (\"
and \\
) vs escape with double quotes (""
i.e. ""abc""
) (so by default EscapeWithBackslash
and option EscapeWithDoubleQuotes
. In the second example you're using both methods. Can you combine the parser logic to handle both cases?
from system.linq.dynamic.core.
The parser cannot handle both cases automatically. You need to use the config.
(I did not notice the error in the example, I will verify it..)
from system.linq.dynamic.core.
Related Issues (20)
- SelectMany collectionSelectorArgs not allowing context.Set<>() HOT 1
- C# Entity Framework Core - OrderBy and Where don't work with `[ComplexType]` HOT 6
- try to call function inside select HOT 3
- Basic performance consideration question HOT 1
- try to parse lambda with function inside .
- Performance Issue with EF Core 8.0 and Microsoft.EntityFrameworkCore.DynamicLinq Package HOT 8
- Question About Parameters HOT 4
- query generated with dynamic linq not parse parameter linq as parameter sql !!! HOT 1
- Add JSON support HOT 9
- .NET 8 (and possible all non-NETSTANDARD and higher versions) attempt to load EF 6 types HOT 16
- Add ParsingConfig option to support single quotes in place of double quotes
- Failure in ParseArgumentList when using lambda filter on list of dictionaries HOT 1
- DynamicExpressionParser.ParseLambda regressions in v1.3.10
- Error with 'Equals' together with other parameters HOT 4
- ExpressionParser finds Types from IEnumerable instead of IQueryable (breaks Code) (worked in 1.3.9) HOT 1
- Updating to 1.3.13 - No property or field 'XXXXX' exists in type 'Char'
- Issue with Where() method when filtering multiple string properties while using ToLower() HOT 1
- >= 1.3.3 Slow First Dynamic Select HOT 2
- Error when parsing a nested object initialization
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from system.linq.dynamic.core.