Skip to content

Commit

Permalink
Target .NET Framework 4.6.2, .NET Standard 2.0 and 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
silkfire committed Aug 14, 2021
1 parent 26d0919 commit a9377b2
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 84 deletions.
4 changes: 1 addition & 3 deletions FlatFiles/DataRecordExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#if NET451 || NETSTANDARD2_0 || NETCOREAPP
using System;
using System;
using System.Data;
using System.Reflection;

Expand Down Expand Up @@ -1087,4 +1086,3 @@ private static T Get<T>(IDataRecord record, string name, Func<int, T> getter)
}
}
}
#endif
4 changes: 0 additions & 4 deletions FlatFiles/DataTableExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#if NET451 || NETSTANDARD2_0 || NETCOREAPP

using System;
using System.Data;
using System.Linq;
Expand Down Expand Up @@ -77,5 +75,3 @@ public static void WriteFlatFile(this DataTable table, IWriter writer)
}
}
}

#endif
14 changes: 1 addition & 13 deletions FlatFiles/FlatFileDataReader.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#if NET451 || NETSTANDARD2_0 || NETCOREAPP

using System;
using System;
using System.Data;
using System.Data.Common;
using System.Globalization;
Expand Down Expand Up @@ -230,11 +228,7 @@ public long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferoffset, i
{
var values = GetValues();
var bytes = (byte[])values[i]!;
#if NET451
Array.Copy(bytes, fieldOffset, buffer, bufferoffset, length);
#else
Array.Copy(bytes, (int)fieldOffset, buffer, bufferoffset, length);
#endif
return Math.Min(bytes.Length - fieldOffset, length);
}

Expand Down Expand Up @@ -266,11 +260,7 @@ public long GetChars(int i, long fieldoffset, char[] buffer, int bufferoffset, i
}
var values = GetValues();
var chars = (char[])values[i]!;
#if NET451
Array.Copy(chars, fieldoffset, buffer, bufferoffset, length);
#else
Array.Copy(chars, (int)fieldoffset, buffer, bufferoffset, length);
#endif
return Math.Min(chars.Length - fieldoffset, length);
}

Expand Down Expand Up @@ -611,5 +601,3 @@ private ColumnCollection GetColumns(ISchema schema)
}
}
}

#endif
4 changes: 0 additions & 4 deletions FlatFiles/FlatFileDataReaderOptions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#if NET451 || NETSTANDARD2_0 || NETCOREAPP

using System;

namespace FlatFiles
Expand Down Expand Up @@ -28,5 +26,3 @@ public FlatFileDataReaderOptions()
public bool IsNullStringAllowed { get; set; }
}
}

#endif
56 changes: 17 additions & 39 deletions FlatFiles/FlatFiles.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.0;netstandard2.1;netstandard2.0;netstandard1.6;net451</TargetFrameworks>
<TargetFrameworks>net462;netstandard2.0;netstandard2.1</TargetFrameworks>
<NeutralLanguage>en-US</NeutralLanguage>
<Description>Reads and writes CSV, fixed-length and other flat file formats with a focus on schema definition, configuration and speed. Supports mapping directly between files and classes.</Description>
<Copyright>Copyright @ 2021</Copyright>
Expand All @@ -26,14 +26,14 @@
<Nullable>enable</Nullable>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netstandard1.6|AnyCPU'">
<DocumentationFile>bin\Debug\netstandard1.6\FlatFiles.xml</DocumentationFile>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net462|AnyCPU'">
<DocumentationFile>bin\Debug\net462\FlatFiles.xml</DocumentationFile>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netstandard1.6|AnyCPU'">
<DocumentationFile>bin\Release\netstandard1.6\FlatFiles.xml</DocumentationFile>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net462|AnyCPU'">
<DocumentationFile>bin\Release\net462\FlatFiles.xml</DocumentationFile>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netstandard2.0|AnyCPU'">
<DocumentationFile>bin\Debug\netstandard2.0\FlatFiles.xml</DocumentationFile>
</PropertyGroup>
Expand All @@ -42,24 +42,12 @@
<DocumentationFile>bin\Release\netstandard2.0\FlatFiles.xml</DocumentationFile>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netstandard2.1|AnyCPU'">
<DocumentationFile>bin\Release\netstandard2.1\FlatFiles.xml</DocumentationFile>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netcoreapp3.0|AnyCPU'">
<DocumentationFile>bin\Debug\netcoreapp3.0\FlatFiles.xml</DocumentationFile>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netcoreapp3.0|AnyCPU'">
<DocumentationFile>bin\Release\netcoreapp3.0\FlatFiles.xml</DocumentationFile>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net451|AnyCPU'">
<DocumentationFile>bin\Debug\net451\FlatFiles.xml</DocumentationFile>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netstandard2.1|AnyCPU'">
<DocumentationFile>bin\Debug\netstandard2.1\FlatFiles.xml</DocumentationFile>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net451|AnyCPU'">
<DocumentationFile>bin\Release\net451\FlatFiles.xml</DocumentationFile>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|netstandard2.1|AnyCPU'">
<DocumentationFile>bin\Release\netstandard2.1\FlatFiles.xml</DocumentationFile>
</PropertyGroup>

