Skip to content

Commit c41dac9

Browse files
committed
Fix some warnings
1 parent 09d558a commit c41dac9

File tree

8 files changed

+139
-156
lines changed

8 files changed

+139
-156
lines changed

src/Microsoft.EntityFrameworkCore.DynamicLinq.EFCore3/EFDynamicQueryableExtensions.cs

Lines changed: 90 additions & 109 deletions
Large diffs are not rendered by default.

src/System.Linq.Dynamic.Core/DynamicClassFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ private static Type EmitType(IList<DynamicProperty> properties, bool createParam
419419

420420
EmitEqualityOperators(typeBuilder, equals);
421421

422-
return typeBuilder.CreateType();
422+
return typeBuilder.CreateType()!;
423423
}
424424

425425
private static void EmitEqualityOperators(TypeBuilder typeBuilder, MethodBuilder equals)

src/System.Linq.Dynamic.Core/DynamicExpressionParser.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public static LambdaExpression ParseLambda(bool createParameterCtor, Type itType
189189
Check.NotNull(itType);
190190
Check.NotEmpty(expression);
191191

192-
return ParseLambda(createParameterCtor, new[] { ParameterExpressionHelper.CreateParameterExpression(itType, string.Empty) }, resultType, expression, values);
192+
return ParseLambda(createParameterCtor, [ParameterExpressionHelper.CreateParameterExpression(itType, string.Empty)], resultType, expression, values);
193193
}
194194

