Skip to content

Commit da0a8d2

Browse files
authored
Merge pull request #47 from codingseb/dev
Dev
2 parents ed39cbc + 256006a commit da0a8d2

File tree

5 files changed

+153
-56
lines changed

5 files changed

+153
-56
lines changed

CodingSeb.ExpressionEvaluator.Tests/CodingSeb.ExpressionEvaluator.Tests.csproj

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@
44
<Company>Coding Seb</Company>
55
<Product>CodingSeb.ExpressionEvaluator.Tests</Product>
66
<Copyright>Copyright © Coding Seb 2018</Copyright>
7-
<TargetFrameworks>net45;netcoreapp2.0</TargetFrameworks>
7+
<TargetFrameworks>net45;netcoreapp2.1</TargetFrameworks>
8+
<UserSecretsId>c4ac27fa-8b9c-4784-a284-7a9a06320537</UserSecretsId>
89
</PropertyGroup>
910
<ItemGroup>
10-
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
11-
<PackageReference Include="NUnit" Version="3.11.0" />
12-
<PackageReference Include="NUnit3TestAdapter" Version="3.11.2" />
11+
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
12+
<PackageReference Include="NUnit" Version="3.12.0" />
13+
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1">
14+
<PrivateAssets>all</PrivateAssets>
15+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
16+
</PackageReference>
1317
<PackageReference Include="Shouldly" Version="3.0.2" />
1418
</ItemGroup>
1519
<ItemGroup>

CodingSeb.ExpressionEvaluator.Tests/ExpressionEvaluatorTests.cs

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,7 +1338,7 @@ public static IEnumerable<TestCaseData> TestCasesForExceptionThrowingEvaluation
13381338

13391339
evaluator = new ExpressionEvaluator()
13401340
{
1341-
OptionStaticProperiesGetActive = false
1341+
OptionStaticPropertiesGetActive = false
13421342
};
13431343

13441344
evaluator.Namespaces.Add(typeof(ClassForTest1).Namespace);
@@ -1366,7 +1366,7 @@ public static IEnumerable<TestCaseData> TestCasesForExceptionThrowingEvaluation
13661366

13671367
evaluator = new ExpressionEvaluator()
13681368
{
1369-
OptionInstanceProperiesGetActive = false
1369+
OptionInstancePropertiesGetActive = false
13701370
};
13711371

