Skip to content

Commit

Permalink
Updated output assemblies and fixed preprocessor directives.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshClose committed Jan 23, 2024
1 parent 7076885 commit 50b8cb5
Show file tree
Hide file tree
Showing 21 changed files with 79 additions and 49 deletions.
11 changes: 10 additions & 1 deletion src/CsvHelper/CsvHelper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<!-- Build -->
<AssemblyName>CsvHelper</AssemblyName>
<TargetFrameworks>net6.0;netstandard2.1;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0;netstandard2.1;netstandard2.0;net48;net47;net462</TargetFrameworks>
<!--<TargetFrameworks>net60</TargetFrameworks>-->
<LangVersion>latest</LangVersion>
<RootNamespace>CsvHelper</RootNamespace>
Expand Down Expand Up @@ -66,6 +66,15 @@
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.2" />
</ItemGroup>

<!-- .NET 4.8 -->
<ItemGroup Condition="'$(TargetFramework)' == 'net48'">
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="1.0.0" />
<PackageReference Include="Microsoft.Bcl.HashCode" Version="1.0.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.3.0" />
<PackageReference Include="System.Memory" Version="4.5.0" />
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.2" />
</ItemGroup>

<!-- .NET Standard 2.0 -->
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="1.0.0" />
Expand Down
5 changes: 5 additions & 0 deletions src/CsvHelper/CsvHelper.net462.v3.ncrunchproject
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<ProjectConfiguration>
<Settings>
<PreventSigningOfAssembly>True</PreventSigningOfAssembly>
</Settings>
</ProjectConfiguration>
5 changes: 5 additions & 0 deletions src/CsvHelper/CsvHelper.net48.v3.ncrunchproject
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<ProjectConfiguration>
<Settings>
<PreventSigningOfAssembly>True</PreventSigningOfAssembly>
</Settings>
</ProjectConfiguration>
5 changes: 5 additions & 0 deletions src/CsvHelper/CsvHelper.net7.0.v3.ncrunchproject
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<ProjectConfiguration>
<Settings>
<PreventSigningOfAssembly>True</PreventSigningOfAssembly>
</Settings>
</ProjectConfiguration>
5 changes: 5 additions & 0 deletions src/CsvHelper/CsvHelper.net8.0.v3.ncrunchproject
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<ProjectConfiguration>
<Settings>
<PreventSigningOfAssembly>True</PreventSigningOfAssembly>
</Settings>
</ProjectConfiguration>
2 changes: 1 addition & 1 deletion src/CsvHelper/CsvReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,7 @@ public virtual IEnumerable<T> EnumerateRecords<T>(T record)
}
}

#if !NET462
#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER
/// <inheritdoc/>
public virtual async IAsyncEnumerable<T> GetRecordsAsync<T>([EnumeratorCancellation] CancellationToken cancellationToken = default(CancellationToken))
{
Expand Down
6 changes: 3 additions & 3 deletions src/CsvHelper/CsvWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ public virtual async Task WriteRecordsAsync<T>(IEnumerable<T> records, Cancellat
}
}

#if !NET462
#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER
/// <inheritdoc/>
public virtual async Task WriteRecordsAsync<T>(IAsyncEnumerable<T> records, CancellationToken cancellationToken = default)
{
Expand Down Expand Up @@ -726,7 +726,7 @@ protected virtual void Dispose(bool disposing)
disposed = true;
}

#if !NET462 && !NET47 && !NETSTANDARD2_0
#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER
/// <inheritdoc/>
public async ValueTask DisposeAsync()
{
Expand Down Expand Up @@ -763,7 +763,7 @@ protected virtual async ValueTask DisposeAsync(bool disposing)
}
#endif

