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 Jul 16, 2021
1 parent fddf7a3 commit efa978a
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 104 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: 1 addition & 3 deletions FlatFiles/DataTableExtensions.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.Linq;

Expand Down Expand Up @@ -71,4 +70,3 @@ public static void WriteFlatFile(this DataTable table, IWriter writer)
}
}
}
#endif
13 changes: 1 addition & 12 deletions FlatFiles/FlatFileDataReader.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#if NET451 || NETSTANDARD2_0 || NETCOREAPP


using System;
using System.Data;
using System.Data.Common;
Expand Down Expand Up @@ -235,11 +234,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 @@ -271,11 +266,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(buffer, fieldoffset, buffer, bufferoffset, length);
#else
Array.Copy(buffer, (int)fieldoffset, buffer, bufferoffset, length);
#endif
return Math.Min(chars.Length - fieldoffset, length);
}

Expand Down Expand Up @@ -600,5 +591,3 @@ private object[] GetValues()
}
}
}

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

namespace FlatFiles
namespace FlatFiles
{
/// <summary>
/// Holds configuration settings for the FlatFileDataReader class.
Expand All @@ -26,5 +24,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 @@ -25,14 +25,14 @@
<PackageIcon>icon.png</PackageIcon>
</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 @@ -41,24 +41,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 @@ -77,27 +65,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
17 changes: 0 additions & 17 deletions FlatFiles/TypeMapping/FixedLengthTypeMapper.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Threading.Tasks;
Expand Down Expand Up @@ -470,15 +469,13 @@ public interface IFixedLengthTypeMapper<TEntity> : IFixedLengthTypeConfiguration
/// <returns>The entities that are extracted from the file.</returns>
IEnumerable<TEntity> Read(TextReader reader, FixedLengthOptions options = null);

#if !NET451 && !NETSTANDARD1_6 && !NETSTANDARD2_0
/// <summary>
/// Reads the entities from the given reader.
/// </summary>
/// <param name="reader">A reader over the fixed-length document.</param>
/// <param name="options">The options controlling how the fixed-length document is read.</param>
/// <returns>An asynchronous enumerable over the entities.</returns>
IAsyncEnumerable<TEntity> ReadAsync(TextReader reader, FixedLengthOptions options = null);
#endif

/// <summary>
/// Gets a typed reader to read entities from the underlying document.
Expand All @@ -504,15 +501,13 @@ public interface IFixedLengthTypeMapper<TEntity> : IFixedLengthTypeConfiguration
/// <param name="options">The options controlling how the separated value document is written.</param>
Task WriteAsync(TextWriter writer, IEnumerable<TEntity> entities, FixedLengthOptions options = null);

#if !NET451 && !NETSTANDARD1_6 && !NETSTANDARD2_0
/// <summary>
/// Writes the given entities to the given writer.
/// </summary>
/// <param name="writer">A writer over the fixed-length document.</param>
/// <param name="entities">The entities to write to the document.</param>
/// <param name="options">The options controlling how the separated value document is written.</param>
Task WriteAsync(TextWriter writer, IAsyncEnumerable<TEntity> entities, FixedLengthOptions options = null);
#endif

/// <summary>
/// Gets a typed writer to write entities to the underlying document.
Expand Down Expand Up @@ -770,15 +765,13 @@ public interface IDynamicFixedLengthTypeMapper : IDynamicFixedLengthTypeConfigur
/// <returns>The entities that are extracted from the file.</returns>
IEnumerable<object> Read(TextReader reader, FixedLengthOptions options = null);

#if !NET451 && !NETSTANDARD1_6 && !NETSTANDARD2_0
/// <summary>
/// Reads the entities from the given reader.
/// </summary>
/// <param name="reader">A reader over the fixed-length document.</param>
/// <param name="options">The options controlling how the fixed-length document is read.</param>
/// <returns>An asynchronous enumerable over the entities.</returns>
IAsyncEnumerable<object> ReadAsync(TextReader reader, FixedLengthOptions options = null);
#endif

/// <summary>
/// Gets a typed reader to read entities from the underlying document.
Expand All @@ -804,15 +797,13 @@ public interface IDynamicFixedLengthTypeMapper : IDynamicFixedLengthTypeConfigur
/// <param name="options">The options used to format the output.</param>
Task WriteAsync(TextWriter writer, IEnumerable<object> entities, FixedLengthOptions options = null);

#if !NET451 && !NETSTANDARD1_6 && !NETSTANDARD2_0
/// <summary>
/// Writes the given entities to the given stream.
/// </summary>
/// <param name="writer">A writer over the separated value document.</param>
/// <param name="entities">The entities to write to the stream.</param>
/// <param name="options">The options used to format the output.</param>
Task WriteAsync(TextWriter writer, IAsyncEnumerable<object> entities, FixedLengthOptions options = null);
#endif

/// <summary>
/// Gets a typed writer to write entities to the underlying document.
Expand Down Expand Up @@ -1369,13 +1360,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 @@ -1410,7 +1399,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 @@ -1420,7 +1408,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 @@ -1629,14 +1616,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 @@ -1657,14 +1642,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
Loading

0 comments on commit efa978a

Please sign in to comment.