Skip to content

Commit f71c941

Browse files
authored
Code format: fix compilation suggestions (#363)
1 parent 61c11fc commit f71c941

File tree

6 files changed

+77
-85
lines changed

6 files changed

+77
-85
lines changed

src/DynamicExpresso.Core/Detector.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,16 @@ public IdentifiersInfo DetectIdentifiers(string expression, DetectorOptions opti
5858
if (withtype != identifier)
5959
{
6060
var typeName = types[t].Value;
61-
if (_settings.KnownTypes.TryGetValue(typeName, out ReferenceType knownType))
61+
if (_settings.KnownTypes.TryGetValue(typeName, out var knownType))
6262
type = knownType.Type;
6363

6464
t++;
6565
}
6666

6767
// there might be several lambda parameters with the same name
6868
// -> in that case, we ignore the detected type
69-
if (lambdaParameters.TryGetValue(identifier, out Identifier already) &&
70-
already.Expression.Type != type)
69+
if (lambdaParameters.TryGetValue(identifier, out var already) &&
70+
already.Expression.Type != type)
7171
type = typeof(object);
7272

7373
var defaultValue = type.IsValueType ? Activator.CreateInstance(type) : null;
@@ -96,11 +96,11 @@ public IdentifiersInfo DetectIdentifiers(string expression, DetectorOptions opti
9696
continue;
9797
}
9898

99-
if (_settings.Identifiers.TryGetValue(identifier, out Identifier knownIdentifier))
99+
if (_settings.Identifiers.TryGetValue(identifier, out var knownIdentifier))
100100
knownIdentifiers.Add(knownIdentifier);
101-
else if (lambdaParameters.TryGetValue(identifier, out Identifier knownLambdaParam))
101+
else if (lambdaParameters.TryGetValue(identifier, out var knownLambdaParam))
102102
knownIdentifiers.Add(knownLambdaParam);
103-
else if (_settings.KnownTypes.TryGetValue(identifier, out ReferenceType knownType))
103+
else if (_settings.KnownTypes.TryGetValue(identifier, out var knownType))
104104
knownTypes.Add(knownType);
105105
else
106106
unknownIdentifiers.Add(identifier);

src/DynamicExpresso.Core/LanguageConstants.cs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using DynamicExpresso.Parsing;
21
using System;
32
using System.Linq.Expressions;
3+
using DynamicExpresso.Parsing;
44

55
namespace DynamicExpresso
66
{
@@ -9,25 +9,25 @@ public static class LanguageConstants
99
public const string This = "this";
1010

1111
public static readonly ReferenceType[] PrimitiveTypes = {
12-
new ReferenceType(typeof(object)),
13-
new ReferenceType(typeof(bool)),
14-
new ReferenceType(typeof(char)),
15-
new ReferenceType(typeof(string)),
16-
new ReferenceType(typeof(sbyte)),
17-
new ReferenceType(typeof(byte)),
18-
new ReferenceType(typeof(short)),
19-
new ReferenceType(typeof(ushort)),
20-
new ReferenceType(typeof(int)),
21-
new ReferenceType(typeof(uint)),
22-
new ReferenceType(typeof(long)),
23-
new ReferenceType(typeof(ulong)),
24-
new ReferenceType(typeof(float)),
25-
new ReferenceType(typeof(double)),
26-
new ReferenceType(typeof(decimal)),
27-
new ReferenceType(typeof(DateTime)),
28-
new ReferenceType(typeof(TimeSpan)),
29-
new ReferenceType(typeof(Guid))
30-
};
12+
new ReferenceType(typeof(object)),
13+
new ReferenceType(typeof(bool)),
14+
new ReferenceType(typeof(char)),
15+
new ReferenceType(typeof(string)),
16+
new ReferenceType(typeof(sbyte)),
17+
new ReferenceType(typeof(byte)),
18+
new ReferenceType(typeof(short)),
19+
new ReferenceType(typeof(ushort)),
20+
new ReferenceType(typeof(int)),
21+
new ReferenceType(typeof(uint)),
22+
new ReferenceType(typeof(long)),
23+
new ReferenceType(typeof(ulong)),
24+
new ReferenceType(typeof(float)),
25+
new ReferenceType(typeof(double)),
26+
new ReferenceType(typeof(decimal)),
27+
new ReferenceType(typeof(DateTime)),
28+
new ReferenceType(typeof(TimeSpan)),
29+
new ReferenceType(typeof(Guid))
30+
};
3131

3232
/// <summary>
3333
/// Primitive types alias (string, int, ...)
@@ -54,10 +54,10 @@ public static class LanguageConstants
5454
/// Common .NET Types (Math, Convert, Enumerable)
5555
/// </summary>
5656
public static readonly ReferenceType[] CommonTypes = {
57-
new ReferenceType(typeof(Math)),
58-
new ReferenceType(typeof(Convert)),
59-
new ReferenceType(typeof(System.Linq.Enumerable))
60-
};
57+
new ReferenceType(typeof(Math)),
58+
new ReferenceType(typeof(Convert)),
59+
new ReferenceType(typeof(System.Linq.Enumerable))
60+
};
6161

6262
/// <summary>
6363
/// true, false, null

src/DynamicExpresso.Core/ParserArguments.cs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
using DynamicExpresso.Parsing;
21
using System;
32
using System.Collections.Generic;
43
using System.Linq;
54
using System.Linq.Expressions;
65
using System.Reflection;
7-
using DynamicExpresso.Exceptions;
86
using System.Text.RegularExpressions;
7+
using DynamicExpresso.Exceptions;
8+
using DynamicExpresso.Parsing;
99

1010
namespace DynamicExpresso
1111
{
@@ -18,8 +18,8 @@ internal class ParserArguments
1818
private readonly HashSet<Identifier> _usedIdentifiers = new HashSet<Identifier>();
1919

2020
public ParserArguments(
21-
string expressionText,
22-
ParserSettings settings,
21+
string expressionText,
22+
ParserSettings settings,
2323
Type expressionReturnType,
2424
IEnumerable<Parameter> declaredParameters
2525
)
@@ -42,7 +42,7 @@ IEnumerable<Parameter> declaredParameters
4242
}
4343
}
4444

