Skip to content

Commit 20a9175

Browse files
committed
Cleanups
1 parent 11c7bd8 commit 20a9175

File tree

2 files changed

+17
-52
lines changed

2 files changed

+17
-52
lines changed

src/Components/Endpoints/test/Binding/FormDataDeserializerTests.cs renamed to src/Components/Endpoints/test/Binding/FormDataMapperTests.cs

Lines changed: 13 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
using System.Diagnostics.CodeAnalysis;
55
using System.Globalization;
66
using Microsoft.Extensions.Primitives;
7-
using Newtonsoft.Json.Linq;
87

98
namespace Microsoft.AspNetCore.Components.Endpoints.Binding;
109

11-
public class FormDataDeserializerTests
10+
public class FormDataMapperTests
1211
{
1312
[Theory]
1413
[MemberData(nameof(PrimitiveTypesData))]
@@ -286,35 +285,18 @@ public static bool TryParse([NotNullWhen(true)] string s, IFormatProvider provid
286285
}
287286
}
288287

289-
public override bool Equals(object obj)
290-
{
291-
return Equals(obj as Point);
292-
}
288+
public override bool Equals(object obj) => Equals(obj as Point);
293289

294-
public bool Equals(Point other)
295-
{
296-
return other is not null &&
297-
X == other.X &&
298-
Y == other.Y;
299-
}
290+
public bool Equals(Point other) => other is not null && X == other.X && Y == other.Y;
300291

301-
public override int GetHashCode()
302-
{
303-
return HashCode.Combine(X, Y);
304-
}
292+
public override int GetHashCode() => HashCode.Combine(X, Y);
305293

306-
public static bool operator ==(Point left, Point right)
307-
{
308-
return EqualityComparer<Point>.Default.Equals(left, right);
309-
}
294+
public static bool operator ==(Point left, Point right) => EqualityComparer<Point>.Default.Equals(left, right);
310295

311-
public static bool operator !=(Point left, Point right)
312-
{
313-
return !(left == right);
314-
}
296+
public static bool operator !=(Point left, Point right) => !(left == right);
315297
}
316298

317-
internal class ValuePoint : IParsable<ValuePoint>, IEquatable<ValuePoint>
299+
internal struct ValuePoint : IParsable<ValuePoint>, IEquatable<ValuePoint>
318300
{
319301
public int X { get; set; }
320302
public int Y { get; set; }
@@ -345,35 +327,18 @@ public static bool TryParse([NotNullWhen(true)] string s, IFormatProvider provid
345327
}
346328
catch (FormatException)
347329
{
348-
result = null;
330+
result = default;
349331
return false;
350332
}
351333
}
352334

353-
public override bool Equals(object obj)
354-
{
355-
return Equals(obj as ValuePoint);
356-
}
335+
public override bool Equals(object obj) => Equals((ValuePoint)obj);
357336

358-
public bool Equals(ValuePoint other)
359-
{
360-
return other is not null &&
361-
X == other.X &&
362-
Y == other.Y;
363-
}
337+
public bool Equals(ValuePoint other) => X == other.X && Y == other.Y;
364338

365-
public override int GetHashCode()
366-
{
367-
return HashCode.Combine(X, Y);
368-
}
339+
public override int GetHashCode() => HashCode.Combine(X, Y);
369340

370-
public static bool operator ==(ValuePoint left, ValuePoint right)
371-
{
372-
return EqualityComparer<ValuePoint>.Default.Equals(left, right);
373-
}
341+
public static bool operator ==(ValuePoint left, ValuePoint right) => EqualityComparer<ValuePoint>.Default.Equals(left, right);
374342

375-
public static bool operator !=(ValuePoint left, ValuePoint right)
376-
{
377-
return !(left == right);
378-
}
343+
public static bool operator !=(ValuePoint left, ValuePoint right) => !(left == right);
379344
}

src/Components/Samples/BlazorUnitedApp/Pages/Index.razor

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
<PageTitle>Index</PageTitle>
44

5-
<h1>Your said @(Parameter?.ToString() ?? "(null)")</h1>
5+
<h1>@Parameter</h1>
66

7-
<EditForm method="POST" Model="@(Parameter ?? 0)">
8-
<input name="value" @bind-value="@Parameter" />
7+
<EditForm method="POST" Model="Parameter">
8+
<InputText @bind-Value="Parameter" />
99
<input type="submit" value="Send" />
1010
</EditForm>
1111

@@ -15,7 +15,7 @@
1515
}
1616

1717
@code{
18-
[SupplyParameterFromForm] int? Parameter { get; set; } = 18;
18+
[SupplyParameterFromForm] string Parameter { get; set; } = "Hello, world!";
1919

2020
bool _submitted = false;
2121
public void Submit()

0 commit comments

Comments
 (0)