Skip to content

Commit

Permalink
Reorganize namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalBrylka committed Mar 16, 2020
1 parent 552e3fb commit e2319ca
Show file tree
Hide file tree
Showing 31 changed files with 49 additions and 34 deletions.
1 change: 1 addition & 0 deletions Benchmarks/EnumBench.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using EnumsNET;
using Nemesis.TextParsers;
using Nemesis.TextParsers.Parsers;
using Nemesis.TextParsers.Utils;

// ReSharper disable CommentTypo

Expand Down
2 changes: 1 addition & 1 deletion Benchmarks/LeanCollectionBench.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using BenchmarkDotNet.Attributes;
using Nemesis.TextParsers;
using Nemesis.TextParsers.Utils;

// ReSharper disable CommentTypo

Expand Down
2 changes: 1 addition & 1 deletion Benchmarks/StringConcatBench.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Text;
using BenchmarkDotNet.Attributes;
using Nemesis.TextParsers;
using Nemesis.TextParsers.Utils;

// ReSharper disable CommentTypo

Expand Down
1 change: 1 addition & 0 deletions Nemesis.TextParsers.Tests/AggressionBased.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Nemesis.TextParsers.Parsers;
using Nemesis.TextParsers.Utils;
#if NETCOREAPP3_0
using NotNull = System.Diagnostics.CodeAnalysis.NotNullAttribute;
#else
Expand Down
1 change: 1 addition & 0 deletions Nemesis.TextParsers.Tests/CollectionTransformerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Reflection;
using System.Runtime.Serialization;
using Nemesis.TextParsers.Parsers;
using Nemesis.TextParsers.Utils;

