Skip to content

Commit d1f8362

Browse files
committed
Cleanups
1 parent fcdc1bf commit d1f8362

11 files changed

+31
-32
lines changed

src/Components/Endpoints/src/Binding/Converters/DictionaryAdapters/DictionaryBufferAdapter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace Microsoft.AspNetCore.Components.Endpoints.Binding;
55

66
// Uses a concrete type that implements IDictionary<TKey, TValue> as a buffer.
7-
internal class DictionaryBufferAdapter<TDictionaryType, TKey, TValue>
7+
internal sealed class DictionaryBufferAdapter<TDictionaryType, TKey, TValue>
88
: IDictionaryBufferAdapter<TDictionaryType, TDictionaryType, TKey, TValue>
99
where TDictionaryType : IDictionary<TKey, TValue>, new()
1010
where TKey : IParsable<TKey>

src/Components/Endpoints/src/Binding/Converters/DictionaryAdapters/DictionaryStaticCastAdapter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace Microsoft.AspNetCore.Components.Endpoints.Binding;
55

66
// Adapts a concrete dictionary type into an interface.
7-
internal class DictionaryStaticCastAdapter<TDictionaryInterface, TDictionaryImplementation, TDictionaryAdapter, TBuffer, TKey, TValue>
7+
internal sealed class DictionaryStaticCastAdapter<TDictionaryInterface, TDictionaryImplementation, TDictionaryAdapter, TBuffer, TKey, TValue>
88
: IDictionaryBufferAdapter<TDictionaryInterface, TBuffer, TKey, TValue>
99
where TDictionaryAdapter : IDictionaryBufferAdapter<TDictionaryImplementation, TBuffer, TKey, TValue>
1010
where TDictionaryImplementation : TDictionaryInterface

src/Components/Endpoints/src/Binding/Converters/DictionaryAdapters/ImmutableDictionaryBufferAdapter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System.Collections.Immutable;
55

66
namespace Microsoft.AspNetCore.Components.Endpoints.Binding;
77