<ItemGroup>
Expand All @@ -78,27 +66,17 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.3" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'=='netstandard1.6'">
<PackageReference Include="System.Reflection.Emit" Version="4.3.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'=='netstandard2.0'">
<PackageReference Include="System.Reflection.Emit" Version="4.6.0" />
<PackageReference Include="System.Data.Common" Version="4.3.0" />

</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'=='netstandard2.1'">
<PackageReference Include="System.Reflection.Emit" Version="4.6.0" />
<PackageReference Include="System.Data.Common" Version="4.3.0" />
<ItemGroup Condition="'$(TargetFramework)'=='net462'">
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="5.0.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)'=='netcoreapp3.0'">
<PackageReference Include="System.Reflection.Emit" Version="4.6.0" />
<PackageReference Include="System.Data.Common" Version="4.3.0" />
<ItemGroup Condition="'$(TargetFramework)'=='netstandard2.0'">
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="5.0.0" />
<PackageReference Include="System.Reflection.Emit" Version="4.7.0" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 1 addition & 5 deletions FlatFiles/IFlatFileDataRecord.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#if NET451 || NETSTANDARD2_0 || NETCOREAPP

using System;
using System;
using System.Data;

namespace FlatFiles
Expand Down Expand Up @@ -53,5 +51,3 @@ public interface IFlatFileDataRecord : IDataRecord
ulong GetUInt64(int i);
}
}

#endif
8 changes: 0 additions & 8 deletions FlatFiles/TypeMapping/FixedLengthTypeMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -639,13 +639,11 @@ public IEnumerable<TEntity> Read(TextReader reader, FixedLengthOptions? options
return typedReader.ReadAll();
}

#if !NET451 && !NETSTANDARD1_6 && !NETSTANDARD2_0
public IAsyncEnumerable<TEntity> ReadAsync(TextReader reader, FixedLengthOptions? options = null)
{
var typedReader = GetReader(reader, options);
return typedReader.ReadAllAsync();
}
#endif

