Skip to content

Commit 96fb650

Browse files
authored
Merge pull request #96 from codingseb/dev
Dev
2 parents 870d79f + 26193fa commit 96fb650

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

CodingSeb.ExpressionEvaluator.Tests/ExpressionEvaluatorTests.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2466,7 +2466,7 @@ ExpressionEvaluator evaluatorForMethodArgs()
24662466

24672467
#endregion
24682468

2469-
#region Bug resolution
2469+
#region Issues/Bug resolution
24702470

24712471
yield return new TestCaseData(new ExpressionEvaluator()
24722472
, "(new List<Regex>()).GetType()"
@@ -2504,6 +2504,17 @@ ExpressionEvaluator evaluatorForMethodArgs()
25042504

25052505
// end of bug #65
25062506

2507+
// For Issue Manage nested class and enum #95
2508+
2509+
yield return new TestCaseData(new ExpressionEvaluator()
2510+
, "Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)"
2511+
, null)
2512+
.Returns(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData))
2513+
.SetCategory("Bug resolution")
2514+
.SetCategory("NestedType");
2515+
2516+
// end of issue #95
2517+
25072518
#endregion
25082519
}
25092520
}

CodingSeb.ExpressionEvaluator/ExpressionEvaluator.cs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/******************************************************************************************************
22
Title : ExpressionEvaluator (https://github.com/codingseb/ExpressionEvaluator)
3-
Version : 1.4.24.0
3+
Version : 1.4.26.0
44
(if last digit (the forth) is not a zero, the version is an intermediate version and can be unstable)
55
66
Author : Coding Seb
@@ -2442,6 +2442,7 @@ where method.GetParameters()[0].ParameterType == objType // static extMethod(thi
24422442
string typeName = $"{varFuncName}{((i < expression.Length && expression.Substring(i)[0] == '?') ? "?" : "") }";
24432443
Type staticType = GetTypeByFriendlyName(typeName, genericsTypes);
24442444

2445+
// For inline namespace parsing
24452446
if (staticType == null && OptionInlineNamespacesEvaluationActive)
24462447
{
24472448
int subIndex = 0;
@@ -2471,6 +2472,38 @@ where method.GetParameters()[0].ParameterType == objType // static extMethod(thi
24712472
}
24722473
}
24732474

2475+
// For nested type parsing
2476+
if (staticType != null)
2477+
{
2478+
int subIndex = 0;
2479+
Match nestedTypeMatch = varOrFunctionRegEx.Match(expression.Substring(i + subIndex));
2480+
Type nestedType = null;
2481+
2482+
while (nestedTypeMatch.Success
2483+
&& !nestedTypeMatch.Groups["sign"].Success
2484+
&& !nestedTypeMatch.Groups["assignationOperator"].Success
2485+
&& !nestedTypeMatch.Groups["postfixOperator"].Success
2486+
&& !nestedTypeMatch.Groups["isfunction"].Success
2487+
&& i + nestedTypeMatch.Length < expression.Length)
2488+
{
2489+
typeName += $"+{nestedTypeMatch.Groups["name"].Value}";
2490+
2491+
nestedType = GetTypeByFriendlyName(typeName, nestedTypeMatch.Groups["isgeneric"].Value);
2492+
2493+
if (nestedType != null)
2494+
{
2495+
i += nestedTypeMatch.Length;
2496+
staticType = nestedType;
2497+
}
2498+
else
2499+
{
2500+
break;
2501+
}
2502+
2503+
nestedTypeMatch = varOrFunctionRegEx.Match(expression.Substring(i + subIndex));
2504+
}
2505+
}
2506+
24742507
if (typeName.EndsWith("?") && staticType != null)
24752508
i++;
24762509

0 commit comments

Comments
 (0)