8-
internal class ImmutableDictionaryBufferAdapter<TKey, TValue>
8+
internal sealed class ImmutableDictionaryBufferAdapter<TKey, TValue>
99
: IDictionaryBufferAdapter<ImmutableDictionary<TKey, TValue>, ImmutableDictionary<TKey, TValue>.Builder, TKey, TValue>
1010
where TKey : IParsable<TKey>
1111
{

src/Components/Endpoints/src/Binding/Converters/DictionaryAdapters/ImmutableSortedDictionaryBufferAdapter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System.Collections.Immutable;
55

66
namespace Microsoft.AspNetCore.Components.Endpoints.Binding;
77

8-
internal class ImmutableSortedDictionaryBufferAdapter<TKey, TValue>
8+
internal sealed class ImmutableSortedDictionaryBufferAdapter<TKey, TValue>
99
: IDictionaryBufferAdapter<ImmutableSortedDictionary<TKey, TValue>, ImmutableSortedDictionary<TKey, TValue>.Builder, TKey, TValue>
1010
where TKey : IParsable<TKey>
1111
{

src/Components/Endpoints/src/Binding/Converters/DictionaryAdapters/ReadOnlyDictionaryBufferAdapter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System.Collections.ObjectModel;
55

66
namespace Microsoft.AspNetCore.Components.Endpoints.Binding;
77

8-
internal class ReadOnlyDictionaryBufferAdapter<TKey, TValue>
8+
internal sealed class ReadOnlyDictionaryBufferAdapter<TKey, TValue>
99
: IDictionaryBufferAdapter<ReadOnlyDictionary<TKey, TValue>, Dictionary<TKey, TValue>, TKey, TValue>
1010
where TKey : IParsable<TKey>
1111
{

src/Components/Endpoints/src/Binding/Converters/DictionaryConverter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ internal abstract class DictionaryConverter<TDictionary> : FormDataConverter<TDi
99
{
1010
}
1111

12-
internal class DictionaryConverter<TDictionary, TDictionaryPolicy, TBuffer, TKey, TValue> : DictionaryConverter<TDictionary>
12+
internal sealed class DictionaryConverter<TDictionary, TDictionaryPolicy, TBuffer, TKey, TValue> : DictionaryConverter<TDictionary>
1313
where TKey : IParsable<TKey>
1414
where TDictionaryPolicy : IDictionaryBufferAdapter<TDictionary, TBuffer, TKey, TValue>
1515
{
@@ -25,7 +25,7 @@ public DictionaryConverter(FormDataConverter<TValue> elementConverter)
2525
internal override bool TryRead(
2626
ref FormDataReader context,
2727
Type type,
28-
FormDataSerializerOptions options,
28+
FormDataMapperOptions options,
2929
[NotNullWhen(true)] out TDictionary? result,
3030
out bool found)
3131
{

src/Components/Endpoints/src/Binding/Factories/Collections/ConcreteTypeCollectionConverterFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ internal class ConcreteTypeCollectionConverterFactory<TCollection, TElement>
99
public static readonly ConcreteTypeCollectionConverterFactory<TCollection, TElement> Instance =
1010
new();
1111

12-
public bool CanConvert(Type _, FormDataSerializerOptions options) => true;
12+
public bool CanConvert(Type _, FormDataMapperOptions options) => true;
1313

14-
public FormDataConverter CreateConverter(Type _, FormDataSerializerOptions options)
14+
public FormDataConverter CreateConverter(Type _, FormDataMapperOptions options)
1515
{
1616
// Resolve the element type converter
1717
var elementTypeConverter = options.ResolveConverter<TElement>() ??

src/Components/Endpoints/src/Binding/Factories/Dictionary/ConcreteTypeDictionaryConverterFactory.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
namespace Microsoft.AspNetCore.Components.Endpoints.Binding;
55

6-
internal class ConcreteTypeDictionaryConverterFactory<TDictionary, TKey, TValue> : IFormDataConverterFactory
6+
internal sealed class ConcreteTypeDictionaryConverterFactory<TDictionary, TKey, TValue> : IFormDataConverterFactory
77
where TKey : IParsable<TKey>
88
{
99
public static readonly ConcreteTypeDictionaryConverterFactory<TDictionary, TKey, TValue> Instance = new();
1010

11-
public bool CanConvert(Type type, FormDataSerializerOptions options) => true;
11+
public bool CanConvert(Type type, FormDataMapperOptions options) => true;
1212

13-
public FormDataConverter CreateConverter(Type type, FormDataSerializerOptions options)
13+
public FormDataConverter CreateConverter(Type type, FormDataMapperOptions options)
1414
{
1515
// Resolve the element type converter
1616
var keyConverter = options.ResolveConverter<TKey>() ??

src/Components/Endpoints/src/Binding/Factories/Dictionary/TypedDictionaryConverterFactory.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77

88
namespace Microsoft.AspNetCore.Components.Endpoints.Binding;
99

10-
internal class TypedDictionaryConverterFactory<TDictionaryType, TKey, TValue> : IFormDataConverterFactory
10+
internal sealed class TypedDictionaryConverterFactory<TDictionaryType, TKey, TValue> : IFormDataConverterFactory
1111
where TKey : IParsable<TKey>
1212
{
13-
public bool CanConvert(Type type, FormDataSerializerOptions options)
13+
public bool CanConvert(Type type, FormDataMapperOptions options)
1414
{
1515
// Resolve the value type converter
1616
var valueTypeConverter = options.ResolveConverter<TValue>();
@@ -70,7 +70,7 @@ var _ when type.IsAssignableTo(typeof(IDictionary<TKey, TValue>)) && type.GetCon
7070
return false;
7171
}
7272

73-
public FormDataConverter CreateConverter(Type type, FormDataSerializerOptions options)
73+
public FormDataConverter CreateConverter(Type type, FormDataMapperOptions options)
7474
{
7575
// Resolve the value type converter
7676
var valueTypeConverter = options.ResolveConverter<TValue>();

src/Components/Endpoints/src/Binding/Factories/DictionaryConverterFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ internal class DictionaryConverterFactory : IFormDataConverterFactory
99
{
1010
internal static readonly DictionaryConverterFactory Instance = new();
1111

12-
public bool CanConvert(Type type, FormDataSerializerOptions options)
12+
public bool CanConvert(Type type, FormDataMapperOptions options)
1313
{
1414
// Well-known dictionary types
1515
// IDictionary<TKey, TValue>
@@ -68,7 +68,7 @@ public bool CanConvert(Type type, FormDataSerializerOptions options)
6868
return factory.CanConvert(type, options);
6969
}
7070

71-
public FormDataConverter CreateConverter(Type type, FormDataSerializerOptions options)
71+
public FormDataConverter CreateConverter(Type type, FormDataMapperOptions options)
7272
{
7373
// Type must implement IDictionary<TKey, TValue> IReadOnlyDictionary<TKey, TValue>
7474
// Note that IDictionary doesn't extend IReadOnlyDictionary, hence the need for two checks

src/Components/Endpoints/test/Binding/FormDataMapperTests.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Buffers;
55
using System.Collections;
66
using System.Collections.Concurrent;
7-
using System.Collections.Generic;
87
using System.Collections.Immutable;
98
using System.Collections.ObjectModel;
109
using System.Diagnostics.CodeAnalysis;
@@ -540,10 +539,10 @@ public void CanDeserialize_Dictionary_IImmutableDictionary()
540539
["[9]"] = "19",
541540
};
542541
var reader = new FormDataReader(collection, CultureInfo.InvariantCulture);
543-
var options = new FormDataSerializerOptions();
542+
var options = new FormDataMapperOptions();
544543

545544
// Act
546-
var result = FormDataDeserializer.Deserialize<IImmutableDictionary<int, int>>(reader, options);
545+
var result = FormDataMapper.Map<IImmutableDictionary<int, int>>(reader, options);
547546

548547
// Assert
549548
var dictionary = Assert.IsType<ImmutableDictionary<int, int>>(result);
@@ -594,10 +593,10 @@ public void CanDeserialize_Dictionary_IReadOnlyDictionary()
594593
["[9]"] = "19",
595594
};
596595
var reader = new FormDataReader(collection, CultureInfo.InvariantCulture);
597-
var options = new FormDataSerializerOptions();
596+
var options = new FormDataMapperOptions();
598597

599598
// Act
600-
var result = FormDataDeserializer.Deserialize<IReadOnlyDictionary<int, int>>(reader, options);
599+
var result = FormDataMapper.Map<IReadOnlyDictionary<int, int>>(reader, options);
601600

602601
// Assert
603602
var dictionary = Assert.IsType<ReadOnlyDictionary<int, int>>(result);
@@ -624,10 +623,10 @@ public void CanDeserialize_Dictionary_ReadOnlyDictionary()
624623
["[9]"] = "19",
625624
};
626625
var reader = new FormDataReader(collection, CultureInfo.InvariantCulture);
627-
var options = new FormDataSerializerOptions();
626+
var options = new FormDataMapperOptions();
628627

629628
// Act
630-
var result = FormDataDeserializer.Deserialize<ReadOnlyDictionary<int, int>>(reader, options);
629+
var result = FormDataMapper.Map<ReadOnlyDictionary<int, int>>(reader, options);
631630

632631
// Assert
633632
var dictionary = Assert.IsType<ReadOnlyDictionary<int, int>>(result);
@@ -641,10 +640,10 @@ public void Deserialize_EmptyDictionary_ReturnsNull()
641640
// Arrange
642641
var collection = new Dictionary<string, StringValues>() { };
643642
var reader = new FormDataReader(collection, CultureInfo.InvariantCulture);
644-
var options = new FormDataSerializerOptions();
643+
var options = new FormDataMapperOptions();
645644

646645
// Act
647-
var result = FormDataDeserializer.Deserialize<IReadOnlyDictionary<int, int>>(reader, options);
646+
var result = FormDataMapper.Map<IReadOnlyDictionary<int, int>>(reader, options);
648647

649648
// Assert
650649
Assert.Null(result);
@@ -656,10 +655,10 @@ public void Deserialize_Dictionary_RespectsMaxCollectionSize()
656655
// Arrange
657656
var collection = new Dictionary<string, StringValues>() { };
658657
var reader = new FormDataReader(collection, CultureInfo.InvariantCulture);
659-
var options = new FormDataSerializerOptions();
658+
var options = new FormDataMapperOptions();
660659

661660
// Act
662-
var result = FormDataDeserializer.Deserialize<IReadOnlyDictionary<int, int>>(reader, options);
661+
var result = FormDataMapper.Map<IReadOnlyDictionary<int, int>>(reader, options);
663662

664663
// Assert
665664
Assert.Null(result);
@@ -684,7 +683,7 @@ private void CanDeserialize_Dictionary<TDictionary, TImplementation, TKey, TValu
684683
["[9]"] = "19",
685684
};
686685
var reader = new FormDataReader(collection, CultureInfo.InvariantCulture);
687-
var options = new FormDataSerializerOptions();
686+
var options = new FormDataMapperOptions();
688687

689688
// Act
690689
var result = CallDeserialize(reader, options, typeof(TDictionary));

0 commit comments

Comments
 (0)