Skip to content

Commit ccea45b

Browse files
authored
* appveyor. Fix zip name for signed artifacts * #192 Upgrade DynamicLinq refference
1 parent 19898ef commit ccea45b

File tree

3 files changed

+59
-3
lines changed

3 files changed

+59
-3
lines changed

ClosedXML.Report/ClosedXML.Report.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@
6161
<ItemGroup>
6262
<PackageReference Include="ClosedXML.Signed" Version="0.95.0" Condition="'$(Configuration)'=='Release.Signed'" />
6363
<PackageReference Include="ClosedXML" Version="0.95.0" Condition="'$(Configuration)'!='Release.Signed'" />
64-
<PackageReference Include="morelinq" Version="2.9.0" />
65-
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.1.1" />
64+
<PackageReference Include="morelinq" Version="2.10.0" />
65+
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.2.10" />
6666
</ItemGroup>
6767

6868
</Project>

tests/ClosedXML.Report.Tests/ClosedXML.Report.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<PackageReference Include="linq2db.t4models" Version="1.0.7.1" />
3737
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
3838
<PackageReference Include="NSubstitute" Version="1.10.0.0" />
39-
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.1.1" />
39+
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.2.10" />
4040
<PackageReference Include="xunit" Version="2.4.1" />
4141
<PackageReference Include="xunit.assert" Version="2.4.1" />
4242
<PackageReference Include="xunit.extensibility.execution" Version="2.4.1" />

tests/ClosedXML.Report.Tests/FormulaEvaluatorTests.cs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using ClosedXML.Report.Utils;
22
using System.Collections.Generic;
33
using System.Linq;
4+
using System.Linq.Dynamic.Core;
5+
using System.Linq.Dynamic.Core.CustomTypeProviders;
46
using System.Linq.Dynamic.Core.Exceptions;
57
using System.Linq.Expressions;
68
using FluentAssertions;
@@ -97,11 +99,65 @@ public void ExpressionParseTestNullPropagation()
9799
eval.Evaluate(@"{{np(b.Manager.Name, null)}}").Should().BeNull();
98100
}
99101

102+
[Fact(Skip = "It doesn't work yet")]
103+
public void EvalDictionaryParams()
104+
{
105+
Parameter CreateDicParameter(string name) => new Parameter("item", new Dictionary<string, object>
106+
{{"Name", new Dictionary<string, object> {{"FirstName", name }}}});
107+
108+
var eval = new FormulaEvaluator();
109+
eval.Evaluate("{{item.Name.FirstName}}", CreateDicParameter("Julio")).Should().Be("Julio");
110+
eval.Evaluate("{{item.Name.FirstName}}", CreateDicParameter("John")).Should().Be("John");
111+
}
112+
113+
[Fact(Skip = "It doesn't work yet")]
114+
public void EvalDictionaryParams2()
115+
{
116+
object CreateDicParameter(string name) => new Dictionary<string, object>
117+
{{"Name", new Dictionary<string, object> {{"FirstName", name }}}};
118+
119+
var config = new ParsingConfig()
120+
{
121+
CustomTypeProvider = new DefaultDynamicLinqCustomTypeProvider()
122+
};
123+
var parType = new Dictionary<string, object>().GetType();
124+
var lambda = DynamicExpressionParser.ParseLambda(config, new [] {Expression.Parameter(parType, "item")}, typeof(object), "item.Name.FirstName").Compile();
125+
lambda.DynamicInvoke(CreateDicParameter("Julio")).Should().Be("Julio");
126+
lambda.DynamicInvoke(CreateDicParameter("John")).Should().Be("John");
127+
}
128+
129+
[Fact]
130+
public void UsingDynamicLinqTypeTest()
131+
{
132+
var eval = new FormulaEvaluator();
133+
eval.AddVariable("a", "1");
134+
eval.Evaluate("{{EvaluateUtils.ParseAsInt(a).IncrementMe()}}").Should().Be(2);
135+
}
136+
100137
class Customer
101138
{
102139
public int Id { get; set; }
103140
public string Name { get; set; }
104141
public Customer Manager { get; set; }
105142
}
106143
}
144+
145+
[DynamicLinqType]
146+
public static class EvaluateUtils
147+
{
148+
public static int ParseAsInt(string value)
149+
{
150+
if (value == null)
151+
{
152+
return 0;
153+
}
154+
155+
return int.Parse(value);
156+
}
157+
158+
public static int IncrementMe(this int values)
159+
{
160+
return values + 1;
161+
}
162+
}
107163
}

0 commit comments

Comments
 (0)