Skip to content

Commit 075be1b

Browse files
dotnet format
1 parent 9f3403e commit 075be1b

File tree

4 files changed

+36
-36
lines changed

4 files changed

+36
-36
lines changed

src/CommunityToolkit.Maui.Core/Primitives/MathOperator.shared.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,23 @@ public enum MathOperatorPrecedence
2727
/// <param name="numericCount">Number of Numerals</param>
2828
/// <param name="calculateFunc">Calculation Function</param>
2929
public sealed class MathOperator(
30-
string name,
31-
int numericCount,
32-
Func<object?[], object?> calculateFunc)
30+
string name,
31+
int numericCount,
32+
Func<object?[], object?> calculateFunc)
3333
{
3434

35-
/// <summary>
36-
/// Name
37-
/// </summary>
38-
public string Name { get; } = name;
35+
/// <summary>
36+
/// Name
37+
/// </summary>
38+
public string Name { get; } = name;
3939

40-
/// <summary>
41-
/// Number of Numerals
42-
/// </summary>
43-
public int NumericCount { get; } = numericCount;
40+
/// <summary>
41+
/// Number of Numerals
42+
/// </summary>
43+
public int NumericCount { get; } = numericCount;
4444

45-
/// <summary>
46-
/// Calculation Function
47-
/// </summary>
48-
public Func<object?[], object?> CalculateFunc { get; } = calculateFunc;
45+
/// <summary>
46+
/// Calculation Function
47+
/// </summary>
48+
public Func<object?[], object?> CalculateFunc { get; } = calculateFunc;
4949
}

src/CommunityToolkit.Maui.UnitTests/Converters/MathExpressionConverterTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,10 @@ public void MathExpressionConverter_WithBooleanOperator_ReturnsCorrectBooleanRes
187187
}
188188

189189
[Theory]
190-
[InlineData("x == 3 && x1", new object?[] { 3d, null})]
190+
[InlineData("x == 3 && x1", new object?[] { 3d, null })]
191191
[InlineData("x != 3 || x1", new object?[] { 3d, null })]
192192
[InlineData("x == 3 ? x1 : x2", new object?[] { 3d, null, 5d })]
193-
[InlineData("x != 3 ? x1 : x2", new object?[] { 3d, 4d, null})]
193+
[InlineData("x != 3 ? x1 : x2", new object?[] { 3d, 4d, null })]
194194
public void MathExpressionConverter_ReturnsCorrectNullResult(string expression, object[] variables)
195195
{
196196
var mathExpressionConverter = new MultiMathExpressionConverter();
@@ -203,7 +203,7 @@ public void MathExpressionConverter_ReturnsCorrectNullResult(string expression,
203203
[Theory]
204204
[InlineData("x == x1", new object?[] { 2d, 2d }, true)]
205205
[InlineData("x == x1", new object?[] { 2d, null }, false)]
206-
[InlineData("x == x1", new object?[] { null, 2d}, false)]
206+
[InlineData("x == x1", new object?[] { null, 2d }, false)]
207207
[InlineData("x == x1", new object?[] { null, null }, true)]
208208
[InlineData("(x ? x1 : x2) == null", new object?[] { true, null, 2d }, true)]
209209
public void MathExpressionConverter_WithEqualityOperator_ReturnsCorrectBooleanResult(string expression, object[] variables, bool expectedResult)
@@ -258,4 +258,4 @@ public void MultiMathExpressionConverterNullInputTest()
258258
#pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type.
259259
Assert.Throws<ArgumentNullException>(() => new MultiMathExpressionConverter().Convert([0.0, 7], typeof(bool), null, null));
260260
}
261-
}
261+
}

src/CommunityToolkit.Maui/Converters/MathExpressionConverter/MathExpression.shared.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System.Collections.ObjectModel;
2-
using System.Text.RegularExpressions;
32
using System.Diagnostics;
43
using System.Diagnostics.CodeAnalysis;
4+
using System.Text.RegularExpressions;
55
using CommunityToolkit.Maui.Core;
66