#if !NET462
#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER
private async Task<bool> WriteHeaderAsync<T>(IAsyncEnumerable<T> records)
{
if (!hasHeaderRecord || hasHeaderBeenWritten)
Expand Down
2 changes: 1 addition & 1 deletion src/CsvHelper/EnumerableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace CsvHelper
{
internal static class EnumerableExtensions
{
#if !NET462
#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER
public static async Task<T?> FirstOrDefaultAsync<T>(this IAsyncEnumerable<T> collection)

Check warning on line 13 in src/CsvHelper/EnumerableExtensions.cs

View workflow job for this annotation

GitHub Actions / ci

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
{
await foreach (var o in collection.ConfigureAwait(false))
Expand Down
2 changes: 1 addition & 1 deletion src/CsvHelper/IReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public interface IReader : IReaderRow, IDisposable
/// <returns>An <see cref="IEnumerable{T}"/> of records.</returns>
IEnumerable<T> EnumerateRecords<T>(T record);

#if !NET462
#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER
/// <summary>
/// Gets all the records in the CSV file and
/// converts each to <see cref="Type"/> T. The Read method
Expand Down
4 changes: 2 additions & 2 deletions src/CsvHelper/IWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace CsvHelper
/// Defines methods used to write to a CSV file.
/// </summary>
public interface IWriter : IWriterRow, IDisposable
#if !NET462 && !NET47 && !NETSTANDARD2_0
#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER
, IAsyncDisposable
#endif
{
Expand Down Expand Up @@ -73,7 +73,7 @@ public interface IWriter : IWriterRow, IDisposable
/// <param name="cancellationToken">The cancellation token to stop the writing.</param>
Task WriteRecordsAsync<T>(IEnumerable<T> records, CancellationToken cancellationToken = default);

#if !NET462
#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER
/// <summary>
/// Writes the list of records to the CSV file.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion src/CsvHelper/ObjectCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private static Type[] GetArgTypes(object[] args)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static int GetConstructorCacheKey(Type type, Type[] args)
{
#if !NET462
#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER
var hashCode = new HashCode();
hashCode.Add(type.GetHashCode());
for (var i = 0; i < args.Length; i++)
Expand Down
2 changes: 1 addition & 1 deletion src/CsvHelper/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

[assembly: CLSCompliant(true)]
#if NCRUNCH
[assembly: InternalsVisibleTo("CsvHelper.Tests")]
[assembly: InternalsVisibleTo("CsvHelper.Tests, PublicKeyToken=null")]
#else
[assembly: InternalsVisibleTo("CsvHelper.Tests, PublicKey=00240000048000009400000006020000002400005253413100040000010001000db97564beef98ad18a76ba31f769fab92b14341c9c37ed12f8004bb2a1a7fe42ad829b0e285915a816f05a32325c5e0ba83bd69d8f4d26a0785ccf446749842ad038f7325601a99c59a323dfa7ecf210139159da0aad1822b5d9c9be6d914ecbaa8b8c908c4af798a89b8777010971d81975079a49662ced398c742ff186a94")]
#endif
14 changes: 7 additions & 7 deletions src/CsvHelper/TypeConversion/EnumConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,21 @@ public EnumConverter(Type type)
}
}

#if NET462 || NET47 || NETSTANDARD2_0
try
#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER
if (Enum.TryParse(type, text, ignoreCase, out var value))
{
return Enum.Parse(type, text, ignoreCase);
return value;
}
catch
else
{
return base.ConvertFromString(text, row, memberMapData);
}
#else
if (Enum.TryParse(type, text, ignoreCase, out var value))
try
{
return value;
return Enum.Parse(type, text, ignoreCase);
}
else
catch
{
return base.ConvertFromString(text, row, memberMapData);
}
Expand Down
34 changes: 5 additions & 29 deletions tests/CsvHelper.Tests/CsvHelper.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

<PropertyGroup>
<TargetFrameworks>net8.0;net7.0;net6.0;net48;net47;net462</TargetFrameworks>
<!--<TargetFrameworks>net6.0</TargetFrameworks>-->
<!--<TargetFrameworks>net8.0</TargetFrameworks>-->
<LangVersion>preview</LangVersion>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>CsvHelper.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>

<ItemGroup>
<None Remove="*.ncrunchproject" />
<None Remove="*.ncrunchproject" />
</ItemGroup>

<ItemGroup>
Expand All @@ -28,35 +28,11 @@
</PackageReference>
</ItemGroup>

<!-- .NET 4.6.2 -->
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0" />
<PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.1" />
<PackageReference Include="System.Buffers" Version="4.5.1" />
<PackageReference Include="System.Memory" Version="4.5.4" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>

<!-- .NET 4.7 -->
<ItemGroup Condition="'$(TargetFramework)' == 'net47'">
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0" />
<PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.1" />
<PackageReference Include="System.Buffers" Version="4.5.1" />
<PackageReference Include="System.Memory" Version="4.5.4" />
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
</ItemGroup>

<!-- .NET Standard 2.0 -->
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0" />
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\CsvHelper\CsvHelper.csproj" />
<ItemGroup>
<Content Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<ItemGroup>
<Content Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
<ProjectReference Include="..\..\src\CsvHelper\CsvHelper.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<ProjectConfiguration>
<Settings>
<PreventSigningOfAssembly>True</PreventSigningOfAssembly>
</Settings>
</ProjectConfiguration>
5 changes: 5 additions & 0 deletions tests/CsvHelper.Tests/CsvHelper.Tests.net48.v3.ncrunchproject
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<ProjectConfiguration>
<Settings>
<PreventSigningOfAssembly>True</PreventSigningOfAssembly>
</Settings>
</ProjectConfiguration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<ProjectConfiguration>
<Settings>
<PreventSigningOfAssembly>True</PreventSigningOfAssembly>
</Settings>
</ProjectConfiguration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<ProjectConfiguration>
<Settings>
<PreventSigningOfAssembly>True</PreventSigningOfAssembly>
</Settings>
</ProjectConfiguration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<ProjectConfiguration>
<Settings>
<PreventSigningOfAssembly>True</PreventSigningOfAssembly>
</Settings>
</ProjectConfiguration>
2 changes: 1 addition & 1 deletion tests/CsvHelper.Tests/Reading/YieldTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void EnumerateRecords_Disposed_ThrowsObjectDisposedExceptionTest()
Assert.Throws<ObjectDisposedException>(() => records.ToList());
}

#if !NET462
#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER
[Fact]
public async Task GetRecordsAsyncGeneric_Disposed_ThrowsObjectDisposedExceptionTest()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/CsvHelper.Tests/Writing/IAsyncEnumerableTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// This file is a part of CsvHelper and is dual licensed under MS-PL and Apache 2.0.
// See LICENSE.txt for details or visit http://www.opensource.org/licenses/ms-pl.html for MS-PL and http://opensource.org/licenses/Apache-2.0 for Apache 2.0.
// https://github.com/JoshClose/CsvHelper
#if !NET462
#if NETSTANDARD2_1_OR_GREATER || NET6_0_OR_GREATER
using System;
using System.Collections.Generic;
using System.Globalization;
Expand Down

0 comments on commit 50b8cb5

Please sign in to comment.