Skip to content

Commit

Permalink
Merge pull request dotnet#32184 from steveharter/FileCleanup
Browse files Browse the repository at this point in the history
System.Text.Json file and converter name clean-up (no functional changes)
  • Loading branch information
steveharter authored Feb 13, 2020
2 parents 48080fa + 640e3a7 commit 0e0e852
Show file tree
Hide file tree
Showing 58 changed files with 263 additions and 270 deletions.
184 changes: 92 additions & 92 deletions src/libraries/System.Text.Json/src/System.Text.Json.csproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ namespace System.Text.Json.Serialization.Converters
/// <summary>
/// Converter for <cref>System.Array</cref>.
/// </summary>
internal sealed class JsonArrayConverter<TCollection, TElement>
: JsonIEnumerableDefaultConverter<TCollection, TElement>
internal sealed class ArrayConverter<TCollection, TElement>
: IEnumerableDefaultConverter<TCollection, TElement>
where TCollection: IEnumerable
{
internal override bool CanHaveIdMetadata => false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

namespace System.Text.Json.Serialization.Converters
{
internal sealed class JsonConcurrentQueueOfTConverter<TCollection, TElement> : JsonIEnumerableDefaultConverter<TCollection, TElement>
internal sealed class ConcurrentQueueOfTConverter<TCollection, TElement>
: IEnumerableDefaultConverter<TCollection, TElement>
where TCollection : ConcurrentQueue<TElement>
{
protected override void Add(TElement value, ref ReadStack state)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

namespace System.Text.Json.Serialization.Converters
{
internal sealed class JsonConcurrentStackOfTConverter<TCollection, TElement> : JsonIEnumerableDefaultConverter<TCollection, TElement>
internal sealed class ConcurrentStackOfTConverter<TCollection, TElement>
: IEnumerableDefaultConverter<TCollection, TElement>
where TCollection : ConcurrentStack<TElement>
{
protected override void Add(TElement value, ref ReadStack state)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace System.Text.Json.Serialization.Converters
/// <summary>
/// Default base class implementation of <cref>JsonDictionaryConverter{TCollection}</cref> .
/// </summary>
internal abstract class JsonDictionaryDefaultConverter<TCollection, TValue>
internal abstract class DictionaryDefaultConverter<TCollection, TValue>
: JsonDictionaryConverter<TCollection>
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ namespace System.Text.Json.Serialization.Converters
/// Converter for Dictionary{string, TValue} that (de)serializes as a JSON object with properties
/// representing the dictionary element key and value.
/// </summary>
internal sealed class JsonDictionaryOfStringTValueConverter<TCollection, TValue>
: JsonDictionaryDefaultConverter<TCollection, TValue>
internal sealed class DictionaryOfStringTValueConverter<TCollection, TValue>
: DictionaryDefaultConverter<TCollection, TValue>
where TCollection : Dictionary<string, TValue>
{
protected override void Add(TValue value, JsonSerializerOptions options, ref ReadStack state)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ namespace System.Text.Json.Serialization.Converters
/// <summary>
/// Converter for <cref>System.Collections.Generic.ICollection{TElement}</cref>.
/// </summary>
internal sealed class JsonICollectionOfTConverter<TCollection, TElement>
: JsonIEnumerableDefaultConverter<TCollection, TElement>
internal sealed class ICollectionOfTConverter<TCollection, TElement>
: IEnumerableDefaultConverter<TCollection, TElement>
where TCollection : ICollection<TElement>
{
protected override void Add(TElement value, ref ReadStack state)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ namespace System.Text.Json.Serialization.Converters
/// Converter for <cref>System.Collections.IDictionary</cref> that (de)serializes as a JSON object with properties
/// representing the dictionary element key and value.
/// </summary>
internal sealed class JsonIDictionaryConverter<TCollection>
: JsonDictionaryDefaultConverter<TCollection, object?>
internal sealed class IDictionaryConverter<TCollection>
: DictionaryDefaultConverter<TCollection, object?>
where TCollection : IDictionary
{
protected override void Add(object? value, JsonSerializerOptions options, ref ReadStack state)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ namespace System.Text.Json.Serialization.Converters
/// Converter for <cref>System.Collections.Generic.IDictionary{string, TValue}</cref> that
/// (de)serializes as a JSON object with properties representing the dictionary element key and value.
/// </summary>
internal sealed class JsonIDictionaryOfStringTValueConverter<TCollection, TValue>
: JsonDictionaryDefaultConverter<TCollection, TValue>
internal sealed class IDictionaryOfStringTValueConverter<TCollection, TValue>
: DictionaryDefaultConverter<TCollection, TValue>
where TCollection : IDictionary<string, TValue>
{
protected override void Add(TValue value, JsonSerializerOptions options, ref ReadStack state)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ namespace System.Text.Json.Serialization.Converters
/// Converter for <cref>System.Collections.IEnumerable</cref>.
/// </summary>
/// <typeparam name="TCollection"></typeparam>
internal sealed class JsonIEnumerableConverter<TCollection>
: JsonIEnumerableDefaultConverter<TCollection, object?>
internal sealed class IEnumerableConverter<TCollection>
: IEnumerableDefaultConverter<TCollection, object?>
where TCollection : IEnumerable
{
protected override void Add(object? value, ref ReadStack state)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,33 @@ namespace System.Text.Json.Serialization.Converters
/// </summary>
internal class JsonIEnumerableConverterFactory : JsonConverterFactory
{
private static readonly JsonIDictionaryConverter<IDictionary> s_converterForIDictionary = new JsonIDictionaryConverter<IDictionary>();
private static readonly JsonIEnumerableConverter<IEnumerable> s_converterForIEnumerable = new JsonIEnumerableConverter<IEnumerable>();
private static readonly JsonIListConverter<IList> s_converterForIList = new JsonIListConverter<IList>();
private static readonly IDictionaryConverter<IDictionary> s_converterForIDictionary = new IDictionaryConverter<IDictionary>();
private static readonly IEnumerableConverter<IEnumerable> s_converterForIEnumerable = new IEnumerableConverter<IEnumerable>();
private static readonly IListConverter<IList> s_converterForIList = new IListConverter<IList>();

public override bool CanConvert(Type typeToConvert)
{
return typeof(IEnumerable).IsAssignableFrom(typeToConvert);
}

[PreserveDependency(".ctor", "System.Text.Json.Serialization.Converters.JsonArrayConverter`2")]
[PreserveDependency(".ctor", "System.Text.Json.Serialization.Converters.JsonConcurrentQueueOfTConverter`2")]
[PreserveDependency(".ctor", "System.Text.Json.Serialization.Converters.JsonConcurrentStackOfTConverter`2")]
[PreserveDependency(".ctor", "System.Text.Json.Serialization.Converters.JsonDefaultArrayConverter`2")]
[PreserveDependency(".ctor", "System.Text.Json.Serialization.Converters.JsonDictionaryOfStringTValueConverter`2")]
[PreserveDependency(".ctor", "System.Text.Json.Serialization.Converters.JsonICollectionOfTConverter`2")]
[PreserveDependency(".ctor", "System.Text.Json.Serialization.Converters.JsonIDictionaryOfStringTValueConverter`2")]
[PreserveDependency(".ctor", "System.Text.Json.Serialization.Converters.JsonIEnumerableOfTConverter`2")]
[PreserveDependency(".ctor", "System.Text.Json.Serialization.Converters.JsonIEnumerableWithAddMethodConverter`1")]
[PreserveDependency(".ctor", "System.Text.Json.Serialization.Converters.JsonIListConverter`1")]
[PreserveDependency(".ctor", "System.Text.Json.Serialization.Converters.JsonIListOfTConverter`2")]
[PreserveDependency(".ctor", "System.Text.Json.Serialization.Converters.JsonImmutableDictionaryOfStringTValueConverter`2")]
[PreserveDependency(".ctor", "System.Text.Json.Serialization.Converters.JsonImmutableEnumerableOfTConverter`2")]
[PreserveDependency(".ctor", "System.Text.Json.Serialization.Converters.JsonIReadOnlyDictionaryOfStringTValueConverter`2")]
[PreserveDependency(".ctor", "System.Text.Json.Serialization.Converters.JsonISetOfTConverter`2")]
[PreserveDependency(".ctor", "System.Text.Json.Serialization.Converters.JsonListOfTConverter`2")]
[PreserveDependency(".ctor", "System.Text.Json.Serialization.Converters.JsonQueueOfTConverter`2")]
[PreserveDependency(".ctor", "System.Text.Json.Serialization.Converters.JsonStackOfTConverter`2")]
[PreserveDependency(".ctor", "System.Text.Json.Serialization.Converters.ArrayConverter`2")]
[PreserveDependency(".ctor", "System.Text.Json.Serialization.Converters.ConcurrentQueueOfTConverter`2")]
[PreserveDependency(".ctor", "System.Text.Json.Serialization.Converters.ConcurrentStackOfTConverter`2")]
[PreserveDependency(".ctor", "System.Text.Json.Serialization.Converters.DefaultArrayConverter`2")]
[PreserveDependency(".ctor", "System.Text.Json.Serialization.Converters.DictionaryOfStringTValueConverter`2")]
[PreserveDependency(".ctor", "System.Text.Json.Serialization.Converters.ICollectionOfTConverter`2")]
[PreserveDependency(".ctor", "System.Text.Json.Serialization.Converters.IDictionaryOfStringTValueConverter`2")]
[PreserveDependency(".ctor", "System.Text.Json.Serialization.Converters.IEnumerableOfTConverter`2")]
[PreserveDependency(".ctor", "System.Text.Json.Serialization.Converters.IEnumerableWithAddMethodConverter`1")]
[PreserveDependency(".ctor", "System.Text.Json.Serialization.Converters.IListConverter`1")]
[PreserveDependency(".ctor", "System.Text.Json.Serialization.Converters.IListOfTConverter`2")]
[PreserveDependency(".ctor", "System.Text.Json.Serialization.Converters.ImmutableDictionaryOfStringTValueConverter`2")]
[PreserveDependency(".ctor", "System.Text.Json.Serialization.Converters.ImmutableEnumerableOfTConverter`2")]
[PreserveDependency(".ctor", "System.Text.Json.Serialization.Converters.IReadOnlyDictionaryOfStringTValueConverter`2")]
[PreserveDependency(".ctor", "System.Text.Json.Serialization.Converters.ISetOfTConverter`2")]
[PreserveDependency(".ctor", "System.Text.Json.Serialization.Converters.ListOfTConverter`2")]
[PreserveDependency(".ctor", "System.Text.Json.Serialization.Converters.QueueOfTConverter`2")]
[PreserveDependency(".ctor", "System.Text.Json.Serialization.Converters.StackOfTConverter`2")]
public override JsonConverter? CreateConverter(Type typeToConvert, JsonSerializerOptions options)
{
JsonConverter? converter = null;
Expand All @@ -60,13 +60,13 @@ public override bool CanConvert(Type typeToConvert)
return null;
}

converterType = typeof(JsonArrayConverter<,>);
converterType = typeof(ArrayConverter<,>);
elementType = typeToConvert.GetElementType();
}
// List<> or deriving from List<>
else if ((actualTypeToConvert = typeToConvert.GetCompatibleGenericBaseClass(typeof(List<>))) != null)
{
converterType = typeof(JsonListOfTConverter<,>);
converterType = typeof(ListOfTConverter<,>);
elementType = actualTypeToConvert.GetGenericArguments()[0];
}
// Dictionary<string,> or deriving from Dictionary<string,>
Expand All @@ -75,7 +75,7 @@ public override bool CanConvert(Type typeToConvert)
genericArgs = actualTypeToConvert.GetGenericArguments();
if (genericArgs[0] == typeof(string))
{
converterType = typeof(JsonDictionaryOfStringTValueConverter<,>);
converterType = typeof(DictionaryOfStringTValueConverter<,>);
elementType = genericArgs[1];
}
else
Expand All @@ -89,7 +89,7 @@ public override bool CanConvert(Type typeToConvert)
genericArgs = typeToConvert.GetGenericArguments();
if (genericArgs[0] == typeof(string))
{
converterType = typeof(JsonImmutableDictionaryOfStringTValueConverter<,>);
converterType = typeof(ImmutableDictionaryOfStringTValueConverter<,>);
elementType = genericArgs[1];
}
else
Expand All @@ -103,7 +103,7 @@ public override bool CanConvert(Type typeToConvert)
genericArgs = actualTypeToConvert.GetGenericArguments();
if (genericArgs[0] == typeof(string))
{
converterType = typeof(JsonIDictionaryOfStringTValueConverter<,>);
converterType = typeof(IDictionaryOfStringTValueConverter<,>);
elementType = genericArgs[1];
}
else
Expand All @@ -117,7 +117,7 @@ public override bool CanConvert(Type typeToConvert)
genericArgs = actualTypeToConvert.GetGenericArguments();
if (genericArgs[0] == typeof(string))
{
converterType = typeof(JsonIReadOnlyDictionaryOfStringTValueConverter<,>);
converterType = typeof(IReadOnlyDictionaryOfStringTValueConverter<,>);
elementType = genericArgs[1];
}
else
Expand All @@ -128,55 +128,55 @@ public override bool CanConvert(Type typeToConvert)
// Immutable non-dictionaries from System.Collections.Immutable, e.g. ImmutableStack<T>
else if (typeToConvert.IsImmutableEnumerableType())
{
converterType = typeof(JsonImmutableEnumerableOfTConverter<,>);
converterType = typeof(ImmutableEnumerableOfTConverter<,>);
elementType = typeToConvert.GetGenericArguments()[0];
}
// IList<>
else if ((actualTypeToConvert = typeToConvert.GetCompatibleGenericInterface(typeof(IList<>))) != null)
{
converterType = typeof(JsonIListOfTConverter<,>);
converterType = typeof(IListOfTConverter<,>);
elementType = actualTypeToConvert.GetGenericArguments()[0];
}
// ISet<>
else if ((actualTypeToConvert = typeToConvert.GetCompatibleGenericInterface(typeof(ISet<>))) != null)
{
converterType = typeof(JsonISetOfTConverter<,>);
converterType = typeof(ISetOfTConverter<,>);
elementType = actualTypeToConvert.GetGenericArguments()[0];
}
// ICollection<>
else if ((actualTypeToConvert = typeToConvert.GetCompatibleGenericInterface(typeof(ICollection<>))) != null)
{
converterType = typeof(JsonICollectionOfTConverter<,>);
converterType = typeof(ICollectionOfTConverter<,>);
elementType = actualTypeToConvert.GetGenericArguments()[0];
}
// Stack<> or deriving from Stack<>
else if ((actualTypeToConvert = typeToConvert.GetCompatibleGenericBaseClass(typeof(Stack<>))) != null)
{
converterType = typeof(JsonStackOfTConverter<,>);
converterType = typeof(StackOfTConverter<,>);
elementType = actualTypeToConvert.GetGenericArguments()[0];
}
// Queue<> or deriving from Queue<>
else if ((actualTypeToConvert = typeToConvert.GetCompatibleGenericBaseClass(typeof(Queue<>))) != null)
{
converterType = typeof(JsonQueueOfTConverter<,>);
converterType = typeof(QueueOfTConverter<,>);
elementType = actualTypeToConvert.GetGenericArguments()[0];
}
// ConcurrentStack<> or deriving from ConcurrentStack<>
else if ((actualTypeToConvert = typeToConvert.GetCompatibleGenericBaseClass(typeof(ConcurrentStack<>))) != null)
{
converterType = typeof(JsonConcurrentStackOfTConverter<,>);
converterType = typeof(ConcurrentStackOfTConverter<,>);
elementType = actualTypeToConvert.GetGenericArguments()[0];
}
// ConcurrentQueue<> or deriving from ConcurrentQueue<>
else if ((actualTypeToConvert = typeToConvert.GetCompatibleGenericBaseClass(typeof(ConcurrentQueue<>))) != null)
{
converterType = typeof(JsonConcurrentQueueOfTConverter<,>);
converterType = typeof(ConcurrentQueueOfTConverter<,>);
elementType = actualTypeToConvert.GetGenericArguments()[0];
}
// IEnumerable<>, types assignable from List<>
else if ((actualTypeToConvert = typeToConvert.GetCompatibleGenericInterface(typeof(IEnumerable<>))) != null)
{
converterType = typeof(JsonIEnumerableOfTConverter<,>);
converterType = typeof(IEnumerableOfTConverter<,>);
elementType = actualTypeToConvert.GetGenericArguments()[0];
}
// Check for non-generics after checking for generics.
Expand All @@ -187,7 +187,7 @@ public override bool CanConvert(Type typeToConvert)
return s_converterForIDictionary;
}

converterType = typeof(JsonIDictionaryConverter<>);
converterType = typeof(IDictionaryConverter<>);
}
else if (typeof(IList).IsAssignableFrom(typeToConvert))
{
Expand All @@ -196,11 +196,11 @@ public override bool CanConvert(Type typeToConvert)
return s_converterForIList;
}

converterType = typeof(JsonIListConverter<>);
converterType = typeof(IListConverter<>);
}
else if (typeToConvert.IsNonGenericStackOrQueue())
{
converterType = typeof(JsonIEnumerableWithAddMethodConverter<>);
converterType = typeof(IEnumerableWithAddMethodConverter<>);
}
else
{
Expand All @@ -210,7 +210,7 @@ public override bool CanConvert(Type typeToConvert)
return s_converterForIEnumerable;
}

converterType = typeof(JsonIEnumerableConverter<>);
converterType = typeof(IEnumerableConverter<>);
}

if (converterType != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Buffers;
using System.Diagnostics;
using System.Reflection;

namespace System.Text.Json.Serialization
{
internal static class ExtensionMethods
internal static class IEnumerableConverterFactoryHelpers
{
private const string ImmutableArrayTypeName = "System.Collections.Immutable.ImmutableArray";
private const string ImmutableArrayGenericTypeName = "System.Collections.Immutable.ImmutableArray`1";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ namespace System.Text.Json.Serialization.Converters
/// <summary>
/// Default base class implementation of <cref>JsonIEnumerableConverter{TCollection, TElement}</cref>.
/// </summary>
internal abstract class JsonIEnumerableDefaultConverter<TCollection, TElement> : JsonCollectionConverter<TCollection, TElement>
internal abstract class IEnumerableDefaultConverter<TCollection, TElement>
: JsonCollectionConverter<TCollection, TElement>
{
protected abstract void Add(TElement value, ref ReadStack state);
protected abstract void CreateCollection(ref ReadStack state, JsonSerializerOptions options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ namespace System.Text.Json.Serialization.Converters
/// <summary>
/// Converter for <cref>System.Collections.Generic.IEnumerable{TElement}</cref>.
/// </summary>
internal sealed class JsonIEnumerableOfTConverter<TCollection, TElement> : JsonIEnumerableDefaultConverter<TCollection, TElement>
internal sealed class IEnumerableOfTConverter<TCollection, TElement>
: IEnumerableDefaultConverter<TCollection, TElement>
where TCollection : IEnumerable<TElement>
{
protected override void Add(TElement value, ref ReadStack state)
Expand Down
Loading

0 comments on commit 0e0e852

Please sign in to comment.