77
namespace CommunityToolkit.Maui.Converters;
@@ -98,7 +98,7 @@ internal MathExpression(in string expression, in IReadOnlyList<object?> argument
9898

9999
this.operators = operators;
100100
}
101-
101+
102102
static ReadOnlyDictionary<string, string> BinaryMappingDictionary { get; } = new Dictionary<string, string>
103103
{
104104
{ "<", "lt" },
@@ -114,11 +114,11 @@ internal MathExpression(in string expression, in IReadOnlyList<object?> argument
114114
{ "-", "neg" },
115115
{ "!", "not" }
116116
}.AsReadOnly();
117-
117+
118118
string Expression { get; }
119119

120120
List<MathToken> RPN { get; } = [];
121-
121+
122122
int ExpressionIndex { get; set; }
123123

124124
Match PatternMatch { get; set; } = Match.Empty;
@@ -141,8 +141,8 @@ internal MathExpression(in string expression, in IReadOnlyList<object?> argument
141141
}
142142

143143
var mathOperator = operators.FirstOrDefault(x => x.Name == token.Text) ?? throw new ArgumentException($"Math Expression Invalid. Can't find operator or value with name \"{token.Text}\".");
144-
145-
if (mathOperator.NumericCount is 0)
144+
145+
if (mathOperator.NumericCount is 0)
146146
{
147147
stack.Push(mathOperator.CalculateFunc([]));
148148
continue;
@@ -157,7 +157,7 @@ internal MathExpression(in string expression, in IReadOnlyList<object?> argument
157157

158158
bool containsNullArgument = false;
159159
List<object?> args = [];
160-
160+
161161
for (var j = 0; j < operatorNumericCount; j++)
162162
{
163163
object? val = stack.Pop();
@@ -184,7 +184,7 @@ internal MathExpression(in string expression, in IReadOnlyList<object?> argument
184184
_ => stack.Pop()
185185
};
186186
}
187-
187+
188188
[GeneratedRegex("""^(\w+)\(""")]
189189
private static partial Regex EvaluateFunctionStart();
190190

@@ -193,16 +193,16 @@ internal MathExpression(in string expression, in IReadOnlyList<object?> argument
193193

194194
[GeneratedRegex("""^(\))""")]
195195
private static partial Regex EvaluateFunctionEnd();
196-
196+
197197
[GeneratedRegex("""^(\?)""")]
198198
private static partial Regex EvaluateConditionalStart();
199199

200200
[GeneratedRegex("""^(\:)""")]
201201
private static partial Regex EvaluateConditionalElse();
202-
202+
203203
[GeneratedRegex("""^(\|\||or)""")]
204204
private static partial Regex EvaluateLogicalOROperator();
205-
205+
206206
[GeneratedRegex("""^(\&\&|and)""")]
207207
private static partial Regex EvaluateLogicalAndOperator();
208208

@@ -238,10 +238,10 @@ internal MathExpression(in string expression, in IReadOnlyList<object?> argument
238238

239239
[GeneratedRegex("""^(\))""")]
240240
private static partial Regex EvaluateParenEnd();
241-
241+
242242
[GeneratedRegex("""^\s*""")]
243243
private static partial Regex EvaluateWhitespace();
244-
244+
245245
static bool ConvertToBoolean(object? b) => b switch
246246
{
247247
bool x => x,
@@ -250,7 +250,7 @@ internal MathExpression(in string expression, in IReadOnlyList<object?> argument
250250
string stringValue => !string.IsNullOrEmpty(stringValue),
251251
_ => Convert.ToBoolean(b)
252252
};
253-
253+
254254
bool ParsePattern(Regex regex)
255255
{
256256
var whitespaceMatch = EvaluateWhitespace().Match(Expression[ExpressionIndex..]);
@@ -458,4 +458,4 @@ bool ParseFunction()
458458

459459
return true;
460460
}
461-
}
461+
}

src/CommunityToolkit.Maui/Converters/MathExpressionConverter/MultiMathExpressionConverter.shared.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ public class MultiMathExpressionConverter : MultiValueConverterExtension, ICommu
2828
throw new ArgumentException("The parameter should be of type String.");
2929
}
3030

31-
return values is null
32-
? null
31+
return values is null
32+
? null
3333
: new MathExpression(expression, values).CalculateResult();
3434
}
3535

0 commit comments

Comments
 (0)