From 126ac062e4fee26d0fbd2efbc85c29e7f5a02749 Mon Sep 17 00:00:00 2001 From: Stef Heyenrath Date: Sun, 30 Apr 2017 11:48:41 +0200 Subject: [PATCH] #71 --- ....EntityFrameworkCore.DynamicLinq_Check.htm | 2 +- ...yFrameworkCore.DynamicLinq_CoreStrings.htm | 2 +- ...amicLinq_CustomIntrospectionExtensions.htm | 2 +- ...ynamicLinq_CustomTypeBuilderExtensions.htm | 2 +- ...ityFrameworkDynamicQueryableExtensions.htm | 2 +- ...ore.DynamicLinq_LinqProviderExtensions.htm | 2 +- ...ft.EntityFrameworkCore.DynamicLinq_Res.htm | 2 +- ..._AbstractDynamicLinqCustomTypeProvider.htm | 48 +- ...nq.Dynamic.Core_AssemblyBuilderFactory.htm | 2 +- ...mic.Core_CustomIntrospectionExtensions.htm | 8 +- ...namic.Core_CustomTypeBuilderExtensions.htm | 2 +- ...inq.Dynamic.Core_DefaultAssemblyHelper.htm | 2 +- ...e_DefaultDynamicLinqCustomTypeProvider.htm | 2 +- .../System.Linq.Dynamic.Core_DynamicClass.htm | 2 +- ....Linq.Dynamic.Core_DynamicClassFactory.htm | 2 +- ...namic.Core_DynamicEnumerableExtensions.htm | 2 +- ...q.Dynamic.Core_DynamicExpressionParser.htm | 26 +- ....Dynamic.Core_DynamicLinqTypeAttribute.htm | 2 +- ...stem.Linq.Dynamic.Core_DynamicOrdering.htm | 2 +- ...stem.Linq.Dynamic.Core_DynamicProperty.htm | 2 +- ...ynamic.Core_DynamicQueryableExtensions.htm | 130 +- ...tem.Linq.Dynamic.Core_ExpressionParser.htm | 3847 +++++++++-------- ...m.Linq.Dynamic.Core_ExtensibilityPoint.htm | 4 +- .../System.Linq.Dynamic.Core_GlobalConfig.htm | 10 +- .../System.Linq.Dynamic.Core_GroupResult.htm | 2 +- ...nq.Dynamic.Core_LinqProviderExtensions.htm | 24 +- .../System.Linq.Dynamic.Core_PagedResult.htm | 2 +- ...System.Linq.Dynamic.Core_PagedResult_1.htm | 2 +- ...ystem.Linq.Dynamic.Core_ParseException.htm | 10 +- report/System.Linq.Dynamic.Core_Res.htm | 2 +- .../System.Linq.Dynamic.Core_TextParser.htm | 399 +- report/System.Linq.Dynamic.Core_Token.htm | 10 +- ...Linq.Dynamic.Core_TypeConverterFactory.htm | 2 +- report/combined.js | 4 +- report/index.htm | 22 +- 35 files changed, 2345 insertions(+), 2241 deletions(-) diff --git a/report/Microsoft.EntityFrameworkCore.DynamicLinq_Check.htm b/report/Microsoft.EntityFrameworkCore.DynamicLinq_Check.htm index 4855dd48..76367718 100644 --- a/report/Microsoft.EntityFrameworkCore.DynamicLinq_Check.htm +++ b/report/Microsoft.EntityFrameworkCore.DynamicLinq_Check.htm @@ -184,7 +184,7 @@

 139} - +

Methods/Properties

diff --git a/report/Microsoft.EntityFrameworkCore.DynamicLinq_CoreStrings.htm b/report/Microsoft.EntityFrameworkCore.DynamicLinq_CoreStrings.htm index bc114fb7..e1f27c99 100644 --- a/report/Microsoft.EntityFrameworkCore.DynamicLinq_CoreStrings.htm +++ b/report/Microsoft.EntityFrameworkCore.DynamicLinq_CoreStrings.htm @@ -81,7 +81,7 @@

 41} -

+

Methods/Properties

diff --git a/report/Microsoft.EntityFrameworkCore.DynamicLinq_CustomIntrospectionExtensions.htm b/report/Microsoft.EntityFrameworkCore.DynamicLinq_CustomIntrospectionExtensions.htm index 4fb3439c..79aedf75 100644 --- a/report/Microsoft.EntityFrameworkCore.DynamicLinq_CustomIntrospectionExtensions.htm +++ b/report/Microsoft.EntityFrameworkCore.DynamicLinq_CustomIntrospectionExtensions.htm @@ -76,7 +76,7 @@

 39} -

+

Methods/Properties

diff --git a/report/Microsoft.EntityFrameworkCore.DynamicLinq_CustomTypeBuilderExtensions.htm b/report/Microsoft.EntityFrameworkCore.DynamicLinq_CustomTypeBuilderExtensions.htm index 21681081..7f3a1486 100644 --- a/report/Microsoft.EntityFrameworkCore.DynamicLinq_CustomTypeBuilderExtensions.htm +++ b/report/Microsoft.EntityFrameworkCore.DynamicLinq_CustomTypeBuilderExtensions.htm @@ -72,7 +72,7 @@

 35} -

+

Methods/Properties

diff --git a/report/Microsoft.EntityFrameworkCore.DynamicLinq_EntityFrameworkDynamicQueryableExtensions.htm b/report/Microsoft.EntityFrameworkCore.DynamicLinq_EntityFrameworkDynamicQueryableExtensions.htm index 2e6e3020..a6e635f8 100644 --- a/report/Microsoft.EntityFrameworkCore.DynamicLinq_EntityFrameworkDynamicQueryableExtensions.htm +++ b/report/Microsoft.EntityFrameworkCore.DynamicLinq_EntityFrameworkDynamicQueryableExtensions.htm @@ -700,7 +700,7 @@

 639} -

+

Methods/Properties

diff --git a/report/Microsoft.EntityFrameworkCore.DynamicLinq_LinqProviderExtensions.htm b/report/Microsoft.EntityFrameworkCore.DynamicLinq_LinqProviderExtensions.htm index 590d8850..7aa4b078 100644 --- a/report/Microsoft.EntityFrameworkCore.DynamicLinq_LinqProviderExtensions.htm +++ b/report/Microsoft.EntityFrameworkCore.DynamicLinq_LinqProviderExtensions.htm @@ -90,7 +90,7 @@

 51} -

+

Methods/Properties

diff --git a/report/Microsoft.EntityFrameworkCore.DynamicLinq_Res.htm b/report/Microsoft.EntityFrameworkCore.DynamicLinq_Res.htm index fe935ee9..b0d45039 100644 --- a/report/Microsoft.EntityFrameworkCore.DynamicLinq_Res.htm +++ b/report/Microsoft.EntityFrameworkCore.DynamicLinq_Res.htm @@ -25,6 +25,6 @@

Summary

File(s)

No files found. This usually happens if a file isn't covered by a test or the class does not contain any sequence points (e.g. a class that only contains auto properties).

-
+ \ No newline at end of file diff --git a/report/System.Linq.Dynamic.Core_AbstractDynamicLinqCustomTypeProvider.htm b/report/System.Linq.Dynamic.Core_AbstractDynamicLinqCustomTypeProvider.htm index f7cfb11a..eccb7dae 100644 --- a/report/System.Linq.Dynamic.Core_AbstractDynamicLinqCustomTypeProvider.htm +++ b/report/System.Linq.Dynamic.Core_AbstractDynamicLinqCustomTypeProvider.htm @@ -55,19 +55,19 @@

 16        /// <param name="assemblies">The assemblies to process.</param>  17        /// <returns>IEnumerable{Type}</returns>  18        protected IEnumerable<Type> FindTypesMarkedWithDynamicLinqTypeAttribute([NotNull] IEnumerable<Assembly> assembli - 1419        { - 1420            Check.NotNull(assemblies, nameof(assemblies)); + 1619        { + 1620            Check.NotNull(assemblies, nameof(assemblies));  21#if !NET35 - 242222            assemblies = assemblies.Where(x => !x.IsDynamic); + 276822            assemblies = assemblies.Where(x => !x.IsDynamic);  23#endif - 1424            var definedTypes = GetAssemblyTypes(assemblies); + 1624            var definedTypes = GetAssemblyTypes(assemblies);  25  26#if (WINDOWS_APP || DOTNET5_1 || UAP10_0 || NETSTANDARD) - 39716627            return definedTypes.Where(x => x.CustomAttributes.Any(y => y.AttributeType == typeof(DynamicLinqTypeAttribut + 45404827            return definedTypes.Where(x => x.CustomAttributes.Any(y => y.AttributeType == typeof(DynamicLinqTypeAttribut  28#else  29            return definedTypes.Where(x => x.GetCustomAttributes(typeof(DynamicLinqTypeAttribute), false).Any());  30#endif - 1431        } + 1631        }  32  33#if (WINDOWS_APP || DOTNET5_1 || UAP10_0 || NETSTANDARD)  34        /// <summary> @@ -76,29 +76,29 @@

 37        /// <param name="assemblies">The assemblies to process.</param>  38        /// <returns>IEnumerable{Type}</returns>  39        protected IEnumerable<TypeInfo> GetAssemblyTypes([NotNull] IEnumerable<Assembly> assemblies) - 1440        { - 1441            Check.NotNull(assemblies, nameof(assemblies)); + 1640        { + 1641            Check.NotNull(assemblies, nameof(assemblies));  42 - 485843            foreach (var assembly in assemblies) - 240844            { - 240845                IEnumerable<TypeInfo> definedTypes = null; + 555243            foreach (var assembly in assemblies) + 275244            { + 275245                IEnumerable<TypeInfo> definedTypes = null;  46  47                try - 240848                { - 240849                    definedTypes = assembly.DefinedTypes; - 240850                } + 275248                { + 275249                    definedTypes = assembly.DefinedTypes; + 275250                }  051                catch (Exception)  052                { }  53 - 240854                 if (definedTypes != null) - 240855                { - 54401256                    foreach (var definedType in definedTypes) - 26839457                    { - 26839458                        yield return definedType; - 26839459                    } - 240860                } - 240861            } - 1462        } + 275254                 if (definedTypes != null) + 275255                { + 62188856                    foreach (var definedType in definedTypes) + 30681657                    { + 30681658                        yield return definedType; + 30681659                    } + 275260                } + 275261            } + 1662        }  63#else  64        /// <summary>  65        /// Gets the assembly types in an Exception friendly way. @@ -134,7 +134,7 @@

 95} - +

Methods/Properties

diff --git a/report/System.Linq.Dynamic.Core_AssemblyBuilderFactory.htm b/report/System.Linq.Dynamic.Core_AssemblyBuilderFactory.htm index be52dbaa..c69b8644 100644 --- a/report/System.Linq.Dynamic.Core_AssemblyBuilderFactory.htm +++ b/report/System.Linq.Dynamic.Core_AssemblyBuilderFactory.htm @@ -62,7 +62,7 @@

 25#endif -

+

Methods/Properties

diff --git a/report/System.Linq.Dynamic.Core_CustomIntrospectionExtensions.htm b/report/System.Linq.Dynamic.Core_CustomIntrospectionExtensions.htm index bf079018..b6a0039c 100644 --- a/report/System.Linq.Dynamic.Core_CustomIntrospectionExtensions.htm +++ b/report/System.Linq.Dynamic.Core_CustomIntrospectionExtensions.htm @@ -68,15 +68,15 @@

 31        }  32#else  33        public static Type[] GetGenericTypeArguments(this TypeInfo typeInfo) - 300134        { - 300135            return typeInfo.GenericTypeArguments; - 300136        } + 327634        { + 327635            return typeInfo.GenericTypeArguments; + 327636        }  37#endif  38    }  39} -

+

Methods/Properties

diff --git a/report/System.Linq.Dynamic.Core_CustomTypeBuilderExtensions.htm b/report/System.Linq.Dynamic.Core_CustomTypeBuilderExtensions.htm index bebb679b..094003e5 100644 --- a/report/System.Linq.Dynamic.Core_CustomTypeBuilderExtensions.htm +++ b/report/System.Linq.Dynamic.Core_CustomTypeBuilderExtensions.htm @@ -72,7 +72,7 @@

 35} -

+

Methods/Properties

diff --git a/report/System.Linq.Dynamic.Core_DefaultAssemblyHelper.htm b/report/System.Linq.Dynamic.Core_DefaultAssemblyHelper.htm index 004f1719..59d8ed36 100644 --- a/report/System.Linq.Dynamic.Core_DefaultAssemblyHelper.htm +++ b/report/System.Linq.Dynamic.Core_DefaultAssemblyHelper.htm @@ -81,7 +81,7 @@

 44} -

+

Methods/Properties

diff --git a/report/System.Linq.Dynamic.Core_DefaultDynamicLinqCustomTypeProvider.htm b/report/System.Linq.Dynamic.Core_DefaultDynamicLinqCustomTypeProvider.htm index 404b80d0..4c7a7b34 100644 --- a/report/System.Linq.Dynamic.Core_DefaultDynamicLinqCustomTypeProvider.htm +++ b/report/System.Linq.Dynamic.Core_DefaultDynamicLinqCustomTypeProvider.htm @@ -71,7 +71,7 @@

 32#endif -

+

Methods/Properties

diff --git a/report/System.Linq.Dynamic.Core_DynamicClass.htm b/report/System.Linq.Dynamic.Core_DynamicClass.htm index 659cfdc6..da2a0184 100644 --- a/report/System.Linq.Dynamic.Core_DynamicClass.htm +++ b/report/System.Linq.Dynamic.Core_DynamicClass.htm @@ -372,7 +372,7 @@

 328#endif -

+

Methods/Properties

diff --git a/report/System.Linq.Dynamic.Core_DynamicClassFactory.htm b/report/System.Linq.Dynamic.Core_DynamicClassFactory.htm index 7453cdcd..45080724 100644 --- a/report/System.Linq.Dynamic.Core_DynamicClassFactory.htm +++ b/report/System.Linq.Dynamic.Core_DynamicClassFactory.htm @@ -415,7 +415,7 @@

 375#endif -

+

Methods/Properties

diff --git a/report/System.Linq.Dynamic.Core_DynamicEnumerableExtensions.htm b/report/System.Linq.Dynamic.Core_DynamicEnumerableExtensions.htm index ec6909af..e50af335 100644 --- a/report/System.Linq.Dynamic.Core_DynamicEnumerableExtensions.htm +++ b/report/System.Linq.Dynamic.Core_DynamicEnumerableExtensions.htm @@ -180,7 +180,7 @@

 135} -

+

Methods/Properties

diff --git a/report/System.Linq.Dynamic.Core_DynamicExpressionParser.htm b/report/System.Linq.Dynamic.Core_DynamicExpressionParser.htm index ffe26e67..d88b0b88 100644 --- a/report/System.Linq.Dynamic.Core_DynamicExpressionParser.htm +++ b/report/System.Linq.Dynamic.Core_DynamicExpressionParser.htm @@ -107,12 +107,12 @@

 65        /// <returns>The generated <see cref="LambdaExpression"/></returns>  66        [PublicAPI]  67        public static LambdaExpression ParseLambda(bool createParameterCtor, [NotNull] Type itType, [CanBeNull] Type res - 31868        { - 31869            Check.NotNull(itType, nameof(itType)); - 31870            Check.NotEmpty(expression, nameof(expression)); + 33368        { + 33369            Check.NotNull(itType, nameof(itType)); + 33370            Check.NotEmpty(expression, nameof(expression));  71 - 31872            return ParseLambda(createParameterCtor, new[] { Expression.Parameter(itType, "") }, resultType, expression,  - 29073        } + 33372            return ParseLambda(createParameterCtor, new[] { Expression.Parameter(itType, "") }, resultType, expression,  + 30173        }  74  75        /// <summary>  76        /// Parses a expression into a LambdaExpression. (Also create a constructor for all the parameters. Note that th @@ -139,20 +139,20 @@

 97        /// <returns>The generated <see cref="LambdaExpression"/></returns>  98        [PublicAPI]  99        public static LambdaExpression ParseLambda(bool createParameterCtor, [NotNull] ParameterExpression[] parameters, - 331100        { - 331101            Check.NotEmpty(parameters, nameof(parameters)); - 998102            Check.Condition(parameters, p => p.Count(x => x == null) == 0, nameof(parameters)); - 331103            Check.NotEmpty(expression, nameof(expression)); + 346100        { + 346101            Check.NotEmpty(parameters, nameof(parameters)); + 1043102            Check.Condition(parameters, p => p.Count(x => x == null) == 0, nameof(parameters)); + 346103            Check.NotEmpty(expression, nameof(expression));  104 - 331105            var parser = new ExpressionParser(parameters, expression, values); + 346105            var parser = new ExpressionParser(parameters, expression, values);  106 - 331107            return Expression.Lambda(parser.Parse(resultType, createParameterCtor), parameters); - 302108        } + 346107            return Expression.Lambda(parser.Parse(resultType, createParameterCtor), parameters); + 313108        }  109    }  110} -

+

Methods/Properties

diff --git a/report/System.Linq.Dynamic.Core_DynamicLinqTypeAttribute.htm b/report/System.Linq.Dynamic.Core_DynamicLinqTypeAttribute.htm index f3732f13..bafa4ada 100644 --- a/report/System.Linq.Dynamic.Core_DynamicLinqTypeAttribute.htm +++ b/report/System.Linq.Dynamic.Core_DynamicLinqTypeAttribute.htm @@ -25,6 +25,6 @@

Summary

File(s)

No files found. This usually happens if a file isn't covered by a test or the class does not contain any sequence points (e.g. a class that only contains auto properties).

-
+ \ No newline at end of file diff --git a/report/System.Linq.Dynamic.Core_DynamicOrdering.htm b/report/System.Linq.Dynamic.Core_DynamicOrdering.htm index 1ad50b4c..583d17bf 100644 --- a/report/System.Linq.Dynamic.Core_DynamicOrdering.htm +++ b/report/System.Linq.Dynamic.Core_DynamicOrdering.htm @@ -25,6 +25,6 @@

Summary

File(s)

No files found. This usually happens if a file isn't covered by a test or the class does not contain any sequence points (e.g. a class that only contains auto properties).

- + \ No newline at end of file diff --git a/report/System.Linq.Dynamic.Core_DynamicProperty.htm b/report/System.Linq.Dynamic.Core_DynamicProperty.htm index 52cb178a..d9ae8350 100644 --- a/report/System.Linq.Dynamic.Core_DynamicProperty.htm +++ b/report/System.Linq.Dynamic.Core_DynamicProperty.htm @@ -72,7 +72,7 @@

 35} - +

Methods/Properties

