Skip to content

Commit

Permalink
Adding proper net461 and net47 targets
Browse files Browse the repository at this point in the history
  • Loading branch information
Leszek-Kowalski committed Nov 8, 2019
1 parent 2e329b0 commit 3526673
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Nemesis.TextParsers/CollectionMeta.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public IReadOnlyCollection<TDestElem> CreateCollectionGeneric<TDestElem>(IList s
{
ISet<TDestElem> result = Kind == CollectionKind.HashSet
? (ISet<TDestElem>)new HashSet<TDestElem>(
#if NETSTANDARD2_0
#if NETSTANDARD2_0 || NETFRAMEWORK

#else
count
Expand Down
2 changes: 1 addition & 1 deletion Nemesis.TextParsers/Legacy/Number.NumberBuffer.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#if NETSTANDARD2_0
#if NETSTANDARD2_0 || NETFRAMEWORK

using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
Expand Down
2 changes: 1 addition & 1 deletion Nemesis.TextParsers/Legacy/Number.Parsing.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#if NETSTANDARD2_0
#if NETSTANDARD2_0 || NETFRAMEWORK

using System;
using System.Diagnostics;
Expand Down
2 changes: 1 addition & 1 deletion Nemesis.TextParsers/Legacy/Number.Small.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// See the LICENSE file in the project root for more information.


#if NETSTANDARD2_0
#if NETSTANDARD2_0 || NETFRAMEWORK

using System;
using System.Diagnostics.CodeAnalysis;
Expand Down
16 changes: 10 additions & 6 deletions Nemesis.TextParsers/Nemesis.TextParsers.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<!--<Nullable>enable</Nullable>-->

<TargetFrameworks>netcoreapp3.0;netcoreapp2.2;netstandard2.1;netstandard2.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.0;netcoreapp2.2;netstandard2.1;netstandard2.0;net461;net47</TargetFrameworks>


<PackageTags>split stringSplit tokenize token parse format list dictionary TextConverter ReadOnlySpan Span Memory fast allocation noAllocation</PackageTags>
Expand Down Expand Up @@ -41,15 +41,19 @@

<!--Legacy on-->
<PropertyGroup>
<AllowUnsafeBlocks Condition=" '$(TargetFramework)' == 'netstandard2.0' ">true</AllowUnsafeBlocks>
<AllowUnsafeBlocks Condition=" '$(TargetFramework)' == 'netstandard2.0' OR '$(TargetFramework)' == 'net461' OR '$(TargetFramework)' == 'net47' ">true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="System.Memory" Version="4.5.3" />
</ItemGroup>

<!--<PropertyGroup Condition="'$(TargetFramework)'=='netstandard2.0' Or '$(TargetFramework)'=='netstandard2.1'">
<DefineConstants>$(DefineConstants);NETSTANDARD</DefineConstants>
</PropertyGroup>-->
<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="System.Memory" Version="4.5.3" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net47'">
<PackageReference Include="System.Memory" Version="4.5.3" />
</ItemGroup>

<!--Legacy off-->


Expand Down
16 changes: 8 additions & 8 deletions Nemesis.TextParsers/Numbers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public sealed class ByteNumber : INumber<byte>


public bool TryParse(in ReadOnlySpan<char> input, out byte value) =>
#if NETSTANDARD2_0
#if NETSTANDARD2_0 || NETFRAMEWORK
Legacy.ByteParser.TryParse(input, NumberStyles.Integer, Culture.InvCult, out value);
#else
byte.TryParse(input, NumberStyles.Integer, Culture.InvCult, out value);
Expand Down Expand Up @@ -121,7 +121,7 @@ public sealed class SByteNumber : INumber<sbyte>
public sbyte Div(sbyte left, sbyte right) => (sbyte)(left / right);

public bool TryParse(in ReadOnlySpan<char> input, out sbyte value) =>
#if NETSTANDARD2_0
#if NETSTANDARD2_0 || NETFRAMEWORK
Legacy.SByteParser.TryParse(input, NumberStyles.Integer, Culture.InvCult, out value);
#else
sbyte.TryParse(input, NumberStyles.Integer, Culture.InvCult, out value);
Expand Down Expand Up @@ -153,7 +153,7 @@ public sealed class Int16Number : INumber<short>
public short Div(short left, short right) => (short)(left / right);

public bool TryParse(in ReadOnlySpan<char> input, out short value) =>
#if NETSTANDARD2_0
#if NETSTANDARD2_0 || NETFRAMEWORK
Legacy.Int16Parser.TryParse(input, NumberStyles.Integer, Culture.InvCult, out value);
#else
short.TryParse(input, NumberStyles.Integer, Culture.InvCult, out value);
Expand Down Expand Up @@ -185,7 +185,7 @@ public sealed class UInt16Number : INumber<ushort>
public ushort Div(ushort left, ushort right) => (ushort)(left / right);

public bool TryParse(in ReadOnlySpan<char> input, out ushort value) =>
#if NETSTANDARD2_0
#if NETSTANDARD2_0 || NETFRAMEWORK
Legacy.UInt16Parser.TryParse(input, NumberStyles.Integer, Culture.InvCult, out value);
#else
ushort.TryParse(input, NumberStyles.Integer, Culture.InvCult, out value);
Expand Down Expand Up @@ -218,7 +218,7 @@ public sealed class Int32Number : INumber<int>


public bool TryParse(in ReadOnlySpan<char> input, out int value) =>
#if NETSTANDARD2_0
#if NETSTANDARD2_0 || NETFRAMEWORK
Legacy.Number.TryParseInt32(input, NumberStyles.Integer, Culture.InvInfo, out value);
#else
int.TryParse(input, NumberStyles.Integer, Culture.InvCult, out value);
Expand Down Expand Up @@ -250,7 +250,7 @@ public sealed class UInt32Number : INumber<uint>
public uint Div(uint left, uint right) => left / right;

public bool TryParse(in ReadOnlySpan<char> input, out uint value) =>
#if NETSTANDARD2_0
#if NETSTANDARD2_0 || NETFRAMEWORK
Legacy.Number.TryParseUInt32(input, NumberStyles.Integer, Culture.InvInfo, out value);
#else
uint.TryParse(input, NumberStyles.Integer, Culture.InvCult, out value);
Expand Down Expand Up @@ -282,7 +282,7 @@ public sealed class Int64Number : INumber<long>
public long Div(long left, long right) => left / right;

public bool TryParse(in ReadOnlySpan<char> input, out long value) =>
#if NETSTANDARD2_0
#if NETSTANDARD2_0 || NETFRAMEWORK
Legacy.Number.TryParseInt64(input, NumberStyles.Integer, Culture.InvInfo, out value);
#else
long.TryParse(input, NumberStyles.Integer, Culture.InvCult, out value);
Expand Down Expand Up @@ -314,7 +314,7 @@ public sealed class UInt64Number : INumber<ulong>
public ulong Div(ulong left, ulong right) => left / right;

public bool TryParse(in ReadOnlySpan<char> input, out ulong value) =>
#if NETSTANDARD2_0
#if NETSTANDARD2_0 || NETFRAMEWORK
Legacy.Number.TryParseUInt64(input, NumberStyles.Integer, Culture.InvInfo, out value);
#else
ulong.TryParse(input, NumberStyles.Integer, Culture.InvCult, out value);
Expand Down
36 changes: 18 additions & 18 deletions Nemesis.TextParsers/Parsers_03_SimpleTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public sealed class StringParser : SimpleTransformer<string>
[UsedImplicitly]
public sealed class BooleanParser : SimpleTransformer<bool>
{
#if NETSTANDARD2_0
#if NETSTANDARD2_0 || NETFRAMEWORK
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
internal static bool EqualsOrdinalIgnoreCase(ReadOnlySpan<char> span, ReadOnlySpan<char> value)
{
Expand Down Expand Up @@ -159,7 +159,7 @@ public override bool Parse(ReadOnlySpan<char> input)
try
{
return
#if NETSTANDARD2_0
#if NETSTANDARD2_0 || NETFRAMEWORK || NETFRAMEWORK
ParseBool(input);
#else
bool.Parse(input);
Expand All @@ -186,7 +186,7 @@ public sealed override string Format(TElement element) =>
public sealed class ByteParser : SimpleFormattableTransformer<byte>
{
public override byte Parse(ReadOnlySpan<char> input) =>
#if NETSTANDARD2_0
#if NETSTANDARD2_0 || NETFRAMEWORK
Legacy.ByteParser.Parse(input, NumberStyles.Integer, Culture.InvCult);
#else
byte.Parse(input, NumberStyles.Integer, Culture.InvCult);
Expand All @@ -197,7 +197,7 @@ public override byte Parse(ReadOnlySpan<char> input) =>
public sealed class SByteParser : SimpleFormattableTransformer<sbyte>
{
public override sbyte Parse(ReadOnlySpan<char> input) =>
#if NETSTANDARD2_0
#if NETSTANDARD2_0 || NETFRAMEWORK
Legacy.SByteParser.Parse(input, NumberStyles.Integer, Culture.InvCult);
#else
sbyte.Parse(input, NumberStyles.Integer, Culture.InvCult);
Expand All @@ -208,7 +208,7 @@ public override sbyte Parse(ReadOnlySpan<char> input) =>
public sealed class Int16Parser : SimpleFormattableTransformer<short>
{
public override short Parse(ReadOnlySpan<char> input) =>
#if NETSTANDARD2_0
#if NETSTANDARD2_0 || NETFRAMEWORK
Legacy.Int16Parser.Parse(input, NumberStyles.Integer, Culture.InvCult);
#else
short.Parse(input, NumberStyles.Integer, Culture.InvCult);
Expand All @@ -220,7 +220,7 @@ public override short Parse(ReadOnlySpan<char> input) =>
public sealed class UInt16Parser : SimpleFormattableTransformer<ushort>
{
public override ushort Parse(ReadOnlySpan<char> input) =>
#if NETSTANDARD2_0
#if NETSTANDARD2_0 || NETFRAMEWORK
Legacy.UInt16Parser.Parse(input, NumberStyles.Integer, Culture.InvCult);
#else
ushort.Parse(input, NumberStyles.Integer, Culture.InvCult);
Expand All @@ -231,7 +231,7 @@ public override ushort Parse(ReadOnlySpan<char> input) =>
public sealed class Int32Parser : SimpleFormattableTransformer<int>
{
public override int Parse(ReadOnlySpan<char> input) =>
#if NETSTANDARD2_0
#if NETSTANDARD2_0 || NETFRAMEWORK
Legacy.Number.ParseInt32(input, NumberStyles.Integer, Culture.InvInfo);
#else
int.Parse(input, NumberStyles.Integer, Culture.InvCult);
Expand All @@ -242,7 +242,7 @@ public override int Parse(ReadOnlySpan<char> input) =>
public sealed class UInt32Parser : SimpleFormattableTransformer<uint>
{
public override uint Parse(ReadOnlySpan<char> input) =>
#if NETSTANDARD2_0
#if NETSTANDARD2_0 || NETFRAMEWORK
Legacy.Number.ParseUInt32(input, NumberStyles.Integer, Culture.InvInfo);
#else
uint.Parse(input, NumberStyles.Integer, Culture.InvCult);
Expand All @@ -253,7 +253,7 @@ public override uint Parse(ReadOnlySpan<char> input) =>
public sealed class Int64Parser : SimpleFormattableTransformer<long>
{
public override long Parse(ReadOnlySpan<char> input) =>
#if NETSTANDARD2_0
#if NETSTANDARD2_0 || NETFRAMEWORK
Legacy.Number.ParseInt64(input, NumberStyles.Integer, Culture.InvInfo);
#else
long.Parse(input, NumberStyles.Integer, Culture.InvCult);
Expand All @@ -264,7 +264,7 @@ public override long Parse(ReadOnlySpan<char> input) =>
public sealed class UInt64Parser : SimpleFormattableTransformer<ulong>
{
public override ulong Parse(ReadOnlySpan<char> input) =>
#if NETSTANDARD2_0
#if NETSTANDARD2_0 || NETFRAMEWORK
Legacy.Number.ParseUInt64(input, NumberStyles.Integer, Culture.InvInfo);
#else
ulong.Parse(input, NumberStyles.Integer, Culture.InvCult);
Expand All @@ -280,7 +280,7 @@ public override float Parse(ReadOnlySpan<char> input)
else if (input.Length == 2 && input[0] == '-' && input[1] == '∞') return float.NegativeInfinity;
else
return float.Parse(
#if NETSTANDARD2_0
#if NETSTANDARD2_0 || NETFRAMEWORK
input.ToString()
#else
input
Expand All @@ -300,7 +300,7 @@ public override double Parse(ReadOnlySpan<char> input)
else if (input.Length == 2 && input[0] == '-' && input[1] == '∞') return double.NegativeInfinity;
else
return double.Parse(
#if NETSTANDARD2_0
#if NETSTANDARD2_0 || NETFRAMEWORK
input.ToString()
#else
input
Expand All @@ -316,7 +316,7 @@ public sealed class DecimalParser : SimpleFormattableTransformer<decimal>
{
public override decimal Parse(ReadOnlySpan<char> input) =>
decimal.Parse(
#if NETSTANDARD2_0
#if NETSTANDARD2_0 || NETFRAMEWORK
input.ToString()
#else
input
Expand All @@ -329,7 +329,7 @@ public sealed class TimeSpanParser : SimpleFormattableTransformer<TimeSpan>
{
public override TimeSpan Parse(ReadOnlySpan<char> input) =>
TimeSpan.Parse(
#if NETSTANDARD2_0
#if NETSTANDARD2_0 || NETFRAMEWORK
input.ToString()
#else
input
Expand All @@ -342,7 +342,7 @@ public sealed class DateTimeParser : SimpleFormattableTransformer<DateTime>
{
public override DateTime Parse(ReadOnlySpan<char> input) =>
DateTime.Parse(
#if NETSTANDARD2_0
#if NETSTANDARD2_0 || NETFRAMEWORK
input.ToString()
#else
input
Expand All @@ -357,7 +357,7 @@ public sealed class DateTimeOffsetParser : SimpleFormattableTransformer<DateTime
{
public override DateTimeOffset Parse(ReadOnlySpan<char> input) =>
DateTimeOffset.Parse(
#if NETSTANDARD2_0
#if NETSTANDARD2_0 || NETFRAMEWORK
input.ToString()
#else
input
Expand All @@ -371,7 +371,7 @@ public override DateTimeOffset Parse(ReadOnlySpan<char> input) =>
public sealed class GuidParser : SimpleFormattableTransformer<Guid>
{
public override Guid Parse(ReadOnlySpan<char> input) => Guid.Parse(
#if NETSTANDARD2_0
#if NETSTANDARD2_0 || NETFRAMEWORK
input.ToString()
#else
input
Expand All @@ -385,7 +385,7 @@ public override Guid Parse(ReadOnlySpan<char> input) => Guid.Parse(
public sealed class BigIntegerParser : SimpleFormattableTransformer<BigInteger>
{
public override BigInteger Parse(ReadOnlySpan<char> input) => BigInteger.Parse(
#if NETSTANDARD2_0
#if NETSTANDARD2_0 || NETFRAMEWORK
input.ToString()
#else
input
Expand Down
2 changes: 1 addition & 1 deletion Nemesis.TextParsers/Parsers_03b_Tuple.cs
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ public static void FormatElement<TElement>(IFormatter<TElement> formatter, TElem

public bool CanHandle(Type type) =>
type.IsValueType && type.IsGenericType && !type.IsGenericTypeDefinition &&
#if NETSTANDARD2_0
#if NETSTANDARD2_0 || NETFRAMEWORK
type.Namespace == "System" &&
type.Name.StartsWith("ValueTuple`") &&
typeof(ValueType).IsAssignableFrom(type) &&
Expand Down
2 changes: 1 addition & 1 deletion Nemesis.TextParsers/SpanParserHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static IReadOnlyCollection<TTo> ToCollection<TTo>(this in ParsedSequence<
{
ISet<TTo> result = kind == CollectionKind.HashSet
? (ISet<TTo>)new HashSet<TTo>(
#if NETSTANDARD2_0
#if NETSTANDARD2_0 || NETFRAMEWORK

#else
capacity
Expand Down

0 comments on commit 3526673

Please sign in to comment.