45-
public ParserSettings Settings { get; private set;}
45+
public ParserSettings Settings { get; private set; }
4646
public string ExpressionText { get; private set; }
4747
public Type ExpressionReturnType { get; private set; }
4848
public IEnumerable<Parameter> DeclaredParameters { get { return _declaredParameters.Values; } }
@@ -64,8 +64,7 @@ public IEnumerable<Identifier> UsedIdentifiers
6464

6565
public bool TryGetKnownType(string name, out Type type)
6666
{
67-
ReferenceType reference;
68-
if (Settings.KnownTypes.TryGetValue(name, out reference))
67+
if (Settings.KnownTypes.TryGetValue(name, out var reference))
6968
{
7069
_usedTypes.Add(reference);
7170
type = reference.Type;
@@ -87,8 +86,7 @@ internal bool HasKnownGenericTypeDefinition(string name)
8786

8887
public bool TryGetIdentifier(string name, out Expression expression)
8988
{
90-
Identifier identifier;
91-
if (Settings.Identifiers.TryGetValue(name, out identifier))
89+
if (Settings.Identifiers.TryGetValue(name, out var identifier))
9290
{
9391
_usedIdentifiers.Add(identifier);
9492
expression = identifier.Expression;
@@ -104,11 +102,10 @@ public bool TryGetIdentifier(string name, out Expression expression)
104102
/// </summary>
105103
public bool TryGetParameters(string name, out ParameterExpression expression)
106104
{
107-
Parameter parameter;
108-
if (_declaredParameters.TryGetValue(name, out parameter))
105+
if (_declaredParameters.TryGetValue(name, out var parameter))
109106
{
110107
_usedParameters.Add(parameter);
111-
expression = parameter.Expression;
108+
expression = parameter.Expression;
112109
return true;
113110
}
114111

0 commit comments

Comments
 (0)