195195
/// <summary>
@@ -207,7 +207,8 @@ public static Expression<Func<T, TResult>> ParseLambda<T, TResult>(ParsingConfig
207207
{
208208
Check.NotEmpty(expression);
209209

210-
return (Expression<Func<T, TResult>>)ParseLambda(parsingConfig, createParameterCtor, new[] { ParameterExpressionHelper.CreateParameterExpression(typeof(T), string.Empty, parsingConfig?.RenameEmptyParameterExpressionNames ?? false) }, typeof(TResult), expression, values);
210+
return (Expression<Func<T, TResult>>)ParseLambda(parsingConfig, createParameterCtor, [ParameterExpressionHelper.CreateParameterExpression(typeof(T), string.Empty, parsingConfig?.RenameEmptyParameterExpressionNames ?? false)
211+
], typeof(TResult), expression, values);
211212
}
212213

213214
/// <summary>
@@ -227,7 +228,8 @@ public static Expression<Func<T, TResult>> ParseLambda<T, TResult>(Type delegate
227228
Check.NotNull(delegateType);
228229
Check.NotEmpty(expression);
229230

230-
return (Expression<Func<T, TResult>>)ParseLambda(delegateType, parsingConfig, createParameterCtor, new[] { ParameterExpressionHelper.CreateParameterExpression(typeof(T), string.Empty, parsingConfig?.RenameEmptyParameterExpressionNames ?? false) }, typeof(TResult), expression, values);
231+
return (Expression<Func<T, TResult>>)ParseLambda(delegateType, parsingConfig, createParameterCtor, [ParameterExpressionHelper.CreateParameterExpression(typeof(T), string.Empty, parsingConfig?.RenameEmptyParameterExpressionNames ?? false)
232+
], typeof(TResult), expression, values);
231233
}
232234

233235
/// <summary>
@@ -374,7 +376,7 @@ public static LambdaExpression ParseLambda(Type delegateType, ParsingConfig? par
374376
Check.NotNull(itType);
375377
Check.NotEmpty(expression);
376378

377-
return ParseLambda(delegateType, parsingConfig, createParameterCtor, new[] { ParameterExpressionHelper.CreateParameterExpression(itType, string.Empty, parsingConfig?.RenameEmptyParameterExpressionNames ?? false) }, resultType, expression, values);
379+
return ParseLambda(delegateType, parsingConfig, createParameterCtor, [ParameterExpressionHelper.CreateParameterExpression(itType, string.Empty, parsingConfig?.RenameEmptyParameterExpressionNames ?? false)], resultType, expression, values);
378380
}
379381

380382
/// <summary>

src/System.Linq.Dynamic.Core/DynamicQueryableExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2094,7 +2094,7 @@ public static IQueryable SelectMany(
20942094
string collectionParameterName,
20952095
string resultParameterName,
20962096
object?[]? collectionSelectorArgs = null,
2097-
params object[]? resultSelectorArgs)
2097+
params object?[]? resultSelectorArgs)
20982098
{
20992099
Check.NotNull(source);
21002100
Check.NotNull(config);

src/System.Linq.Dynamic.Core/GroupResult.cs

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,45 @@
22
using System.Collections.Generic;
33
using System.Globalization;
44

5-
namespace System.Linq.Dynamic.Core
5+
namespace System.Linq.Dynamic.Core;
6+
7+
/// <summary>
8+
/// The result of a call to a <see cref="DynamicQueryableExtensions"/>.GroupByMany() overload.
9+
/// </summary>
10+
public class GroupResult
611
{
712
/// <summary>
8-
/// The result of a call to a <see cref="DynamicQueryableExtensions"/>.GroupByMany() overload.
13+
/// The key value of the group.
914
/// </summary>
10-
public class GroupResult
11-
{
12-
/// <summary>
13-
/// The key value of the group.
14-
/// </summary>
1515
#if NET35 || SILVERLIGHT
16-
public object Key { get; internal set; } = null!;
16+
public object Key { get; internal set; } = null!;
1717
#else
18-
public dynamic Key { get; internal set; } = null!;
18+
public dynamic Key { get; internal set; } = null!;
1919
#endif
2020

21-
/// <summary>
22-
/// The number of resulting elements in the group.
23-
/// </summary>
24-
public int Count { get; internal set; }
21+
/// <summary>
22+
/// The number of resulting elements in the group.
23+
/// </summary>
24+
public int Count { get; internal set; }
2525

26-
/// <summary>
27-
/// The resulting elements in the group.
28-
/// </summary>
29-
public IEnumerable Items { get; internal set; }
26+
/// <summary>
27+
/// The resulting elements in the group.
28+
/// </summary>
29+
public IEnumerable Items { get; internal set; } = null!;
3030

31-
/// <summary>
32-
/// The resulting subgroups in the group.
33-
/// </summary>
34-
public IEnumerable<GroupResult>? Subgroups { get; internal set; }
31+
/// <summary>
32+
/// The resulting subgroups in the group.
33+
/// </summary>
34+
public IEnumerable<GroupResult>? Subgroups { get; internal set; }
3535

36-
/// <summary>
37-
/// Returns a <see cref="System.String" /> showing the key of the group and the number of items in the group.
38-
/// </summary>
39-
/// <returns>
40-
/// A <see cref="System.String" /> that represents this instance.
41-
/// </returns>
42-
public override string ToString()
43-
{
44-
return string.Format(CultureInfo.CurrentCulture, "{0} ({1})", ((object)Key).ToString(), Count);
45-
}
36+
/// <summary>
37+
/// Returns a <see cref="System.String" /> showing the key of the group and the number of items in the group.
38+
/// </summary>
39+
/// <returns>
40+
/// A <see cref="System.String" /> that represents this instance.
41+
/// </returns>
42+
public override string ToString()
43+
{
44+
return string.Format(CultureInfo.CurrentCulture, "{0} ({1})", ((object)Key).ToString(), Count);
4645
}
4746
}
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
using System.Linq.Expressions;
22
using System.Reflection;
33

4-
namespace System.Linq.Dynamic.Core.Parser.SupportedMethods
4+
namespace System.Linq.Dynamic.Core.Parser.SupportedMethods;
5+
6+
internal class MethodData(MethodBase methodBase, ParameterInfo[] parameters)
57
{
6-
internal class MethodData
7-
{
8-
public MethodBase MethodBase { get; set; }
9-
public ParameterInfo[] Parameters { get; set; }
10-
public Expression[] Args { get; set; }
11-
}
12-
}
8+
public MethodBase MethodBase => methodBase;
9+
10+
public ParameterInfo[] Parameters => parameters;
11+
12+
public Expression[] Args { get; set; } = [];
13+
}

src/System.Linq.Dynamic.Core/Parser/SupportedMethods/MethodFinder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public int FindBestMethodBasedOnArguments(IEnumerable<MethodBase> methods, ref E
170170
var inlineArgs = args;
171171

172172
MethodData[] applicable = methods
173-
.Select(m => new MethodData { MethodBase = m, Parameters = m.GetParameters() })
173+
.Select(m => new MethodData(m, m.GetParameters()))
174174
.Where(m => IsApplicable(m, inlineArgs))
175175
.ToArray();
176176

src/System.Linq.Dynamic.Core/Util/ParameterExpressionRenamer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public Expression Rename(Expression expression, out ParameterExpression? paramet
4848
return visitedExpression;
4949
}
5050

51-
/// <inheritdoc cref="ExpressionVisitor.VisitParameter"/>
51+
/// <inheritdoc />
5252
protected override Expression VisitParameter(ParameterExpression node)
5353
{
5454
if (string.Equals(_oldName, node.Name, StringComparison.Ordinal))

0 commit comments

Comments
 (0)