diff --git a/report/System.Linq.Dynamic.Core_DynamicQueryableExtensions.htm b/report/System.Linq.Dynamic.Core_DynamicQueryableExtensions.htm index 225aa274..6371192a 100644 --- a/report/System.Linq.Dynamic.Core_DynamicQueryableExtensions.htm +++ b/report/System.Linq.Dynamic.Core_DynamicQueryableExtensions.htm @@ -126,23 +126,23 @@

 530        private static readonly Func<MethodInfo, bool> _predicateParameterHas2 = (mi) => mi.GetParameters()[1].ToString(  31  32        private static Expression OptimizeExpression(Expression expression) - 40933        { - 40934             if (ExtensibilityPoint.QueryOptimizer != null) - 40835            { - 40836                var optimized = ExtensibilityPoint.QueryOptimizer(expression); + 42133        { + 42134             if (ExtensibilityPoint.QueryOptimizer != null) + 42035            { + 42036                var optimized = ExtensibilityPoint.QueryOptimizer(expression);  37  38#if !(WINDOWS_APP45x || SILVERLIGHT) - 40839                 if (optimized != expression) + 42039                 if (optimized != expression)  040                {  41                    _ts.TraceEvent(TraceEventType.Verbose, 0, "Expression before : {0}", expression);  42                    _ts.TraceEvent(TraceEventType.Verbose, 0, "Expression after  : {0}", optimized);  043                }  44#endif - 40845                return optimized; + 42045                return optimized;  46            }  47  148            return expression; - 40949        } + 42149        }  50  51        #region Any  152        private static readonly MethodInfo _any = GetMethod(nameof(Queryable.Any)); @@ -233,11 +233,11 @@

 137        /// </example>  138        /// <returns>The number of elements in the input sequence.</returns>  139        public static int Count([NotNull] this IQueryable source) - 31140        { - 31141            Check.NotNull(source, nameof(source)); + 32140        { + 32141            Check.NotNull(source, nameof(source));  142 - 31143            return Execute<int>(_count, source); - 31144        } + 32143            return Execute<int>(_count, source); + 32144        }  145  1146        private static readonly MethodInfo _countPredicate = GetMethod(nameof(Queryable.Count), 1);  147 @@ -833,21 +833,21 @@

 737        /// </code>  738        /// </example>  739        public static IQueryable Select([NotNull] this IQueryable source, [NotNull] string selector, params object[] arg - 77740        { - 77741            Check.NotNull(source, nameof(source)); - 76742            Check.NotEmpty(selector, nameof(selector)); + 83740        { + 83741            Check.NotNull(source, nameof(source)); + 82742            Check.NotEmpty(selector, nameof(selector));  743 - 73744            bool createParameterCtor = source.IsLinqToObjects(); - 73745            LambdaExpression lambda = DynamicExpressionParser.ParseLambda(createParameterCtor, source.ElementType, null, + 79744            bool createParameterCtor = source.IsLinqToObjects(); + 79745            LambdaExpression lambda = DynamicExpressionParser.ParseLambda(createParameterCtor, source.ElementType, null,  746 - 66747            var optimized = OptimizeExpression(Expression.Call( - 66748                typeof(Queryable), nameof(Queryable.Select), - 66749                new[] { source.ElementType, lambda.Body.Type }, - 66750                source.Expression, Expression.Quote(lambda)) - 66751            ); + 72747            var optimized = OptimizeExpression(Expression.Call( + 72748                typeof(Queryable), nameof(Queryable.Select), + 72749                new[] { source.ElementType, lambda.Body.Type }, + 72750                source.Expression, Expression.Quote(lambda)) + 72751            );  752 - 66753            return source.Provider.CreateQuery(optimized); - 66754        } + 72753            return source.Provider.CreateQuery(optimized); + 72754        }  755  756        /// <summary>  757        /// Projects each element of a sequence into a new class of type TResult. @@ -927,12 +927,12 @@

 831        /// </code>  832        /// </example>  833        public static IQueryable SelectMany([NotNull] this IQueryable source, [NotNull] string selector, params object[] - 6834        { - 6835            Check.NotNull(source, nameof(source)); - 6836            Check.NotEmpty(selector, nameof(selector)); + 13834        { + 13835            Check.NotNull(source, nameof(source)); + 13836            Check.NotEmpty(selector, nameof(selector));  837 - 6838            return SelectManyInternal(source, null, selector, args); - 6839        } + 13838            return SelectManyInternal(source, null, selector, args); + 11839        }  840  841        /// <summary>  842        /// Projects each element of a sequence to an <see cref="IQueryable"/> and combines the resulting sequences into @@ -957,38 +957,38 @@

 2861        }  862  863        private static IQueryable SelectManyInternal(IQueryable source, Type resultType, string selector, params object[ - 8864        { - 8865            bool createParameterCtor = source.IsLinqToObjects(); - 8866            LambdaExpression lambda = DynamicExpressionParser.ParseLambda(createParameterCtor, source.ElementType, null, + 15864        { + 15865            bool createParameterCtor = source.IsLinqToObjects(); + 15866            LambdaExpression lambda = DynamicExpressionParser.ParseLambda(createParameterCtor, source.ElementType, null,  867  868            //Extra help to get SelectMany to work from StackOverflow Answer  869            //http://stackoverflow.com/a/3001674/2465182  870  871            // if resultType is not specified, create one based on the lambda.Body.Type - 8872             if (resultType == null) - 6873            { + 13872             if (resultType == null) + 11873            {  874                // SelectMany assumes that lambda.Body.Type is a generic type and throws an exception on  875                // lambda.Body.Type.GetGenericArguments()[0] when used over an array as GetGenericArguments() returns an - 6876                 if (lambda.Body.Type.IsArray) - 1877                    resultType = lambda.Body.Type.GetElementType(); + 11876                 if (lambda.Body.Type.IsArray) + 6877                    resultType = lambda.Body.Type.GetElementType();  878                else  5879                    resultType = lambda.Body.Type.GetGenericArguments()[0]; - 6880            } + 11880            }  881  882            //we have to adjust to lambda to return an IEnumerable<T> instead of whatever the actual property is. - 8883            Type enumerableType = typeof(IEnumerable<>).MakeGenericType(resultType); - 8884            Type inputType = source.Expression.Type.GetTypeInfo().GetGenericTypeArguments()[0]; - 8885            Type delegateType = typeof(Func<,>).MakeGenericType(inputType, enumerableType); - 8886            lambda = Expression.Lambda(delegateType, lambda.Body, lambda.Parameters); + 13883            Type enumerableType = typeof(IEnumerable<>).MakeGenericType(resultType); + 13884            Type inputType = source.Expression.Type.GetTypeInfo().GetGenericTypeArguments()[0]; + 13885            Type delegateType = typeof(Func<,>).MakeGenericType(inputType, enumerableType); + 13886            lambda = Expression.Lambda(delegateType, lambda.Body, lambda.Parameters);  887 - 8888            var optimized = OptimizeExpression(Expression.Call( - 8889                typeof(Queryable), "SelectMany", - 8890                new[] { source.ElementType, resultType }, - 8891                source.Expression, Expression.Quote(lambda)) - 8892            ); + 13888            var optimized = OptimizeExpression(Expression.Call( + 13889                typeof(Queryable), "SelectMany", + 13890                new[] { source.ElementType, resultType }, + 13891                source.Expression, Expression.Quote(lambda)) + 13892            );  893 - 8894            return source.Provider.CreateQuery(optimized); - 8895        } + 13894            return source.Provider.CreateQuery(optimized); + 13895        }  896  897        /// <summary>  898        /// Projects each element of a sequence to an <see cref="IQueryable{TResult}"/> and combines the resulting seque @@ -1351,11 +1351,11 @@

 1255        /// </code>  1256        /// </example>  1257        public static IQueryable<TSource> Where<TSource>([NotNull] this IQueryable<TSource> source, [NotNull] string pre - 1591258        { - 1591259            Check.NotNull(source, nameof(source)); - 1591260            Check.NotEmpty(predicate, nameof(predicate)); + 1611258        { + 1611259            Check.NotNull(source, nameof(source)); + 1611260            Check.NotEmpty(predicate, nameof(predicate));  1261 - 1561262            return (IQueryable<TSource>)Where((IQueryable)source, predicate, args); + 1581262            return (IQueryable<TSource>)Where((IQueryable)source, predicate, args);  1401263        }  1264  1265        /// <summary> @@ -1375,12 +1375,12 @@

 1279        /// </code>  1280        /// </example>  1281        public static IQueryable Where([NotNull] this IQueryable source, [NotNull] string predicate, params object[] arg - 1601282        { - 1601283            Check.NotNull(source, nameof(source)); - 1591284            Check.NotEmpty(predicate, nameof(predicate)); + 1621282        { + 1621283            Check.NotNull(source, nameof(source)); + 1611284            Check.NotEmpty(predicate, nameof(predicate));  1285 - 1591286            bool createParameterCtor = source.IsLinqToObjects(); - 1591287            LambdaExpression lambda = DynamicExpressionParser.ParseLambda(createParameterCtor, source.ElementType, typeo + 1611286            bool createParameterCtor = source.IsLinqToObjects(); + 1611287            LambdaExpression lambda = DynamicExpressionParser.ParseLambda(createParameterCtor, source.ElementType, typeo  1288  1431289            var optimized = OptimizeExpression(Expression.Call(typeof(Queryable), "Where", new[] { source.ElementType },  1431290            return source.Provider.CreateQuery(optimized); @@ -1425,15 +1425,15 @@

 181329        }  1330  1331        private static TResult Execute<TResult>(MethodInfo operatorMethodInfo, IQueryable source) - 411332        { - 411333             if (operatorMethodInfo.IsGenericMethod) - 411334            { - 411335                operatorMethodInfo = operatorMethodInfo.MakeGenericMethod(source.ElementType); - 411336            } + 421332        { + 421333             if (operatorMethodInfo.IsGenericMethod) + 421334            { + 421335                operatorMethodInfo = operatorMethodInfo.MakeGenericMethod(source.ElementType); + 421336            }  1337 - 411338            var optimized = OptimizeExpression(Expression.Call(null, operatorMethodInfo, source.Expression)); - 411339            return source.Provider.Execute<TResult>(optimized); - 411340        } + 421338            var optimized = OptimizeExpression(Expression.Call(null, operatorMethodInfo, source.Expression)); + 421339            return source.Provider.Execute<TResult>(optimized); + 421340        }  1341  1342        private static object Execute(MethodInfo operatorMethodInfo, IQueryable source, LambdaExpression expression)  41343            => Execute(operatorMethodInfo, source, Expression.Quote(expression)); @@ -1471,7 +1471,7 @@

 1375} -

+

Methods/Properties

diff --git a/report/System.Linq.Dynamic.Core_ExpressionParser.htm b/report/System.Linq.Dynamic.Core_ExpressionParser.htm index fc6b52b9..8970ccc0 100644 --- a/report/System.Linq.Dynamic.Core_ExpressionParser.htm +++ b/report/System.Linq.Dynamic.Core_ExpressionParser.htm @@ -16,12 +16,12 @@

Summary

Class:System.Linq.Dynamic.Core.ExpressionParser Assembly:System.Linq.Dynamic.Core File(s):C:\Users\Stef\Documents\GitHub\System.Linq.Dynamic.Core\src\System.Linq.Dynamic.Core\ExpressionParser.cs -Covered lines:1268 -Uncovered lines:196 -Coverable lines:1464 -Total lines:2611 -Line coverage:86.6% -Branch coverage:73.4% +Covered lines:1323 +Uncovered lines:187 +Coverable lines:1510 +Total lines:2670 +Line coverage:87.6% +Branch coverage:75.3%

Metrics

@@ -54,7 +54,7 @@

Metrics

ParsePrimary()34100100 ParsePrimaryStart()7988.8960 ParseStringLiteral()3461.5440 -ParseIntegerLiteral()226553684.9175.76 +ParseIntegerLiteral()32419430488.0682.22 ParseRealLiteral()10100100 TryParseAsFloat(...)44100100 TryParseAsDouble(...)5891.6785.71 @@ -66,14 +66,15 @@

Metrics

ParseRoot()2283.3366.67 ParseIif()2287.566.67 GenerateConditional(...)1651258.3342.11 -ParseNew()1325693.0282.35 +ParseNew()20409696.5592 +CreateArrayInitializerExpression(...)51610077.78 CreateNewExpression(...)61694.1288.89 ParseLambdaInvocation(...)2200 ParseTypeAccess(...)13102490.3271.43 GenerateConversion(...)2140964444 ParseMemberAccess(...)18409688.8980 FindGenericType(...)81610088.89 -FindType(...)1412868.4260 +FindType(...)1412873.6866.67 ParseAggregate(...)126497.7892.31 ParseArgumentList()22100100 ParseArguments()22100100 @@ -100,7 +101,7 @@

Metrics

FindBestMethod(...)58100100 IsApplicable(...)51694.7488.89 PromoteExpression(...)191638495.3593.10 -ParseNumber(...)23419430461.0257.78 +ParseNumber(...)23419430471.1971.11 ParseEnum(...)2266.6766.67 IsCompatibleWith(...)71167772169593.88 IsBetterThan(...)51693.7577.78 @@ -421,41 +422,41 @@

 0287        }  288        private readonly TextParser _textParser;  289 - 357290        public ExpressionParser(ParameterExpression[] parameters, string expression, object[] values) - 357291        { - 357292             if (_keywords == null) - 12293                _keywords = CreateKeywords(); + 372290        public ExpressionParser(ParameterExpression[] parameters, string expression, object[] values) + 372291        { + 372292             if (_keywords == null) + 14293                _keywords = CreateKeywords();  294 - 357295            _symbols = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase); - 357296            _internals = new Dictionary<string, object>(); - 357297            _literals = new Dictionary<Expression, string>(); + 372295            _symbols = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase); + 372296            _internals = new Dictionary<string, object>(); + 372297            _literals = new Dictionary<Expression, string>();  298 - 357299             if (parameters != null) - 357300                ProcessParameters(parameters); + 372299             if (parameters != null) + 372300                ProcessParameters(parameters);  301 - 357302             if (values != null) - 347303                ProcessValues(values); + 372302             if (values != null) + 362303                ProcessValues(values);  304 - 357305            _textParser = new TextParser(expression); - 357306        } + 372305            _textParser = new TextParser(expression); + 372306        }  307  308        void ProcessParameters(ParameterExpression[] parameters) - 357309        { - 1789310            foreach (ParameterExpression pe in parameters) - 359311                 if (!string.IsNullOrEmpty(pe.Name)) + 372309        { + 1864310            foreach (ParameterExpression pe in parameters) + 374311                 if (!string.IsNullOrEmpty(pe.Name))  18312                    AddSymbol(pe.Name, pe); - 357313             if (parameters.Length == 1 && string.IsNullOrEmpty(parameters[0].Name)) - 341314            { - 341315                _parent = _it; - 341316                _it = parameters[0]; - 341317                 if (_root == null) - 341318                    _root = _it; - 341319            } - 357320        } + 372313             if (parameters.Length == 1 && string.IsNullOrEmpty(parameters[0].Name)) + 356314            { + 356315                _parent = _it; + 356316                _it = parameters[0]; + 356317                 if (_root == null) + 356318                    _root = _it; + 356319            } + 372320        }  321  322        void ProcessValues(object[] values) - 347323        { - 866324             for (int i = 0; i < values.Length; i++) + 362323        { + 896324             for (int i = 0; i < values.Length; i++)  86325            {  86326                object value = values[i];  327                IDictionary<string, object> externals; @@ -469,7 +470,7 @@

 83335                    AddSymbol("@" + i.ToString(CultureInfo.InvariantCulture), value);  83336                }  86337            } - 347338        } + 362338        }  339  340        void AddSymbol(string name, object value)  101341        { @@ -481,25 +482,25 @@

 347        private Type _resultType;  348        private bool _createParameterCtor;  349        public Expression Parse(Type resultType, bool createParameterCtor) - 334350        { - 334351            _resultType = resultType; - 334352            _createParameterCtor = createParameterCtor; + 349350        { + 349351            _resultType = resultType; + 349352            _createParameterCtor = createParameterCtor;  353 - 334354            int exprPos = _textParser.CurrentToken.Pos; - 334355            Expression expr = ParseConditionalOperator(); + 349354            int exprPos = _textParser.CurrentToken.Pos; + 349355            Expression expr = ParseConditionalOperator();  356 - 309357             if (resultType != null) - 175358            { - 175359                 if ((expr = PromoteExpression(expr, resultType, true, false)) == null) + 321357             if (resultType != null) + 176358            { + 176359                 if ((expr = PromoteExpression(expr, resultType, true, false)) == null)  1360                {  1361                    throw ParseError(exprPos, Res.ExpressionTypeMismatch, GetTypeName(resultType));  362                } - 174363            } + 175363            }  364 - 308365            _textParser.ValidateToken(TokenId.End, Res.SyntaxError); + 320365            _textParser.ValidateToken(TokenId.End, Res.SyntaxError);  366 - 305367            return expr; - 305368        } + 316367            return expr; + 316368        }  369  370#pragma warning disable 0219  371        public IList<DynamicOrdering> ParseOrdering(bool forceThenBy = false) @@ -540,10 +541,10 @@

 406  407        // ?: operator  408        Expression ParseConditionalOperator() - 546409        { - 546410            int errorPos = _textParser.CurrentToken.Pos; - 546411            Expression expr = ParseNullCoalescingOperator(); - 517412             if (_textParser.CurrentToken.Id == TokenId.Question) + 576409        { + 576410            int errorPos = _textParser.CurrentToken.Pos; + 576411            Expression expr = ParseNullCoalescingOperator(); + 544412             if (_textParser.CurrentToken.Id == TokenId.Question)  1413            {  1414                _textParser.NextToken();  1415                Expression expr1 = ParseConditionalOperator(); @@ -552,27 +553,27 @@

 1418                Expression expr2 = ParseConditionalOperator();  1419                expr = GenerateConditional(expr, expr1, expr2, errorPos);  1420            } - 517421            return expr; - 517422        } + 544421            return expr; + 544422        }  423  424        // ?? (null-coalescing) operator  425        Expression ParseNullCoalescingOperator() - 546426        { - 546427            Expression expr = ParseLambdaOperator(); - 517428             if (_textParser.CurrentToken.Id == TokenId.NullCoalescing) + 576426        { + 576427            Expression expr = ParseLambdaOperator(); + 544428             if (_textParser.CurrentToken.Id == TokenId.NullCoalescing)  6429            {  6430                _textParser.NextToken();  6431                Expression right = ParseConditionalOperator();  6432                expr = Expression.Coalesce(expr, right);  6433            } - 517434            return expr; - 517435        } + 544434            return expr; + 544435        }  436  437        // => operator - Added Support for projection operator  438        Expression ParseLambdaOperator() - 546439        { - 546440            Expression expr = ParseOrOperator(); - 517441             if (_textParser.CurrentToken.Id == TokenId.Lambda && _it.Type == expr.Type) + 576439        { + 576440            Expression expr = ParseOrOperator(); + 544441             if (_textParser.CurrentToken.Id == TokenId.Lambda && _it.Type == expr.Type)  0442            {  0443                _textParser.NextToken();  0444                 if (_textParser.CurrentToken.Id == TokenId.Identifier || @@ -583,8 +584,8 @@

 449                }  0450                _textParser.ValidateToken(TokenId.OpenParen, Res.OpenParenExpected);  0451            } - 517452            return expr; - 517453        } + 544452            return expr; + 544453        }  454  455        // isnull(a,b) operator  456        Expression ParseIsNull() @@ -600,9 +601,9 @@

 466  467        // ||, or operator  468        Expression ParseOrOperator() - 546469        { - 546470            Expression left = ParseAndOperator(); - 530471             while (_textParser.CurrentToken.Id == TokenId.DoubleBar || TokenIdentifierIs("or")) + 576469        { + 576470            Expression left = ParseAndOperator(); + 557471             while (_textParser.CurrentToken.Id == TokenId.DoubleBar || TokenIdentifierIs("or"))  13472            {  13473                Token op = _textParser.CurrentToken;  13474                _textParser.NextToken(); @@ -610,14 +611,14 @@

 13476                CheckAndPromoteOperands(typeof(ILogicalSignatures), op.Text, ref left, ref right, op.Pos);  13477                left = Expression.OrElse(left, right);  13478            } - 517479            return left; - 517480        } + 544479            return left; + 544480        }  481  482        // &&, and operator  483        Expression ParseAndOperator() - 559484        { - 559485            Expression left = ParseIn(); - 536486             while (_textParser.CurrentToken.Id == TokenId.DoubleAmphersand || TokenIdentifierIs("and")) + 589484        { + 589485            Expression left = ParseIn(); + 563486             while (_textParser.CurrentToken.Id == TokenId.DoubleAmphersand || TokenIdentifierIs("and"))  6487            {  6488                Token op = _textParser.CurrentToken;  6489                _textParser.NextToken(); @@ -625,18 +626,18 @@

 6491                CheckAndPromoteOperands(typeof(ILogicalSignatures), op.Text, ref left, ref right, op.Pos);  6492                left = Expression.AndAlso(left, right);  6493            } - 530494            return left; - 530495        } + 557494            return left; + 557495        }  496  497        // in operator for literals - example: "x in (1,2,3,4)"  498        // in operator to mimic contains - example: "x in @0", compare to @0.Contains(x)  499        // Adapted from ticket submitted by github user mlewis9548  500        Expression ParseIn() - 559501        { - 559502            Expression left = ParseLogicalAndOrOperator(); - 534503            Expression accumulate = left; + 589501        { + 589502            Expression left = ParseLogicalAndOrOperator(); + 561503            Expression accumulate = left;  504 - 547505             while (TokenIdentifierIs("in")) + 574505             while (TokenIdentifierIs("in"))  17506            {  17507                var op = _textParser.CurrentToken;  508 @@ -707,14 +708,14 @@

 13573                _textParser.NextToken();  13574            }  575 - 530576            return accumulate; - 530577        } + 557576            return accumulate; + 557577        }  578  579        // &, | bitwise operators  580        Expression ParseLogicalAndOrOperator() - 559581        { - 559582            Expression left = ParseComparisonOperator(); - 541583             while (_textParser.CurrentToken.Id == TokenId.Amphersand || _textParser.CurrentToken.Id == TokenId.Bar) + 589581        { + 589582            Expression left = ParseComparisonOperator(); + 568583             while (_textParser.CurrentToken.Id == TokenId.Amphersand || _textParser.CurrentToken.Id == TokenId.Bar)  7584            {  7585                Token op = _textParser.CurrentToken;  7586                _textParser.NextToken(); @@ -750,26 +751,26 @@

 0616                        break;  617                }  7618            } - 534619            return left; - 534620        } + 561619            return left; + 561620        }  621  622        // =, ==, !=, <>, >, >=, <, <= operators  623        Expression ParseComparisonOperator() - 572624        { - 572625            Expression left = ParseShiftOperator(); - 717626             while (_textParser.CurrentToken.Id == TokenId.Equal || _textParser.CurrentToken.Id == TokenId.DoubleEqual || - 717627                   _textParser.CurrentToken.Id == TokenId.ExclamationEqual || _textParser.CurrentToken.Id == TokenId.Les - 717628                   _textParser.CurrentToken.Id == TokenId.GreaterThan || _textParser.CurrentToken.Id == TokenId.GreaterT - 717629                   _textParser.CurrentToken.Id == TokenId.LessThan || _textParser.CurrentToken.Id == TokenId.LessThanEqu - 170630            { + 602624        { + 602625            Expression left = ParseShiftOperator(); + 746626             while (_textParser.CurrentToken.Id == TokenId.Equal || _textParser.CurrentToken.Id == TokenId.DoubleEqual || + 746627                   _textParser.CurrentToken.Id == TokenId.ExclamationEqual || _textParser.CurrentToken.Id == TokenId.Les + 746628                   _textParser.CurrentToken.Id == TokenId.GreaterThan || _textParser.CurrentToken.Id == TokenId.GreaterT + 746629                   _textParser.CurrentToken.Id == TokenId.LessThan || _textParser.CurrentToken.Id == TokenId.LessThanEqu + 172630            {  631                ConstantExpression constantExpr;  632                TypeConverter typeConverter; - 170633                Token op = _textParser.CurrentToken; - 170634                _textParser.NextToken(); - 169635                Expression right = ParseShiftOperator(); - 165636                bool isEquality = op.Id == TokenId.Equal || op.Id == TokenId.DoubleEqual || op.Id == TokenId.Exclamation + 172633                Token op = _textParser.CurrentToken; + 172634                _textParser.NextToken(); + 170635                Expression right = ParseShiftOperator(); + 166636                bool isEquality = op.Id == TokenId.Equal || op.Id == TokenId.DoubleEqual || op.Id == TokenId.Exclamation  637 - 165638                 if (isEquality && (!left.Type.GetTypeInfo().IsValueType && !right.Type.GetTypeInfo().IsValueType || left + 166638                 if (isEquality && (!left.Type.GetTypeInfo().IsValueType && !right.Type.GetTypeInfo().IsValueType || left  25639                {  25640                     if (left.Type != right.Type)  5641                    { @@ -787,7 +788,7 @@

 653                        }  5654                    }  25655                } - 140656                 else if (IsEnumType(left.Type) || IsEnumType(right.Type)) + 141656                 else if (IsEnumType(left.Type) || IsEnumType(right.Type))  24657                {  24658                     if (left.Type != right.Type)  14659                    { @@ -814,21 +815,21 @@

 680                        }  14681                    }  24682                } - 116683                 else if ((constantExpr = right as ConstantExpression) != null && constantExpr.Value is string && (typeCo + 117683                 else if ((constantExpr = right as ConstantExpression) != null && constantExpr.Value is string && (typeCo  7684                {  7685                    right = Expression.Constant(typeConverter.ConvertFromInvariantString((string)constantExpr.Value), le  7686                } - 109687                 else if ((constantExpr = left as ConstantExpression) != null && constantExpr.Value is string && (typeCon + 110687                 else if ((constantExpr = left as ConstantExpression) != null && constantExpr.Value is string && (typeCon  3688                {  3689                    left = Expression.Constant(typeConverter.ConvertFromInvariantString((string)constantExpr.Value), rig  3690                }  691                else - 106692                { - 106693                     CheckAndPromoteOperands(isEquality ? typeof(IEqualitySignatures) : typeof(IRelationalSignatures), - 106694                        op.Text, ref left, ref right, op.Pos); - 103695                } + 107692                { + 107693                     CheckAndPromoteOperands(isEquality ? typeof(IEqualitySignatures) : typeof(IRelationalSignatures), + 107694                        op.Text, ref left, ref right, op.Pos); + 104695                }  696 - 162697                 switch (op.Id) + 163697                 switch (op.Id)  698                {  699                    case TokenId.Equal:  700                    case TokenId.DoubleEqual: @@ -845,16 +846,16 @@

 3711                        left = GenerateGreaterThanEqual(left, right);  3712                        break;  713                    case TokenId.LessThan: - 4714                        left = GenerateLessThan(left, right); - 4715                        break; + 5714                        left = GenerateLessThan(left, right); + 5715                        break;  716                    case TokenId.LessThanEqual:  4717                        left = GenerateLessThanEqual(left, right);  4718                        break;  719                } - 162720            } + 163720            }  721 - 547722            return left; - 547723        } + 574722            return left; + 574723        }  724  725        private ConstantExpression ParseEnumToConstantExpression(int pos, Type leftType, ConstantExpression constantExpr  14726        { @@ -883,9 +884,9 @@

 749  750        // <<, >> operators  751        Expression ParseShiftOperator() - 741752        { - 741753            Expression left = ParseAdditive(); - 752754             while (_textParser.CurrentToken.Id == TokenId.DoubleLessThan || _textParser.CurrentToken.Id == TokenId.Doubl + 772752        { + 772753            Expression left = ParseAdditive(); + 781754             while (_textParser.CurrentToken.Id == TokenId.DoubleLessThan || _textParser.CurrentToken.Id == TokenId.Doubl  32755            {  32756                Token op = _textParser.CurrentToken;  32757                _textParser.NextToken(); @@ -902,56 +903,56 @@

 8768                        break;  769                }  32770            } - 720771            return left; - 720772        } + 749771            return left; + 749772        }  773  774        // +, - operators  775        Expression ParseAdditive() - 773776        { - 773777            Expression left = ParseMultiplicative(); - 759778             while (_textParser.CurrentToken.Id == TokenId.Plus || _textParser.CurrentToken.Id == TokenId.Minus) - 7779            { - 7780                Token op = _textParser.CurrentToken; - 7781                _textParser.NextToken(); - 7782                Expression right = ParseMultiplicative(); - 7783                 switch (op.Id) + 804776        { + 804777            Expression left = ParseMultiplicative(); + 797778             while (_textParser.CurrentToken.Id == TokenId.Plus || _textParser.CurrentToken.Id == TokenId.Minus) + 16779            { + 16780                Token op = _textParser.CurrentToken; + 16781                _textParser.NextToken(); + 16782                Expression right = ParseMultiplicative(); + 16783                 switch (op.Id)  784                {  785                    case TokenId.Plus: - 7786                         if (left.Type == typeof(string) || right.Type == typeof(string)) + 16786                         if (left.Type == typeof(string) || right.Type == typeof(string))  5787                        {  5788                            left = GenerateStringConcat(left, right);  5789                        }  790                        else - 2791                        { - 2792                            CheckAndPromoteOperands(typeof(IAddSignatures), op.Text, ref left, ref right, op.Pos); - 2793                            left = GenerateAdd(left, right); - 2794                        } - 7795                        break; + 11791                        { + 11792                            CheckAndPromoteOperands(typeof(IAddSignatures), op.Text, ref left, ref right, op.Pos); + 11793                            left = GenerateAdd(left, right); + 11794                        } + 16795                        break;  796                    case TokenId.Minus:  0797                        CheckAndPromoteOperands(typeof(ISubtractSignatures), op.Text, ref left, ref right, op.Pos);  0798                        left = GenerateSubtract(left, right);  0799                        break;  800                } - 7801            } - 752802            return left; - 752803        } + 16801            } + 781802            return left; + 781803        }  804  805        // *, /, %, mod operators  806        Expression ParseMultiplicative() - 780807        { - 780808            Expression left = ParseUnary(); - 768809             while (_textParser.CurrentToken.Id == TokenId.Asterisk || _textParser.CurrentToken.Id == TokenId.Slash || - 768810                _textParser.CurrentToken.Id == TokenId.Percent || TokenIdentifierIs("mod")) - 9811            { - 9812                Token op = _textParser.CurrentToken; - 9813                _textParser.NextToken(); - 9814                Expression right = ParseUnary(); - 9815                CheckAndPromoteOperands(typeof(IArithmeticSignatures), op.Text, ref left, ref right, op.Pos); - 8816                 switch (op.Id) + 820807        { + 820808            Expression left = ParseUnary(); + 812809             while (_textParser.CurrentToken.Id == TokenId.Asterisk || _textParser.CurrentToken.Id == TokenId.Slash || + 812810                _textParser.CurrentToken.Id == TokenId.Percent || TokenIdentifierIs("mod")) + 15811            { + 15812                Token op = _textParser.CurrentToken; + 15813                _textParser.NextToken(); + 15814                Expression right = ParseUnary(); + 15815                CheckAndPromoteOperands(typeof(IArithmeticSignatures), op.Text, ref left, ref right, op.Pos); + 14816                 switch (op.Id)  817                {  818                    case TokenId.Asterisk: - 8819                        left = Expression.Multiply(left, right); - 8820                        break; + 14819                        left = Expression.Multiply(left, right); + 14820                        break;  821                    case TokenId.Slash:  0822                        left = Expression.Divide(left, right);  0823                        break; @@ -960,22 +961,22 @@

 0826                        left = Expression.Modulo(left, right);  0827                        break;  828                } - 8829            } - 759830            return left; - 759831        } + 14829            } + 797830            return left; + 797831        }  832  833        // -, !, not unary operators  834        Expression ParseUnary() - 816835        { - 816836             if (_textParser.CurrentToken.Id == TokenId.Minus || _textParser.CurrentToken.Id == TokenId.Exclamation || To - 20837            { - 20838                Token op = _textParser.CurrentToken; - 20839                _textParser.NextToken(); - 17840                 if (op.Id == TokenId.Minus && (_textParser.CurrentToken.Id == TokenId.IntegerLiteral || _textParser.Curr - 17841                { - 17842                    _textParser.CurrentToken.Text = "-" + _textParser.CurrentToken.Text; - 17843                    _textParser.CurrentToken.Pos = op.Pos; - 17844                    return ParsePrimary(); + 862835        { + 862836             if (_textParser.CurrentToken.Id == TokenId.Minus || _textParser.CurrentToken.Id == TokenId.Exclamation || To + 22837            { + 22838                Token op = _textParser.CurrentToken; + 22839                _textParser.NextToken(); + 19840                 if (op.Id == TokenId.Minus && (_textParser.CurrentToken.Id == TokenId.IntegerLiteral || _textParser.Curr + 19841                { + 19842                    _textParser.CurrentToken.Text = "-" + _textParser.CurrentToken.Text; + 19843                    _textParser.CurrentToken.Pos = op.Pos; + 19844                    return ParsePrimary();  845                }  846  0847                Expression expr = ParseUnary(); @@ -993,41 +994,41 @@

 0859                return expr;  860            }  861 - 796862            return ParsePrimary(); - 796863        } + 840862            return ParsePrimary(); + 840863        }  864  865        Expression ParsePrimary() - 816866        { - 816867            Expression expr = ParsePrimaryStart(); - 934868            while (true) - 934869            { - 934870                 if (_textParser.CurrentToken.Id == TokenId.Dot) + 862866        { + 862867            Expression expr = ParsePrimaryStart(); + 978868            while (true) + 978869            { + 978870                 if (_textParser.CurrentToken.Id == TokenId.Dot)  134871                {  134872                    _textParser.NextToken();  134873                    expr = ParseMemberAccess(null, expr);  134874                } - 800875                 else if (_textParser.CurrentToken.Id == TokenId.OpenBracket) + 844875                 else if (_textParser.CurrentToken.Id == TokenId.OpenBracket)  1876                {  1877                    expr = ParseElementAccess(expr);  1878                }  879                else - 799880                { - 799881                    break; + 843880                { + 843881                    break;  882                }  135883            } - 799884            return expr; - 799885        } + 843884            return expr; + 843885        }  886  887        Expression ParsePrimaryStart() - 816888        { - 816889             switch (_textParser.CurrentToken.Id) + 862888        { + 862889             switch (_textParser.CurrentToken.Id)  890            {  891                case TokenId.Identifier: - 630892                    return ParseIdentifier(); + 660892                    return ParseIdentifier();  893                case TokenId.StringLiteral:  28894                    return ParseStringLiteral();  895                case TokenId.IntegerLiteral: - 138896                    return ParseIntegerLiteral(); + 154896                    return ParseIntegerLiteral();  897                case TokenId.RealLiteral:  11898                    return ParseRealLiteral();  899                case TokenId.OpenParen: @@ -1035,7 +1036,7 @@

 901                default:  0902                    throw ParseError(Res.ExpressionExpected);  903            } - 799904        } + 843904        }  905  906        Expression ParseStringLiteral()  28907        { @@ -1055,1697 +1056,1756 @@

 28921        }  922  923        Expression ParseIntegerLiteral() - 138924        { - 138925            _textParser.ValidateToken(TokenId.IntegerLiteral); + 154924        { + 154925            _textParser.ValidateToken(TokenId.IntegerLiteral);  926 - 138927            string text = _textParser.CurrentToken.Text; - 138928            string qualifier = null; - 138929            char last = text[text.Length - 1];930 - 138931             if (char.IsLetter(last)) - 18932            { - 36933                int pos = text.Length - 1, count = 0; - 39934                 while (char.IsLetter(text[pos])) - 21935                { - 21936                    ++count; - 21937                    --pos; - 21938                } - 18939                qualifier = text.Substring(text.Length - count, count); - 18940                text = text.Substring(0, text.Length - count); - 18941            }942 - 138943             if (text[0] != '-') - 127944            {945                ulong value; - 127946                 if (!ulong.TryParse(text, out value)) - 0947                    throw ParseError(Res.InvalidIntegerLiteral, text);948 - 127949                _textParser.NextToken(); - 127950                 if (!string.IsNullOrEmpty(qualifier)) - 10951                { - 12952                     if (qualifier == "U" || qualifier == "u") return CreateLiteral((uint)value, text); - 10953                     if (qualifier == "L" || qualifier == "l") return CreateLiteral((long)value, text);954955                    // in case of UL, just return - 6956                    return CreateLiteral(value, text);957                }958 - 234959                 if (value <= int.MaxValue) return CreateLiteral((int)value, text); - 0960                 if (value <= uint.MaxValue) return CreateLiteral((uint)value, text); - 0961                 if (value <= long.MaxValue) return CreateLiteral((long)value, text);962 - 0963                return CreateLiteral(value, text);964            }965            else - 11966            {967                long value; - 11968                 if (!long.TryParse(text, out value)) - 0969                    throw ParseError(Res.InvalidIntegerLiteral, text);970 - 11971                _textParser.NextToken(); - 11972                 if (!string.IsNullOrEmpty(qualifier)) - 8973                { - 8974                     if (qualifier == "L" || qualifier == "l") - 3975                        return CreateLiteral(value, text);976 - 5977                     if (qualifier == "F" || qualifier == "f") - 2978                        return TryParseAsFloat(text, qualifier[0]);979 - 3980                     if (qualifier == "D" || qualifier == "d") - 2981                        return TryParseAsDouble(text, qualifier[0]);982 - 1983                    throw ParseError(Res.MinusCannotBeAppliedToUnsignedInteger);984                }985 - 6986                 if (value <= int.MaxValue) return CreateLiteral((int)value, text);987 - 0988                return CreateLiteral(value, text);989            } - 137990        }991992        Expression ParseRealLiteral() - 11993        { - 11994            _textParser.ValidateToken(TokenId.RealLiteral); + 154927            string text = _textParser.CurrentToken.Text; + 154928            string qualifier = null; + 154929            char last = text[text.Length - 1]; + 154930             bool isHexadecimal = text.StartsWith(text[0] == '-' ? "-0x" : "0x", StringComparison.CurrentCultureIgnoreCas + 154931            char[] qualifierLetters = isHexadecimal + 154932                                          ? new[] { 'U', 'u', 'L', 'l' } + 154933                                          : new[] { 'U', 'u', 'L', 'l', 'F', 'f', 'D', 'd' };934 + 154935             if (qualifierLetters.Contains(last)) + 22936            { + 44937                int pos = text.Length - 1, count = 0; + 48938                 while (qualifierLetters.Contains(text[pos])) + 26939                { + 26940                    ++count; + 26941                    --pos; + 26942                } + 22943                qualifier = text.Substring(text.Length - count, count); + 22944                text = text.Substring(0, text.Length - count); + 22945            }946 + 154947             if (text[0] != '-') + 141948            { + 141949                 if (isHexadecimal) + 4950                { + 4951                    text = text.Substring(2); + 4952                }953954                ulong value; + 141955                 if (!ulong.TryParse(text, isHexadecimal ? NumberStyles.HexNumber : NumberStyles.Integer, CultureInfo.Cur + 0956                    throw ParseError(Res.InvalidIntegerLiteral, text);957 + 141958                _textParser.NextToken(); + 141959                 if (!string.IsNullOrEmpty(qualifier)) + 13960                { + 16961                     if (qualifier == "U" || qualifier == "u") return CreateLiteral((uint)value, text); + 13962                     if (qualifier == "L" || qualifier == "l") return CreateLiteral((long)value, text);963964                    // in case of UL, just return + 7965                    return CreateLiteral(value, text);966                }967 + 256968                 if (value <= int.MaxValue) return CreateLiteral((int)value, text); + 0969                 if (value <= uint.MaxValue) return CreateLiteral((uint)value, text); + 0970                 if (value <= long.MaxValue) return CreateLiteral((long)value, text);971 + 0972                return CreateLiteral(value, text);973            }974            else + 13975            { + 13976                 if (isHexadecimal) + 2977                { + 2978                    text = text.Substring(3); + 2979                }980981                long value; + 13982                 if (!long.TryParse(text, isHexadecimal ? NumberStyles.HexNumber : NumberStyles.Integer, CultureInfo.Curr + 0983                    throw ParseError(Res.InvalidIntegerLiteral, text);984 + 13985                 if (isHexadecimal) + 2986                { + 2987                    value = -value; + 2988                }989 + 13990                _textParser.NextToken(); + 13991                 if (!string.IsNullOrEmpty(qualifier)) + 9992                { + 9993                     if (qualifier == "L" || qualifier == "l") + 4994                        return CreateLiteral(value, text);  995 - 11996            string text = _textParser.CurrentToken.Text; - 11997            char qualifier = text[text.Length - 1]; + 5996                     if (qualifier == "F" || qualifier == "f") + 2997                        return TryParseAsFloat(text, qualifier[0]);  998 - 11999            _textParser.NextToken(); - 111000            return TryParseAsFloat(text, qualifier); - 111001        }10021003        Expression TryParseAsFloat(string text, char qualifier) - 131004        { - 131005             if (qualifier == 'F' || qualifier == 'f') - 61006            {1007                float f; - 61008                 if (float.TryParse(text.Substring(0, text.Length - 1), NumberStyles.Float, CultureInfo.InvariantCulture, - 41009                { - 41010                    return CreateLiteral(f, text);1011                } - 21012            }10131014            // not possible to find float qualifier, so try to parse as double - 91015            return TryParseAsDouble(text, qualifier); - 131016        } + 3999                     if (qualifier == "D" || qualifier == "d") + 21000                        return TryParseAsDouble(text, qualifier[0]);1001 + 11002                    throw ParseError(Res.MinusCannotBeAppliedToUnsignedInteger);1003                }1004 + 81005                 if (value <= int.MaxValue) return CreateLiteral((int)value, text);1006 + 01007                return CreateLiteral(value, text);1008            } + 1531009        }10101011        Expression ParseRealLiteral() + 111012        { + 111013            _textParser.ValidateToken(TokenId.RealLiteral);1014 + 111015            string text = _textParser.CurrentToken.Text; + 111016            char qualifier = text[text.Length - 1];  10171018        Expression TryParseAsDouble(string text, char qualifier) - 111019        {1020            double d; - 111021             if (qualifier == 'D' || qualifier == 'd') - 61022            { - 61023                 if (double.TryParse(text.Substring(0, text.Length - 1), NumberStyles.Number, CultureInfo.InvariantCultur - 41024                { - 41025                    return CreateLiteral(d, text);1026                } - 21027            }1028 - 71029             if (double.TryParse(text, NumberStyles.Number, CultureInfo.InvariantCulture, out d)) - 71030            { - 71031                return CreateLiteral(d, text);1032            }1033 - 01034            throw ParseError(Res.InvalidRealLiteral, text); - 111035        } + 111018            _textParser.NextToken(); + 111019            return TryParseAsFloat(text, qualifier); + 111020        }10211022        Expression TryParseAsFloat(string text, char qualifier) + 131023        { + 131024             if (qualifier == 'F' || qualifier == 'f') + 61025            {1026                float f; + 61027                 if (float.TryParse(text.Substring(0, text.Length - 1), NumberStyles.Float, CultureInfo.InvariantCulture, + 41028                { + 41029                    return CreateLiteral(f, text);1030                } + 21031            }10321033            // not possible to find float qualifier, so try to parse as double + 91034            return TryParseAsDouble(text, qualifier); + 131035        }  10361037        Expression CreateLiteral(object value, string text) - 1761038        { - 1761039            ConstantExpression expr = Expression.Constant(value); - 1761040            _literals.Add(expr, text); - 1761041            return expr; - 1761042        }10431044        Expression ParseParenExpression() - 91045        { - 91046            _textParser.ValidateToken(TokenId.OpenParen, Res.OpenParenExpected); - 91047            _textParser.NextToken(); - 91048            Expression e = ParseConditionalOperator(); - 91049            _textParser.ValidateToken(TokenId.CloseParen, Res.CloseParenOrOperatorExpected); - 91050            _textParser.NextToken(); - 91051            return e; - 91052        }10531054        Expression ParseIdentifier() - 6301055        { - 6301056            _textParser.ValidateToken(TokenId.Identifier);1057            object value;1058 - 6301059             if (_keywords.TryGetValue(_textParser.CurrentToken.Text, out value)) - 2671060            { - 2671061                var typeValue = value as Type; - 2791062                 if (typeValue != null) return ParseTypeAccess(typeValue);1063 - 4441064                 if (value == (object)KEYWORD_IT) return ParseIt(); - 671065                 if (value == (object)KEYWORD_PARENT) return ParseParent(); - 651066                 if (value == (object)KEYWORD_ROOT) return ParseRoot(); - 691067                 if (value == (object)SYMBOL_IT) return ParseIt(); - 621068                 if (value == (object)SYMBOL_PARENT) return ParseParent(); - 621069                 if (value == (object)SYMBOL_ROOT) return ParseRoot(); - 591070                 if (value == (object)KEYWORD_IIF) return ParseIif(); - 981071                 if (value == (object)KEYWORD_NEW) return ParseNew(); - 221072                 if (value == (object)KEYWORD_ISNULL) return ParseIsNull();1073 - 101074                _textParser.NextToken();1075 - 101076                return (Expression)value;1077            }1078 - 3631079             if (_symbols.TryGetValue(_textParser.CurrentToken.Text, out value) || - 3631080                _externals != null && _externals.TryGetValue(_textParser.CurrentToken.Text, out value) || - 3631081                _internals.TryGetValue(_textParser.CurrentToken.Text, out value)) - 1111082            { - 1111083                Expression expr = value as Expression; - 1111084                 if (expr == null) - 861085                { - 861086                    expr = Expression.Constant(value); - 861087                }1088                else - 251089                { - 251090                    LambdaExpression lambda = expr as LambdaExpression; - 251091                     if (lambda != null) return ParseLambdaInvocation(lambda); - 251092                }1093 - 1111094                _textParser.NextToken();1095 - 1111096                return expr;1097            }1098 - 2521099             if (_it != null) - 2521100                return ParseMemberAccess(null, _it);1101 - 01102            throw ParseError(Res.UnknownIdentifier, _textParser.CurrentToken.Text); - 6141103        }11041105        Expression ParseIt() - 1931106        { - 1931107             if (_it == null) - 01108                throw ParseError(Res.NoItInScope); - 1931109            _textParser.NextToken(); - 1931110            return _it; - 1931111        }1037        Expression TryParseAsDouble(string text, char qualifier) + 111038        {1039            double d; + 111040             if (qualifier == 'D' || qualifier == 'd') + 61041            { + 61042                 if (double.TryParse(text.Substring(0, text.Length - 1), NumberStyles.Number, CultureInfo.InvariantCultur + 41043                { + 41044                    return CreateLiteral(d, text);1045                } + 21046            }1047 + 71048             if (double.TryParse(text, NumberStyles.Number, CultureInfo.InvariantCulture, out d)) + 71049            { + 71050                return CreateLiteral(d, text);1051            }1052 + 01053            throw ParseError(Res.InvalidRealLiteral, text); + 111054        }10551056        Expression CreateLiteral(object value, string text) + 1921057        { + 1921058            ConstantExpression expr = Expression.Constant(value); + 1921059            _literals.Add(expr, text); + 1921060            return expr; + 1921061        }10621063        Expression ParseParenExpression() + 91064        { + 91065            _textParser.ValidateToken(TokenId.OpenParen, Res.OpenParenExpected); + 91066            _textParser.NextToken(); + 91067            Expression e = ParseConditionalOperator(); + 91068            _textParser.ValidateToken(TokenId.CloseParen, Res.CloseParenOrOperatorExpected); + 91069            _textParser.NextToken(); + 91070            return e; + 91071        }10721073        Expression ParseIdentifier() + 6601074        { + 6601075            _textParser.ValidateToken(TokenId.Identifier);1076            object value;1077 + 6601078             if (_keywords.TryGetValue(_textParser.CurrentToken.Text, out value)) + 2971079            { + 2971080                var typeValue = value as Type; + 3131081                 if (typeValue != null) return ParseTypeAccess(typeValue);1082 + 4881083                 if (value == (object)KEYWORD_IT) return ParseIt(); + 751084                 if (value == (object)KEYWORD_PARENT) return ParseParent(); + 731085                 if (value == (object)KEYWORD_ROOT) return ParseRoot(); + 771086                 if (value == (object)SYMBOL_IT) return ParseIt(); + 701087                 if (value == (object)SYMBOL_PARENT) return ParseParent(); + 701088                 if (value == (object)SYMBOL_ROOT) return ParseRoot(); + 671089                 if (value == (object)KEYWORD_IIF) return ParseIif(); + 1141090                 if (value == (object)KEYWORD_NEW) return ParseNew(); + 221091                 if (value == (object)KEYWORD_ISNULL) return ParseIsNull();1092 + 101093                _textParser.NextToken();1094 + 101095                return (Expression)value;1096            }1097 + 3631098             if (_symbols.TryGetValue(_textParser.CurrentToken.Text, out value) || + 3631099                _externals != null && _externals.TryGetValue(_textParser.CurrentToken.Text, out value) || + 3631100                _internals.TryGetValue(_textParser.CurrentToken.Text, out value)) + 1111101            { + 1111102                Expression expr = value as Expression; + 1111103                 if (expr == null) + 861104                { + 861105                    expr = Expression.Constant(value); + 861106                }1107                else + 251108                { + 251109                    LambdaExpression lambda = expr as LambdaExpression; + 251110                     if (lambda != null) return ParseLambdaInvocation(lambda); + 251111                }  11121113        Expression ParseParent() - 21114        { - 21115             if (_parent == null) - 01116                throw ParseError(Res.NoParentInScope); - 21117            _textParser.NextToken(); - 21118            return _parent; - 21119        } + 1111113                _textParser.NextToken();1114 + 1111115                return expr;1116            }1117 + 2521118             if (_it != null) + 2521119                return ParseMemberAccess(null, _it);  11201121        Expression ParseRoot() - 21122        { - 21123             if (_root == null) - 01124                throw ParseError(Res.NoRootInScope); - 21125            _textParser.NextToken(); - 21126            return _root; - 21127        }11281129        Expression ParseIif() - 11130        { - 11131            int errorPos = _textParser.CurrentToken.Pos; - 11132            _textParser.NextToken(); - 11133            Expression[] args = ParseArgumentList(); - 11134             if (args.Length != 3) - 01135                throw ParseError(errorPos, Res.IifRequiresThreeArgs);1136 - 11137            return GenerateConditional(args[0], args[1], args[2], errorPos); - 11138        } + 01121            throw ParseError(Res.UnknownIdentifier, _textParser.CurrentToken.Text); + 6421122        }11231124        Expression ParseIt() + 2111125        { + 2111126             if (_it == null) + 01127                throw ParseError(Res.NoItInScope); + 2111128            _textParser.NextToken(); + 2111129            return _it; + 2111130        }11311132        Expression ParseParent() + 21133        { + 21134             if (_parent == null) + 01135                throw ParseError(Res.NoParentInScope); + 21136            _textParser.NextToken(); + 21137            return _parent; + 21138        }  11391140        Expression GenerateConditional(Expression test, Expression expr1, Expression expr2, int errorPos)1140        Expression ParseRoot()  21141        { - 21142             if (test.Type != typeof(bool)) - 01143                throw ParseError(errorPos, Res.FirstExprMustBeBool); - 21144             if (expr1.Type != expr2.Type) - 11145            { - 11146                 Expression expr1As2 = expr2 != NullLiteral ? PromoteExpression(expr1, expr2.Type, true, false) : null; - 11147                 Expression expr2As1 = expr1 != NullLiteral ? PromoteExpression(expr2, expr1.Type, true, false) : null; - 11148                 if (expr1As2 != null && expr2As1 == null) - 01149                { - 01150                    expr1 = expr1As2; - 01151                } - 11152                 else if (expr2As1 != null && expr1As2 == null) - 11153                { - 11154                    expr2 = expr2As1; - 11155                }1156                else - 01157                { - 01158                     string type1 = expr1 != NullLiteral ? expr1.Type.Name : "null"; - 01159                     string type2 = expr2 != NullLiteral ? expr2.Type.Name : "null"; - 01160                     if (expr1As2 != null) - 01161                        throw ParseError(errorPos, Res.BothTypesConvertToOther, type1, type2);1162 - 01163                    throw ParseError(errorPos, Res.NeitherTypeConvertsToOther, type1, type2);1164                } - 11165            }1166 - 21167            return Expression.Condition(test, expr1, expr2); - 21168        }11691170        Expression ParseNew() - 411171        { - 411172            _textParser.NextToken(); - 411173             if (_textParser.CurrentToken.Id != TokenId.OpenParen && - 411174                _textParser.CurrentToken.Id != TokenId.OpenCurlyParen && - 411175                _textParser.CurrentToken.Id != TokenId.Identifier) - 01176                throw ParseError(Res.OpenParenOrIdentifierExpected);1177 - 411178            Type newType = null; - 411179             if (_textParser.CurrentToken.Id == TokenId.Identifier) - 31180            { - 31181                var newTypeName = _textParser.CurrentToken.Text; - 31182                newType = FindType(newTypeName); - 31183                 if (newType == null) - 21184                    throw ParseError(_textParser.CurrentToken.Pos, Res.TypeNotFound, newTypeName); - 11185                _textParser.NextToken(); - 11186                 if (_textParser.CurrentToken.Id != TokenId.OpenParen && - 11187                    _textParser.CurrentToken.Id != TokenId.OpenCurlyParen) - 01188                    throw ParseError(Res.OpenParenExpected); - 11189            }1190 - 391191            _textParser.NextToken();1192 - 391193            var properties = new List<DynamicProperty>(); - 391194            var expressions = new List<Expression>();1195 - 851196            while (true) - 851197            { - 851198                int exprPos = _textParser.CurrentToken.Pos; - 851199                Expression expr = ParseConditionalOperator();1200                string propName; - 831201                 if (TokenIdentifierIs("as")) - 501202                { - 501203                    _textParser.NextToken(); - 501204                    propName = GetIdentifier(); - 501205                    _textParser.NextToken(); - 501206                }1207                else - 331208                { - 331209                     if (!TryGetMemberName(expr, out propName)) - 01210                        throw ParseError(exprPos, Res.MissingAsClause); - 331211                }1212 - 831213                expressions.Add(expr); - 831214                properties.Add(new DynamicProperty(propName, expr.Type));1215 - 831216                 if (_textParser.CurrentToken.Id != TokenId.Comma) - 371217                    break;1218 - 461219                _textParser.NextToken(); - 461220            } + 21142             if (_root == null) + 01143                throw ParseError(Res.NoRootInScope); + 21144            _textParser.NextToken(); + 21145            return _root; + 21146        }11471148        Expression ParseIif() + 11149        { + 11150            int errorPos = _textParser.CurrentToken.Pos; + 11151            _textParser.NextToken(); + 11152            Expression[] args = ParseArgumentList(); + 11153             if (args.Length != 3) + 01154                throw ParseError(errorPos, Res.IifRequiresThreeArgs);1155 + 11156            return GenerateConditional(args[0], args[1], args[2], errorPos); + 11157        }11581159        Expression GenerateConditional(Expression test, Expression expr1, Expression expr2, int errorPos) + 21160        { + 21161             if (test.Type != typeof(bool)) + 01162                throw ParseError(errorPos, Res.FirstExprMustBeBool); + 21163             if (expr1.Type != expr2.Type) + 11164            { + 11165                 Expression expr1As2 = expr2 != NullLiteral ? PromoteExpression(expr1, expr2.Type, true, false) : null; + 11166                 Expression expr2As1 = expr1 != NullLiteral ? PromoteExpression(expr2, expr1.Type, true, false) : null; + 11167                 if (expr1As2 != null && expr2As1 == null) + 01168                { + 01169                    expr1 = expr1As2; + 01170                } + 11171                 else if (expr2As1 != null && expr1As2 == null) + 11172                { + 11173                    expr2 = expr2As1; + 11174                }1175                else + 01176                { + 01177                     string type1 = expr1 != NullLiteral ? expr1.Type.Name : "null"; + 01178                     string type2 = expr2 != NullLiteral ? expr2.Type.Name : "null"; + 01179                     if (expr1As2 != null) + 01180                        throw ParseError(errorPos, Res.BothTypesConvertToOther, type1, type2);1181 + 01182                    throw ParseError(errorPos, Res.NeitherTypeConvertsToOther, type1, type2);1183                } + 11184            }1185 + 21186            return Expression.Condition(test, expr1, expr2); + 21187        }11881189        Expression ParseNew() + 491190        { + 491191            _textParser.NextToken(); + 491192             if (_textParser.CurrentToken.Id != TokenId.OpenParen && + 491193                _textParser.CurrentToken.Id != TokenId.OpenCurlyParen && + 491194                _textParser.CurrentToken.Id != TokenId.OpenBracket && + 491195                _textParser.CurrentToken.Id != TokenId.Identifier) + 11196                throw ParseError(Res.OpenParenOrIdentifierExpected);1197 + 481198            Type newType = null; + 481199             if (_textParser.CurrentToken.Id == TokenId.Identifier) + 41200            { + 41201                var newTypeName = _textParser.CurrentToken.Text; + 41202                newType = FindType(newTypeName); + 41203                 if (newType == null) + 21204                    throw ParseError(_textParser.CurrentToken.Pos, Res.TypeNotFound, newTypeName); + 21205                _textParser.NextToken(); + 21206                 if (_textParser.CurrentToken.Id != TokenId.OpenParen && + 21207                    _textParser.CurrentToken.Id != TokenId.OpenBracket && + 21208                    _textParser.CurrentToken.Id != TokenId.OpenCurlyParen) + 01209                    throw ParseError(Res.OpenParenExpected); + 21210            }1211 + 461212            bool arrayInitializer = false; + 461213             if (_textParser.CurrentToken.Id == TokenId.OpenBracket) + 71214            { + 71215                _textParser.NextToken(); + 71216                _textParser.ValidateToken(TokenId.CloseBracket, Res.CloseBracketExpected); + 61217                _textParser.NextToken(); + 61218                _textParser.ValidateToken(TokenId.OpenCurlyParen, Res.OpenCurlyParenExpected); + 61219                arrayInitializer = true; + 61220            }  1221 - 371222             if (_textParser.CurrentToken.Id != TokenId.CloseParen && - 371223                _textParser.CurrentToken.Id != TokenId.CloseCurlyParen) - 21224                throw ParseError(Res.CloseParenOrCommaExpected); - 351225            _textParser.NextToken(); + 451222            _textParser.NextToken();1223 + 451224            var properties = new List<DynamicProperty>(); + 451225            var expressions = new List<Expression>();  1226 - 351227            return CreateNewExpression(properties, expressions, newType); - 351228        }12291230        private Expression CreateNewExpression(List<DynamicProperty> properties, List<Expression> expressions, Type newT - 351231        {1232            // http://solutionizing.net/category/linq/ - 351233             Type type = newType ?? _resultType;1234 - 351235             if (type == null) - 341236            {1237#if UAP10_01238                type = typeof(DynamicClass);1239                Type typeForKeyValuePair = typeof(KeyValuePair<string, object>);1240                ConstructorInfo constructorForKeyValuePair = typeForKeyValuePair.GetTypeInfo().DeclaredConstructors.Firs12411242                var arrayIndexParams = new List<Expression>();1243                for (int i = 0; i < expressions.Count; i++)1244                {1245                    // Just convert the expression always to an object expression.1246                    UnaryExpression boxingExpression = Expression.Convert(expressions[i], typeof(object));1247                    NewExpression parameter = Expression.New(constructorForKeyValuePair, new[] { (Expression)Expression. + 971227             while (_textParser.CurrentToken.Id != TokenId.CloseParen + 971228                   && _textParser.CurrentToken.Id != TokenId.CloseCurlyParen) + 961229            { + 961230                int exprPos = _textParser.CurrentToken.Pos; + 961231                Expression expr = ParseConditionalOperator(); + 941232                 if (!arrayInitializer) + 831233                {1234                    string propName; + 831235                     if (TokenIdentifierIs("as")) + 501236                    { + 501237                        _textParser.NextToken(); + 501238                        propName = GetIdentifier(); + 501239                        _textParser.NextToken(); + 501240                    }1241                    else + 331242                    { + 331243                         if (!TryGetMemberName(expr, out propName)) throw ParseError(exprPos, Res.MissingAsClause); + 331244                    }1245 + 831246                    properties.Add(new DynamicProperty(propName, expr.Type)); + 831247                }  12481249                    arrayIndexParams.Add(parameter);1250                }12511252                // Create an expression tree that represents creating and initializing a one-dimensional array of type K1253                NewArrayExpression newArrayExpression = Expression.NewArrayInit(typeof(KeyValuePair<string, object>), ar12541255                // Get the "public DynamicClass(KeyValuePair<string, object>[] propertylist)" constructor1256                ConstructorInfo constructor = type.GetTypeInfo().DeclaredConstructors.First();1257                return Expression.New(constructor, newArrayExpression);1258#else - 341259                type = DynamicClassFactory.CreateType(properties, _createParameterCtor);1260#endif - 341261            }1262 - 1491263            Type[] propertyTypes = type.GetProperties().Select(p => p.PropertyType).ToArray(); - 351264            ConstructorInfo ctor = type.GetConstructor(propertyTypes); - 351265             if (ctor != null) - 01266                return Expression.New(ctor, expressions);1267 - 351268            MemberBinding[] bindings = new MemberBinding[properties.Count]; - 2201269             for (int i = 0; i < bindings.Length; i++) - 751270                bindings[i] = Expression.Bind(type.GetProperty(properties[i].Name), expressions[i]); - 351271            return Expression.MemberInit(Expression.New(type), bindings); - 351272        }12731274        Expression ParseLambdaInvocation(LambdaExpression lambda) - 01275        { - 01276            int errorPos = _textParser.CurrentToken.Pos; - 01277            _textParser.NextToken(); - 01278            Expression[] args = ParseArgumentList();1279            MethodBase method; - 01280             if (FindMethod(lambda.Type, "Invoke", false, args, out method) != 1) - 01281                throw ParseError(errorPos, Res.ArgsIncompatibleWithLambda);1282 - 01283            return Expression.Invoke(lambda, args); - 01284        }12851286        Expression ParseTypeAccess(Type type) - 121287        { - 121288            int errorPos = _textParser.CurrentToken.Pos; - 121289            _textParser.NextToken();1290 - 121291             if (_textParser.CurrentToken.Id == TokenId.Question) - 51292            { - 51293                 if (!type.GetTypeInfo().IsValueType || IsNullableType(type)) - 01294                    throw ParseError(errorPos, Res.TypeHasNoNullableForm, GetTypeName(type));1295 - 51296                type = typeof(Nullable<>).MakeGenericType(type); - 51297                _textParser.NextToken(); - 51298            }12991300            // This is a shorthand for explicitely converting a string to something - 121301            bool shorthand = _textParser.CurrentToken.Id == TokenId.StringLiteral; - 121302             if (_textParser.CurrentToken.Id == TokenId.OpenParen || shorthand) - 81303            { - 81304                 Expression[] args = shorthand ? new[] { ParseStringLiteral() } : ParseArgumentList();13051306                // If only 1 argument, and if the type is a ValueType and argType is also a ValueType, just Convert - 81307                 if (args.Length == 1) - 81308                { - 81309                    Type argType = args[0].Type; + 941249                expressions.Add(expr);1250 + 941251                 if (_textParser.CurrentToken.Id != TokenId.Comma) + 421252                    break;1253 + 521254                _textParser.NextToken(); + 521255            }1256 + 431257             if (_textParser.CurrentToken.Id != TokenId.CloseParen && + 431258                _textParser.CurrentToken.Id != TokenId.CloseCurlyParen) + 21259                throw ParseError(Res.CloseParenOrCommaExpected); + 411260            _textParser.NextToken();1261 + 411262             if (arrayInitializer) + 61263            { + 61264                return CreateArrayInitializerExpression(expressions, newType);1265            }1266 + 351267            return CreateNewExpression(properties, expressions, newType); + 411268        }12691270        private Expression CreateArrayInitializerExpression(List<Expression> expressions, Type newType) + 61271        { + 61272             if (expressions.Count == 0) + 11273            { + 11274                 return Expression.NewArrayInit(newType ?? typeof(object));1275            }1276 + 51277             if (newType != null) + 11278            { + 11279                return Expression.NewArrayInit( + 11280                    newType, + 41281                    expressions.Select(expression => PromoteExpression(expression, newType, true, true)));1282            }1283 + 41284             return Expression.NewArrayInit( + 121285                expressions.All(expression => expression.Type == expressions[0].Type) ? expressions[0].Type : typeof(obj + 41286                expressions); + 61287        }12881289        private Expression CreateNewExpression(List<DynamicProperty> properties, List<Expression> expressions, Type newT + 351290        {1291            // http://solutionizing.net/category/linq/ + 351292             Type type = newType ?? _resultType;1293 + 351294             if (type == null) + 341295            {1296#if UAP10_01297                type = typeof(DynamicClass);1298                Type typeForKeyValuePair = typeof(KeyValuePair<string, object>);1299                ConstructorInfo constructorForKeyValuePair = typeForKeyValuePair.GetTypeInfo().DeclaredConstructors.Firs13001301                var arrayIndexParams = new List<Expression>();1302                for (int i = 0; i < expressions.Count; i++)1303                {1304                    // Just convert the expression always to an object expression.1305                    UnaryExpression boxingExpression = Expression.Convert(expressions[i], typeof(object));1306                    NewExpression parameter = Expression.New(constructorForKeyValuePair, new[] { (Expression)Expression.13071308                    arrayIndexParams.Add(parameter);1309                }  1310 - 81311                     if (type.GetTypeInfo().IsValueType && IsNullableType(type) && argType.GetTypeInfo().IsValueType) - 51312                    { - 51313                        return Expression.Convert(args[0], type);1314                    } - 31315                }13161317                MethodBase method; - 31318                 switch (FindBestMethod(type.GetConstructors(), args, out method))1319                {1320                    case 0: - 21321                         if (args.Length == 1) - 21322                            return GenerateConversion(args[0], type, errorPos);1323 - 01324                        throw ParseError(errorPos, Res.NoMatchingConstructor, GetTypeName(type));13251326                    case 1: - 11327                        return Expression.New((ConstructorInfo)method, args);13281329                    default: - 01330                        throw ParseError(errorPos, Res.AmbiguousConstructorInvocation, GetTypeName(type));1331                }1332            }1333 - 41334            _textParser.ValidateToken(TokenId.Dot, Res.DotOrOpenParenOrStringLiteralExpected); - 41335            _textParser.NextToken();1336 - 41337            return ParseMemberAccess(type, null); - 121338        }13391340        static Expression GenerateConversion(Expression expr, Type type, int errorPos) - 21341        { - 21342            Type exprType = expr.Type; - 21343             if (exprType == type) - 01344                return expr;1345 - 21346             if (exprType.GetTypeInfo().IsValueType && type.GetTypeInfo().IsValueType) - 11347            { - 11348                 if ((IsNullableType(exprType) || IsNullableType(type)) && GetNonNullableType(exprType) == GetNonNullable - 01349                    return Expression.Convert(expr, type);1350 - 11351                 if ((IsNumericType(exprType) || IsEnumType(exprType)) && IsNumericType(type) || IsEnumType(type)) - 11352                    return Expression.ConvertChecked(expr, type); - 01353            }1311                // Create an expression tree that represents creating and initializing a one-dimensional array of type K1312                NewArrayExpression newArrayExpression = Expression.NewArrayInit(typeof(KeyValuePair<string, object>), ar13131314                // Get the "public DynamicClass(KeyValuePair<string, object>[] propertylist)" constructor1315                ConstructorInfo constructor = type.GetTypeInfo().DeclaredConstructors.First();1316                return Expression.New(constructor, newArrayExpression);1317#else + 341318                type = DynamicClassFactory.CreateType(properties, _createParameterCtor);1319#endif + 341320            }1321 + 1491322            Type[] propertyTypes = type.GetProperties().Select(p => p.PropertyType).ToArray(); + 351323            ConstructorInfo ctor = type.GetConstructor(propertyTypes); + 351324             if (ctor != null) + 01325                return Expression.New(ctor, expressions);1326 + 351327            MemberBinding[] bindings = new MemberBinding[properties.Count]; + 2201328             for (int i = 0; i < bindings.Length; i++) + 751329                bindings[i] = Expression.Bind(type.GetProperty(properties[i].Name), expressions[i]); + 351330            return Expression.MemberInit(Expression.New(type), bindings); + 351331        }13321333        Expression ParseLambdaInvocation(LambdaExpression lambda) + 01334        { + 01335            int errorPos = _textParser.CurrentToken.Pos; + 01336            _textParser.NextToken(); + 01337            Expression[] args = ParseArgumentList();1338            MethodBase method; + 01339             if (FindMethod(lambda.Type, "Invoke", false, args, out method) != 1) + 01340                throw ParseError(errorPos, Res.ArgsIncompatibleWithLambda);1341 + 01342            return Expression.Invoke(lambda, args); + 01343        }13441345        Expression ParseTypeAccess(Type type) + 161346        { + 161347            int errorPos = _textParser.CurrentToken.Pos; + 161348            _textParser.NextToken();1349 + 161350             if (_textParser.CurrentToken.Id == TokenId.Question) + 51351            { + 51352                 if (!type.GetTypeInfo().IsValueType || IsNullableType(type)) + 01353                    throw ParseError(errorPos, Res.TypeHasNoNullableForm, GetTypeName(type));  1354 - 11355             if (exprType.IsAssignableFrom(type) || type.IsAssignableFrom(exprType) || exprType.GetTypeInfo().IsInterface - 11356                return Expression.Convert(expr, type);13571358            // Try to Parse the string rather that just generate the convert statement - 01359             if (expr.NodeType == ExpressionType.Constant && exprType == typeof(string)) - 01360            { - 01361                string text = (string)((ConstantExpression)expr).Value;13621363                // DateTime is parsed as UTC time.1364                DateTime dateTime; - 01365                 if (type == typeof(DateTime) && DateTime.TryParse(text, CultureInfo.InvariantCulture, DateTimeStyles.Non - 01366                    return Expression.Constant(dateTime, type);1367 - 01368                object[] arguments = { text, null };1369#if NETFX_CORE || WINDOWS_APP || DOTNET5_1 || UAP10_0 || NETSTANDARD - 01370                MethodInfo method = type.GetMethod("TryParse", new[] { typeof(string), type.MakeByRefType() });1371#else1372                MethodInfo method = type.GetMethod("TryParse", BindingFlags.Public | BindingFlags.Static, null, new Type1373#endif - 01374                 if (method != null && (bool)method.Invoke(null, arguments)) - 01375                    return Expression.Constant(arguments[1], type); - 01376            }1377 - 01378            throw ParseError(errorPos, Res.CannotConvertValue, GetTypeName(exprType), GetTypeName(type)); - 21379        }13801381        Expression ParseMemberAccess(Type type, Expression instance) - 3901382        { - 7761383             if (instance != null) type = instance.Type; - 3901384            int errorPos = _textParser.CurrentToken.Pos; - 3901385            string id = GetIdentifier(); - 3901386            _textParser.NextToken(); + 51355                type = typeof(Nullable<>).MakeGenericType(type); + 51356                _textParser.NextToken(); + 51357            }13581359            // This is a shorthand for explicitely converting a string to something + 161360            bool shorthand = _textParser.CurrentToken.Id == TokenId.StringLiteral; + 161361             if (_textParser.CurrentToken.Id == TokenId.OpenParen || shorthand) + 121362            { + 121363                 Expression[] args = shorthand ? new[] { ParseStringLiteral() } : ParseArgumentList();13641365                // If only 1 argument, and if the type is a ValueType and argType is also a ValueType, just Convert + 121366                 if (args.Length == 1) + 121367                { + 121368                    Type argType = args[0].Type;1369 + 121370                     if (type.GetTypeInfo().IsValueType && IsNullableType(type) && argType.GetTypeInfo().IsValueType) + 51371                    { + 51372                        return Expression.Convert(args[0], type);1373                    } + 71374                }13751376                MethodBase method; + 71377                 switch (FindBestMethod(type.GetConstructors(), args, out method))1378                {1379                    case 0: + 61380                         if (args.Length == 1) + 61381                            return GenerateConversion(args[0], type, errorPos);1382 + 01383                        throw ParseError(errorPos, Res.NoMatchingConstructor, GetTypeName(type));13841385                    case 1: + 11386                        return Expression.New((ConstructorInfo)method, args);  1387 - 3901388             if (_textParser.CurrentToken.Id == TokenId.OpenParen) - 671389            { - 671390                 if (instance != null && type != typeof(string)) - 631391                { - 631392                    Type enumerableType = FindGenericType(typeof(IEnumerable<>), type); - 631393                     if (enumerableType != null) - 531394                    { - 531395                        Type elementType = enumerableType.GetTypeInfo().GetGenericTypeArguments()[0]; - 531396                        return ParseAggregate(instance, elementType, id, errorPos);1397                    } - 101398                }1399 - 141400                Expression[] args = ParseArgumentList();1401                MethodBase mb; - 141402                 switch (FindMethod(type, id, instance == null, args, out mb))1403                {1404                    case 0: - 01405                        throw ParseError(errorPos, Res.NoApplicableMethod, id, GetTypeName(type));14061407                    case 1: - 141408                        MethodInfo method = (MethodInfo)mb; - 141409                         if (!IsPredefinedType(method.DeclaringType) && !(method.IsPublic && IsPredefinedType(method.Retu - 01410                            throw ParseError(errorPos, Res.MethodsAreInaccessible, GetTypeName(method.DeclaringType));1411 - 141412                         if (method.ReturnType == typeof(void)) - 01413                            throw ParseError(errorPos, Res.MethodIsVoid, id, GetTypeName(method.DeclaringType));1414 - 141415                        return Expression.Call(instance, method, args);1388                    default: + 01389                        throw ParseError(errorPos, Res.AmbiguousConstructorInvocation, GetTypeName(type));1390                }1391            }1392 + 41393            _textParser.ValidateToken(TokenId.Dot, Res.DotOrOpenParenOrStringLiteralExpected); + 41394            _textParser.NextToken();1395 + 41396            return ParseMemberAccess(type, null); + 161397        }13981399        static Expression GenerateConversion(Expression expr, Type type, int errorPos) + 61400        { + 61401            Type exprType = expr.Type; + 61402             if (exprType == type) + 01403                return expr;1404 + 61405             if (exprType.GetTypeInfo().IsValueType && type.GetTypeInfo().IsValueType) + 51406            { + 51407                 if ((IsNullableType(exprType) || IsNullableType(type)) && GetNonNullableType(exprType) == GetNonNullable + 01408                    return Expression.Convert(expr, type);1409 + 51410                 if ((IsNumericType(exprType) || IsEnumType(exprType)) && IsNumericType(type) || IsEnumType(type)) + 51411                    return Expression.ConvertChecked(expr, type); + 01412            }1413 + 11414             if (exprType.IsAssignableFrom(type) || type.IsAssignableFrom(exprType) || exprType.GetTypeInfo().IsInterface + 11415                return Expression.Convert(expr, type);  14161417                    default: - 01418                        throw ParseError(errorPos, Res.AmbiguousMethodInvocation, id, GetTypeName(type));1419                }1420            }1417            // Try to Parse the string rather that just generate the convert statement + 01418             if (expr.NodeType == ExpressionType.Constant && exprType == typeof(string)) + 01419            { + 01420                string text = (string)((ConstantExpression)expr).Value;  1421 - 3231422             if (type.GetTypeInfo().IsEnum) - 61423            { - 61424                var @enum = Enum.Parse(type, id, true);1425 - 61426                return Expression.Constant(@enum);1427            }14281429#if NETFX_CORE1430            if (type == typeof(DynamicObjectClass))1431            {1432                return Expression.MakeIndex(instance, typeof(DynamicObjectClass).GetProperty("Item"), new[] { Expression1433            }1434#endif - 3171435            MemberInfo member = FindPropertyOrField(type, id, instance == null); - 3171436             if (member == null) - 151437            { - 151438                 if (_textParser.CurrentToken.Id == TokenId.Lambda && _it.Type == type) - 61439                {1440                    // This might be an internal variable for use within a lambda expression, so store it as such - 61441                    _internals.Add(id, _it); - 61442                    _textParser.NextToken();1443 - 61444                    return ParseConditionalOperator();1445                }1446                else - 91447                { - 91448                    throw ParseError(errorPos, Res.UnknownPropertyOrField, id, GetTypeName(type));1449                }14501451            }1452 - 3021453            var property = member as PropertyInfo; - 3021454             if (property != null) - 3021455                return Expression.Property(instance, property);1456 - 01457            return Expression.Field(instance, (FieldInfo)member); - 3811458        }14591460        static Type FindGenericType(Type generic, Type type) - 2021461        { - 2361462             while (type != null && type != typeof(object)) - 2021463            { - 2021464                 if (type.GetTypeInfo().IsGenericType && type.GetGenericTypeDefinition() == generic) - 531465                    return type; - 1491466                 if (generic.GetTypeInfo().IsInterface) - 1491467                { - 6101468                    foreach (Type intfType in type.GetInterfaces()) - 1391469                    { - 1391470                        Type found = FindGenericType(generic, intfType); - 2541471                         if (found != null) return found; - 241472                    } - 341473                } - 341474                type = type.GetTypeInfo().BaseType; - 341475            } - 341476            return null; - 2021477        }14781479        Type FindType(string name) - 31480        {1481            object type; - 31482            _keywords.TryGetValue(name, out type); - 31483            var result = type as Type; - 31484             if (result != null) - 01485                return result; - 31486             if (_it != null && _it.Type.Name == name) - 11487                return _it.Type; - 21488             if (_parent != null && _parent.Type.Name == name) - 01489                return _parent.Type; - 21490             if (_root != null && _root.Type.Name == name) - 01491                return _root.Type; - 21492             if (_it != null && _it.Type.Namespace + "." + _it.Type.Name == name) - 01493                return _it.Type; - 21494             if (_parent != null && _parent.Type.Namespace + "." + _parent.Type.Name == name) - 01495                return _parent.Type; - 21496             if (_root != null && _root.Type.Namespace + "." + _root.Type.Name == name) - 01497                return _root.Type; - 21498            return null; - 31499        }15001501        Expression ParseAggregate(Expression instance, Type elementType, string methodName, int errorPos) - 531502        { - 531503            var oldParent = _parent;1504 - 531505            ParameterExpression outerIt = _it; - 531506            ParameterExpression innerIt = Expression.Parameter(elementType, "");1507 - 531508            _parent = _it;1422                // DateTime is parsed as UTC time.1423                DateTime dateTime; + 01424                 if (type == typeof(DateTime) && DateTime.TryParse(text, CultureInfo.InvariantCulture, DateTimeStyles.Non + 01425                    return Expression.Constant(dateTime, type);1426 + 01427                object[] arguments = { text, null };1428#if NETFX_CORE || WINDOWS_APP || DOTNET5_1 || UAP10_0 || NETSTANDARD + 01429                MethodInfo method = type.GetMethod("TryParse", new[] { typeof(string), type.MakeByRefType() });1430#else1431                MethodInfo method = type.GetMethod("TryParse", BindingFlags.Public | BindingFlags.Static, null, new Type1432#endif + 01433                 if (method != null && (bool)method.Invoke(null, arguments)) + 01434                    return Expression.Constant(arguments[1], type); + 01435            }1436 + 01437            throw ParseError(errorPos, Res.CannotConvertValue, GetTypeName(exprType), GetTypeName(type)); + 61438        }14391440        Expression ParseMemberAccess(Type type, Expression instance) + 3901441        { + 7761442             if (instance != null) type = instance.Type; + 3901443            int errorPos = _textParser.CurrentToken.Pos; + 3901444            string id = GetIdentifier(); + 3901445            _textParser.NextToken();1446 + 3901447             if (_textParser.CurrentToken.Id == TokenId.OpenParen) + 671448            { + 671449                 if (instance != null && type != typeof(string)) + 631450                { + 631451                    Type enumerableType = FindGenericType(typeof(IEnumerable<>), type); + 631452                     if (enumerableType != null) + 531453                    { + 531454                        Type elementType = enumerableType.GetTypeInfo().GetGenericTypeArguments()[0]; + 531455                        return ParseAggregate(instance, elementType, id, errorPos);1456                    } + 101457                }1458 + 141459                Expression[] args = ParseArgumentList();1460                MethodBase mb; + 141461                 switch (FindMethod(type, id, instance == null, args, out mb))1462                {1463                    case 0: + 01464                        throw ParseError(errorPos, Res.NoApplicableMethod, id, GetTypeName(type));14651466                    case 1: + 141467                        MethodInfo method = (MethodInfo)mb; + 141468                         if (!IsPredefinedType(method.DeclaringType) && !(method.IsPublic && IsPredefinedType(method.Retu + 01469                            throw ParseError(errorPos, Res.MethodsAreInaccessible, GetTypeName(method.DeclaringType));1470 + 141471                         if (method.ReturnType == typeof(void)) + 01472                            throw ParseError(errorPos, Res.MethodIsVoid, id, GetTypeName(method.DeclaringType));1473 + 141474                        return Expression.Call(instance, method, args);14751476                    default: + 01477                        throw ParseError(errorPos, Res.AmbiguousMethodInvocation, id, GetTypeName(type));1478                }1479            }1480 + 3231481             if (type.GetTypeInfo().IsEnum) + 61482            { + 61483                var @enum = Enum.Parse(type, id, true);1484 + 61485                return Expression.Constant(@enum);1486            }14871488#if NETFX_CORE1489            if (type == typeof(DynamicObjectClass))1490            {1491                return Expression.MakeIndex(instance, typeof(DynamicObjectClass).GetProperty("Item"), new[] { Expression1492            }1493#endif + 3171494            MemberInfo member = FindPropertyOrField(type, id, instance == null); + 3171495             if (member == null) + 151496            { + 151497                 if (_textParser.CurrentToken.Id == TokenId.Lambda && _it.Type == type) + 61498                {1499                    // This might be an internal variable for use within a lambda expression, so store it as such + 61500                    _internals.Add(id, _it); + 61501                    _textParser.NextToken();1502 + 61503                    return ParseConditionalOperator();1504                }1505                else + 91506                { + 91507                    throw ParseError(errorPos, Res.UnknownPropertyOrField, id, GetTypeName(type));1508                }  1509 - 531510             if (methodName == "Contains" || methodName == "Skip" || methodName == "Take") - 61511            {1512                //for any method that acts on the parent element type, we need to specify the outerIt as scope. - 61513                _it = outerIt; - 61514            }1515            else - 471516            { - 471517                _it = innerIt; - 471518            }1519 - 531520            Expression[] args = ParseArgumentList();1521 - 531522            _it = outerIt; - 531523            _parent = oldParent;15241525            MethodBase signature; - 531526             if (FindMethod(typeof(IEnumerableSignatures), methodName, false, args, out signature) != 1) - 01527                throw ParseError(errorPos, Res.NoApplicableAggregate, methodName);15281529            Type[] typeArgs; - 531530             if (new[] { "Min", "Max", "Select", "OrderBy", "OrderByDescending", "ThenBy", "ThenByDescending", "GroupBy"  - 141531            { - 141532                typeArgs = new[] { elementType, args[0].Type }; - 141533            } - 391534             else if (signature.Name == "SelectMany") - 31535            { - 31536                var type = Expression.Lambda(args[0], innerIt).Body.Type; - 31537                var interfaces = type.GetInterfaces().Union(new[] { type }); - 301538                Type interfaceType = interfaces.Single(i => i.Name == typeof(IEnumerable<>).Name); - 31539                Type resultType = interfaceType.GetTypeInfo().GetGenericTypeArguments()[0]; - 31540                typeArgs = new[] { elementType, resultType }; - 31541            }1542            else - 361543            { - 361544                typeArgs = new[] { elementType }; - 361545            }1546 - 531547             if (signature.Name == "Contains" || signature.Name == "Take" || signature.Name == "Skip") - 61548            { - 61549                args = new[] { instance, args[0] }; - 61550            } - 471551             else if (args.Length == 0) - 121552            { - 121553                args = new[] { instance }; - 121554            }1555            else - 351556            { - 351557                args = new[] { instance, Expression.Lambda(args[0], innerIt) }; - 351558            }1510            }1511 + 3021512            var property = member as PropertyInfo; + 3021513             if (property != null) + 3021514                return Expression.Property(instance, property);1515 + 01516            return Expression.Field(instance, (FieldInfo)member); + 3811517        }15181519        static Type FindGenericType(Type generic, Type type) + 2021520        { + 2361521             while (type != null && type != typeof(object)) + 2021522            { + 2021523                 if (type.GetTypeInfo().IsGenericType && type.GetGenericTypeDefinition() == generic) + 531524                    return type; + 1491525                 if (generic.GetTypeInfo().IsInterface) + 1491526                { + 6101527                    foreach (Type intfType in type.GetInterfaces()) + 1391528                    { + 1391529                        Type found = FindGenericType(generic, intfType); + 2541530                         if (found != null) return found; + 241531                    } + 341532                } + 341533                type = type.GetTypeInfo().BaseType; + 341534            } + 341535            return null; + 2021536        }15371538        Type FindType(string name) + 41539        {1540            object type; + 41541            _keywords.TryGetValue(name, out type); + 41542            var result = type as Type; + 41543             if (result != null) + 11544                return result; + 31545             if (_it != null && _it.Type.Name == name) + 11546                return _it.Type; + 21547             if (_parent != null && _parent.Type.Name == name) + 01548                return _parent.Type; + 21549             if (_root != null && _root.Type.Name == name) + 01550                return _root.Type; + 21551             if (_it != null && _it.Type.Namespace + "." + _it.Type.Name == name) + 01552                return _it.Type; + 21553             if (_parent != null && _parent.Type.Namespace + "." + _parent.Type.Name == name) + 01554                return _parent.Type; + 21555             if (_root != null && _root.Type.Namespace + "." + _root.Type.Name == name) + 01556                return _root.Type; + 21557            return null; + 41558        }  1559 - 531560            return Expression.Call(typeof(Enumerable), signature.Name, typeArgs, args); - 531561        }15621563        Expression[] ParseArgumentList() - 821564        { - 821565            _textParser.ValidateToken(TokenId.OpenParen, Res.OpenParenExpected); - 821566            _textParser.NextToken(); - 821567             Expression[] args = _textParser.CurrentToken.Id != TokenId.CloseParen ? ParseArguments() : new Expression[0] - 821568            _textParser.ValidateToken(TokenId.CloseParen, Res.CloseParenOrCommaExpected); - 821569            _textParser.NextToken(); - 821570            return args; - 821571        }15721573        Expression[] ParseArguments() - 681574        { - 681575            List<Expression> argList = new List<Expression>(); - 771576            while (true) - 771577            { - 771578                argList.Add(ParseConditionalOperator());1579 - 771580                 if (_textParser.CurrentToken.Id != TokenId.Comma) - 681581                    break;1582 - 91583                _textParser.NextToken(); - 91584            }1585 - 681586            return argList.ToArray(); - 681587        }15881589        Expression ParseElementAccess(Expression expr) - 11590        { - 11591            int errorPos = _textParser.CurrentToken.Pos; - 11592            _textParser.ValidateToken(TokenId.OpenBracket, Res.OpenParenExpected); - 11593            _textParser.NextToken(); - 11594            Expression[] args = ParseArguments(); - 11595            _textParser.ValidateToken(TokenId.CloseBracket, Res.CloseBracketOrCommaExpected); - 11596            _textParser.NextToken(); - 11597             if (expr.Type.IsArray) - 01598            { - 01599                 if (expr.Type.GetArrayRank() != 1 || args.Length != 1) - 01600                    throw ParseError(errorPos, Res.CannotIndexMultiDimArray); - 01601                Expression index = PromoteExpression(args[0], typeof(int), true, false); - 01602                 if (index == null) - 01603                    throw ParseError(errorPos, Res.InvalidIndex); - 01604                return Expression.ArrayIndex(expr, index);1605            }1606            else - 11607            {1608                MethodBase mb; - 11609                 switch (FindIndexer(expr.Type, args, out mb))1610                {1611                    case 0: - 01612                        throw ParseError(errorPos, Res.NoApplicableIndexer, - 01613                            GetTypeName(expr.Type));1614                    case 1: - 11615                        return Expression.Call(expr, (MethodInfo)mb, args);1616                    default: - 01617                        throw ParseError(errorPos, Res.AmbiguousIndexerInvocation, - 01618                            GetTypeName(expr.Type));1619                }1620            } - 11621        }16221623        static bool IsPredefinedType(Type type) - 241624        { - 381625             if (_predefinedTypes.ContainsKey(type)) return true;1626 - 101627             if (GlobalConfig.CustomTypeProvider != null && GlobalConfig.CustomTypeProvider.GetCustomTypes().Contains(typ1628 - 101629            return false; - 241630        }1560        Expression ParseAggregate(Expression instance, Type elementType, string methodName, int errorPos) + 531561        { + 531562            var oldParent = _parent;1563 + 531564            ParameterExpression outerIt = _it; + 531565            ParameterExpression innerIt = Expression.Parameter(elementType, "");1566 + 531567            _parent = _it;1568 + 531569             if (methodName == "Contains" || methodName == "Skip" || methodName == "Take") + 61570            {1571                //for any method that acts on the parent element type, we need to specify the outerIt as scope. + 61572                _it = outerIt; + 61573            }1574            else + 471575            { + 471576                _it = innerIt; + 471577            }1578 + 531579            Expression[] args = ParseArgumentList();1580 + 531581            _it = outerIt; + 531582            _parent = oldParent;15831584            MethodBase signature; + 531585             if (FindMethod(typeof(IEnumerableSignatures), methodName, false, args, out signature) != 1) + 01586                throw ParseError(errorPos, Res.NoApplicableAggregate, methodName);15871588            Type[] typeArgs; + 531589             if (new[] { "Min", "Max", "Select", "OrderBy", "OrderByDescending", "ThenBy", "ThenByDescending", "GroupBy"  + 141590            { + 141591                typeArgs = new[] { elementType, args[0].Type }; + 141592            } + 391593             else if (signature.Name == "SelectMany") + 31594            { + 31595                var type = Expression.Lambda(args[0], innerIt).Body.Type; + 31596                var interfaces = type.GetInterfaces().Union(new[] { type }); + 301597                Type interfaceType = interfaces.Single(i => i.Name == typeof(IEnumerable<>).Name); + 31598                Type resultType = interfaceType.GetTypeInfo().GetGenericTypeArguments()[0]; + 31599                typeArgs = new[] { elementType, resultType }; + 31600            }1601            else + 361602            { + 361603                typeArgs = new[] { elementType }; + 361604            }1605 + 531606             if (signature.Name == "Contains" || signature.Name == "Take" || signature.Name == "Skip") + 61607            { + 61608                args = new[] { instance, args[0] }; + 61609            } + 471610             else if (args.Length == 0) + 121611            { + 121612                args = new[] { instance }; + 121613            }1614            else + 351615            { + 351616                args = new[] { instance, Expression.Lambda(args[0], innerIt) }; + 351617            }1618 + 531619            return Expression.Call(typeof(Enumerable), signature.Name, typeArgs, args); + 531620        }16211622        Expression[] ParseArgumentList() + 861623        { + 861624            _textParser.ValidateToken(TokenId.OpenParen, Res.OpenParenExpected); + 861625            _textParser.NextToken(); + 861626             Expression[] args = _textParser.CurrentToken.Id != TokenId.CloseParen ? ParseArguments() : new Expression[0] + 861627            _textParser.ValidateToken(TokenId.CloseParen, Res.CloseParenOrCommaExpected); + 861628            _textParser.NextToken(); + 861629            return args; + 861630        }  16311632        public static bool IsNullableType(Type type) - 107311633        { - 107311634            return type.GetTypeInfo().IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>); - 107311635        }16361637        public static Type ToNullableType(Type type) - 21638        { - 21639             if (!type.GetTypeInfo().IsValueType || IsNullableType(type)) - 01640                throw ParseError(-1, Res.TypeHasNoNullableForm, GetTypeName(type));1632        Expression[] ParseArguments() + 721633        { + 721634            List<Expression> argList = new List<Expression>(); + 811635            while (true) + 811636            { + 811637                argList.Add(ParseConditionalOperator());1638 + 811639                 if (_textParser.CurrentToken.Id != TokenId.Comma) + 721640                    break;  1641 - 21642            return typeof(Nullable<>).MakeGenericType(type); - 21643        } + 91642                _textParser.NextToken(); + 91643            }  16441645        static Type GetNonNullableType(Type type) - 106781646        { - 106781647             return IsNullableType(type) ? type.GetTypeInfo().GetGenericTypeArguments()[0] : type; - 106781648        }16491650        static string GetTypeName(Type type) - 181651        { - 181652            Type baseType = GetNonNullableType(type); - 181653            string s = baseType.Name; - 181654             if (type != baseType) s += '?'; - 181655            return s; - 181656        }16571658        static bool TryGetMemberName(Expression expression, out string memberName) - 331659        { - 331660            var memberExpression = expression as MemberExpression; - 331661             if (memberExpression == null && expression.NodeType == ExpressionType.Coalesce) - 01662            { - 01663                memberExpression = (expression as BinaryExpression).Left as MemberExpression; - 01664            }1665 - 331666             if (memberExpression != null) - 331667            { - 331668                memberName = memberExpression.Member.Name; - 331669                return true;1670            }16711672#if NETFX_CORE1673            var indexExpression = expression as IndexExpression;1674            if (indexExpression != null && indexExpression.Indexer.DeclaringType == typeof(DynamicObjectClass))1675            {1676                memberName = ((ConstantExpression)indexExpression.Arguments.First()).Value as string;1677                return true;1678            }1679#endif1680            //#if !NET351681            //            var dynamicExpression = expression as Expressions.DynamicExpression;1682            //            if (dynamicExpression != null)1683            //            {1684            //                memberName = ((GetMemberBinder)dynamicExpression.Binder).Name;1685            //                return true;1686            //            }1687            //#endif1688 - 01689            memberName = null; - 01690            return false; - 331691        }16921693        static bool IsNumericType(Type type) - 21694        { - 21695            return GetNumericTypeKind(type) != 0; - 21696        }16971698        static bool IsSignedIntegralType(Type type) - 1921699        { - 1921700            return GetNumericTypeKind(type) == 2; - 1921701        }17021703        static bool IsUnsignedIntegralType(Type type) - 1281704        { - 1281705            return GetNumericTypeKind(type) == 3; - 1281706        }17071708        static int GetNumericTypeKind(Type type) - 3221709        { - 3221710            type = GetNonNullableType(type);1711#if !(NETFX_CORE || WINDOWS_APP || DOTNET5_1 || UAP10_0 || NETSTANDARD)1712            if (type.GetTypeInfo().IsEnum) return 0;17131714            switch (Type.GetTypeCode(type))1715            {1716                case TypeCode.Char:1717                case TypeCode.Single:1718                case TypeCode.Double:1719                case TypeCode.Decimal:1720                    return 1;1721                case TypeCode.SByte:1722                case TypeCode.Int16:1723                case TypeCode.Int32:1724                case TypeCode.Int64:1725                    return 2;1726                case TypeCode.Byte:1727                case TypeCode.UInt16:1728                case TypeCode.UInt32:1729                case TypeCode.UInt64:1730                    return 3;1731                default:1732                    return 0;1733            }1734#else - 3221735             if (type.GetTypeInfo().IsEnum) return 0;1736 - 3221737             if (type == typeof(Char) || type == typeof(Single) || type == typeof(Double) || type == typeof(Decimal)) - 21738                return 1; - 3201739             if (type == typeof(SByte) || type == typeof(Int16) || type == typeof(Int32) || type == typeof(Int64)) - 1281740                return 2; - 1921741             if (type == typeof(Byte) || type == typeof(UInt16) || type == typeof(UInt32) || type == typeof(UInt64)) - 1921742                return 3; - 01743            return 0;1744#endif - 3221745        }17461747        static bool IsEnumType(Type type) - 2761748        { - 2761749            return GetNonNullableType(type).GetTypeInfo().IsEnum; - 2761750        } + 721645            return argList.ToArray(); + 721646        }16471648        Expression ParseElementAccess(Expression expr) + 11649        { + 11650            int errorPos = _textParser.CurrentToken.Pos; + 11651            _textParser.ValidateToken(TokenId.OpenBracket, Res.OpenParenExpected); + 11652            _textParser.NextToken(); + 11653            Expression[] args = ParseArguments(); + 11654            _textParser.ValidateToken(TokenId.CloseBracket, Res.CloseBracketOrCommaExpected); + 11655            _textParser.NextToken(); + 11656             if (expr.Type.IsArray) + 01657            { + 01658                 if (expr.Type.GetArrayRank() != 1 || args.Length != 1) + 01659                    throw ParseError(errorPos, Res.CannotIndexMultiDimArray); + 01660                Expression index = PromoteExpression(args[0], typeof(int), true, false); + 01661                 if (index == null) + 01662                    throw ParseError(errorPos, Res.InvalidIndex); + 01663                return Expression.ArrayIndex(expr, index);1664            }1665            else + 11666            {1667                MethodBase mb; + 11668                 switch (FindIndexer(expr.Type, args, out mb))1669                {1670                    case 0: + 01671                        throw ParseError(errorPos, Res.NoApplicableIndexer, + 01672                            GetTypeName(expr.Type));1673                    case 1: + 11674                        return Expression.Call(expr, (MethodInfo)mb, args);1675                    default: + 01676                        throw ParseError(errorPos, Res.AmbiguousIndexerInvocation, + 01677                            GetTypeName(expr.Type));1678                }1679            } + 11680        }16811682        static bool IsPredefinedType(Type type) + 241683        { + 381684             if (_predefinedTypes.ContainsKey(type)) return true;1685 + 101686             if (GlobalConfig.CustomTypeProvider != null && GlobalConfig.CustomTypeProvider.GetCustomTypes().Contains(typ1687 + 101688            return false; + 241689        }16901691        public static bool IsNullableType(Type type) + 117491692        { + 117491693            return type.GetTypeInfo().IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>); + 117491694        }16951696        public static Type ToNullableType(Type type) + 21697        { + 21698             if (!type.GetTypeInfo().IsValueType || IsNullableType(type)) + 01699                throw ParseError(-1, Res.TypeHasNoNullableForm, GetTypeName(type));1700 + 21701            return typeof(Nullable<>).MakeGenericType(type); + 21702        }17031704        static Type GetNonNullableType(Type type) + 116841705        { + 116841706             return IsNullableType(type) ? type.GetTypeInfo().GetGenericTypeArguments()[0] : type; + 116841707        }17081709        static string GetTypeName(Type type) + 181710        { + 181711            Type baseType = GetNonNullableType(type); + 181712            string s = baseType.Name; + 181713             if (type != baseType) s += '?'; + 181714            return s; + 181715        }17161717        static bool TryGetMemberName(Expression expression, out string memberName) + 331718        { + 331719            var memberExpression = expression as MemberExpression; + 331720             if (memberExpression == null && expression.NodeType == ExpressionType.Coalesce) + 01721            { + 01722                memberExpression = (expression as BinaryExpression).Left as MemberExpression; + 01723            }1724 + 331725             if (memberExpression != null) + 331726            { + 331727                memberName = memberExpression.Member.Name; + 331728                return true;1729            }17301731#if NETFX_CORE1732            var indexExpression = expression as IndexExpression;1733            if (indexExpression != null && indexExpression.Indexer.DeclaringType == typeof(DynamicObjectClass))1734            {1735                memberName = ((ConstantExpression)indexExpression.Arguments.First()).Value as string;1736                return true;1737            }1738#endif1739            //#if !NET351740            //            var dynamicExpression = expression as Expressions.DynamicExpression;1741            //            if (dynamicExpression != null)1742            //            {1743            //                memberName = ((GetMemberBinder)dynamicExpression.Binder).Name;1744            //                return true;1745            //            }1746            //#endif1747 + 01748            memberName = null; + 01749            return false; + 331750        }  17511752        void CheckAndPromoteOperand(Type signatures, string opName, ref Expression expr, int errorPos) - 01753        { - 01754            Expression[] args = { expr };1755            MethodBase method; - 01756             if (FindMethod(signatures, "F", false, args, out method) != 1) - 01757                throw ParseError(errorPos, Res.IncompatibleOperand, opName, GetTypeName(args[0].Type));1758 - 01759            expr = args[0]; - 01760        }1752        static bool IsNumericType(Type type) + 101753        { + 101754            return GetNumericTypeKind(type) != 0; + 101755        }17561757        static bool IsSignedIntegralType(Type type) + 1921758        { + 1921759            return GetNumericTypeKind(type) == 2; + 1921760        }  17611762        void CheckAndPromoteOperands(Type signatures, string opName, ref Expression left, ref Expression right, int erro - 1681763        { - 1681764            Expression[] args = { left, right };17651766            MethodBase method; - 1681767             if (FindMethod(signatures, "F", false, args, out method) != 1) - 41768                throw IncompatibleOperandsError(opName, left, right, errorPos);1769 - 1641770            left = args[0]; - 1641771            right = args[1]; - 1641772        }17731774        static Exception IncompatibleOperandsError(string opName, Expression left, Expression right, int pos) - 41775        { - 41776            return ParseError(pos, Res.IncompatibleOperands, opName, GetTypeName(left.Type), GetTypeName(right.Type)); - 41777        }17781779        static MemberInfo FindPropertyOrField(Type type, string memberName, bool staticAccess) - 3171780        {1781#if !(NETFX_CORE || WINDOWS_APP || DOTNET5_1 || UAP10_0 || NETSTANDARD)1782            BindingFlags flags = BindingFlags.Public | BindingFlags.DeclaredOnly | (staticAccess ? BindingFlags.Static :1783            foreach (Type t in SelfAndBaseTypes(type))1784            {1785                MemberInfo[] members = t.FindMembers(MemberTypes.Property | MemberTypes.Field, flags, Type.FilterNameIgn1786                if (members.Length != 0)1787                    return members[0];1788            }1789            return null;1790#else - 13251791            foreach (Type t in SelfAndBaseTypes(type)) - 3381792            {1793                // Try to find a property with the specified memberName - 13141794                MemberInfo member = t.GetTypeInfo().DeclaredProperties.FirstOrDefault(x => x.Name.ToLowerInvariant() ==  - 3381795                 if (member != null) - 3021796                    return member;17971798                // If no property is found, try to get a field with the specified memberName - 1081799                 member = t.GetTypeInfo().DeclaredFields.FirstOrDefault(x => (x.IsStatic || !staticAccess) && x.Name.ToLo - 361800                 if (member != null) - 01801                    return member;18021803                // No property or field is found, try the base type. - 361804            } - 151805            return null;1806#endif - 3171807        }18081809        int FindMethod(Type type, string methodName, bool staticAccess, Expression[] args, out MethodBase method) - 2381810        {1811#if !(NETFX_CORE || WINDOWS_APP || DOTNET5_1 || UAP10_0 || NETSTANDARD)1812            BindingFlags flags = BindingFlags.Public | BindingFlags.DeclaredOnly |1813                (staticAccess ? BindingFlags.Static : BindingFlags.Instance);1814            foreach (Type t in SelfAndBaseTypes(type))1815            {1816                MemberInfo[] members = t.FindMembers(MemberTypes.Method,1817                    flags, Type.FilterNameIgnoreCase, methodName);1818                int count = FindBestMethod(members.Cast<MethodBase>(), args, out method);1819                if (count != 0) return count;1820            }1821            method = null;1822            return 0;1823#else - 12941824            foreach (Type t in SelfAndBaseTypes(type)) - 4071825            { - 78281826                 MethodInfo[] methods = t.GetTypeInfo().DeclaredMethods.Where(x => (x.IsStatic || !staticAccess) && x.Nam - 4071827                int count = FindBestMethod(methods, args, out method); - 6411828                 if (count != 0) return count; - 1731829            }1830 - 41831            method = null; - 41832            return 0;1833#endif - 2381834        }18351836        int FindIndexer(Type type, Expression[] args, out MethodBase method) - 11837        { - 41838            foreach (Type t in SelfAndBaseTypes(type)) - 11839            {1840                //#if !(NETFX_CORE || WINDOWS_APP || DOTNET5_1 || UAP10_0 || NETSTANDARD) - 11841                MemberInfo[] members = t.GetDefaultMembers();1842                //#else1843                //                MemberInfo[] members = new MemberInfo[0];1844                //#endif - 11845                 if (members.Length != 0) - 11846                { - 11847                    IEnumerable<MethodBase> methods = members - 11848                        .OfType<PropertyInfo>(). - 11849#if !(NETFX_CORE || WINDOWS_APP || DOTNET5_1 || UAP10_0 || NETSTANDARD) - 11850                        Select(p => (MethodBase)p.GetGetMethod()). - 11851                        Where(m => m != null); - 11852#else - 31853                    Select(p => (MethodBase)p.GetMethod);1854#endif1855 - 11856                    int count = FindBestMethod(methods, args, out method); - 21857                     if (count != 0) return count; - 01858                } - 01859            } - 01860            method = null; - 01861            return 0; - 11862        }18631864        static IEnumerable<Type> SelfAndBaseTypes(Type type) - 5561865        { - 5561866             if (type.GetTypeInfo().IsInterface) - 2351867            { - 2351868                List<Type> types = new List<Type>(); - 2351869                AddInterface(types, type); - 2351870                return types;1871            } - 3211872            return SelfAndBaseClasses(type); - 5561873        }18741875        static IEnumerable<Type> SelfAndBaseClasses(Type type) - 3211876        { - 3511877             while (type != null) - 3381878            { - 3381879                yield return type; - 301880                type = type.GetTypeInfo().BaseType; - 301881            } - 131882        }18831884        static void AddInterface(List<Type> types, Type type) - 5061885        { - 5061886             if (!types.Contains(type)) - 4301887            { - 4301888                types.Add(type); - 21031889                foreach (Type t in type.GetInterfaces()) AddInterface(types, t); - 4301890            } - 5061891        }18921893        class MethodData1894        {1895            public MethodBase MethodBase;1896            public ParameterInfo[] Parameters;1897            public Expression[] Args;1898        }18991900        int FindBestMethod(IEnumerable<MethodBase> methods, Expression[] args, out MethodBase method) - 4111901        { - 4111902            MethodData[] applicable = methods. - 41901903                Select(m => new MethodData { MethodBase = m, Parameters = m.GetParameters() }). - 41901904                Where(m => IsApplicable(m, args)). - 4111905                ToArray();1906 - 4111907             if (applicable.Length > 1) - 1681908            { - 38531909                applicable = applicable.Where(m => applicable.All(n => m == n || IsBetterThan(args, m, n))).ToArray(); - 1681910            }1911 - 4111912             if (applicable.Length == 1) - 2361913            { - 2361914                MethodData md = applicable[0]; - 16271915                 for (int i = 0; i < args.Length; i++) args[i] = md.Args[i]; - 2361916                method = md.MethodBase; - 2361917            }1918            else - 1751919            { - 1751920                method = null; - 1751921            }1762        static bool IsUnsignedIntegralType(Type type) + 1281763        { + 1281764            return GetNumericTypeKind(type) == 3; + 1281765        }17661767        static int GetNumericTypeKind(Type type) + 3301768        { + 3301769            type = GetNonNullableType(type);1770#if !(NETFX_CORE || WINDOWS_APP || DOTNET5_1 || UAP10_0 || NETSTANDARD)1771            if (type.GetTypeInfo().IsEnum) return 0;17721773            switch (Type.GetTypeCode(type))1774            {1775                case TypeCode.Char:1776                case TypeCode.Single:1777                case TypeCode.Double:1778                case TypeCode.Decimal:1779                    return 1;1780                case TypeCode.SByte:1781                case TypeCode.Int16:1782                case TypeCode.Int32:1783                case TypeCode.Int64:1784                    return 2;1785                case TypeCode.Byte:1786                case TypeCode.UInt16:1787                case TypeCode.UInt32:1788                case TypeCode.UInt64:1789                    return 3;1790                default:1791                    return 0;1792            }1793#else + 3301794             if (type.GetTypeInfo().IsEnum) return 0;1795 + 3301796             if (type == typeof(Char) || type == typeof(Single) || type == typeof(Double) || type == typeof(Decimal)) + 21797                return 1; + 3281798             if (type == typeof(SByte) || type == typeof(Int16) || type == typeof(Int32) || type == typeof(Int64)) + 1331799                return 2; + 1951800             if (type == typeof(Byte) || type == typeof(UInt16) || type == typeof(UInt32) || type == typeof(UInt64)) + 1951801                return 3; + 01802            return 0;1803#endif + 3301804        }18051806        static bool IsEnumType(Type type) + 2781807        { + 2781808            return GetNonNullableType(type).GetTypeInfo().IsEnum; + 2781809        }18101811        void CheckAndPromoteOperand(Type signatures, string opName, ref Expression expr, int errorPos) + 01812        { + 01813            Expression[] args = { expr };1814            MethodBase method; + 01815             if (FindMethod(signatures, "F", false, args, out method) != 1) + 01816                throw ParseError(errorPos, Res.IncompatibleOperand, opName, GetTypeName(args[0].Type));1817 + 01818            expr = args[0]; + 01819        }18201821        void CheckAndPromoteOperands(Type signatures, string opName, ref Expression left, ref Expression right, int erro + 1841822        { + 1841823            Expression[] args = { left, right };18241825            MethodBase method; + 1841826             if (FindMethod(signatures, "F", false, args, out method) != 1) + 41827                throw IncompatibleOperandsError(opName, left, right, errorPos);1828 + 1801829            left = args[0]; + 1801830            right = args[1]; + 1801831        }18321833        static Exception IncompatibleOperandsError(string opName, Expression left, Expression right, int pos) + 41834        { + 41835            return ParseError(pos, Res.IncompatibleOperands, opName, GetTypeName(left.Type), GetTypeName(right.Type)); + 41836        }18371838        static MemberInfo FindPropertyOrField(Type type, string memberName, bool staticAccess) + 3171839        {1840#if !(NETFX_CORE || WINDOWS_APP || DOTNET5_1 || UAP10_0 || NETSTANDARD)1841            BindingFlags flags = BindingFlags.Public | BindingFlags.DeclaredOnly | (staticAccess ? BindingFlags.Static :1842            foreach (Type t in SelfAndBaseTypes(type))1843            {1844                MemberInfo[] members = t.FindMembers(MemberTypes.Property | MemberTypes.Field, flags, Type.FilterNameIgn1845                if (members.Length != 0)1846                    return members[0];1847            }1848            return null;1849#else + 13251850            foreach (Type t in SelfAndBaseTypes(type)) + 3381851            {1852                // Try to find a property with the specified memberName + 13141853                MemberInfo member = t.GetTypeInfo().DeclaredProperties.FirstOrDefault(x => x.Name.ToLowerInvariant() ==  + 3381854                 if (member != null) + 3021855                    return member;18561857                // If no property is found, try to get a field with the specified memberName + 1081858                 member = t.GetTypeInfo().DeclaredFields.FirstOrDefault(x => (x.IsStatic || !staticAccess) && x.Name.ToLo + 361859                 if (member != null) + 01860                    return member;18611862                // No property or field is found, try the base type. + 361863            } + 151864            return null;1865#endif + 3171866        }18671868        int FindMethod(Type type, string methodName, bool staticAccess, Expression[] args, out MethodBase method) + 2541869        {1870#if !(NETFX_CORE || WINDOWS_APP || DOTNET5_1 || UAP10_0 || NETSTANDARD)1871            BindingFlags flags = BindingFlags.Public | BindingFlags.DeclaredOnly |1872                (staticAccess ? BindingFlags.Static : BindingFlags.Instance);1873            foreach (Type t in SelfAndBaseTypes(type))1874            {1875                MemberInfo[] members = t.FindMembers(MemberTypes.Method,1876                    flags, Type.FilterNameIgnoreCase, methodName);1877                int count = FindBestMethod(members.Cast<MethodBase>(), args, out method);1878                if (count != 0) return count;1879            }1880            method = null;1881            return 0;1882#else + 13781883            foreach (Type t in SelfAndBaseTypes(type)) + 4331884            { + 81231885                 MethodInfo[] methods = t.GetTypeInfo().DeclaredMethods.Where(x => (x.IsStatic || !staticAccess) && x.Nam + 4331886                int count = FindBestMethod(methods, args, out method); + 6831887                 if (count != 0) return count; + 1831888            }1889 + 41890            method = null; + 41891            return 0;1892#endif + 2541893        }18941895        int FindIndexer(Type type, Expression[] args, out MethodBase method) + 11896        { + 41897            foreach (Type t in SelfAndBaseTypes(type)) + 11898            {1899                //#if !(NETFX_CORE || WINDOWS_APP || DOTNET5_1 || UAP10_0 || NETSTANDARD) + 11900                MemberInfo[] members = t.GetDefaultMembers();1901                //#else1902                //                MemberInfo[] members = new MemberInfo[0];1903                //#endif + 11904                 if (members.Length != 0) + 11905                { + 11906                    IEnumerable<MethodBase> methods = members + 11907                        .OfType<PropertyInfo>(). + 11908#if !(NETFX_CORE || WINDOWS_APP || DOTNET5_1 || UAP10_0 || NETSTANDARD) + 11909                        Select(p => (MethodBase)p.GetGetMethod()). + 11910                        Where(m => m != null); + 11911#else + 31912                    Select(p => (MethodBase)p.GetMethod);1913#endif1914 + 11915                    int count = FindBestMethod(methods, args, out method); + 21916                     if (count != 0) return count; + 01917                } + 01918            } + 01919            method = null; + 01920            return 0; + 11921        }  1922 - 4111923            return applicable.Length; - 4111924        }19251926        bool IsApplicable(MethodData method, Expression[] args) - 37791927        { - 38021928             if (method.Parameters.Length != args.Length) return false; - 37561929            Expression[] promotedArgs = new Expression[args.Length]; - 127761930             for (int i = 0; i < args.Length; i++) - 50361931            { - 50361932                ParameterInfo pi = method.Parameters[i]; - 50361933                 if (pi.IsOut) return false; - 50361934                Expression promoted = PromoteExpression(args[i], pi.ParameterType, false, method.MethodBase.DeclaringTyp - 74401935                 if (promoted == null) return false; - 26321936                promotedArgs[i] = promoted; - 26321937            } - 13521938            method.Args = promotedArgs; - 13521939            return true; - 37791940        }19411942        Expression PromoteExpression(Expression expr, Type type, bool exact, bool convertExpr) - 52381943        { - 52381944             if (expr.Type == type) - 6311945                return expr;1946 - 46071947            var ce = expr as ConstantExpression;1948 - 46071949             if (ce != null) - 10251950            { - 10251951                 if (ce == NullLiteral) - 391952                { - 391953                     if (!type.GetTypeInfo().IsValueType || IsNullableType(type)) - 231954                        return Expression.Constant(null, type); - 161955                }1956                else - 9861957                {1958                    string text; - 9861959                     if (_literals.TryGetValue(ce, out text)) - 8311960                    { - 8311961                        Type target = GetNonNullableType(type); - 8311962                        object value = null;19631964#if !(NETFX_CORE || WINDOWS_APP || DOTNET5_1 || UAP10_0 || NETSTANDARD)1965                        switch (Type.GetTypeCode(ce.Type))1966                        {1967                            case TypeCode.Int32:1968                            case TypeCode.UInt32:1969                            case TypeCode.Int64:1970                            case TypeCode.UInt64:1971                                value = ParseNumber(text, target);19721973                                // Make sure an enum value stays an enum value1974                                if (target.IsEnum)1975                                    value = Enum.ToObject(target, value);1976                                break;19771978                            case TypeCode.Double:1979                                if (target == typeof(decimal)) value = ParseNumber(text, target);1980                                break;1923        static IEnumerable<Type> SelfAndBaseTypes(Type type) + 5721924        { + 5721925             if (type.GetTypeInfo().IsInterface) + 2511926            { + 2511927                List<Type> types = new List<Type>(); + 2511928                AddInterface(types, type); + 2511929                return types;1930            } + 3211931            return SelfAndBaseClasses(type); + 5721932        }19331934        static IEnumerable<Type> SelfAndBaseClasses(Type type) + 3211935        { + 3511936             while (type != null) + 3381937            { + 3381938                yield return type; + 301939                type = type.GetTypeInfo().BaseType; + 301940            } + 131941        }19421943        static void AddInterface(List<Type> types, Type type) + 5321944        { + 5321945             if (!types.Contains(type)) + 4561946            { + 4561947                types.Add(type); + 22111948                foreach (Type t in type.GetInterfaces()) AddInterface(types, t); + 4561949            } + 5321950        }19511952        class MethodData1953        {1954            public MethodBase MethodBase;1955            public ParameterInfo[] Parameters;1956            public Expression[] Args;1957        }19581959        int FindBestMethod(IEnumerable<MethodBase> methods, Expression[] args, out MethodBase method) + 4411960        { + 4411961            MethodData[] applicable = methods. + 44891962                Select(m => new MethodData { MethodBase = m, Parameters = m.GetParameters() }). + 44891963                Where(m => IsApplicable(m, args)). + 4411964                ToArray();1965 + 4411966             if (applicable.Length > 1) + 1841967            { + 43211968                applicable = applicable.Where(m => applicable.All(n => m == n || IsBetterThan(args, m, n))).ToArray(); + 1841969            }1970 + 4411971             if (applicable.Length == 1) + 2521972            { + 2521973                MethodData md = applicable[0]; + 17551974                 for (int i = 0; i < args.Length; i++) args[i] = md.Args[i]; + 2521975                method = md.MethodBase; + 2521976            }1977            else + 1891978            { + 1891979                method = null; + 1891980            }  19811982                            case TypeCode.String:1983                                value = ParseEnum(text, target);1984                                break;1985                        }1986#else - 8311987                         if (ce.Type == typeof(Int32) || ce.Type == typeof(UInt32) || ce.Type == typeof(Int64) || ce.Type - 8031988                        { - 8031989                            value = ParseNumber(text, target);19901991                            // Make sure an enum value stays an enum value - 8031992                             if (target.GetTypeInfo().IsEnum) - 01993                                value = Enum.ToObject(target, value); - 8031994                        } - 281995                         else if (ce.Type == typeof(Double)) - 151996                        { - 151997                             if (target == typeof(decimal)) value = ParseNumber(text, target); - 151998                        } - 131999                         else if (ce.Type == typeof(String)) - 12000                        { - 12001                            value = ParseEnum(text, target); - 12002                        }2003#endif - 8312004                         if (value != null) - 7522005                            return Expression.Constant(value, type); - 792006                    } - 2342007                } - 2502008            }2009 - 38322010             if (IsCompatibleWith(expr.Type, type)) - 14052011            { - 14052012                 if (type.GetTypeInfo().IsValueType || exact || (expr.Type.GetTypeInfo().IsValueType && convertExpr)) - 13792013                    return Expression.Convert(expr, type);2014 - 262015                return expr;2016            }2017 - 24272018            return null; - 52382019        }20202021        static object ParseNumber(string text, Type type) - 8032022        { + 4411982            return applicable.Length; + 4411983        }19841985        bool IsApplicable(MethodData method, Expression[] args) + 40481986        { + 40711987             if (method.Parameters.Length != args.Length) return false; + 40251988            Expression[] promotedArgs = new Expression[args.Length]; + 139461989             for (int i = 0; i < args.Length; i++) + 54651990            { + 54651991                ParameterInfo pi = method.Parameters[i]; + 54651992                 if (pi.IsOut) return false; + 54651993                Expression promoted = PromoteExpression(args[i], pi.ParameterType, false, method.MethodBase.DeclaringTyp + 79821994                 if (promoted == null) return false; + 29481995                promotedArgs[i] = promoted; + 29481996            } + 15081997            method.Args = promotedArgs; + 15081998            return true; + 40481999        }20002001        Expression PromoteExpression(Expression expr, Type type, bool exact, bool convertExpr) + 56712002        { + 56712003             if (expr.Type == type) + 6642004                return expr;2005 + 50072006            var ce = expr as ConstantExpression;2007 + 50072008             if (ce != null) + 11692009            { + 11692010                 if (ce == NullLiteral) + 392011                { + 392012                     if (!type.GetTypeInfo().IsValueType || IsNullableType(type)) + 232013                        return Expression.Constant(null, type); + 162014                }2015                else + 11302016                {2017                    string text; + 11302018                     if (_literals.TryGetValue(ce, out text)) + 9752019                    { + 9752020                        Type target = GetNonNullableType(type); + 9752021                        object value = null;2022  2023#if !(NETFX_CORE || WINDOWS_APP || DOTNET5_1 || UAP10_0 || NETSTANDARD)2024            switch (Type.GetTypeCode(GetNonNullableType(type)))2025            {2026                case TypeCode.SByte:2027                    sbyte sb;2028                    if (sbyte.TryParse(text, out sb)) return sb;2029                    break;2030                case TypeCode.Byte:2031                    byte b;2032                    if (byte.TryParse(text, out b)) return b;2033                    break;2034                case TypeCode.Int16:2035                    short s;2036                    if (short.TryParse(text, out s)) return s;2037                    break;2038                case TypeCode.UInt16:2039                    ushort us;2040                    if (ushort.TryParse(text, out us)) return us;2041                    break;2042                case TypeCode.Int32:2043                    int i;2044                    if (int.TryParse(text, out i)) return i;2045                    break;2046                case TypeCode.UInt32:2047                    uint ui;2048                    if (uint.TryParse(text, out ui)) return ui;2049                    break;2050                case TypeCode.Int64:2051                    long l;2052                    if (long.TryParse(text, out l)) return l;2053                    break;2054                case TypeCode.UInt64:2055                    ulong ul;2056                    if (ulong.TryParse(text, out ul)) return ul;2057                    break;2058                case TypeCode.Single:2059                    float f;2060                    if (float.TryParse(text, out f)) return f;2061                    break;2062                case TypeCode.Double:2063                    double d;2064                    if (double.TryParse(text, out d)) return d;2065                    break;2066                case TypeCode.Decimal:2067                    decimal e;2068                    if (decimal.TryParse(text, out e)) return e;2069                    break;2070            }2071#else - 8032072            var tp = GetNonNullableType(type); - 8032073             if (tp == typeof(SByte)) - 02074            {2075                sbyte sb; - 02076                 if (sbyte.TryParse(text, out sb)) return sb; - 02077            } - 8032078             else if (tp == typeof(Byte)) - 02079            {2080                byte b; - 02081                 if (byte.TryParse(text, out b)) return b; - 02082            } - 8032083             else if (tp == typeof(Int16)) - 02084            {2085                short s; - 02086                 if (short.TryParse(text, out s)) return s; - 02087            } - 8032088             else if (tp == typeof(UInt16)) - 02089            {2090                ushort us; - 02091                 if (ushort.TryParse(text, out us)) return us; - 02092            } - 8032093             else if (tp == typeof(Int32)) - 1722094            {2095                int i; - 3442096                 if (int.TryParse(text, out i)) return i; - 02097            } - 6312098             else if (tp == typeof(UInt32)) - 162099            {2100                uint ui; - 322101                 if (uint.TryParse(text, out ui)) return ui; - 02102            } - 6152103             else if (tp == typeof(Int64)) - 1272104            {2105                long l; - 2542106                 if (long.TryParse(text, out l)) return l; - 02107            } - 4882108             else if (tp == typeof(UInt64)) - 202109            {2110                ulong ul; - 402111                 if (ulong.TryParse(text, out ul)) return ul; - 02112            } - 4682113             else if (tp == typeof(Single)) - 1362114            {2115                float f; - 2722116                 if (float.TryParse(text, out f)) return f; - 02117            } - 3322118             else if (tp == typeof(Double)) - 1482119            {2120                double d; - 2962121                 if (double.TryParse(text, out d)) return d; - 02122            } - 1842123             else if (tp == typeof(Decimal)) - 1332124            {2125                decimal e; - 2662126                 if (decimal.TryParse(text, out e)) return e; - 02127            }2128#endif - 512129            return null; - 8032130        }21312132        static object ParseEnum(string value, Type type) - 12133        {2134#if !(NETFX_CORE || WINDOWS_APP || DOTNET5_1 || UAP10_0 || NETSTANDARD)2135            if (type.IsEnum)2136            {2137                MemberInfo[] memberInfos = type.FindMembers(MemberTypes.Field,2138                    BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.Static,2139                    Type.FilterNameIgnoreCase, value);21402141                if (memberInfos.Length != 0)2142                    return ((FieldInfo)memberInfos[0]).GetValue(null);2143            }2144#else - 12145             if (type.GetTypeInfo().IsEnum) - 02146            { - 02147                return Enum.Parse(type, value, true);2148            }2149#endif - 12150            return null; - 12151        }21522153        static bool IsCompatibleWith(Type source, Type target) - 44882154        {2155#if !(NETFX_CORE || WINDOWS_APP || DOTNET5_1 || UAP10_0 || NETSTANDARD)2156            if (source == target) return true;2157            if (!target.IsValueType) return target.IsAssignableFrom(source);2158            Type st = GetNonNullableType(source);2159            Type tt = GetNonNullableType(target);2160            if (st != source && tt == target) return false;2161            TypeCode sc = st.GetTypeInfo().IsEnum ? TypeCode.Object : Type.GetTypeCode(st);2162            TypeCode tc = tt.GetTypeInfo().IsEnum ? TypeCode.Object : Type.GetTypeCode(tt);2163            switch (sc)2164            {2165                case TypeCode.SByte:2166                    switch (tc)2167                    {2168                        case TypeCode.SByte:2169                        case TypeCode.Int16:2170                        case TypeCode.Int32:2171                        case TypeCode.Int64:2172                        case TypeCode.Single:2173                        case TypeCode.Double:2174                        case TypeCode.Decimal:2175                            return true;2176                    }2177                    break;2178                case TypeCode.Byte:2179                    switch (tc)2180                    {2181                        case TypeCode.Byte:2182                        case TypeCode.Int16:2183                        case TypeCode.UInt16:2184                        case TypeCode.Int32:2185                        case TypeCode.UInt32:2186                        case TypeCode.Int64:2187                        case TypeCode.UInt64:2188                        case TypeCode.Single:2189                        case TypeCode.Double:2190                        case TypeCode.Decimal:2191                            return true;2192                    }2193                    break;2194                case TypeCode.Int16:2195                    switch (tc)2196                    {2197                        case TypeCode.Int16:2198                        case TypeCode.Int32:2199                        case TypeCode.Int64:2200                        case TypeCode.Single:2201                        case TypeCode.Double:2202                        case TypeCode.Decimal:2203                            return true;2204                    }2205                    break;2206                case TypeCode.UInt16:2207                    switch (tc)2208                    {2209                        case TypeCode.UInt16:2210                        case TypeCode.Int32:2211                        case TypeCode.UInt32:2212                        case TypeCode.Int64:2213                        case TypeCode.UInt64:2214                        case TypeCode.Single:2215                        case TypeCode.Double:2216                        case TypeCode.Decimal:2217                            return true;2218                    }2219                    break;2220                case TypeCode.Int32:2221                    switch (tc)2222                    {2223                        case TypeCode.Int32:2224                        case TypeCode.Int64:2225                        case TypeCode.Single:2226                        case TypeCode.Double:2227                        case TypeCode.Decimal:2228                            return true;2229                    }2230                    break;2231                case TypeCode.UInt32:2232                    switch (tc)2233                    {2234                        case TypeCode.UInt32:2235                        case TypeCode.Int64:2236                        case TypeCode.UInt64:2237                        case TypeCode.Single:2238                        case TypeCode.Double:2239                        case TypeCode.Decimal:2240                            return true;2241                    }2242                    break;2243                case TypeCode.Int64:2244                    switch (tc)2245                    {2246                        case TypeCode.Int64:2024                        switch (Type.GetTypeCode(ce.Type))2025                        {2026                            case TypeCode.Int32:2027                            case TypeCode.UInt32:2028                            case TypeCode.Int64:2029                            case TypeCode.UInt64:2030                                value = ParseNumber(text, target);20312032                                // Make sure an enum value stays an enum value2033                                if (target.IsEnum)2034                                    value = Enum.ToObject(target, value);2035                                break;20362037                            case TypeCode.Double:2038                                if (target == typeof(decimal)) value = ParseNumber(text, target);2039                                break;20402041                            case TypeCode.String:2042                                value = ParseEnum(text, target);2043                                break;2044                        }2045#else + 9752046                         if (ce.Type == typeof(Int32) || ce.Type == typeof(UInt32) || ce.Type == typeof(Int64) || ce.Type + 9472047                        { + 9472048                            value = ParseNumber(text, target);20492050                            // Make sure an enum value stays an enum value + 9472051                             if (target.GetTypeInfo().IsEnum) + 02052                                value = Enum.ToObject(target, value); + 9472053                        } + 282054                         else if (ce.Type == typeof(Double)) + 152055                        { + 152056                             if (target == typeof(decimal)) value = ParseNumber(text, target); + 152057                        } + 132058                         else if (ce.Type == typeof(String)) + 12059                        { + 12060                            value = ParseEnum(text, target); + 12061                        }2062#endif + 9752063                         if (value != null) + 8532064                            return Expression.Constant(value, type); + 1222065                    } + 2772066                } + 2932067            }2068 + 41312069             if (IsCompatibleWith(expr.Type, type)) + 15912070            { + 15912071                 if (type.GetTypeInfo().IsValueType || exact || (expr.Type.GetTypeInfo().IsValueType && convertExpr)) + 15652072                    return Expression.Convert(expr, type);2073 + 262074                return expr;2075            }2076 + 25402077            return null; + 56712078        }20792080        static object ParseNumber(string text, Type type) + 9472081        {2082#if !(NETFX_CORE || WINDOWS_APP || DOTNET5_1 || UAP10_0 || NETSTANDARD)2083            switch (Type.GetTypeCode(GetNonNullableType(type)))2084            {2085                case TypeCode.SByte:2086                    sbyte sb;2087                    if (sbyte.TryParse(text, out sb)) return sb;2088                    break;2089                case TypeCode.Byte:2090                    byte b;2091                    if (byte.TryParse(text, out b)) return b;2092                    break;2093                case TypeCode.Int16:2094                    short s;2095                    if (short.TryParse(text, out s)) return s;2096                    break;2097                case TypeCode.UInt16:2098                    ushort us;2099                    if (ushort.TryParse(text, out us)) return us;2100                    break;2101                case TypeCode.Int32:2102                    int i;2103                    if (int.TryParse(text, out i)) return i;2104                    break;2105                case TypeCode.UInt32:2106                    uint ui;2107                    if (uint.TryParse(text, out ui)) return ui;2108                    break;2109                case TypeCode.Int64:2110                    long l;2111                    if (long.TryParse(text, out l)) return l;2112                    break;2113                case TypeCode.UInt64:2114                    ulong ul;2115                    if (ulong.TryParse(text, out ul)) return ul;2116                    break;2117                case TypeCode.Single:2118                    float f;2119                    if (float.TryParse(text, out f)) return f;2120                    break;2121                case TypeCode.Double:2122                    double d;2123                    if (double.TryParse(text, out d)) return d;2124                    break;2125                case TypeCode.Decimal:2126                    decimal e;2127                    if (decimal.TryParse(text, out e)) return e;2128                    break;2129            }2130#else + 9472131            var tp = GetNonNullableType(type); + 9472132             if (tp == typeof(SByte)) + 02133            {2134                sbyte sb; + 02135                 if (sbyte.TryParse(text, out sb)) return sb; + 02136            } + 9472137             else if (tp == typeof(Byte)) + 02138            {2139                byte b; + 02140                 if (byte.TryParse(text, out b)) return b; + 02141            } + 9472142             else if (tp == typeof(Int16)) + 02143            {2144                short s; + 02145                 if (short.TryParse(text, out s)) return s; + 02146            } + 9472147             else if (tp == typeof(UInt16)) + 02148            {2149                ushort us; + 02150                 if (ushort.TryParse(text, out us)) return us; + 02151            } + 9472152             else if (tp == typeof(Int32)) + 1882153            {2154                int i; + 3702155                 if (int.TryParse(text, out i)) return i; + 62156            } + 7592157             else if (tp == typeof(UInt32)) + 172158            {2159                uint ui; + 342160                 if (uint.TryParse(text, out ui)) return ui; + 02161            } + 7422162             else if (tp == typeof(Int64)) + 1552163            {2164                long l; + 3042165                 if (long.TryParse(text, out l)) return l; + 62166            } + 5872167             else if (tp == typeof(UInt64)) + 232168            {2169                ulong ul; + 452170                 if (ulong.TryParse(text, out ul)) return ul; + 12171            } + 5642172             else if (tp == typeof(Single)) + 1682173            {2174                float f; + 3262175                 if (float.TryParse(text, out f)) return f; + 102176            } + 3962177             else if (tp == typeof(Double)) + 1802178            {2179                double d; + 3502180                 if (double.TryParse(text, out d)) return d; + 102181            } + 2162182             else if (tp == typeof(Decimal)) + 1652183            {2184                decimal e; + 3202185                 if (decimal.TryParse(text, out e)) return e; + 102186            }2187#endif + 942188            return null; + 9472189        }21902191        static object ParseEnum(string value, Type type) + 12192        {2193#if !(NETFX_CORE || WINDOWS_APP || DOTNET5_1 || UAP10_0 || NETSTANDARD)2194            if (type.IsEnum)2195            {2196                MemberInfo[] memberInfos = type.FindMembers(MemberTypes.Field,2197                    BindingFlags.Public | BindingFlags.DeclaredOnly | BindingFlags.Static,2198                    Type.FilterNameIgnoreCase, value);21992200                if (memberInfos.Length != 0)2201                    return ((FieldInfo)memberInfos[0]).GetValue(null);2202            }2203#else + 12204             if (type.GetTypeInfo().IsEnum) + 02205            { + 02206                return Enum.Parse(type, value, true);2207            }2208#endif + 12209            return null; + 12210        }22112212        static bool IsCompatibleWith(Type source, Type target) + 48432213        {2214#if !(NETFX_CORE || WINDOWS_APP || DOTNET5_1 || UAP10_0 || NETSTANDARD)2215            if (source == target) return true;2216            if (!target.IsValueType) return target.IsAssignableFrom(source);2217            Type st = GetNonNullableType(source);2218            Type tt = GetNonNullableType(target);2219            if (st != source && tt == target) return false;2220            TypeCode sc = st.GetTypeInfo().IsEnum ? TypeCode.Object : Type.GetTypeCode(st);2221            TypeCode tc = tt.GetTypeInfo().IsEnum ? TypeCode.Object : Type.GetTypeCode(tt);2222            switch (sc)2223            {2224                case TypeCode.SByte:2225                    switch (tc)2226                    {2227                        case TypeCode.SByte:2228                        case TypeCode.Int16:2229                        case TypeCode.Int32:2230                        case TypeCode.Int64:2231                        case TypeCode.Single:2232                        case TypeCode.Double:2233                        case TypeCode.Decimal:2234                            return true;2235                    }2236                    break;2237                case TypeCode.Byte:2238                    switch (tc)2239                    {2240                        case TypeCode.Byte:2241                        case TypeCode.Int16:2242                        case TypeCode.UInt16:2243                        case TypeCode.Int32:2244                        case TypeCode.UInt32:2245                        case TypeCode.Int64:2246                        case TypeCode.UInt64:  2247                        case TypeCode.Single:  2248                        case TypeCode.Double:  2249                        case TypeCode.Decimal:  2250                            return true;  2251                    }  2252                    break;2253                case TypeCode.UInt64:2253                case TypeCode.Int16:  2254                    switch (tc)  2255                    {2256                        case TypeCode.UInt64:2257                        case TypeCode.Single:2258                        case TypeCode.Double:2259                        case TypeCode.Decimal:2260                            return true;2261                    }2262                    break;2263                case TypeCode.Single:2264                    switch (tc)2265                    {2266                        case TypeCode.Single:2267                        case TypeCode.Double:2268                            return true;2269                    }2270                    break;2271                default:2272                    if (st == tt) return true;2273                    break;2274            }2275            return false;2276#else - 44882277             if (source == target) return true; - 47672278             if (!target.GetTypeInfo().IsValueType) return target.IsAssignableFrom(source); - 42092279            Type st = GetNonNullableType(source); - 42092280            Type tt = GetNonNullableType(target); - 44222281             if (st != source && tt == target) return false; - 39962282             Type sc = st.GetTypeInfo().IsEnum ? typeof(Object) : st; - 39962283             Type tc = tt.GetTypeInfo().IsEnum ? typeof(Object) : tt;2284 - 39962285             if (sc == typeof(SByte)) - 642286            { - 642287                 if (tc == typeof(SByte) || tc == typeof(Int16) || tc == typeof(Int32) || tc == typeof(Int64) || tc == ty - 322288                    return true; - 322289            } - 39322290             else if (sc == typeof(Byte)) - 642291            { - 642292                 if (tc == typeof(Byte) || tc == typeof(Int16) || tc == typeof(UInt16) || tc == typeof(Int32) || tc == ty - 642293                    return true; - 02294            } - 38682295             else if (sc == typeof(Int16)) - 642296            { - 642297                 if (tc == typeof(Int16) || tc == typeof(Int32) || tc == typeof(Int64) || tc == typeof(Single) || tc == t - 322298                    return true; - 322299            } - 38042300             else if (sc == typeof(UInt16)) - 642301            { - 642302                 if (tc == typeof(UInt16) || tc == typeof(Int32) || tc == typeof(UInt32) || tc == typeof(Int64) || tc ==  - 642303                    return true; - 02304            } - 37402305             else if (sc == typeof(Int32)) - 23152306            { - 23152307                 if (tc == typeof(Int32) || tc == typeof(Int64) || tc == typeof(Single) || tc == typeof(Double) || tc ==  - 11312308                    return true; - 11842309            } - 14252310             else if (sc == typeof(UInt32)) - 1422311            { - 1422312                 if (tc == typeof(UInt32) || tc == typeof(Int64) || tc == typeof(UInt64) || tc == typeof(Single) || tc == - 622313                    return true; - 802314            } - 12832315             else if (sc == typeof(Int64)) - 2162316            { - 2162317                 if (tc == typeof(Int64) || tc == typeof(Single) || tc == typeof(Double) || tc == typeof(Decimal)) - 362318                    return true; - 1802319            } - 10672320             else if (sc == typeof(UInt64)) - 1422321            { - 1422322                 if (tc == typeof(UInt64) || tc == typeof(Single) || tc == typeof(Double) || tc == typeof(Decimal)) - 222323                    return true; - 1202324            } - 9252325             else if (sc == typeof(Single)) - 2462326            { - 2462327                 if (tc == typeof(Single) || tc == typeof(Double)) - 402328                    return true; - 2062329            }2330 - 25132331             if (st == tt) - 922332                return true; - 24212333            return false;2334#endif - 44882335        }23362337        static bool IsBetterThan(Expression[] args, MethodData first, MethodData second) - 22322338        { - 22322339            bool better = false; - 45922340             for (int i = 0; i < args.Length; i++) - 22962341            { - 22962342                CompareConversionType result = CompareConversions(args[i].Type, first.Parameters[i].ParameterType, secon2256                        case TypeCode.Int16:2257                        case TypeCode.Int32:2258                        case TypeCode.Int64:2259                        case TypeCode.Single:2260                        case TypeCode.Double:2261                        case TypeCode.Decimal:2262                            return true;2263                    }2264                    break;2265                case TypeCode.UInt16:2266                    switch (tc)2267                    {2268                        case TypeCode.UInt16:2269                        case TypeCode.Int32:2270                        case TypeCode.UInt32:2271                        case TypeCode.Int64:2272                        case TypeCode.UInt64:2273                        case TypeCode.Single:2274                        case TypeCode.Double:2275                        case TypeCode.Decimal:2276                            return true;2277                    }2278                    break;2279                case TypeCode.Int32:2280                    switch (tc)2281                    {2282                        case TypeCode.Int32:2283                        case TypeCode.Int64:2284                        case TypeCode.Single:2285                        case TypeCode.Double:2286                        case TypeCode.Decimal:2287                            return true;2288                    }2289                    break;2290                case TypeCode.UInt32:2291                    switch (tc)2292                    {2293                        case TypeCode.UInt32:2294                        case TypeCode.Int64:2295                        case TypeCode.UInt64:2296                        case TypeCode.Single:2297                        case TypeCode.Double:2298                        case TypeCode.Decimal:2299                            return true;2300                    }2301                    break;2302                case TypeCode.Int64:2303                    switch (tc)2304                    {2305                        case TypeCode.Int64:2306                        case TypeCode.Single:2307                        case TypeCode.Double:2308                        case TypeCode.Decimal:2309                            return true;2310                    }2311                    break;2312                case TypeCode.UInt64:2313                    switch (tc)2314                    {2315                        case TypeCode.UInt64:2316                        case TypeCode.Single:2317                        case TypeCode.Double:2318                        case TypeCode.Decimal:2319                            return true;2320                    }2321                    break;2322                case TypeCode.Single:2323                    switch (tc)2324                    {2325                        case TypeCode.Single:2326                        case TypeCode.Double:2327                            return true;2328                    }2329                    break;2330                default:2331                    if (st == tt) return true;2332                    break;2333            }2334            return false;2335#else + 48432336             if (source == target) return true; + 51232337             if (!target.GetTypeInfo().IsValueType) return target.IsAssignableFrom(source); + 45632338            Type st = GetNonNullableType(source); + 45632339            Type tt = GetNonNullableType(target); + 47922340             if (st != source && tt == target) return false; + 43342341             Type sc = st.GetTypeInfo().IsEnum ? typeof(Object) : st; + 43342342             Type tc = tt.GetTypeInfo().IsEnum ? typeof(Object) : tt;  23432344                // If second is better, return false - 22962345                 if (result == CompareConversionType.Second) - 11162346                    return false;23472348                // If first is better, return true - 11802349                 if (result == CompareConversionType.First) - 11162350                    return true;23512352                // If both are same, just set better to true and continue - 642353                 if (result == CompareConversionType.Both) - 642354                    better = true; - 642355            }2356 - 02357            return better; - 22322358        }23592360        enum CompareConversionType2361        {2362            Both = 0,2363            First = 1,2364            Second = -12365        }23662367        // Return "First" if s -> t1 is a better conversion than s -> t22368        // Return "Second" if s -> t2 is a better conversion than s -> t12369        // Return "Both" if neither conversion is better2370        static CompareConversionType CompareConversions(Type source, Type first, Type second) - 22962371        { - 23602372             if (first == second) return CompareConversionType.Both; - 31842373             if (source == first) return CompareConversionType.First; - 22322374             if (source == second) return CompareConversionType.Second;2375 - 3282376            bool firstIsCompatibleWithSecond = IsCompatibleWith(first, second); - 3282377            bool secondIsCompatibleWithFirst = IsCompatibleWith(second, first);2378 - 4282379             if (firstIsCompatibleWithSecond && !secondIsCompatibleWithFirst) return CompareConversionType.First; - 3282380             if (secondIsCompatibleWithFirst && !firstIsCompatibleWithSecond) return CompareConversionType.Second;2381 - 1922382             if (IsSignedIntegralType(first) && IsUnsignedIntegralType(second)) return CompareConversionType.First; - 1282383             if (IsSignedIntegralType(second) && IsUnsignedIntegralType(first)) return CompareConversionType.Second;2384 - 02385            return CompareConversionType.Both; - 22962386        }23872388        static Expression GenerateEqual(Expression left, Expression right) - 1332389        { - 1332390            OptimizeForEqualityIfPossible(ref left, ref right); - 1332391            return Expression.Equal(left, right); - 1332392        }23932394        static Expression GenerateNotEqual(Expression left, Expression right) - 62395        { - 62396            OptimizeForEqualityIfPossible(ref left, ref right); - 62397            return Expression.NotEqual(left, right); - 62398        }23992400        static Expression GenerateGreaterThan(Expression left, Expression right) - 382401        { - 382402             if (left.Type == typeof(string)) - 12403            { - 12404                return Expression.GreaterThan(GenerateStaticMethodCall("Compare", left, right), Expression.Constant(0));2405            } + 43342344             if (sc == typeof(SByte)) + 642345            { + 642346                 if (tc == typeof(SByte) || tc == typeof(Int16) || tc == typeof(Int32) || tc == typeof(Int64) || tc == ty + 322347                    return true; + 322348            } + 42702349             else if (sc == typeof(Byte)) + 652350            { + 652351                 if (tc == typeof(Byte) || tc == typeof(Int16) || tc == typeof(UInt16) || tc == typeof(Int32) || tc == ty + 652352                    return true; + 02353            } + 42052354             else if (sc == typeof(Int16)) + 652355            { + 652356                 if (tc == typeof(Int16) || tc == typeof(Int32) || tc == typeof(Int64) || tc == typeof(Single) || tc == t + 332357                    return true; + 322358            } + 41402359             else if (sc == typeof(UInt16)) + 642360            { + 642361                 if (tc == typeof(UInt16) || tc == typeof(Int32) || tc == typeof(UInt32) || tc == typeof(Int64) || tc ==  + 642362                    return true; + 02363            } + 40762364             else if (sc == typeof(Int32)) + 25602365            { + 25602366                 if (tc == typeof(Int32) || tc == typeof(Int64) || tc == typeof(Single) || tc == typeof(Double) || tc ==  + 12762367                    return true; + 12842368            } + 15162369             else if (sc == typeof(UInt32)) + 1552370            { + 1552371                 if (tc == typeof(UInt32) || tc == typeof(Int64) || tc == typeof(UInt64) || tc == typeof(Single) || tc == + 732372                    return true; + 822373            } + 13612374             else if (sc == typeof(Int64)) + 2622375            { + 2622376                 if (tc == typeof(Int64) || tc == typeof(Single) || tc == typeof(Double) || tc == typeof(Decimal)) + 782377                    return true; + 1842378            } + 10992379             else if (sc == typeof(UInt64)) + 1622380            { + 1622381                 if (tc == typeof(UInt64) || tc == typeof(Single) || tc == typeof(Double) || tc == typeof(Decimal)) + 362382                    return true; + 1262383            } + 9372384             else if (sc == typeof(Single)) + 2502385            { + 2502386                 if (tc == typeof(Single) || tc == typeof(Double)) + 402387                    return true; + 2102388            }2389 + 26372390             if (st == tt) + 922391                return true; + 25452392            return false;2393#endif + 48432394        }23952396        static bool IsBetterThan(Expression[] args, MethodData first, MethodData second) + 25122397        { + 25122398            bool better = false; + 51522399             for (int i = 0; i < args.Length; i++) + 25762400            { + 25762401                CompareConversionType result = CompareConversions(args[i].Type, first.Parameters[i].ParameterType, secon24022403                // If second is better, return false + 25762404                 if (result == CompareConversionType.Second) + 12562405                    return false;  2406 - 372407             if (left.Type.GetTypeInfo().IsEnum || right.Type.GetTypeInfo().IsEnum) - 12408            { - 12409                 var leftPart = left.Type.GetTypeInfo().IsEnum ? Expression.Convert(left, Enum.GetUnderlyingType(left.Typ - 12410                 var rightPart = right.Type.GetTypeInfo().IsEnum ? Expression.Convert(right, Enum.GetUnderlyingType(right - 12411                return Expression.GreaterThan(leftPart, rightPart);2412            }2413 - 362414            return Expression.GreaterThan(left, right); - 382415        }24162417        static Expression GenerateGreaterThanEqual(Expression left, Expression right) - 32418        { - 32419             if (left.Type == typeof(string)) - 12420            { - 12421                return Expression.GreaterThanOrEqual(GenerateStaticMethodCall("Compare", left, right), Expression.Consta2422            }2423 - 22424             if (left.Type.GetTypeInfo().IsEnum || right.Type.GetTypeInfo().IsEnum) - 12425            { - 12426                 return Expression.GreaterThanOrEqual(left.Type.GetTypeInfo().IsEnum ? Expression.Convert(left, Enum.GetU - 12427                    right.Type.GetTypeInfo().IsEnum ? Expression.Convert(right, Enum.GetUnderlyingType(right.Type)) : ri2428            }2429 - 12430            return Expression.GreaterThanOrEqual(left, right); - 32431        }24322433        static Expression GenerateLessThan(Expression left, Expression right) - 42434        { - 42435             if (left.Type == typeof(string)) - 12436            { - 12437                return Expression.LessThan(GenerateStaticMethodCall("Compare", left, right), Expression.Constant(0));2438            }2439 - 32440             if (left.Type.GetTypeInfo().IsEnum || right.Type.GetTypeInfo().IsEnum) - 12441            { - 12442                 return Expression.LessThan(left.Type.GetTypeInfo().IsEnum ? Expression.Convert(left, Enum.GetUnderlyingT - 12443                    right.Type.GetTypeInfo().IsEnum ? Expression.Convert(right, Enum.GetUnderlyingType(right.Type)) : ri2444            }2445 - 22446            return Expression.LessThan(left, right); - 42447        }24482449        static Expression GenerateLessThanEqual(Expression left, Expression right) - 42450        { - 42451             if (left.Type == typeof(string)) - 12452            { - 12453                return Expression.LessThanOrEqual(GenerateStaticMethodCall("Compare", left, right), Expression.Constant(2454            }2455 - 32456             if (left.Type.GetTypeInfo().IsEnum || right.Type.GetTypeInfo().IsEnum) - 12457            { - 12458                 return Expression.LessThanOrEqual(left.Type.GetTypeInfo().IsEnum ? Expression.Convert(left, Enum.GetUnde - 12459                    right.Type.GetTypeInfo().IsEnum ? Expression.Convert(right, Enum.GetUnderlyingType(right.Type)) : ri2460            }2461 - 22462            return Expression.LessThanOrEqual(left, right); - 42463        }24642465        static Expression GenerateAdd(Expression left, Expression right) - 22466        { - 22467             if (left.Type == typeof(string) && right.Type == typeof(string)) - 02468            { - 02469                return GenerateStaticMethodCall("Concat", left, right);2470            } - 22471            return Expression.Add(left, right); - 22472        }24732474        static Expression GenerateSubtract(Expression left, Expression right) - 02475        { - 02476            return Expression.Subtract(left, right); - 02477        }24782479        static Expression GenerateStringConcat(Expression left, Expression right) - 102480        {2481            // Allow concat String with something else - 102482            return Expression.Call(null, typeof(string).GetMethod("Concat", new[] { left.Type, right.Type }), new[] { le - 102483        }24842485        static MethodInfo GetStaticMethod(string methodName, Expression left, Expression right) - 42486        { - 42487            return left.Type.GetMethod(methodName, new[] { left.Type, right.Type }); - 42488        }24892490        static Expression GenerateStaticMethodCall(string methodName, Expression left, Expression right) - 42491        { - 42492            return Expression.Call(null, GetStaticMethod(methodName, left, right), new[] { left, right }); - 42493        }24942495        static void OptimizeForEqualityIfPossible(ref Expression left, ref Expression right) - 1392496        {2497            // The goal here is to provide the way to convert some types from the string form in a way that is compatibl2498            //2499            // The Expression.Call(typeof(Guid).GetMethod("Parse"), right); does the job only for Linq to Object but Lin2500            // - 1392501            Type leftType = left.Type; - 1392502            Type rightType = right.Type;2503 - 1392504             if (rightType == typeof(string) && right.NodeType == ExpressionType.Constant) - 192505            { - 192506                 right = OptimizeStringForEqualityIfPossible((string)((ConstantExpression)right).Value, leftType) ?? righ - 192507            }2508 - 1392509             if (leftType == typeof(string) && left.NodeType == ExpressionType.Constant) - 02510            { - 02511                 left = OptimizeStringForEqualityIfPossible((string)((ConstantExpression)left).Value, rightType) ?? left; - 02512            } - 1392513        }2407                // If first is better, return true + 13202408                 if (result == CompareConversionType.First) + 12562409                    return true;24102411                // If both are same, just set better to true and continue + 642412                 if (result == CompareConversionType.Both) + 642413                    better = true; + 642414            }2415 + 02416            return better; + 25122417        }24182419        enum CompareConversionType2420        {2421            Both = 0,2422            First = 1,2423            Second = -12424        }24252426        // Return "First" if s -> t1 is a better conversion than s -> t22427        // Return "Second" if s -> t2 is a better conversion than s -> t12428        // Return "Both" if neither conversion is better2429        static CompareConversionType CompareConversions(Type source, Type first, Type second) + 25762430        { + 26402431             if (first == second) return CompareConversionType.Both; + 35902432             if (source == first) return CompareConversionType.First; + 25122433             if (source == second) return CompareConversionType.Second;2434 + 3562435            bool firstIsCompatibleWithSecond = IsCompatibleWith(first, second); + 3562436            bool secondIsCompatibleWithFirst = IsCompatibleWith(second, first);2437 + 4702438             if (firstIsCompatibleWithSecond && !secondIsCompatibleWithFirst) return CompareConversionType.First; + 3562439             if (secondIsCompatibleWithFirst && !firstIsCompatibleWithSecond) return CompareConversionType.Second;2440 + 1922441             if (IsSignedIntegralType(first) && IsUnsignedIntegralType(second)) return CompareConversionType.First; + 1282442             if (IsSignedIntegralType(second) && IsUnsignedIntegralType(first)) return CompareConversionType.Second;2443 + 02444            return CompareConversionType.Both; + 25762445        }24462447        static Expression GenerateEqual(Expression left, Expression right) + 1332448        { + 1332449            OptimizeForEqualityIfPossible(ref left, ref right); + 1332450            return Expression.Equal(left, right); + 1332451        }24522453        static Expression GenerateNotEqual(Expression left, Expression right) + 62454        { + 62455            OptimizeForEqualityIfPossible(ref left, ref right); + 62456            return Expression.NotEqual(left, right); + 62457        }24582459        static Expression GenerateGreaterThan(Expression left, Expression right) + 382460        { + 382461             if (left.Type == typeof(string)) + 12462            { + 12463                return Expression.GreaterThan(GenerateStaticMethodCall("Compare", left, right), Expression.Constant(0));2464            }2465 + 372466             if (left.Type.GetTypeInfo().IsEnum || right.Type.GetTypeInfo().IsEnum) + 12467            { + 12468                 var leftPart = left.Type.GetTypeInfo().IsEnum ? Expression.Convert(left, Enum.GetUnderlyingType(left.Typ + 12469                 var rightPart = right.Type.GetTypeInfo().IsEnum ? Expression.Convert(right, Enum.GetUnderlyingType(right + 12470                return Expression.GreaterThan(leftPart, rightPart);2471            }2472 + 362473            return Expression.GreaterThan(left, right); + 382474        }24752476        static Expression GenerateGreaterThanEqual(Expression left, Expression right) + 32477        { + 32478             if (left.Type == typeof(string)) + 12479            { + 12480                return Expression.GreaterThanOrEqual(GenerateStaticMethodCall("Compare", left, right), Expression.Consta2481            }2482 + 22483             if (left.Type.GetTypeInfo().IsEnum || right.Type.GetTypeInfo().IsEnum) + 12484            { + 12485                 return Expression.GreaterThanOrEqual(left.Type.GetTypeInfo().IsEnum ? Expression.Convert(left, Enum.GetU + 12486                    right.Type.GetTypeInfo().IsEnum ? Expression.Convert(right, Enum.GetUnderlyingType(right.Type)) : ri2487            }2488 + 12489            return Expression.GreaterThanOrEqual(left, right); + 32490        }24912492        static Expression GenerateLessThan(Expression left, Expression right) + 52493        { + 52494             if (left.Type == typeof(string)) + 12495            { + 12496                return Expression.LessThan(GenerateStaticMethodCall("Compare", left, right), Expression.Constant(0));2497            }2498 + 42499             if (left.Type.GetTypeInfo().IsEnum || right.Type.GetTypeInfo().IsEnum) + 12500            { + 12501                 return Expression.LessThan(left.Type.GetTypeInfo().IsEnum ? Expression.Convert(left, Enum.GetUnderlyingT + 12502                    right.Type.GetTypeInfo().IsEnum ? Expression.Convert(right, Enum.GetUnderlyingType(right.Type)) : ri2503            }2504 + 32505            return Expression.LessThan(left, right); + 52506        }25072508        static Expression GenerateLessThanEqual(Expression left, Expression right) + 42509        { + 42510             if (left.Type == typeof(string)) + 12511            { + 12512                return Expression.LessThanOrEqual(GenerateStaticMethodCall("Compare", left, right), Expression.Constant(2513            }  25142515        static Expression OptimizeStringForEqualityIfPossible(string text, Type type) - 192516        {2517            DateTime dateTime;2518 - 192519             if (type == typeof(DateTime) && - 192520                DateTime.TryParse(text, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime)) - 02521                return Expression.Constant(dateTime, typeof(DateTime));2522#if !NET352523            Guid guid; - 192524             if (type == typeof(Guid) && Guid.TryParse(text, out guid)) - 02525                return Expression.Constant(guid, typeof(Guid));2526#else2527            try2528            {2529                return Expression.Constant(new Guid(text));2530            }2531            catch2532            {2533                //Doing it in old fashion way when no TryParse interface was provided by .NET2534            }2535#endif - 192536            return null; - 192537        }25382539        bool TokenIdentifierIs(string id) - 33262540        { - 33262541            return _textParser.CurrentToken.Id == TokenId.Identifier && string.Equals(id, _textParser.CurrentToken.Text, - 33262542        } + 32515             if (left.Type.GetTypeInfo().IsEnum || right.Type.GetTypeInfo().IsEnum) + 12516            { + 12517                 return Expression.LessThanOrEqual(left.Type.GetTypeInfo().IsEnum ? Expression.Convert(left, Enum.GetUnde + 12518                    right.Type.GetTypeInfo().IsEnum ? Expression.Convert(right, Enum.GetUnderlyingType(right.Type)) : ri2519            }2520 + 22521            return Expression.LessThanOrEqual(left, right); + 42522        }25232524        static Expression GenerateAdd(Expression left, Expression right) + 112525        { + 112526             if (left.Type == typeof(string) && right.Type == typeof(string)) + 02527            { + 02528                return GenerateStaticMethodCall("Concat", left, right);2529            } + 112530            return Expression.Add(left, right); + 112531        }25322533        static Expression GenerateSubtract(Expression left, Expression right) + 02534        { + 02535            return Expression.Subtract(left, right); + 02536        }25372538        static Expression GenerateStringConcat(Expression left, Expression right) + 102539        {2540            // Allow concat String with something else + 102541            return Expression.Call(null, typeof(string).GetMethod("Concat", new[] { left.Type, right.Type }), new[] { le + 102542        }  25432544        string GetIdentifier() - 4402545        { - 4402546            _textParser.ValidateToken(TokenId.Identifier, Res.IdentifierExpected); - 4402547            string id = _textParser.CurrentToken.Text; - 4402548             if (id.Length > 1 && id[0] == '@') id = id.Substring(1); - 4402549            return id; - 4402550        }25512552        Exception ParseError(string format, params object[] args) - 32553        { - 32554            return ParseError(_textParser.CurrentToken.Pos, format, args); - 32555        }25562557        static Exception ParseError(int pos, string format, params object[] args) - 212558        { - 212559            return new ParseException(string.Format(CultureInfo.CurrentCulture, format, args), pos); - 212560        }25612562        static Dictionary<string, object> CreateKeywords() - 122563        { - 122564            var d = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase) - 122565            { - 122566                {"true", TrueLiteral}, - 122567                {"false", FalseLiteral}, - 122568                {"null", NullLiteral} - 122569            };2570 - 122571             if (GlobalConfig.AreContextKeywordsEnabled) - 112572            { - 112573                d.Add(KEYWORD_IT, KEYWORD_IT); - 112574                d.Add(KEYWORD_PARENT, KEYWORD_PARENT); - 112575                d.Add(KEYWORD_ROOT, KEYWORD_ROOT); - 112576            }2544        static MethodInfo GetStaticMethod(string methodName, Expression left, Expression right) + 42545        { + 42546            return left.Type.GetMethod(methodName, new[] { left.Type, right.Type }); + 42547        }25482549        static Expression GenerateStaticMethodCall(string methodName, Expression left, Expression right) + 42550        { + 42551            return Expression.Call(null, GetStaticMethod(methodName, left, right), new[] { left, right }); + 42552        }25532554        static void OptimizeForEqualityIfPossible(ref Expression left, ref Expression right) + 1392555        {2556            // The goal here is to provide the way to convert some types from the string form in a way that is compatibl2557            //2558            // The Expression.Call(typeof(Guid).GetMethod("Parse"), right); does the job only for Linq to Object but Lin2559            // + 1392560            Type leftType = left.Type; + 1392561            Type rightType = right.Type;2562 + 1392563             if (rightType == typeof(string) && right.NodeType == ExpressionType.Constant) + 192564            { + 192565                 right = OptimizeStringForEqualityIfPossible((string)((ConstantExpression)right).Value, leftType) ?? righ + 192566            }2567 + 1392568             if (leftType == typeof(string) && left.NodeType == ExpressionType.Constant) + 02569            { + 02570                 left = OptimizeStringForEqualityIfPossible((string)((ConstantExpression)left).Value, rightType) ?? left; + 02571            } + 1392572        }25732574        static Expression OptimizeStringForEqualityIfPossible(string text, Type type) + 192575        {2576            DateTime dateTime;  2577 - 122578            d.Add(SYMBOL_IT, SYMBOL_IT); - 122579            d.Add(SYMBOL_PARENT, SYMBOL_PARENT); - 122580            d.Add(SYMBOL_ROOT, SYMBOL_ROOT); - 122581            d.Add(KEYWORD_IIF, KEYWORD_IIF); - 122582            d.Add(KEYWORD_NEW, KEYWORD_NEW); - 122583            d.Add(KEYWORD_ISNULL, KEYWORD_ISNULL);2584 - 10922585            foreach (Type type in _predefinedTypes.OrderBy(kvp => kvp.Value).Select(kvp => kvp.Key)) - 2642586            { - 2642587                d[type.FullName] = type; - 2642588                d[type.Name] = type; - 2642589            }2590 - 2282591            foreach (KeyValuePair<string, Type> pair in _predefinedTypesShorthands) - 962592                d.Add(pair.Key, pair.Value);2593 - 122594             if (GlobalConfig.CustomTypeProvider != null) - 92595            { - 452596                foreach (Type type in GlobalConfig.CustomTypeProvider.GetCustomTypes()) - 92597                { - 92598                    d[type.FullName] = type; - 92599                    d[type.Name] = type; - 92600                } - 92601            } + 192578             if (type == typeof(DateTime) && + 192579                DateTime.TryParse(text, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime)) + 02580                return Expression.Constant(dateTime, typeof(DateTime));2581#if !NET352582            Guid guid; + 192583             if (type == typeof(Guid) && Guid.TryParse(text, out guid)) + 02584                return Expression.Constant(guid, typeof(Guid));2585#else2586            try2587            {2588                return Expression.Constant(new Guid(text));2589            }2590            catch2591            {2592                //Doing it in old fashion way when no TryParse interface was provided by .NET2593            }2594#endif + 192595            return null; + 192596        }25972598        bool TokenIdentifierIs(string id) + 34892599        { + 34892600            return _textParser.CurrentToken.Id == TokenId.Identifier && string.Equals(id, _textParser.CurrentToken.Text, + 34892601        }  2602 - 122603            return d; - 122604        }26052606        internal static void ResetDynamicLinqTypes() - 72607        { - 72608            _keywords = null; - 72609        }2610    }2611}2603        string GetIdentifier() + 4402604        { + 4402605            _textParser.ValidateToken(TokenId.Identifier, Res.IdentifierExpected); + 4402606            string id = _textParser.CurrentToken.Text; + 4402607             if (id.Length > 1 && id[0] == '@') id = id.Substring(1); + 4402608            return id; + 4402609        }26102611        Exception ParseError(string format, params object[] args) + 42612        { + 42613            return ParseError(_textParser.CurrentToken.Pos, format, args); + 42614        }26152616        static Exception ParseError(int pos, string format, params object[] args) + 222617        { + 222618            return new ParseException(string.Format(CultureInfo.CurrentCulture, format, args), pos); + 222619        }26202621        static Dictionary<string, object> CreateKeywords() + 142622        { + 142623            var d = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase) + 142624            { + 142625                {"true", TrueLiteral}, + 142626                {"false", FalseLiteral}, + 142627                {"null", NullLiteral} + 142628            };2629 + 142630             if (GlobalConfig.AreContextKeywordsEnabled) + 132631            { + 132632                d.Add(KEYWORD_IT, KEYWORD_IT); + 132633                d.Add(KEYWORD_PARENT, KEYWORD_PARENT); + 132634                d.Add(KEYWORD_ROOT, KEYWORD_ROOT); + 132635            }2636 + 142637            d.Add(SYMBOL_IT, SYMBOL_IT); + 142638            d.Add(SYMBOL_PARENT, SYMBOL_PARENT); + 142639            d.Add(SYMBOL_ROOT, SYMBOL_ROOT); + 142640            d.Add(KEYWORD_IIF, KEYWORD_IIF); + 142641            d.Add(KEYWORD_NEW, KEYWORD_NEW); + 142642            d.Add(KEYWORD_ISNULL, KEYWORD_ISNULL);2643 + 12742644            foreach (Type type in _predefinedTypes.OrderBy(kvp => kvp.Value).Select(kvp => kvp.Key)) + 3082645            { + 3082646                d[type.FullName] = type; + 3082647                d[type.Name] = type; + 3082648            }2649 + 2662650            foreach (KeyValuePair<string, Type> pair in _predefinedTypesShorthands) + 1122651                d.Add(pair.Key, pair.Value);2652 + 142653             if (GlobalConfig.CustomTypeProvider != null) + 92654            { + 452655                foreach (Type type in GlobalConfig.CustomTypeProvider.GetCustomTypes()) + 92656                { + 92657                    d[type.FullName] = type; + 92658                    d[type.Name] = type; + 92659                } + 92660            }2661 + 142662            return d; + 142663        }26642665        internal static void ResetDynamicLinqTypes() + 72666        { + 72667            _keywords = null; + 72668        }2669    }2670} -

+

Methods/Properties

@@ -2776,76 +2836,77 @@

Methods/Properties

ParsePrimaryStart()
ParseStringLiteral()
ParseIntegerLiteral()
-ParseRealLiteral()
-TryParseAsFloat(System.String,System.Char)
-TryParseAsDouble(System.String,System.Char)
-CreateLiteral(System.Object,System.String)
-ParseParenExpression()
-ParseIdentifier()
-ParseIt()
-ParseParent()
-ParseRoot()
-ParseIif()
-GenerateConditional(System.Linq.Expressions.Expression,System.Linq.Expressions.Expression,System.Linq.Expressions.Expression,System.Int32)
-ParseNew()
-CreateNewExpression(System.Collections.Generic.List`1<System.Linq.Dynamic.Core.DynamicProperty>,System.Collections.Generic.List`1<System.Linq.Expressions.Expression>,System.Type)
-ParseLambdaInvocation(System.Linq.Expressions.LambdaExpression)
-ParseTypeAccess(System.Type)
-GenerateConversion(System.Linq.Expressions.Expression,System.Type,System.Int32)
-ParseMemberAccess(System.Type,System.Linq.Expressions.Expression)
-FindGenericType(System.Type,System.Type)
-FindType(System.String)
-ParseAggregate(System.Linq.Expressions.Expression,System.Type,System.String,System.Int32)
-ParseArgumentList()
-ParseArguments()
-ParseElementAccess(System.Linq.Expressions.Expression)
-IsPredefinedType(System.Type)
-IsNullableType(System.Type)
-ToNullableType(System.Type)
-GetNonNullableType(System.Type)
-GetTypeName(System.Type)
-TryGetMemberName(System.Linq.Expressions.Expression,System.String&)
-IsNumericType(System.Type)
-IsSignedIntegralType(System.Type)
-IsUnsignedIntegralType(System.Type)
-GetNumericTypeKind(System.Type)
-IsEnumType(System.Type)
-CheckAndPromoteOperand(System.Type,System.String,System.Linq.Expressions.Expression&,System.Int32)
-CheckAndPromoteOperands(System.Type,System.String,System.Linq.Expressions.Expression&,System.Linq.Expressions.Expression&,System.Int32)
-IncompatibleOperandsError(System.String,System.Linq.Expressions.Expression,System.Linq.Expressions.Expression,System.Int32)
-FindPropertyOrField(System.Type,System.String,System.Boolean)
-FindMethod(System.Type,System.String,System.Boolean,System.Linq.Expressions.Expression[],System.Reflection.MethodBase&)
-FindIndexer(System.Type,System.Linq.Expressions.Expression[],System.Reflection.MethodBase&)
-SelfAndBaseTypes(System.Type)
-SelfAndBaseClasses()
-AddInterface(System.Collections.Generic.List`1<System.Type>,System.Type)
-FindBestMethod(System.Collections.Generic.IEnumerable`1<System.Reflection.MethodBase>,System.Linq.Expressions.Expression[],System.Reflection.MethodBase&)
-IsApplicable(System.Linq.Dynamic.Core.ExpressionParser/MethodData,System.Linq.Expressions.Expression[])
-PromoteExpression(System.Linq.Expressions.Expression,System.Type,System.Boolean,System.Boolean)
-ParseNumber(System.String,System.Type)
-ParseEnum(System.String,System.Type)
-IsCompatibleWith(System.Type,System.Type)
-IsBetterThan(System.Linq.Expressions.Expression[],System.Linq.Dynamic.Core.ExpressionParser/MethodData,System.Linq.Dynamic.Core.ExpressionParser/MethodData)
-CompareConversions(System.Type,System.Type,System.Type)
-GenerateEqual(System.Linq.Expressions.Expression,System.Linq.Expressions.Expression)
-GenerateNotEqual(System.Linq.Expressions.Expression,System.Linq.Expressions.Expression)
-GenerateGreaterThan(System.Linq.Expressions.Expression,System.Linq.Expressions.Expression)
-GenerateGreaterThanEqual(System.Linq.Expressions.Expression,System.Linq.Expressions.Expression)
-GenerateLessThan(System.Linq.Expressions.Expression,System.Linq.Expressions.Expression)
-GenerateLessThanEqual(System.Linq.Expressions.Expression,System.Linq.Expressions.Expression)
-GenerateAdd(System.Linq.Expressions.Expression,System.Linq.Expressions.Expression)
-GenerateSubtract(System.Linq.Expressions.Expression,System.Linq.Expressions.Expression)
-GenerateStringConcat(System.Linq.Expressions.Expression,System.Linq.Expressions.Expression)
-GetStaticMethod(System.String,System.Linq.Expressions.Expression,System.Linq.Expressions.Expression)
-GenerateStaticMethodCall(System.String,System.Linq.Expressions.Expression,System.Linq.Expressions.Expression)
-OptimizeForEqualityIfPossible(System.Linq.Expressions.Expression&,System.Linq.Expressions.Expression&)
-OptimizeStringForEqualityIfPossible(System.String,System.Type)
-TokenIdentifierIs(System.String)
-GetIdentifier()
-ParseError(System.String,System.Object[])
-ParseError(System.Int32,System.String,System.Object[])
-CreateKeywords()
-ResetDynamicLinqTypes()
+ParseRealLiteral()
+TryParseAsFloat(System.String,System.Char)
+TryParseAsDouble(System.String,System.Char)
+CreateLiteral(System.Object,System.String)
+ParseParenExpression()
+ParseIdentifier()
+ParseIt()
+ParseParent()
+ParseRoot()
+ParseIif()
+GenerateConditional(System.Linq.Expressions.Expression,System.Linq.Expressions.Expression,System.Linq.Expressions.Expression,System.Int32)
+ParseNew()
+CreateArrayInitializerExpression(System.Collections.Generic.List`1<System.Linq.Expressions.Expression>,System.Type)
+CreateNewExpression(System.Collections.Generic.List`1<System.Linq.Dynamic.Core.DynamicProperty>,System.Collections.Generic.List`1<System.Linq.Expressions.Expression>,System.Type)
+ParseLambdaInvocation(System.Linq.Expressions.LambdaExpression)
+ParseTypeAccess(System.Type)
+GenerateConversion(System.Linq.Expressions.Expression,System.Type,System.Int32)
+ParseMemberAccess(System.Type,System.Linq.Expressions.Expression)
+FindGenericType(System.Type,System.Type)
+FindType(System.String)
+ParseAggregate(System.Linq.Expressions.Expression,System.Type,System.String,System.Int32)
+ParseArgumentList()
+ParseArguments()
+ParseElementAccess(System.Linq.Expressions.Expression)
+IsPredefinedType(System.Type)
+IsNullableType(System.Type)
+ToNullableType(System.Type)
+GetNonNullableType(System.Type)
+GetTypeName(System.Type)
+TryGetMemberName(System.Linq.Expressions.Expression,System.String&)
+IsNumericType(System.Type)
+IsSignedIntegralType(System.Type)
+IsUnsignedIntegralType(System.Type)
+GetNumericTypeKind(System.Type)
+IsEnumType(System.Type)
+CheckAndPromoteOperand(System.Type,System.String,System.Linq.Expressions.Expression&,System.Int32)
+CheckAndPromoteOperands(System.Type,System.String,System.Linq.Expressions.Expression&,System.Linq.Expressions.Expression&,System.Int32)
+IncompatibleOperandsError(System.String,System.Linq.Expressions.Expression,System.Linq.Expressions.Expression,System.Int32)
+FindPropertyOrField(System.Type,System.String,System.Boolean)
+FindMethod(System.Type,System.String,System.Boolean,System.Linq.Expressions.Expression[],System.Reflection.MethodBase&)
+FindIndexer(System.Type,System.Linq.Expressions.Expression[],System.Reflection.MethodBase&)
+SelfAndBaseTypes(System.Type)
+SelfAndBaseClasses()
+AddInterface(System.Collections.Generic.List`1<System.Type>,System.Type)
+FindBestMethod(System.Collections.Generic.IEnumerable`1<System.Reflection.MethodBase>,System.Linq.Expressions.Expression[],System.Reflection.MethodBase&)
+IsApplicable(System.Linq.Dynamic.Core.ExpressionParser/MethodData,System.Linq.Expressions.Expression[])
+PromoteExpression(System.Linq.Expressions.Expression,System.Type,System.Boolean,System.Boolean)
+ParseNumber(System.String,System.Type)
+ParseEnum(System.String,System.Type)
+IsCompatibleWith(System.Type,System.Type)
+IsBetterThan(System.Linq.Expressions.Expression[],System.Linq.Dynamic.Core.ExpressionParser/MethodData,System.Linq.Dynamic.Core.ExpressionParser/MethodData)
+CompareConversions(System.Type,System.Type,System.Type)
+GenerateEqual(System.Linq.Expressions.Expression,System.Linq.Expressions.Expression)
+GenerateNotEqual(System.Linq.Expressions.Expression,System.Linq.Expressions.Expression)
+GenerateGreaterThan(System.Linq.Expressions.Expression,System.Linq.Expressions.Expression)
+GenerateGreaterThanEqual(System.Linq.Expressions.Expression,System.Linq.Expressions.Expression)
+GenerateLessThan(System.Linq.Expressions.Expression,System.Linq.Expressions.Expression)
+GenerateLessThanEqual(System.Linq.Expressions.Expression,System.Linq.Expressions.Expression)
+GenerateAdd(System.Linq.Expressions.Expression,System.Linq.Expressions.Expression)
+GenerateSubtract(System.Linq.Expressions.Expression,System.Linq.Expressions.Expression)
+GenerateStringConcat(System.Linq.Expressions.Expression,System.Linq.Expressions.Expression)
+GetStaticMethod(System.String,System.Linq.Expressions.Expression,System.Linq.Expressions.Expression)
+GenerateStaticMethodCall(System.String,System.Linq.Expressions.Expression,System.Linq.Expressions.Expression)
+OptimizeForEqualityIfPossible(System.Linq.Expressions.Expression&,System.Linq.Expressions.Expression&)
+OptimizeStringForEqualityIfPossible(System.String,System.Type)
+TokenIdentifierIs(System.String)
+GetIdentifier()
+ParseError(System.String,System.Object[])
+ParseError(System.Int32,System.String,System.Object[])
+CreateKeywords()
+ResetDynamicLinqTypes()

diff --git a/report/System.Linq.Dynamic.Core_ExtensibilityPoint.htm b/report/System.Linq.Dynamic.Core_ExtensibilityPoint.htm index 2d9feb9f..968be09c 100644 --- a/report/System.Linq.Dynamic.Core_ExtensibilityPoint.htm +++ b/report/System.Linq.Dynamic.Core_ExtensibilityPoint.htm @@ -49,12 +49,12 @@

 12        /// Place to optimize your queries. Example: Add a reference to Nuget package Linq.Expression.Optimizer  13        /// and in your program initializers set Extensibility.QueryOptimizer = ExpressionOptimizer.visit;  14        /// </summary> - 3015        public static Func<Expression, Expression> QueryOptimizer = e => e; + 4315        public static Func<Expression, Expression> QueryOptimizer = e => e;  16    }  17} - +

Methods/Properties

diff --git a/report/System.Linq.Dynamic.Core_GlobalConfig.htm b/report/System.Linq.Dynamic.Core_GlobalConfig.htm index 14ed088b..2c29994b 100644 --- a/report/System.Linq.Dynamic.Core_GlobalConfig.htm +++ b/report/System.Linq.Dynamic.Core_GlobalConfig.htm @@ -53,14 +53,14 @@

 15        public static IDynamicLinkCustomTypeProvider CustomTypeProvider  16        {  17            get - 3618            { + 4018            {  19#if !(DOTNET5_1 || WINDOWS_APP || UAP10_0 || NETSTANDARD)  20                // only use DefaultDynamicLinqCustomTypeProvider if not WINDOWS_APP || UAP10_0 || NETSTANDARD  21                return _customTypeProvider ?? (_customTypeProvider = new DefaultDynamicLinqCustomTypeProvider());  22#else - 3623                return _customTypeProvider; + 4023                return _customTypeProvider;  24#endif - 3625            } + 4025            }  26  27            set  528            { @@ -81,7 +81,7 @@

 43        /// </summary>  44        public static bool AreContextKeywordsEnabled  45        { - 3646            get { return _contextKeywordsEnabled; } + 4246            get { return _contextKeywordsEnabled; }  47            set  348            {  349                 if (value != _contextKeywordsEnabled) @@ -104,7 +104,7 @@

 66} -

+

Methods/Properties

diff --git a/report/System.Linq.Dynamic.Core_GroupResult.htm b/report/System.Linq.Dynamic.Core_GroupResult.htm index 3b93deb5..99f02c93 100644 --- a/report/System.Linq.Dynamic.Core_GroupResult.htm +++ b/report/System.Linq.Dynamic.Core_GroupResult.htm @@ -84,7 +84,7 @@

 47} -

+

Methods/Properties

diff --git a/report/System.Linq.Dynamic.Core_LinqProviderExtensions.htm b/report/System.Linq.Dynamic.Core_LinqProviderExtensions.htm index 8bfdcb36..06490eeb 100644 --- a/report/System.Linq.Dynamic.Core_LinqProviderExtensions.htm +++ b/report/System.Linq.Dynamic.Core_LinqProviderExtensions.htm @@ -51,22 +51,22 @@

 12        /// <param name="source">The IQueryable</param>  13        /// <returns>true if provider is LinqToObjects, else false</returns>  14        public static bool IsLinqToObjects([NotNull] this IQueryable source) - 29915        { - 29916            Check.NotNull(source, nameof(source)); - 29917            Check.NotNull(source.Provider, nameof(source.Provider)); + 31415        { + 31416            Check.NotNull(source, nameof(source)); + 31417            Check.NotNull(source.Provider, nameof(source.Provider));  18 - 29919            return IsProviderEnumerableQuery(source.Provider); - 29920        } + 31419            return IsProviderEnumerableQuery(source.Provider); + 31420        }  21  22        private static bool IsProviderEnumerableQuery(IQueryProvider provider) - 30023        { - 30024            Type baseType = provider.GetType().GetTypeInfo().BaseType; + 31523        { + 31524            Type baseType = provider.GetType().GetTypeInfo().BaseType;  25#if NET35  26            bool isLinqToObjects = baseType.FullName.Contains("EnumerableQuery");  27#else - 30028            bool isLinqToObjects = baseType == typeof(EnumerableQuery); + 31528            bool isLinqToObjects = baseType == typeof(EnumerableQuery);  29#endif - 30030             if (!isLinqToObjects) + 31530             if (!isLinqToObjects)  3431            {  32                // add support for https://github.com/StefH/QueryInterceptor.Core, version 1.0.1 and up  3433                 if (baseType.Name == "QueryTranslatorProvider") @@ -84,13 +84,13 @@

 45                }  3346            }  47 - 29948            return isLinqToObjects; - 30049        } + 31448            return isLinqToObjects; + 31549        }  50    }  51} -

+

Methods/Properties

diff --git a/report/System.Linq.Dynamic.Core_PagedResult.htm b/report/System.Linq.Dynamic.Core_PagedResult.htm index f31756cc..aa4a36ad 100644 --- a/report/System.Linq.Dynamic.Core_PagedResult.htm +++ b/report/System.Linq.Dynamic.Core_PagedResult.htm @@ -94,7 +94,7 @@

 64} -

+

Methods/Properties

diff --git a/report/System.Linq.Dynamic.Core_PagedResult_1.htm b/report/System.Linq.Dynamic.Core_PagedResult_1.htm index 17d8c07a..4b1156bd 100644 --- a/report/System.Linq.Dynamic.Core_PagedResult_1.htm +++ b/report/System.Linq.Dynamic.Core_PagedResult_1.htm @@ -94,7 +94,7 @@

 64} -

+

Methods/Properties

diff --git a/report/System.Linq.Dynamic.Core_ParseException.htm b/report/System.Linq.Dynamic.Core_ParseException.htm index 7c9e8d03..d3a9def3 100644 --- a/report/System.Linq.Dynamic.Core_ParseException.htm +++ b/report/System.Linq.Dynamic.Core_ParseException.htm @@ -58,10 +58,10 @@

 20        /// <param name="message">The message that describes the error.</param>  21        /// <param name="position">The location in the parsed string that produced the <see cref="ParseException"/></par  22        public ParseException(string message, int position) - 3123            : base(message) - 3124        { - 3125            Position = position; - 3126        } + 3823            : base(message) + 3824        { + 3825            Position = position; + 3826        }  27  28        /// <summary>  29        /// The location in the parsed string that produced the <see cref="ParseException"/>. @@ -104,7 +104,7 @@

 66} -

+

Methods/Properties

diff --git a/report/System.Linq.Dynamic.Core_Res.htm b/report/System.Linq.Dynamic.Core_Res.htm index 8a9f5377..f592e3d9 100644 --- a/report/System.Linq.Dynamic.Core_Res.htm +++ b/report/System.Linq.Dynamic.Core_Res.htm @@ -25,6 +25,6 @@

Summary

File(s)

No files found. This usually happens if a file isn't covered by a test or the class does not contain any sequence points (e.g. a class that only contains auto properties).

-
+ \ No newline at end of file diff --git a/report/System.Linq.Dynamic.Core_TextParser.htm b/report/System.Linq.Dynamic.Core_TextParser.htm index 90667801..56ce6f8c 100644 --- a/report/System.Linq.Dynamic.Core_TextParser.htm +++ b/report/System.Linq.Dynamic.Core_TextParser.htm @@ -16,12 +16,12 @@

Summary

Class:System.Linq.Dynamic.Core.Tokenizer.TextParser Assembly:System.Linq.Dynamic.Core File(s):C:\Users\Stef\Documents\GitHub\System.Linq.Dynamic.Core\src\System.Linq.Dynamic.Core\Tokenizer\TextParser.cs -Covered lines:261 +Covered lines:287 Uncovered lines:1 -Coverable lines:262 -Total lines:384 +Coverable lines:288 +Total lines:423 Line coverage:99.6% -Branch coverage:91.6% +Branch coverage:93.9%

Metrics

@@ -31,14 +31,16 @@

Metrics

.ctor(...)10100100 SetTextPos(...)3210066.67 NextChar()4410080 -NextToken()7051299.5594.29 +NextToken()74409610096.40 ValidateToken(...)22100100 ValidateToken(...)227566.67 ValidateExpression()22100100 -ValidateDigit()227566.67 +ValidateDigit()22100100 +ValidateHexChar()22100100 ParseError(...)10100100 ParseError(...)10100100 GetAliasedTokenId(...)42100100 +IsHexChar(...)449080 .cctor()10100100 @@ -81,35 +83,35 @@

 32        private char _ch;  33        public Token CurrentToken;  34 - 36835        public TextParser(string text) - 36836        { - 36837            _text = text; - 36838            _textLen = _text.Length; - 36839            SetTextPos(0); - 36840            NextToken(); - 36841        } + 38735        public TextParser(string text) + 38736        { + 38737            _text = text; + 38738            _textLen = _text.Length; + 38739            SetTextPos(0); + 38740            NextToken(); + 38441        }  42  43        private void SetTextPos(int pos) - 36844        { - 36845            _textPos = pos; - 36846             _ch = _textPos < _textLen ? _text[_textPos] : '\0'; - 36847        } + 38744        { + 38745            _textPos = pos; + 38746             _ch = _textPos < _textLen ? _text[_textPos] : '\0'; + 38747        }  48  49        private void NextChar() - 611550        { - 1223051             if (_textPos < _textLen) _textPos++; - 611552             _ch = _textPos < _textLen ? _text[_textPos] : '\0'; - 611553        } + 643250        { + 1286451             if (_textPos < _textLen) _textPos++; + 643252             _ch = _textPos < _textLen ? _text[_textPos] : '\0'; + 643253        }  54  55        public void NextToken() - 221756        { - 298157             while (char.IsWhiteSpace(_ch)) - 76458                NextChar(); + 234156        { + 316457             while (char.IsWhiteSpace(_ch)) + 82358                NextChar();  59 - 221760            TokenId tokenId = TokenId.Unknown; - 221761            int tokenPos = _textPos; + 234160            TokenId tokenId = TokenId.Unknown; + 234161            int tokenPos = _textPos;  62 - 221763             switch (_ch) + 234163             switch (_ch)  64            {  65                case '!':  866                    NextChar(); @@ -143,43 +145,43 @@

 1194                    break;  95  96                case '(': - 14297                    NextChar(); - 14298                    tokenId = TokenId.OpenParen; - 14299                    break; + 14697                    NextChar(); + 14698                    tokenId = TokenId.OpenParen; + 14699                    break;  100  101                case ')': - 136102                    NextChar(); - 136103                    tokenId = TokenId.CloseParen; - 136104                    break; + 140102                    NextChar(); + 140103                    tokenId = TokenId.CloseParen; + 140104                    break;  105  106                case '{': - 2107                    NextChar(); - 2108                    tokenId = TokenId.OpenCurlyParen; - 2109                    break; + 9107                    NextChar(); + 9108                    tokenId = TokenId.OpenCurlyParen; + 9109                    break;  110  111                case '}': - 2112                    NextChar(); - 2113                    tokenId = TokenId.CloseCurlyParen; - 2114                    break; + 8112                    NextChar(); + 8113                    tokenId = TokenId.CloseCurlyParen; + 8114                    break;  115  116                case '*': - 9117                    NextChar(); - 9118                    tokenId = TokenId.Asterisk; - 9119                    break; + 15117                    NextChar(); + 15118                    tokenId = TokenId.Asterisk; + 15119                    break;  120                case '+': - 7121                    NextChar(); - 7122                    tokenId = TokenId.Plus; - 7123                    break; + 16121                    NextChar(); + 16122                    tokenId = TokenId.Plus; + 16123                    break;  124  125                case ',': - 77126                    NextChar(); - 77127                    tokenId = TokenId.Comma; - 77128                    break; + 83126                    NextChar(); + 83127                    tokenId = TokenId.Comma; + 83128                    break;  129  130                case '-': - 20131                    NextChar(); - 20132                    tokenId = TokenId.Minus; - 20133                    break; + 22131                    NextChar(); + 22132                    tokenId = TokenId.Minus; + 22133                    break;  134  135                case '.':  138136                    NextChar(); @@ -197,27 +199,27 @@

 2148                    break;  149  150                case '<': - 37151                    NextChar(); - 37152                     if (_ch == '=') + 39151                    NextChar(); + 39152                     if (_ch == '=')  4153                    {  4154                        NextChar();  4155                        tokenId = TokenId.LessThanEqual;  4156                    } - 33157                     else if (_ch == '>') + 35157                     else if (_ch == '>')  1158                    {  1159                        NextChar();  1160                        tokenId = TokenId.LessGreater;  1161                    } - 32162                     else if (_ch == '<') + 34162                     else if (_ch == '<')  24163                    {  24164                        NextChar();  24165                        tokenId = TokenId.DoubleLessThan;  24166                    }  167                    else - 8168                    { - 8169                        tokenId = TokenId.LessThan; - 8170                    } - 37171                    break; + 10168                    { + 10169                        tokenId = TokenId.LessThan; + 10170                    } + 39171                    break;  172  173                case '=':  122174                    NextChar(); @@ -269,14 +271,14 @@

 12220                    break;  221  222                case '[': - 1223                    NextChar(); - 1224                    tokenId = TokenId.OpenBracket; - 1225                    break; + 8223                    NextChar(); + 8224                    tokenId = TokenId.OpenBracket; + 8225                    break;  226  227                case ']': - 1228                    NextChar(); - 1229                    tokenId = TokenId.CloseBracket; - 1230                    break; + 8228                    NextChar(); + 8229                    tokenId = TokenId.CloseBracket; + 8230                    break;  231  232                case '|':  2233                    NextChar(); @@ -321,119 +323,158 @@

 28272                    break;  273  274                default: - 1407275                     if (char.IsLetter(_ch) || _ch == '@' || _ch == '_' || _ch == '$' || _ch == '^' || _ch == '~') - 909276                    { + 1471275                     if (char.IsLetter(_ch) || _ch == '@' || _ch == '_' || _ch == '$' || _ch == '^' || _ch == '~') + 941276                    {  277                        do - 3885278                        { - 3885279                            NextChar(); - 7770280                         } while (char.IsLetterOrDigit(_ch) || _ch == '_'); - 909281                        tokenId = TokenId.Identifier; - 909282                        break; + 3968278                        { + 3968279                            NextChar(); + 7936280                         } while (char.IsLetterOrDigit(_ch) || _ch == '_'); + 941281                        tokenId = TokenId.Identifier; + 941282                        break;  283                    }  284 - 498285                     if (char.IsDigit(_ch)) - 158286                    { - 158287                        tokenId = TokenId.IntegerLiteral; + 530285                     if (char.IsDigit(_ch)) + 178286                    { + 178287                        tokenId = TokenId.IntegerLiteral;  288                        do - 228289                        { - 228290                            NextChar(); - 456291                         } while (char.IsDigit(_ch)); + 249289                        { + 249290                            NextChar(); + 498291                         } while (char.IsDigit(_ch));  292 - 158293                         if (_ch == 'U' || _ch == 'L') - 16294                        { - 16295                            NextChar(); - 16296                             if (_ch == 'L') - 5297                            { - 8298                                 if (_text[_textPos - 1] == 'U') NextChar(); - 2299                                else throw ParseError(_textPos, Res.InvalidIntegerQualifier, _text.Substring(_textPos -  - 3300                            } - 14301                            ValidateExpression(); - 10302                            break;303                        }304 - 142305                         if (_ch == NumberDecimalSeparator) - 14306                        { - 14307                            tokenId = TokenId.RealLiteral; - 14308                            NextChar(); - 14309                            ValidateDigit();310                            do - 19311                            { - 19312                                NextChar(); - 38313                             } while (char.IsDigit(_ch)); - 14314                        }315 - 142316                         if (_ch == 'E' || _ch == 'e') - 3317                        { - 3318                            tokenId = TokenId.RealLiteral; - 3319                            NextChar(); - 5320                             if (_ch == '+' || _ch == '-') NextChar(); - 3321                            ValidateDigit();322                            do - 6323                            { - 6324                                NextChar(); - 12325                             } while (char.IsDigit(_ch)); - 3326                        }327 - 150328                         if (_ch == 'F' || _ch == 'f') NextChar(); - 150329                         if (_ch == 'D' || _ch == 'd') NextChar(); - 142330                        break;331                    }332 - 340333                     if (_textPos == _textLen) - 340334                    { - 340335                        tokenId = TokenId.End; - 340336                        break;337                    }338 - 0339                    throw ParseError(_textPos, Res.InvalidCharacter, _ch);340            }341 - 2210342            CurrentToken.Pos = tokenPos; - 2210343            CurrentToken.Text = _text.Substring(tokenPos, _textPos - tokenPos); - 2210344            CurrentToken.OriginalId = tokenId; - 2210345            CurrentToken.Id = GetAliasedTokenId(tokenId, CurrentToken.Text); - 2210346        }347348        public void ValidateToken(TokenId t, string errorMessage) - 958349        { - 961350             if (CurrentToken.Id != t) throw ParseError(errorMessage); - 955351        }352353        public void ValidateToken(TokenId t) - 807354        { - 807355             if (CurrentToken.Id != t) throw ParseError(Res.SyntaxError); - 807356        }357358        private void ValidateExpression() - 14359        { - 18360             if (char.IsLetterOrDigit(_ch)) throw ParseError(_textPos, Res.ExpressionExpected); - 10361        }362363        private void ValidateDigit() - 17364        { - 17365             if (!char.IsDigit(_ch)) throw ParseError(_textPos, Res.DigitExpected); - 17366        }367368        private Exception ParseError(string format, params object[] args) - 3369        { - 3370            return ParseError(CurrentToken.Pos, format, args); - 3371        }372373        private static Exception ParseError(int pos, string format, params object[] args) - 10374        { - 10375            return new ParseException(string.Format(CultureInfo.CurrentCulture, format, args), pos); - 10376        }377378        private static TokenId GetAliasedTokenId(TokenId t, string alias) - 2210379        {380            TokenId id; - 2210381             return t == TokenId.Identifier && _predefinedAliases.TryGetValue(alias, out id) ? id : t; - 2210382        }383    }384} + 178293                        bool hexInteger = false; + 178294                         if (_ch == 'X' || _ch == 'x') + 9295                        { + 9296                            NextChar(); + 9297                            ValidateHexChar();298                            do + 78299                            { + 78300                                NextChar(); + 156301                             } while (IsHexChar(_ch));302 + 7303                            hexInteger = true; + 7304                        }305 + 176306                         if (_ch == 'U' || _ch == 'L') + 21307                        { + 21308                            NextChar(); + 21309                             if (_ch == 'L') + 6310                            { + 10311                                 if (_text[_textPos - 1] == 'U') NextChar(); + 2312                                else throw ParseError(_textPos, Res.InvalidIntegerQualifier, _text.Substring(_textPos -  + 4313                            } + 19314                            ValidateExpression(); + 15315                            break;316                        }317 + 155318                         if (hexInteger) + 2319                        { + 2320                            break;321                        }322 + 153323                         if (_ch == NumberDecimalSeparator) + 15324                        { + 15325                            tokenId = TokenId.RealLiteral; + 15326                            NextChar(); + 15327                            ValidateDigit();328                            do + 19329                            { + 19330                                NextChar(); + 38331                             } while (char.IsDigit(_ch)); + 14332                        }333 + 152334                         if (_ch == 'E' || _ch == 'e') + 3335                        { + 3336                            tokenId = TokenId.RealLiteral; + 3337                            NextChar(); + 5338                             if (_ch == '+' || _ch == '-') NextChar(); + 3339                            ValidateDigit();340                            do + 6341                            { + 6342                                NextChar(); + 12343                             } while (char.IsDigit(_ch)); + 3344                        }345 + 160346                         if (_ch == 'F' || _ch == 'f') NextChar(); + 160347                         if (_ch == 'D' || _ch == 'd') NextChar(); + 152348                        break;349                    }350 + 352351                     if (_textPos == _textLen) + 351352                    { + 351353                        tokenId = TokenId.End; + 351354                        break;355                    }356 + 1357                    throw ParseError(_textPos, Res.InvalidCharacter, _ch);358            }359 + 2330360            CurrentToken.Pos = tokenPos; + 2330361            CurrentToken.Text = _text.Substring(tokenPos, _textPos - tokenPos); + 2330362            CurrentToken.OriginalId = tokenId; + 2330363            CurrentToken.Id = GetAliasedTokenId(tokenId, CurrentToken.Text); + 2330364        }365366        public void ValidateToken(TokenId t, string errorMessage) + 991367        { + 996368             if (CurrentToken.Id != t) throw ParseError(errorMessage); + 986369        }370371        public void ValidateToken(TokenId t) + 853372        { + 853373             if (CurrentToken.Id != t) throw ParseError(Res.SyntaxError); + 853374        }375376        private void ValidateExpression() + 19377        { + 23378             if (char.IsLetterOrDigit(_ch)) throw ParseError(_textPos, Res.ExpressionExpected); + 15379        }380381        private void ValidateDigit() + 18382        { + 19383             if (!char.IsDigit(_ch)) throw ParseError(_textPos, Res.DigitExpected); + 17384        }385386        private void ValidateHexChar() + 9387        { + 11388             if (!IsHexChar(_ch)) throw ParseError(_textPos, Res.HexCharExpected); + 7389        }390391        private Exception ParseError(string format, params object[] args) + 5392        { + 5393            return ParseError(CurrentToken.Pos, format, args); + 5394        }395396        private static Exception ParseError(int pos, string format, params object[] args) + 16397        { + 16398            return new ParseException(string.Format(CultureInfo.CurrentCulture, format, args), pos); + 16399        }400401        private static TokenId GetAliasedTokenId(TokenId t, string alias) + 2330402        {403            TokenId id; + 2330404             return t == TokenId.Identifier && _predefinedAliases.TryGetValue(alias, out id) ? id : t; + 2330405        }406407        private static bool IsHexChar(char c) + 87408        { + 87409             if (char.IsDigit(c)) + 46410            { + 46411                return true;412            }413 + 41414             if (c <= '\x007f') + 41415            { + 41416                c |= (char)0x20; + 41417                return c >= 'a' && c <= 'f';418            }419 + 0420            return false; + 87421        }422    }423} - + diff --git a/report/System.Linq.Dynamic.Core_Token.htm b/report/System.Linq.Dynamic.Core_Token.htm index 10b6b191..1d5044ba 100644 --- a/report/System.Linq.Dynamic.Core_Token.htm +++ b/report/System.Linq.Dynamic.Core_Token.htm @@ -32,18 +32,18 @@

 2{  3    internal struct Token  4    { - 267945        public TokenId Id { get; set; } + 283895        public TokenId Id { get; set; }  6 - 22107        public TokenId OriginalId { get; set; } + 23307        public TokenId OriginalId { get; set; }  8 - 75289        public string Text { get; set; } + 78709        public string Text { get; set; }  10 - 382111        public int Pos { get; set; } + 402511        public int Pos { get; set; }  12    }  13} - +

Methods/Properties

diff --git a/report/System.Linq.Dynamic.Core_TypeConverterFactory.htm b/report/System.Linq.Dynamic.Core_TypeConverterFactory.htm index 6b585125..2a854b65 100644 --- a/report/System.Linq.Dynamic.Core_TypeConverterFactory.htm +++ b/report/System.Linq.Dynamic.Core_TypeConverterFactory.htm @@ -73,7 +73,7 @@

 36} -

+

Methods/Properties

diff --git a/report/combined.js b/report/combined.js index 389381eb..251de559 100644 --- a/report/combined.js +++ b/report/combined.js @@ -338,7 +338,7 @@ var assemblies = [ { "name" : "System.Linq.Dynamic.Core.DynamicProperty", "reportPath" : "System.Linq.Dynamic.Core_DynamicProperty.htm", "coveredLines" : 7, "uncoveredLines" : 0, "coverableLines" : 7, "totalLines" : 35, "coverageType" : "LineCoverage", "methodCoverage" : "-", "coveredBranches" : 0, "totalBranches" : 0, "lineCoverageHistory" : [], "branchCoverageHistory" : [] }, { "name" : "System.Linq.Dynamic.Core.DynamicQueryableExtensions", "reportPath" : "System.Linq.Dynamic.Core_DynamicQueryableExtensions.htm", "coveredLines" : 478, "uncoveredLines" : 16, "coverableLines" : 494, "totalLines" : 1375, "coverageType" : "LineCoverage", "methodCoverage" : "-", "coveredBranches" : 20, "totalBranches" : 28, "lineCoverageHistory" : [], "branchCoverageHistory" : [] }, { "name" : "System.Linq.Dynamic.Core.Exceptions.ParseException", "reportPath" : "System.Linq.Dynamic.Core_ParseException.htm", "coveredLines" : 4, "uncoveredLines" : 4, "coverableLines" : 8, "totalLines" : 66, "coverageType" : "LineCoverage", "methodCoverage" : "-", "coveredBranches" : 0, "totalBranches" : 0, "lineCoverageHistory" : [], "branchCoverageHistory" : [] }, - { "name" : "System.Linq.Dynamic.Core.ExpressionParser", "reportPath" : "System.Linq.Dynamic.Core_ExpressionParser.htm", "coveredLines" : 1268, "uncoveredLines" : 196, "coverableLines" : 1464, "totalLines" : 2611, "coverageType" : "LineCoverage", "methodCoverage" : "-", "coveredBranches" : 497, "totalBranches" : 677, "lineCoverageHistory" : [], "branchCoverageHistory" : [] }, + { "name" : "System.Linq.Dynamic.Core.ExpressionParser", "reportPath" : "System.Linq.Dynamic.Core_ExpressionParser.htm", "coveredLines" : 1323, "uncoveredLines" : 187, "coverableLines" : 1510, "totalLines" : 2670, "coverageType" : "LineCoverage", "methodCoverage" : "-", "coveredBranches" : 531, "totalBranches" : 705, "lineCoverageHistory" : [], "branchCoverageHistory" : [] }, { "name" : "System.Linq.Dynamic.Core.ExtensibilityPoint", "reportPath" : "System.Linq.Dynamic.Core_ExtensibilityPoint.htm", "coveredLines" : 1, "uncoveredLines" : 0, "coverableLines" : 1, "totalLines" : 17, "coverageType" : "LineCoverage", "methodCoverage" : "-", "coveredBranches" : 0, "totalBranches" : 0, "lineCoverageHistory" : [], "branchCoverageHistory" : [] }, { "name" : "System.Linq.Dynamic.Core.Extensions.LinqProviderExtensions", "reportPath" : "System.Linq.Dynamic.Core_LinqProviderExtensions.htm", "coveredLines" : 19, "uncoveredLines" : 3, "coverableLines" : 22, "totalLines" : 51, "coverageType" : "LineCoverage", "methodCoverage" : "-", "coveredBranches" : 5, "totalBranches" : 6, "lineCoverageHistory" : [], "branchCoverageHistory" : [] }, { "name" : "System.Linq.Dynamic.Core.GlobalConfig", "reportPath" : "System.Linq.Dynamic.Core_GlobalConfig.htm", "coveredLines" : 19, "uncoveredLines" : 1, "coverableLines" : 20, "totalLines" : 66, "coverageType" : "LineCoverage", "methodCoverage" : "-", "coveredBranches" : 3, "totalBranches" : 4, "lineCoverageHistory" : [], "branchCoverageHistory" : [] }, @@ -346,7 +346,7 @@ var assemblies = [ { "name" : "System.Linq.Dynamic.Core.PagedResult", "reportPath" : "System.Linq.Dynamic.Core_PagedResult.htm", "coveredLines" : 5, "uncoveredLines" : 0, "coverableLines" : 5, "totalLines" : 64, "coverageType" : "LineCoverage", "methodCoverage" : "-", "coveredBranches" : 0, "totalBranches" : 0, "lineCoverageHistory" : [], "branchCoverageHistory" : [] }, { "name" : "System.Linq.Dynamic.Core.PagedResult`1", "reportPath" : "System.Linq.Dynamic.Core_PagedResult_1.htm", "coveredLines" : 1, "uncoveredLines" : 0, "coverableLines" : 1, "totalLines" : 64, "coverageType" : "LineCoverage", "methodCoverage" : "-", "coveredBranches" : 0, "totalBranches" : 0, "lineCoverageHistory" : [], "branchCoverageHistory" : [] }, { "name" : "System.Linq.Dynamic.Core.Res", "reportPath" : "System.Linq.Dynamic.Core_Res.htm", "coveredLines" : 0, "uncoveredLines" : 0, "coverableLines" : 0, "totalLines" : 0, "coverageType" : "MethodCoverage", "methodCoverage" : "-", "coveredBranches" : 0, "totalBranches" : 0, "lineCoverageHistory" : [], "branchCoverageHistory" : [] }, - { "name" : "System.Linq.Dynamic.Core.Tokenizer.TextParser", "reportPath" : "System.Linq.Dynamic.Core_TextParser.htm", "coveredLines" : 261, "uncoveredLines" : 1, "coverableLines" : 262, "totalLines" : 384, "coverageType" : "LineCoverage", "methodCoverage" : "-", "coveredBranches" : 110, "totalBranches" : 120, "lineCoverageHistory" : [], "branchCoverageHistory" : [] }, + { "name" : "System.Linq.Dynamic.Core.Tokenizer.TextParser", "reportPath" : "System.Linq.Dynamic.Core_TextParser.htm", "coveredLines" : 287, "uncoveredLines" : 1, "coverableLines" : 288, "totalLines" : 423, "coverageType" : "LineCoverage", "methodCoverage" : "-", "coveredBranches" : 124, "totalBranches" : 132, "lineCoverageHistory" : [], "branchCoverageHistory" : [] }, { "name" : "System.Linq.Dynamic.Core.Tokenizer.Token", "reportPath" : "System.Linq.Dynamic.Core_Token.htm", "coveredLines" : 4, "uncoveredLines" : 0, "coverableLines" : 4, "totalLines" : 13, "coverageType" : "LineCoverage", "methodCoverage" : "-", "coveredBranches" : 0, "totalBranches" : 0, "lineCoverageHistory" : [], "branchCoverageHistory" : [] }, { "name" : "System.Linq.Dynamic.Core.TypeConverterFactory", "reportPath" : "System.Linq.Dynamic.Core_TypeConverterFactory.htm", "coveredLines" : 4, "uncoveredLines" : 0, "coverableLines" : 4, "totalLines" : 36, "coverageType" : "LineCoverage", "methodCoverage" : "-", "coveredBranches" : 0, "totalBranches" : 0, "lineCoverageHistory" : [], "branchCoverageHistory" : [] }, { "name" : "System.Reflection.CustomIntrospectionExtensions", "reportPath" : "System.Linq.Dynamic.Core_CustomIntrospectionExtensions.htm", "coveredLines" : 3, "uncoveredLines" : 0, "coverableLines" : 3, "totalLines" : 39, "coverageType" : "LineCoverage", "methodCoverage" : "-", "coveredBranches" : 0, "totalBranches" : 0, "lineCoverageHistory" : [], "branchCoverageHistory" : [] }, diff --git a/report/index.htm b/report/index.htm index fb89c356..206eee11 100644 --- a/report/index.htm +++ b/report/index.htm @@ -13,17 +13,17 @@

Summary

-Generated on:30-4-2017 - 11:34:21 +Generated on:30-4-2017 - 11:48:13 Parser:OpenCoverParser Assemblies:2 Classes:33 Files:25 -Covered lines:2485 -Uncovered lines:441 -Coverable lines:2926 -Total lines:6991 -Line coverage:84.9% -Branch coverage:73% +Covered lines:2566 +Uncovered lines:432 +Coverable lines:2998 +Total lines:7089 +Line coverage:85.5% +Branch coverage:74.9%

Assemblies

@@ -53,7 +53,7 @@

Assemblies

System.Linq.Dynamic.Core.Validation.CoreStrings01212410%
 
 
System.Reflection.CustomIntrospectionExtensions033390%
 
 
System.Reflection.CustomTypeBuilderExtensions033350%
 
 
-System.Linq.Dynamic.Core23782992677604788.8%
  
74.9%
  
+System.Linq.Dynamic.Core24592902749614589.4%
  
76.9%
  
System.Linq.Dynamic.Core.AssemblyBuilderFactory30325100%
 
 
System.Linq.Dynamic.Core.CustomTypeProviders.AbstractDynamicLinqCustomTypeProvider232259592%
  
50%
  
System.Linq.Dynamic.Core.CustomTypeProviders.DefaultDynamicLinqCustomTypeProvider088320%
 
0%
 
@@ -67,7 +67,7 @@

Assemblies

System.Linq.Dynamic.Core.DynamicProperty70735100%
 
 
System.Linq.Dynamic.Core.DynamicQueryableExtensions47816494137596.7%
  
71.4%
  
System.Linq.Dynamic.Core.Exceptions.ParseException4486650%
  
 
-System.Linq.Dynamic.Core.ExpressionParser12681961464261186.6%
  
73.4%
  
+System.Linq.Dynamic.Core.ExpressionParser13231871510267087.6%
  
75.3%
  
System.Linq.Dynamic.Core.ExtensibilityPoint10117100%
 
 
System.Linq.Dynamic.Core.Extensions.LinqProviderExtensions193225186.3%
  
83.3%
  
System.Linq.Dynamic.Core.GlobalConfig191206695%
  
75%
  
@@ -75,13 +75,13 @@

Assemblies

System.Linq.Dynamic.Core.PagedResult50564100%
 
 
System.Linq.Dynamic.Core.PagedResult`110164100%
 
 
System.Linq.Dynamic.Core.Res0000
 
 
-System.Linq.Dynamic.Core.Tokenizer.TextParser261126238499.6%
 
91.6%
  
+System.Linq.Dynamic.Core.Tokenizer.TextParser287128842399.6%
 
93.9%
  
System.Linq.Dynamic.Core.Tokenizer.Token40413100%
 
 
System.Linq.Dynamic.Core.TypeConverterFactory40436100%
 
 
System.Reflection.CustomIntrospectionExtensions30339100%
 
 
System.Reflection.CustomTypeBuilderExtensions30335100%
 
 
-
+ \ No newline at end of file