namespace Nemesis.TextParsers.Tests
{
Expand Down
1 change: 1 addition & 0 deletions Nemesis.TextParsers.Tests/EnumTransformerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Text;
using NUnit.Framework;
using Nemesis.TextParsers.Parsers;
using Nemesis.TextParsers.Utils;

namespace Nemesis.TextParsers.Tests
{
Expand Down
1 change: 1 addition & 0 deletions Nemesis.TextParsers.Tests/LeanCollectionTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Nemesis.TextParsers.Utils;
using NUnit.Framework;

namespace Nemesis.TextParsers.Tests
Expand Down
1 change: 1 addition & 0 deletions Nemesis.TextParsers.Tests/LinqTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Globalization;
using System.Text;
using Nemesis.TextParsers.Utils;
using NUnit.Framework;

namespace Nemesis.TextParsers.Tests
Expand Down
1 change: 1 addition & 0 deletions Nemesis.TextParsers.Tests/NumberTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Globalization;
using Nemesis.TextParsers.Utils;
using NUnit.Framework;

namespace Nemesis.TextParsers.Tests
Expand Down
1 change: 1 addition & 0 deletions Nemesis.TextParsers.Tests/SpanCollectionSerializerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using NUnit.Framework;
using Dss = System.Collections.Generic.SortedDictionary<string, string>;
using Nemesis.TextParsers.Parsers;
using Nemesis.TextParsers.Utils;

namespace Nemesis.TextParsers.Tests
{
Expand Down
1 change: 1 addition & 0 deletions Nemesis.TextParsers.Tests/TestClasses.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Runtime.CompilerServices;
using JetBrains.Annotations;
using Nemesis.TextParsers.Parsers;
using Nemesis.TextParsers.Utils;

namespace Nemesis.TextParsers.Tests
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Globalization;
using NUnit.Framework;
using JetBrains.Annotations;
using Nemesis.TextParsers.Utils;

namespace Nemesis.TextParsers.Tests
{
Expand Down
2 changes: 1 addition & 1 deletion Nemesis.TextParsers/01_Contracts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using JetBrains.Annotations;
using Nemesis.TextParsers.Runtime;

namespace Nemesis.TextParsers.Parsers
namespace Nemesis.TextParsers
{
public interface ITransformer
{
Expand Down
2 changes: 1 addition & 1 deletion Nemesis.TextParsers/02_EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using JetBrains.Annotations;
using Nemesis.TextParsers.Runtime;

namespace Nemesis.TextParsers.Parsers
namespace Nemesis.TextParsers
{
public interface ITransformerStore
{
Expand Down
2 changes: 1 addition & 1 deletion Nemesis.TextParsers/ParsedSequence.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.Runtime.CompilerServices;
using Nemesis.TextParsers.Parsers;
using Nemesis.TextParsers.Utils;

namespace Nemesis.TextParsers
{
Expand Down
5 changes: 5 additions & 0 deletions Nemesis.TextParsers/Parsers/03_SimpleTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public ITransformer<TSimpleType> CreateTransformer<TSimpleType>() =>
public sbyte Priority => 10;
}

internal static class Culture
{
internal static CultureInfo InvCult => CultureInfo.InvariantCulture;
internal static NumberFormatInfo InvInfo = NumberFormatInfo.InvariantInfo;
}

public abstract class SimpleTransformer<TElement> : TransformerBase<TElement>, ICanTransformType
{
Expand Down
1 change: 1 addition & 0 deletions Nemesis.TextParsers/Parsers/03a_KeyValuePair.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Runtime.CompilerServices;
using JetBrains.Annotations;
using Nemesis.TextParsers.Runtime;
using Nemesis.TextParsers.Utils;

namespace Nemesis.TextParsers.Parsers
{
Expand Down
1 change: 1 addition & 0 deletions Nemesis.TextParsers/Parsers/03b_ValueTuple.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Runtime.CompilerServices;
using JetBrains.Annotations;
using Nemesis.TextParsers.Runtime;
using Nemesis.TextParsers.Utils;

namespace Nemesis.TextParsers.Parsers
{
Expand Down
1 change: 1 addition & 0 deletions Nemesis.TextParsers/Parsers/05_Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using JetBrains.Annotations;
using Nemesis.TextParsers.Utils;
#if NETCOREAPP3_0
using NotNull = System.Diagnostics.CodeAnalysis.NotNullAttribute;
#else
Expand Down
1 change: 1 addition & 0 deletions Nemesis.TextParsers/Parsers/07_Dictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using JetBrains.Annotations;
using Nemesis.TextParsers.Runtime;
using Nemesis.TextParsers.Utils;

namespace Nemesis.TextParsers.Parsers
{
Expand Down
1 change: 1 addition & 0 deletions Nemesis.TextParsers/Parsers/09_Collection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using JetBrains.Annotations;
using Nemesis.TextParsers.Runtime;
using Nemesis.TextParsers.Utils;

namespace Nemesis.TextParsers.Parsers
{
Expand Down
1 change: 1 addition & 0 deletions Nemesis.TextParsers/Parsers/09a_LeanCollection.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using JetBrains.Annotations;
using Nemesis.TextParsers.Runtime;
using Nemesis.TextParsers.Utils;

namespace Nemesis.TextParsers.Parsers
{
Expand Down
4 changes: 3 additions & 1 deletion Nemesis.TextParsers/SpanCollectionSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.CompilerServices;
using Nemesis.TextParsers.Parsers;
using JetBrains.Annotations;
using Nemesis.TextParsers.Utils;
using PureMethod = System.Diagnostics.Contracts.PureAttribute;

namespace Nemesis.TextParsers
{
[PublicAPI]
public sealed class SpanCollectionSerializer
{
#region Fields and properties
Expand Down
1 change: 1 addition & 0 deletions Nemesis.TextParsers/SpanParserHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Collections.ObjectModel;
using System.Globalization;
using Nemesis.TextParsers.Runtime;
using Nemesis.TextParsers.Utils;
using PureMethod = System.Diagnostics.Contracts.PureAttribute;

namespace Nemesis.TextParsers
Expand Down
4 changes: 2 additions & 2 deletions Nemesis.TextParsers/Utils/CollectionMeta.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Reflection;
using JetBrains.Annotations;
using Nemesis.TextParsers.Runtime;

namespace Nemesis.TextParsers
namespace Nemesis.TextParsers.Utils
{
/// <summary>
/// Aids in providing metadata for GUI applications
Expand Down
4 changes: 2 additions & 2 deletions Nemesis.TextParsers/Utils/DictionaryMeta.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using JetBrains.Annotations;
using Nemesis.TextParsers.Runtime;

namespace Nemesis.TextParsers
namespace Nemesis.TextParsers.Utils
{
/// <summary>
/// Aids in providing metadata for GUI applications
Expand Down Expand Up @@ -130,7 +130,7 @@ internal static class DictionaryKindHelper
public static DictionaryMeta GetDictionaryMeta(Type dictType)
{
if (IsTypeSupported(dictType) &&
GetDictionaryKind(dictType) is DictionaryKind kind &&
GetDictionaryKind(dictType) is { } kind &&
kind != DictionaryKind.Unknown
)
{
Expand Down
28 changes: 10 additions & 18 deletions Nemesis.TextParsers/Utils/LeanCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,23 @@
using System.Collections.Generic;
using JetBrains.Annotations;

namespace Nemesis.TextParsers
namespace Nemesis.TextParsers.Utils
{
[PublicAPI]
public static class LeanCollectionFactory
{
public static LeanCollection<T> FromArrayChecked<T>(T[] items) => new LeanCollection<T>(items);

public static LeanCollection<T> FromArray<T>(T[] items)
{
int? length = items?.Length;
switch (length)
public static LeanCollection<T> FromArray<T>(T[] items) =>
items?.Length switch
{
case null:
case 0:
return new LeanCollection<T>();
case 1:
return new LeanCollection<T>(items[0]);
case 2:
return new LeanCollection<T>(items[0], items[1]);
case 3:
return new LeanCollection<T>(items[0], items[1], items[2]);
default:
return new LeanCollection<T>(items);
}
}
null => new LeanCollection<T>(),
0 => new LeanCollection<T>(),
1 => new LeanCollection<T>(items[0]),
2 => new LeanCollection<T>(items[0], items[1]),
3 => new LeanCollection<T>(items[0], items[1], items[2]),
_ => new LeanCollection<T>(items)
};

public static LeanCollection<T> ToLeanCollection<T>(T one) => new LeanCollection<T>(one);
public static LeanCollection<T> ToLeanCollection<T>((T, T) pair) => new LeanCollection<T>(pair.Item1, pair.Item2);
Expand Down
2 changes: 1 addition & 1 deletion Nemesis.TextParsers/Utils/LightLinq.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using JetBrains.Annotations;

namespace Nemesis.TextParsers
namespace Nemesis.TextParsers.Utils
{
[PublicAPI]
public static class LightLinq
Expand Down
2 changes: 1 addition & 1 deletion Nemesis.TextParsers/Utils/Numbers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Linq;
using JetBrains.Annotations;

namespace Nemesis.TextParsers
namespace Nemesis.TextParsers.Utils
{
public static class NumberHandlerCache
{
Expand Down
5 changes: 2 additions & 3 deletions Nemesis.TextParsers/Utils/UniversalTextTypeConverter.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using System;
using System.ComponentModel;
using System.Globalization;
using Nemesis.TextParsers.Parsers;

namespace Nemesis.TextParsers
namespace Nemesis.TextParsers.Utils
{
public sealed class UniversalTextTypeConverter<TValue> : TypeConverter
{
Expand All @@ -24,4 +23,4 @@ public override object ConvertTo(ITypeDescriptorContext context, CultureInfo cul
? TextTransformer.Default.GetTransformer<TValue>().Format((TValue)value)
: base.ConvertTo(context, culture, value, destinationType);
}
}
}
2 changes: 1 addition & 1 deletion Nemesis.TextParsers/Utils/ValueSequenceBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Buffers;
using System.Runtime.CompilerServices;

namespace Nemesis.TextParsers
namespace Nemesis.TextParsers.Utils
{
public ref struct ValueSequenceBuilder<T>
{
Expand Down

0 comments on commit e2319ca

Please sign in to comment.