diff --git a/src/Microsoft.EntityFrameworkCore.DynamicLinq.EFCore3/EFDynamicQueryableExtensions.cs b/src/Microsoft.EntityFrameworkCore.DynamicLinq.EFCore3/EFDynamicQueryableExtensions.cs index 1e3a5d6e..c10f1c15 100644 --- a/src/Microsoft.EntityFrameworkCore.DynamicLinq.EFCore3/EFDynamicQueryableExtensions.cs +++ b/src/Microsoft.EntityFrameworkCore.DynamicLinq.EFCore3/EFDynamicQueryableExtensions.cs @@ -52,7 +52,7 @@ public static class EntityFrameworkDynamicQueryableExtensions [PublicAPI] public static Task AllAsync([NotNull] this IQueryable source, [NotNull] string predicate, [CanBeNull] params object[] args) { - return AllAsync(source, predicate, default(CancellationToken), args); + return AllAsync(source, predicate, default, args); } /// @@ -74,11 +74,10 @@ public static Task AllAsync([NotNull] this IQueryable source, [NotNull] st /// A task that represents the asynchronous operation. The task result contains true if every element of the source sequence passes the test in the specified predicate; otherwise, false. /// [PublicAPI] - public static Task AllAsync([NotNull] this IQueryable source, [NotNull] string predicate, CancellationToken cancellationToken = default(CancellationToken), [CanBeNull] params object[] args) + public static Task AllAsync([NotNull] this IQueryable source, [NotNull] string predicate, CancellationToken cancellationToken = default, [CanBeNull] params object[] args) { - Check.NotNull(source, nameof(source)); - Check.NotEmpty(predicate, nameof(predicate)); - Check.NotNull(cancellationToken, nameof(cancellationToken)); + Check.NotNull(source); + Check.NotEmpty(predicate); LambdaExpression lambda = DynamicExpressionParser.ParseLambda(false, source.ElementType, null, predicate, args); @@ -106,10 +105,9 @@ public static Task AllAsync([NotNull] this IQueryable source, [NotNull] st /// A task that represents the asynchronous operation. The task result contains true if the source sequence contains any elements; otherwise, false. /// [PublicAPI] - public static Task AnyAsync([NotNull] this IQueryable source, CancellationToken cancellationToken = default(CancellationToken)) + public static Task AnyAsync([NotNull] this IQueryable source, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); - Check.NotNull(cancellationToken, nameof(cancellationToken)); + Check.NotNull(source); return ExecuteAsync(_any, source, cancellationToken); } @@ -134,7 +132,7 @@ public static Task AllAsync([NotNull] this IQueryable source, [NotNull] st [PublicAPI] public static Task AnyAsync([NotNull] this IQueryable source, [NotNull] string predicate, [CanBeNull] params object[] args) { - return AnyAsync(source, predicate, default(CancellationToken), args); + return AnyAsync(source, predicate, default, args); } /// @@ -156,11 +154,10 @@ public static Task AnyAsync([NotNull] this IQueryable source, [NotNull] st /// A task that represents the asynchronous operation. The task result contains true if the source sequence contains any elements; otherwise, false. /// [PublicAPI] - public static Task AnyAsync([NotNull] this IQueryable source, [NotNull] string predicate, CancellationToken cancellationToken = default(CancellationToken), [CanBeNull] params object[] args) + public static Task AnyAsync([NotNull] this IQueryable source, [NotNull] string predicate, CancellationToken cancellationToken = default, [CanBeNull] params object[] args) { - Check.NotNull(source, nameof(source)); - Check.NotEmpty(predicate, nameof(predicate)); - Check.NotNull(cancellationToken, nameof(cancellationToken)); + Check.NotNull(source); + Check.NotEmpty(predicate); LambdaExpression lambda = DynamicExpressionParser.ParseLambda(false, source.ElementType, null, predicate, args); @@ -188,10 +185,9 @@ public static Task AnyAsync([NotNull] this IQueryable source, [NotNull] st /// A task that represents the asynchronous operation. The task result contains the average of the sequence of values. /// [PublicAPI] - public static Task AverageAsync([NotNull] this IQueryable source, CancellationToken cancellationToken = default(CancellationToken)) + public static Task AverageAsync([NotNull] this IQueryable source, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); - Check.NotNull(cancellationToken, nameof(cancellationToken)); + Check.NotNull(source); return ExecuteAsync(_averageForDouble, source, cancellationToken); } @@ -218,7 +214,7 @@ public static Task AnyAsync([NotNull] this IQueryable source, [NotNull] st [PublicAPI] public static Task AverageAsync([NotNull] this IQueryable source, [NotNull] string selector, [CanBeNull] params object[] args) { - return AverageAsync(source, selector, default(CancellationToken), args); + return AverageAsync(source, selector, default, args); } /// @@ -242,11 +238,10 @@ public static Task AverageAsync([NotNull] this IQueryable source, [NotNu /// predicate; otherwise, false. /// [PublicAPI] - public static Task AverageAsync([NotNull] this IQueryable source, [NotNull] string selector, CancellationToken cancellationToken = default(CancellationToken), [CanBeNull] params object[] args) + public static Task AverageAsync([NotNull] this IQueryable source, [NotNull] string selector, CancellationToken cancellationToken = default, [CanBeNull] params object[] args) { - Check.NotNull(source, nameof(source)); - Check.NotEmpty(selector, nameof(selector)); - Check.NotNull(cancellationToken, nameof(cancellationToken)); + Check.NotNull(source); + Check.NotEmpty(selector); LambdaExpression lambda = DynamicExpressionParser.ParseLambda(false, source.ElementType, null, selector, args); @@ -275,10 +270,9 @@ public static Task AverageAsync([NotNull] this IQueryable source, [NotNu /// The task result contains the number of elements in the input sequence. /// [PublicAPI] - public static Task CountAsync([NotNull] this IQueryable source, CancellationToken cancellationToken = default(CancellationToken)) + public static Task CountAsync([NotNull] this IQueryable source, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); - Check.NotNull(cancellationToken, nameof(cancellationToken)); + Check.NotNull(source); return ExecuteAsync(_count, source, cancellationToken); } @@ -305,7 +299,7 @@ public static Task AverageAsync([NotNull] this IQueryable source, [NotNu [PublicAPI] public static Task CountAsync([NotNull] this IQueryable source, [NotNull] string predicate, [CanBeNull] params object[] args) { - return CountAsync(source, default(CancellationToken), predicate, args); + return CountAsync(source, default, predicate, args); } /// @@ -331,9 +325,8 @@ public static Task CountAsync([NotNull] this IQueryable source, [NotNull] s [PublicAPI] public static Task CountAsync([NotNull] this IQueryable source, CancellationToken cancellationToken, [NotNull] string predicate, [CanBeNull] params object[] args) { - Check.NotNull(source, nameof(source)); - Check.NotNull(predicate, nameof(predicate)); - Check.NotNull(cancellationToken, nameof(cancellationToken)); + Check.NotNull(source); + Check.NotNull(predicate); LambdaExpression lambda = DynamicExpressionParser.ParseLambda(false, source.ElementType, null, predicate, args); @@ -362,9 +355,9 @@ public static Task CountAsync([NotNull] this IQueryable source, Cancellatio /// The task result contains the first element in . /// [PublicAPI] - public static Task FirstAsync([NotNull] this IQueryable source, CancellationToken cancellationToken = default(CancellationToken)) + public static Task FirstAsync([NotNull] this IQueryable source, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); + Check.NotNull(source); return ExecuteAsync(_first, source, cancellationToken); } @@ -391,7 +384,7 @@ public static Task CountAsync([NotNull] this IQueryable source, Cancellatio [PublicAPI] public static Task FirstAsync([NotNull] this IQueryable source, [NotNull] string predicate, [CanBeNull] params object[] args) { - return FirstAsync(source, default(CancellationToken), predicate, args); + return FirstAsync(source, default, predicate, args); } /// @@ -417,8 +410,8 @@ public static Task FirstAsync([NotNull] this IQueryable source, [NotNul [PublicAPI] public static Task FirstAsync([NotNull] this IQueryable source, CancellationToken cancellationToken, [NotNull] string predicate, [CanBeNull] params object[] args) { - Check.NotNull(source, nameof(source)); - Check.NotNull(predicate, nameof(predicate)); + Check.NotNull(source); + Check.NotNull(predicate); LambdaExpression lambda = DynamicExpressionParser.ParseLambda(false, source.ElementType, null, predicate, args); @@ -448,10 +441,9 @@ public static Task FirstAsync([NotNull] this IQueryable source, Cancell /// is empty; otherwise, the first element in . /// [PublicAPI] - public static Task FirstOrDefaultAsync([NotNull] this IQueryable source, CancellationToken cancellationToken = default(CancellationToken)) + public static Task FirstOrDefaultAsync([NotNull] this IQueryable source, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); - Check.NotNull(cancellationToken, nameof(cancellationToken)); + Check.NotNull(source); return ExecuteAsync(_firstOrDefault, source, cancellationToken); } @@ -480,7 +472,7 @@ public static Task FirstAsync([NotNull] this IQueryable source, Cancell [PublicAPI] public static Task FirstOrDefaultAsync([NotNull] this IQueryable source, [NotNull] string predicate, [CanBeNull] params object[] args) { - return FirstOrDefaultAsync(source, default(CancellationToken), predicate, args); + return FirstOrDefaultAsync(source, default, predicate, args); } /// @@ -508,9 +500,8 @@ public static Task FirstOrDefaultAsync([NotNull] this IQueryable source [PublicAPI] public static Task FirstOrDefaultAsync([NotNull] this IQueryable source, CancellationToken cancellationToken, [NotNull] string predicate, [CanBeNull] params object[] args) { - Check.NotNull(source, nameof(source)); - Check.NotNull(predicate, nameof(predicate)); - Check.NotNull(cancellationToken, nameof(cancellationToken)); + Check.NotNull(source); + Check.NotNull(predicate); LambdaExpression lambda = DynamicExpressionParser.ParseLambda(false, source.ElementType, null, predicate, args); @@ -539,9 +530,9 @@ public static Task FirstOrDefaultAsync([NotNull] this IQueryable source /// The task result contains the last element in . /// [PublicAPI] - public static Task LastAsync([NotNull] this IQueryable source, CancellationToken cancellationToken = default(CancellationToken)) + public static Task LastAsync([NotNull] this IQueryable source, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); + Check.NotNull(source); return ExecuteAsync(_last, source, cancellationToken); } @@ -568,7 +559,7 @@ public static Task FirstOrDefaultAsync([NotNull] this IQueryable source [PublicAPI] public static Task LastAsync([NotNull] this IQueryable source, [NotNull] string predicate, [CanBeNull] params object[] args) { - return LastAsync(source, default(CancellationToken), predicate, args); + return LastAsync(source, default, predicate, args); } /// @@ -594,8 +585,8 @@ public static Task LastAsync([NotNull] this IQueryable source, [NotNull [PublicAPI] public static Task LastAsync([NotNull] this IQueryable source, CancellationToken cancellationToken, [NotNull] string predicate, [CanBeNull] params object[] args) { - Check.NotNull(source, nameof(source)); - Check.NotNull(predicate, nameof(predicate)); + Check.NotNull(source); + Check.NotNull(predicate); LambdaExpression lambda = DynamicExpressionParser.ParseLambda(false, source.ElementType, null, predicate, args); @@ -625,10 +616,9 @@ public static Task LastAsync([NotNull] this IQueryable source, Cancella /// is empty; otherwise, the last element in . /// [PublicAPI] - public static Task LastOrDefaultAsync([NotNull] this IQueryable source, CancellationToken cancellationToken = default(CancellationToken)) + public static Task LastOrDefaultAsync([NotNull] this IQueryable source, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); - Check.NotNull(cancellationToken, nameof(cancellationToken)); + Check.NotNull(source); return ExecuteAsync(_lastOrDefault, source, cancellationToken); } @@ -657,7 +647,7 @@ public static Task LastAsync([NotNull] this IQueryable source, Cancella [PublicAPI] public static Task LastOrDefaultAsync([NotNull] this IQueryable source, [NotNull] string predicate, [CanBeNull] params object[] args) { - return LastOrDefaultAsync(source, default(CancellationToken), predicate, args); + return LastOrDefaultAsync(source, default, predicate, args); } /// @@ -685,9 +675,8 @@ public static Task LastOrDefaultAsync([NotNull] this IQueryable source, [PublicAPI] public static Task LastOrDefaultAsync([NotNull] this IQueryable source, CancellationToken cancellationToken, [NotNull] string predicate, [CanBeNull] params object[] args) { - Check.NotNull(source, nameof(source)); - Check.NotNull(predicate, nameof(predicate)); - Check.NotNull(cancellationToken, nameof(cancellationToken)); + Check.NotNull(source); + Check.NotNull(predicate); LambdaExpression lambda = DynamicExpressionParser.ParseLambda(false, source.ElementType, null, predicate, args); @@ -716,10 +705,9 @@ public static Task LastOrDefaultAsync([NotNull] this IQueryable source, /// The task result contains the number of elements in the input sequence. /// [PublicAPI] - public static Task LongCountAsync([NotNull] this IQueryable source, CancellationToken cancellationToken = default(CancellationToken)) + public static Task LongCountAsync([NotNull] this IQueryable source, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); - Check.NotNull(cancellationToken, nameof(cancellationToken)); + Check.NotNull(source); return ExecuteAsync(_longCount, source, cancellationToken); } @@ -746,7 +734,7 @@ public static Task LastOrDefaultAsync([NotNull] this IQueryable source, [PublicAPI] public static Task LongCountAsync([NotNull] this IQueryable source, [NotNull] string predicate, [CanBeNull] params object[] args) { - return LongCountAsync(source, default(CancellationToken), predicate, args); + return LongCountAsync(source, default, predicate, args); } /// @@ -772,9 +760,8 @@ public static Task LongCountAsync([NotNull] this IQueryable source, [NotNu [PublicAPI] public static Task LongCountAsync([NotNull] this IQueryable source, CancellationToken cancellationToken, [NotNull] string predicate, [CanBeNull] params object[] args) { - Check.NotNull(source, nameof(source)); - Check.NotNull(predicate, nameof(predicate)); - Check.NotNull(cancellationToken, nameof(cancellationToken)); + Check.NotNull(source); + Check.NotNull(predicate); LambdaExpression lambda = DynamicExpressionParser.ParseLambda(false, source.ElementType, null, predicate, args); @@ -803,10 +790,9 @@ public static Task LongCountAsync([NotNull] this IQueryable source, Cancel /// A task that represents the asynchronous operation. The task result contains the single element of the input sequence that satisfies the condition in predicate. /// [PublicAPI] - public static Task SingleOrDefaultAsync([NotNull] this IQueryable source, CancellationToken cancellationToken = default(CancellationToken)) + public static Task SingleOrDefaultAsync([NotNull] this IQueryable source, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); - Check.NotNull(cancellationToken, nameof(cancellationToken)); + Check.NotNull(source); return ExecuteAsync(_singleOrDefault, source, cancellationToken); } @@ -832,7 +818,7 @@ public static Task LongCountAsync([NotNull] this IQueryable source, Cancel [PublicAPI] public static Task SingleOrDefaultAsync([NotNull] this IQueryable source, [NotNull] string predicate, [CanBeNull] params object[] args) { - return SingleOrDefaultAsync(source, default(CancellationToken), predicate, args); + return SingleOrDefaultAsync(source, default, predicate, args); } /// @@ -857,9 +843,8 @@ public static Task SingleOrDefaultAsync([NotNull] this IQueryable sourc [PublicAPI] public static Task SingleOrDefaultAsync([NotNull] this IQueryable source, CancellationToken cancellationToken, [NotNull] string predicate, [CanBeNull] params object[] args) { - Check.NotNull(source, nameof(source)); - Check.NotNull(predicate, nameof(predicate)); - Check.NotNull(cancellationToken, nameof(cancellationToken)); + Check.NotNull(source); + Check.NotNull(predicate); LambdaExpression lambda = DynamicExpressionParser.ParseLambda(false, source.ElementType, null, predicate, args); @@ -886,10 +871,9 @@ public static Task SingleOrDefaultAsync([NotNull] this IQueryable sourc /// The task result contains sum of the values in the sequence. /// [PublicAPI] - public static Task SumAsync([NotNull] this IQueryable source, CancellationToken cancellationToken = default(CancellationToken)) + public static Task SumAsync([NotNull] this IQueryable source, CancellationToken cancellationToken = default) { - Check.NotNull(source, nameof(source)); - Check.NotNull(cancellationToken, nameof(cancellationToken)); + Check.NotNull(source); var sum = GetMethod(nameof(Queryable.Sum), source.ElementType); @@ -916,7 +900,7 @@ public static Task SingleOrDefaultAsync([NotNull] this IQueryable sourc [PublicAPI] public static Task SumAsync([NotNull] this IQueryable source, [NotNull] string selector, [CanBeNull] params object[] args) { - return SumAsync(source, default(CancellationToken), selector, args); + return SumAsync(source, default, selector, args); } /// @@ -941,9 +925,8 @@ public static Task SumAsync([NotNull] this IQueryable source, [NotNull] [PublicAPI] public static Task SumAsync([NotNull] this IQueryable source, CancellationToken cancellationToken, [NotNull] string selector, [CanBeNull] params object[] args) { - Check.NotNull(source, nameof(source)); - Check.NotNull(selector, nameof(selector)); - Check.NotNull(cancellationToken, nameof(cancellationToken)); + Check.NotNull(source); + Check.NotNull(selector); LambdaExpression lambda = DynamicExpressionParser.ParseLambda(false, source.ElementType, null, selector, args); @@ -963,7 +946,7 @@ public static Task SumAsync([NotNull] this IQueryable source, Cancellat .GetMethod(nameof(ExecuteAsync), BindingFlags.Static | BindingFlags.NonPublic, null, new[] { typeof(MethodInfo), typeof(IQueryable), typeof(CancellationToken) }, null); #endif - private static Task ExecuteDynamicAsync(MethodInfo operatorMethodInfo, IQueryable source, CancellationToken cancellationToken = default(CancellationToken)) + private static Task ExecuteDynamicAsync(MethodInfo operatorMethodInfo, IQueryable source, CancellationToken cancellationToken = default) { var executeAsyncMethod = _executeAsyncMethod.MakeGenericMethod(operatorMethodInfo.ReturnType); @@ -973,7 +956,7 @@ public static Task SumAsync([NotNull] this IQueryable source, Cancellat return castedTask; } - private static Task ExecuteAsync(MethodInfo operatorMethodInfo, IQueryable source, CancellationToken cancellationToken = default(CancellationToken)) + private static Task ExecuteAsync(MethodInfo operatorMethodInfo, IQueryable source, CancellationToken cancellationToken = default) { #if EFCORE var provider = source.Provider as IAsyncQueryProvider; @@ -1002,7 +985,7 @@ public static Task SumAsync([NotNull] this IQueryable source, Cancellat throw new InvalidOperationException(Res.IQueryableProviderNotAsync); } - private static Task ExecuteAsync(MethodInfo operatorMethodInfo, IQueryable source, LambdaExpression expression, CancellationToken cancellationToken = default(CancellationToken)) + private static Task ExecuteAsync(MethodInfo operatorMethodInfo, IQueryable source, LambdaExpression expression, CancellationToken cancellationToken = default) => ExecuteAsync(operatorMethodInfo, source, Expression.Quote(expression), cancellationToken); private static readonly MethodInfo _executeAsyncMethodWithExpression = @@ -1014,7 +997,7 @@ public static Task SumAsync([NotNull] this IQueryable source, Cancellat .GetMethod(nameof(ExecuteAsync), BindingFlags.Static | BindingFlags.NonPublic, null, new[] { typeof(MethodInfo), typeof(IQueryable), typeof(Expression), typeof(CancellationToken) }, null); #endif - private static Task ExecuteDynamicAsync(MethodInfo operatorMethodInfo, IQueryable source, Expression expression, CancellationToken cancellationToken = default(CancellationToken)) + private static Task ExecuteDynamicAsync(MethodInfo operatorMethodInfo, IQueryable source, Expression expression, CancellationToken cancellationToken = default) { var executeAsyncMethod = _executeAsyncMethodWithExpression.MakeGenericMethod(operatorMethodInfo.ReturnType); @@ -1024,7 +1007,7 @@ public static Task SumAsync([NotNull] this IQueryable source, Cancellat return castedTask; } - private static Task ExecuteAsync(MethodInfo operatorMethodInfo, IQueryable source, Expression expression, CancellationToken cancellationToken = default(CancellationToken)) + private static Task ExecuteAsync(MethodInfo operatorMethodInfo, IQueryable source, Expression expression, CancellationToken cancellationToken = default) { #if EFCORE var provider = source.Provider as IAsyncQueryProvider; @@ -1081,7 +1064,7 @@ private static IQueryable CastSource(IQueryable source, MethodInfo operatorMetho return source; } - private static Task ExecuteAsync(IAsyncQueryProvider provider, Expression expression, CancellationToken cancellationToken = default(CancellationToken)) + private static Task ExecuteAsync(IAsyncQueryProvider provider, Expression expression, CancellationToken cancellationToken = default) { if (typeof(TResult) == typeof(object) && expression.Type != typeof(object)) { diff --git a/src/Microsoft.EntityFrameworkCore.DynamicLinq.EFCore3/EFDynamicQueryableWithFormattableStringExtensions.cs b/src/Microsoft.EntityFrameworkCore.DynamicLinq.EFCore3/EFDynamicQueryableWithFormattableStringExtensions.cs index 2a75ae60..ae250610 100644 --- a/src/Microsoft.EntityFrameworkCore.DynamicLinq.EFCore3/EFDynamicQueryableWithFormattableStringExtensions.cs +++ b/src/Microsoft.EntityFrameworkCore.DynamicLinq.EFCore3/EFDynamicQueryableWithFormattableStringExtensions.cs @@ -43,7 +43,7 @@ public static Task AllInterpolatedAsync([NotNull] this IQueryable source, } [PublicAPI] - public static Task AllInterpolatedAsync([NotNull] this IQueryable source, [NotNull] FormattableString predicate, CancellationToken cancellationToken = default(CancellationToken)) + public static Task AllInterpolatedAsync([NotNull] this IQueryable source, [NotNull] FormattableString predicate, CancellationToken cancellationToken = default) { string predicateStr = ParseFormattableString(predicate, out object[] args); return EntityFrameworkDynamicQueryableExtensions.AllAsync(source, predicateStr, cancellationToken, args); @@ -57,7 +57,7 @@ public static Task AnyInterpolatedAsync([NotNull] this IQueryable source, } [PublicAPI] - public static Task AnyInterpolatedAsync([NotNull] this IQueryable source, [NotNull] FormattableString predicate, CancellationToken cancellationToken = default(CancellationToken)) + public static Task AnyInterpolatedAsync([NotNull] this IQueryable source, [NotNull] FormattableString predicate, CancellationToken cancellationToken = default) { string predicateStr = ParseFormattableString(predicate, out object[] args); return EntityFrameworkDynamicQueryableExtensions.AnyAsync(source, predicateStr, cancellationToken, args); @@ -72,7 +72,7 @@ public static Task AverageInterpolatedAsync([NotNull] this IQueryable so [PublicAPI] - public static Task AverageInterpolatedAsync([NotNull] this IQueryable source, [NotNull] FormattableString selector, CancellationToken cancellationToken = default(CancellationToken)) + public static Task AverageInterpolatedAsync([NotNull] this IQueryable source, [NotNull] FormattableString selector, CancellationToken cancellationToken = default) { string selectorStr = ParseFormattableString(selector, out object[] args); return EntityFrameworkDynamicQueryableExtensions.AverageAsync(source, selectorStr, cancellationToken, args); diff --git a/src/System.Linq.Dynamic.Core/Parser/ExpressionParser.cs b/src/System.Linq.Dynamic.Core/Parser/ExpressionParser.cs index 4a6319aa..fdb41c56 100644 --- a/src/System.Linq.Dynamic.Core/Parser/ExpressionParser.cs +++ b/src/System.Linq.Dynamic.Core/Parser/ExpressionParser.cs @@ -2496,7 +2496,7 @@ private Expression ParseElementAccess(Expression expr) internal static Type ToNullableType(Type type) { - Check.NotNull(type, nameof(type)); + Check.NotNull(type); if (!type.GetTypeInfo().IsValueType || TypeHelper.IsNullableType(type)) { diff --git a/src/System.Linq.Dynamic.Core/Util/RuntimeInformationUtils.cs b/src/System.Linq.Dynamic.Core/Util/RuntimeInformationUtils.cs index 77e55032..38332291 100644 --- a/src/System.Linq.Dynamic.Core/Util/RuntimeInformationUtils.cs +++ b/src/System.Linq.Dynamic.Core/Util/RuntimeInformationUtils.cs @@ -2,7 +2,7 @@ internal static class RuntimeInformationUtils { - public static bool IsBlazorWASM; + public static readonly bool IsBlazorWASM; static RuntimeInformationUtils() { diff --git a/src/System.Linq.Dynamic.Core/Validation/Check.cs b/src/System.Linq.Dynamic.Core/Validation/Check.cs index e0bbb32b..741e040a 100644 --- a/src/System.Linq.Dynamic.Core/Validation/Check.cs +++ b/src/System.Linq.Dynamic.Core/Validation/Check.cs @@ -10,7 +10,7 @@ internal static class Check { private const string ParsingConfigError = "The ParsingConfig should be provided as first argument to this method."; - public static object?[]? Args(object?[]? args, [CallerArgumentExpression("args")] string? parameterName = null) + public static object?[]? Args(object?[]? args, [CallerArgumentExpression(nameof(args))] string? parameterName = null) { if (args?.Any(a => a is ParsingConfig) == true) { @@ -20,7 +20,7 @@ internal static class Check return args; } - public static T Condition(T value, Predicate predicate, [CallerArgumentExpression("value")] string? parameterName = null) + public static T Condition(T value, Predicate predicate, [CallerArgumentExpression(nameof(value))] string? parameterName = null) { NotNull(predicate); @@ -34,7 +34,7 @@ public static T Condition(T value, Predicate predicate, [CallerArgumentExp return value; } - public static T NotNull(T value, [CallerArgumentExpression("value")] string? parameterName = null) + public static T NotNull(T value, [CallerArgumentExpression(nameof(value))] string? parameterName = null) { if (value is null) { @@ -59,7 +59,7 @@ public static T NotNull(T value, string parameterName, string propertyName) return value; } - public static IEnumerable NotNullOrEmpty(IEnumerable value, [CallerArgumentExpression("value")] string? parameterName = null) + public static IEnumerable NotNullOrEmpty(IEnumerable value, [CallerArgumentExpression(nameof(value))] string? parameterName = null) { IEnumerable result = NotNull(value, parameterName); @@ -75,10 +75,10 @@ public static IEnumerable NotNullOrEmpty(IEnumerable value, [CallerArgu return result; } - public static string NotEmpty(string? value, [CallerArgumentExpression("value")] string? parameterName = null) => + public static string NotEmpty(string? value, [CallerArgumentExpression(nameof(value))] string? parameterName = null) => NotNullOrWhiteSpace(value, parameterName); - public static string NotNullOrEmpty(string? value, [CallerArgumentExpression("value")] string? parameterName = null) + public static string NotNullOrEmpty(string? value, [CallerArgumentExpression(nameof(value))] string? parameterName = null) { if (value is null) { @@ -95,7 +95,7 @@ public static string NotNullOrEmpty(string? value, [CallerArgumentExpression("va return value; } - public static string NotNullOrWhiteSpace(string? value, [CallerArgumentExpression("value")] string? parameterName = null) + public static string NotNullOrWhiteSpace(string? value, [CallerArgumentExpression(nameof(value))] string? parameterName = null) { if (value is null) { @@ -112,7 +112,7 @@ public static string NotNullOrWhiteSpace(string? value, [CallerArgumentExpressio return value; } - public static IEnumerable HasNoNulls(IEnumerable value, [CallerArgumentExpression("value")] string? parameterName = null) + public static IEnumerable HasNoNulls(IEnumerable value, [CallerArgumentExpression(nameof(value))] string? parameterName = null) { if (value is null) {