public IFixedLengthTypedReader<TEntity> GetReader(TextReader reader, FixedLengthOptions? options = null)
{
Expand Down Expand Up @@ -680,7 +678,6 @@ public Task WriteAsync(TextWriter writer, IEnumerable<TEntity> entities, FixedLe
return typedWriter.WriteAllAsync(entities);
}

#if !NET451 && !NETSTANDARD1_6 && !NETSTANDARD2_0
public Task WriteAsync(TextWriter writer, IAsyncEnumerable<TEntity> entities, FixedLengthOptions? options = null)
{
if (entities == null)
Expand All @@ -690,7 +687,6 @@ public Task WriteAsync(TextWriter writer, IAsyncEnumerable<TEntity> entities, Fi
var typedWriter = GetWriter(writer, options);
return typedWriter.WriteAllAsync(entities);
}
#endif

public ITypedWriter<TEntity> GetWriter(TextWriter writer, FixedLengthOptions? options = null)
{
Expand Down Expand Up @@ -902,14 +898,12 @@ IEnumerable<object> IDynamicFixedLengthTypeMapper.Read(TextReader reader, FixedL
return untypedReader.ReadAll();
}

#if !NET451 && !NETSTANDARD1_6 && !NETSTANDARD2_0
IAsyncEnumerable<object> IDynamicFixedLengthTypeMapper.ReadAsync(TextReader reader, FixedLengthOptions? options)
{
IDynamicFixedLengthTypeMapper untypedMapper = this;
var untypedReader = untypedMapper.GetReader(reader, options);
return untypedReader.ReadAllAsync();
}
#endif

IFixedLengthTypedReader<object> IDynamicFixedLengthTypeMapper.GetReader(TextReader reader, FixedLengthOptions? options)
{
Expand All @@ -930,14 +924,12 @@ Task IDynamicFixedLengthTypeMapper.WriteAsync(TextWriter writer, IEnumerable<obj
return untypedWriter.WriteAllAsync(entities);
}

#if !NET451 && !NETSTANDARD1_6 && !NETSTANDARD2_0
Task IDynamicFixedLengthTypeMapper.WriteAsync(TextWriter writer, IAsyncEnumerable<object> entities, FixedLengthOptions? options)
{
IDynamicFixedLengthTypeMapper untypedMapper = this;
var untypedWriter = untypedMapper.GetWriter(writer, options);
return untypedWriter.WriteAllAsync(entities);
}
#endif

ITypedWriter<object> IDynamicFixedLengthTypeMapper.GetWriter(TextWriter writer, FixedLengthOptions? options)
{
Expand Down
8 changes: 0 additions & 8 deletions FlatFiles/TypeMapping/SeparatedValueTypeMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -839,13 +839,11 @@ public IEnumerable<TEntity> Read(TextReader reader, SeparatedValueOptions? optio
return typedReader.ReadAll();
}

#if !NET451 && !NETSTANDARD1_6 && !NETSTANDARD2_0
public IAsyncEnumerable<TEntity> ReadAsync(TextReader reader, SeparatedValueOptions? options = null)
{
var typedReader = GetReader(reader, options);
return typedReader.ReadAllAsync();
}
#endif

public ISeparatedValueTypedReader<TEntity> GetReader(TextReader reader, SeparatedValueOptions? options = null)
{
Expand Down Expand Up @@ -886,7 +884,6 @@ public Task WriteAsync(TextWriter writer, IEnumerable<TEntity> entities, Separat
return typedWriter.WriteAllAsync(entities);
}

#if !NET451 && !NETSTANDARD1_6 && !NETSTANDARD2_0
public Task WriteAsync(TextWriter writer, IAsyncEnumerable<TEntity> entities, SeparatedValueOptions? options = null)
{
if (entities == null)
Expand All @@ -896,7 +893,6 @@ public Task WriteAsync(TextWriter writer, IAsyncEnumerable<TEntity> entities, Se
var typedWriter = GetWriter(writer, options);
return typedWriter.WriteAllAsync(entities);
}
#endif

public ITypedWriter<TEntity> GetWriter(TextWriter writer, SeparatedValueOptions? options = null)
{
Expand Down Expand Up @@ -1107,14 +1103,12 @@ IEnumerable<object> IDynamicSeparatedValueTypeMapper.Read(TextReader reader, Sep
return untypedReader.ReadAll();
}

#if !NET451 && !NETSTANDARD1_6 && !NETSTANDARD2_0
IAsyncEnumerable<object> IDynamicSeparatedValueTypeMapper.ReadAsync(TextReader reader, SeparatedValueOptions? options)
{
IDynamicSeparatedValueTypeMapper untypedMapper = this;
var untypedReader = untypedMapper.GetReader(reader, options);
return untypedReader.ReadAllAsync();
}
#endif

ISeparatedValueTypedReader<object> IDynamicSeparatedValueTypeMapper.GetReader(TextReader reader, SeparatedValueOptions? options)
{
Expand All @@ -1135,14 +1129,12 @@ Task IDynamicSeparatedValueTypeMapper.WriteAsync(TextWriter writer, IEnumerable<
return untypedWriter.WriteAllAsync(entities);
}

#if !NET451 && !NETSTANDARD1_6 && !NETSTANDARD2_0
Task IDynamicSeparatedValueTypeMapper.WriteAsync(TextWriter writer, IAsyncEnumerable<object> entities, SeparatedValueOptions? options)
{
IDynamicSeparatedValueTypeMapper untypedMapper = this;
var untypedWriter = untypedMapper.GetWriter(writer, options);
return untypedWriter.WriteAllAsync(entities);
}
#endif

ITypedWriter<object> IDynamicSeparatedValueTypeMapper.GetWriter(TextWriter writer, SeparatedValueOptions? options)
{
Expand Down

0 comments on commit a9377b2

Please sign in to comment.