13721372
evaluator.Variables["customObject"] = new ClassForTest1();
@@ -1742,7 +1742,7 @@ void Evaluator_PreEvaluateVariable(object sender, VariablePreEvaluationEventArg
17421742

17431743
#endregion
17441744

1745-
#region with Context object
1745+
#region With Context object
17461746

17471747
ExpressionEvaluator evaluatorWithContext = new ExpressionEvaluator(new ContextObject1());
17481748

@@ -1780,6 +1780,54 @@ void Evaluator_PreEvaluateVariable(object sender, VariablePreEvaluationEventArg
17801780

17811781
#endregion
17821782

1783+
#region NonPublic members
1784+
1785+
ExpressionEvaluator nonPublicEvaluator = new ExpressionEvaluator(new Dictionary<string, object>()
1786+
{
1787+
{ "obj", new ClassWithNonPublicMembersAndMethods() }
1788+
})
1789+
{
1790+
OptionAllowNonPublicMembersAccess = true
1791+
};
1792+
1793+
yield return new TestCaseData(nonPublicEvaluator
1794+
, "obj.myPrivateField"
1795+
, null)
1796+
.Returns(5)
1797+
.SetCategory("NonPublic Members and methods");
1798+
1799+
yield return new TestCaseData(nonPublicEvaluator
1800+
, "obj.myProtectedField"
1801+
, null)
1802+
.Returns(10)
1803+
.SetCategory("NonPublic Members and methods");
1804+
1805+
yield return new TestCaseData(nonPublicEvaluator
1806+
, "obj.MyPrivateProperty"
1807+
, null)
1808+
.Returns(15)
1809+
.SetCategory("NonPublic Members and methods");
1810+
1811+
yield return new TestCaseData(nonPublicEvaluator
1812+
, "obj.MyProtectedProperty"
1813+
, null)
1814+
.Returns(20)
1815+
.SetCategory("NonPublic Members and methods");
1816+
1817+
yield return new TestCaseData(nonPublicEvaluator
1818+
, "obj.MyPrivateMethod(\"Bob\")"
1819+
, null)
1820+
.Returns("Hello Bob")
1821+
.SetCategory("NonPublic Members and methods");
1822+
1823+
yield return new TestCaseData(nonPublicEvaluator
1824+
, "obj.MyProtectedMethod(\"Bob\")"
1825+
, null)
1826+
.Returns("GoodBye Bob")
1827+
.SetCategory("NonPublic Members and methods");
1828+
1829+
#endregion
1830+
17831831
#region inherits ExpressionEvaluator
17841832

17851833
#region Redefine existing operators
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
namespace CodingSeb.ExpressionEvaluator.Tests
2+
{
3+
public class ClassWithNonPublicMembersAndMethods
4+
{
5+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "RCS1169:Make field read-only.", Justification = "<Pending>")]
6+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Redundancy", "RCS1213:Remove unused member declaration.", Justification = "<Pending>")]
7+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0044:Add readonly modifier", Justification = "<Pending>")]
8+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Code Quality", "IDE0051:Remove unused private members", Justification = "<Pending>")]
9+
private int myPrivateField = 5;
10+
11+
protected int myProtectedField = 10;
12+
13+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "RCS1170:Use read-only auto-implemented property.", Justification = "<Pending>")]
14+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Redundancy", "RCS1213:Remove unused member declaration.", Justification = "<Pending>")]
15+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Code Quality", "IDE0051:Remove unused private members", Justification = "<Pending>")]
16+
private int MyPrivateProperty { get; set; } = 15;
17+
18+
protected int MyProtectedProperty { get; set; } = 20;
19+
20+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Redundancy", "RCS1213:Remove unused member declaration.", Justification = "<Pending>")]
21+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Code Quality", "IDE0051:Remove unused private members", Justification = "<Pending>")]
22+
private string MyPrivateMethod(string name)
23+
{
24+
return "Hello " + name;
25+
}
26+
27+
protected string MyProtectedMethod(string name)
28+
{
29+
return "GoodBye " + name;
30+
}
31+
}
32+
}

CodingSeb.ExpressionEvaluator/CodingSeb.ExpressionEvaluator.csproj

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
<Product>CodingSeb.ExpressionEvaluator</Product>
66
<Description>A Simple Math and Pseudo C# Expression Evaluator in One C# File. Can also execute small C# like scripts</Description>
77
<Copyright>Copyright © Coding Seb 2017</Copyright>
8-
<Version>1.4.6.0</Version>
9-
<AssemblyVersion>1.4.6.0</AssemblyVersion>
10-
<FileVersion>1.4.6.0</FileVersion>
8+
<Version>1.4.7.0</Version>
9+
<AssemblyVersion>1.4.7.0</AssemblyVersion>
10+
<FileVersion>1.4.7.0</FileVersion>
1111
<OutputPath>bin\$(Configuration)\</OutputPath>
1212
<Authors>Coding Seb</Authors>
1313
<PackageId>CodingSeb.ExpressionEvaluator</PackageId>
@@ -18,7 +18,9 @@
1818
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
1919
<PackageIconUrl>https://github.com/codingseb/ExpressionEvaluator/blob/master/Icon.png?raw=true</PackageIconUrl>
2020
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
21-
<PackageReleaseNotes>* Add a Context object in addition to variables dictionnary on which properties, fields and method are available directly.</PackageReleaseNotes>
21+
<PackageReleaseNotes>* Add OptionAllowNonPublicMembersAccess to use private or protected members of variables and context (By default false)
22+
* Correction of spelling of options : OptionStaticPropertiesGetActive and OptionInstancePropertiesGetActive (Warning breaking change if you use it)
23+
* More of virtual and partial for better extensibility</PackageReleaseNotes>
2224
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
2325
</PropertyGroup>
2426
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">

0 commit comments

Comments
 (0)