Skip to content

Commit

Permalink
Merge pull request #941 from dotnet/dropnet462Support
Browse files Browse the repository at this point in the history
Retarget from net462 to net472
  • Loading branch information
AArnott authored May 11, 2023
2 parents 3f945a8 + 2a7a328 commit 1de484b
Show file tree
Hide file tree
Showing 16 changed files with 33 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public override long Position
set => throw new NotImplementedException();
}

#if NETSTANDARD2_0
#if NETFRAMEWORK
/// <summary>
/// Reads a sequence of bytes from the current <see cref="GitPackDeltafiedStream"/> and advances the position
/// within the stream by the number of bytes read.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public override void Flush()
throw new NotSupportedException();
}

#if NETSTANDARD2_0
#if NETFRAMEWORK
public int Read(Span<byte> buffer)
#else
/// <inheritdoc/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public override int Read(byte[] buffer, int offset, int count)
return this.Read(buffer.AsSpan(offset, count));
}

#if NETSTANDARD2_0
#if NETFRAMEWORK
public int Read(Span<byte> buffer)
#else
/// <inheritdoc/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public override void Flush()
this.stream.Flush();
}

#if !NETSTANDARD2_0
#if NET6_0_OR_GREATER
/// <inheritdoc/>
public override int Read(Span<byte> buffer)
{
Expand Down
4 changes: 2 additions & 2 deletions src/NerdBank.GitVersioning/ManagedGit/GitRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ public void Dispose()

private static string TrimEndingDirectorySeparator(string path)
{
#if NETSTANDARD2_0
#if NETFRAMEWORK
if (string.IsNullOrEmpty(path) || path.Length == 1)
{
return path;
Expand Down Expand Up @@ -699,7 +699,7 @@ private static bool TryConvertHexStringToByteArray(string hexString, Span<byte>
Requires.Argument(data.Length == hexString.Length / 2, nameof(data), "Length must be exactly half that of " + nameof(hexString) + ".");
for (int index = 0; index < data.Length; index++)
{
#if !NETSTANDARD2_0
#if NET6_0_OR_GREATER
ReadOnlySpan<char> byteValue = hexString.AsSpan(index * 2, 2);
if (!byte.TryParse(byteValue, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out data[index]))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public override int Read(byte[] buffer, int offset, int count)
return read;
}

#if !NETSTANDARD2_0
#if NET6_0_OR_GREATER
/// <inheritdoc/>
public override int Read(Span<byte> buffer)
{
Expand Down
2 changes: 1 addition & 1 deletion src/NerdBank.GitVersioning/ManagedGit/StreamExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static int ReadMbsInt(this Stream stream)
return value;
}

#if NETSTANDARD2_0
#if NETFRAMEWORK
/// <summary>
/// Reads a sequence of bytes from the current stream and advances the position within the stream by
/// the number of bytes read.
Expand Down
4 changes: 2 additions & 2 deletions src/NerdBank.GitVersioning/ManagedGit/ZLibStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public override int Read(byte[] array, int offset, int count)
return read;
}

#if !NETSTANDARD2_0
#if NET6_0_OR_GREATER
/// <inheritdoc/>
public override int Read(Span<byte> buffer)
{
Expand All @@ -110,7 +110,7 @@ public override async Task<int> ReadAsync(byte[] array, int offset, int count, C
return read;
}

#if !NETSTANDARD2_0
#if NET6_0_OR_GREATER
/// <inheritdoc/>
public override async ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken cancellationToken = default)
{
Expand Down
2 changes: 1 addition & 1 deletion src/NerdBank.GitVersioning/Nerdbank.GitVersioning.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<DebugType>Full</DebugType>
<IsPackable>false</IsPackable>
Expand Down
8 changes: 4 additions & 4 deletions src/Nerdbank.GitVersioning.Tasks/AssemblyVersionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ the code is regenerated.
------------------------------------------------------------------------------
";

#if NET462
#if NETFRAMEWORK
private static readonly CodeGeneratorOptions CodeGeneratorOptions = new CodeGeneratorOptions
{
BlankLinesBetweenMembers = false,
Expand Down Expand Up @@ -136,7 +136,7 @@ public string BuildCode()
return null;
}

#if NET462
#if NETFRAMEWORK
/// <inheritdoc/>
public override bool Execute()
{
Expand Down Expand Up @@ -186,7 +186,7 @@ public override bool Execute()
}
#endif

#if !NET462
#if !NETFRAMEWORK
/// <inheritdoc/>
public override bool Execute()
{
Expand Down Expand Up @@ -233,7 +233,7 @@ private static byte[] GetPublicKeyFromKeyPair(byte[] keyPair)
}
}

#if NET462
#if NETFRAMEWORK
private static CodeMemberField CreateField<T>(string name, T value)
{
return new CodeMemberField(typeof(T), name)
Expand Down
2 changes: 1 addition & 1 deletion src/Nerdbank.GitVersioning.Tasks/NativeVersionInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private void CreateDefines()
{
if (!int.TryParse(this.AssemblyLanguage, out lcid))
{
#if NET462
#if NETFRAMEWORK
try
{
var cultureInfo = new CultureInfo(this.AssemblyLanguage);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net462;net6.0</TargetFrameworks>
<TargetFrameworks>net472;net6.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

<NuSpecFile>Nerdbank.GitVersioning.nuspec</NuSpecFile>
Expand Down Expand Up @@ -41,16 +41,13 @@
</ItemDefinitionGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Build.Tasks.Core" />
<PackageReference Include="Nerdbank.GitVersioning.LKG" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NerdBank.GitVersioning\Nerdbank.GitVersioning.csproj" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net462' ">
<PackageReference Include="Microsoft.Build.Tasks.Core" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="Microsoft.Build.Tasks.Core" />
<PackageReference Include="System.Runtime.Loader" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Target Name="PackBuildOutputs" DependsOnTargets="SatelliteDllsProjectOutputGroup;DebugSymbolsProjectOutputGroup">
<PropertyGroup>
<BuildSubDir Condition=" '$(TargetFramework)' == 'net6.0' ">MSBuildCore\</BuildSubDir>
<BuildSubDir Condition=" '$(TargetFramework)' == 'net462' ">MSBuildFull\</BuildSubDir>
<BuildSubDir Condition=" '$(TargetFramework)' == 'net472' ">MSBuildFull\</BuildSubDir>
</PropertyGroup>
<Error Text="Unrecognized TargetFramework" Condition=" '$(BuildSubDir)' == '' " />
<ItemGroup>
Expand Down
24 changes: 12 additions & 12 deletions src/Nerdbank.GitVersioning.Tasks/Nerdbank.GitVersioning.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ IMPORTANT: The 3.x release may produce a different version height than prior maj
<repository type="git" url="https://github.com/dotnet/Nerdbank.GitVersioning.git" commit="$commit$" />
</metadata>
<files>
<file src="$BaseOutputPath$net462\LibGit2Sharp.dll" target="build\MSBuildFull\LibGit2Sharp.dll" />
<file src="$BaseOutputPath$net462\LibGit2Sharp.dll.config" target="build\MSBuildFull\LibGit2Sharp.dll.config" />
<file src="$BaseOutputPath$net462\Microsoft.DotNet.PlatformAbstractions.dll" target="build\MSBuildFull\Microsoft.DotNet.PlatformAbstractions.dll" />
<file src="$BaseOutputPath$net462\Nerdbank.GitVersioning.dll" target="build\MSBuildFull\Nerdbank.GitVersioning.dll" />
<file src="$BaseOutputPath$net462\Nerdbank.GitVersioning.Tasks.dll" target="build\MSBuildFull\Nerdbank.GitVersioning.Tasks.dll" />
<file src="$BaseOutputPath$net462\Newtonsoft.Json.dll" target="build\MSBuildFull\Newtonsoft.Json.dll" />
<file src="$BaseOutputPath$net462\System.Buffers.dll" target="build\MSBuildFull\System.Buffers.dll" />
<file src="$BaseOutputPath$net462\System.Memory.dll" target="build\MSBuildFull\System.Memory.dll" />
<file src="$BaseOutputPath$net462\System.Numerics.Vectors.dll" target="build\MSBuildFull\System.Numerics.Vectors.dll" />
<file src="$BaseOutputPath$net462\System.Runtime.CompilerServices.Unsafe.dll" target="build\MSBuildFull\System.Runtime.CompilerServices.Unsafe.dll" />
<file src="$BaseOutputPath$net462\System.Text.Json.dll" target="build\MSBuildFull\System.Text.Json.dll" />
<file src="$BaseOutputPath$net462\Validation.dll" target="build\MSBuildFull\Validation.dll" />
<file src="$BaseOutputPath$net472\LibGit2Sharp.dll" target="build\MSBuildFull\LibGit2Sharp.dll" />
<file src="$BaseOutputPath$net472\LibGit2Sharp.dll.config" target="build\MSBuildFull\LibGit2Sharp.dll.config" />
<file src="$BaseOutputPath$net472\Microsoft.DotNet.PlatformAbstractions.dll" target="build\MSBuildFull\Microsoft.DotNet.PlatformAbstractions.dll" />
<file src="$BaseOutputPath$net472\Nerdbank.GitVersioning.dll" target="build\MSBuildFull\Nerdbank.GitVersioning.dll" />
<file src="$BaseOutputPath$net472\Nerdbank.GitVersioning.Tasks.dll" target="build\MSBuildFull\Nerdbank.GitVersioning.Tasks.dll" />
<file src="$BaseOutputPath$net472\Newtonsoft.Json.dll" target="build\MSBuildFull\Newtonsoft.Json.dll" />
<file src="$BaseOutputPath$net472\System.Buffers.dll" target="build\MSBuildFull\System.Buffers.dll" />
<file src="$BaseOutputPath$net472\System.Memory.dll" target="build\MSBuildFull\System.Memory.dll" />
<file src="$BaseOutputPath$net472\System.Numerics.Vectors.dll" target="build\MSBuildFull\System.Numerics.Vectors.dll" />
<file src="$BaseOutputPath$net472\System.Runtime.CompilerServices.Unsafe.dll" target="build\MSBuildFull\System.Runtime.CompilerServices.Unsafe.dll" />
<file src="$BaseOutputPath$net472\System.Text.Json.dll" target="build\MSBuildFull\System.Text.Json.dll" />
<file src="$BaseOutputPath$net472\Validation.dll" target="build\MSBuildFull\Validation.dll" />
<file src="$LibGit2SharpNativeBinaries$runtimes\**" target="build\runtimes\" />

<!-- Additional copies to work around DllNotFoundException on Mono (https://github.com/dotnet/Nerdbank.GitVersioning/issues/222) -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace Nerdbank.GitVersioning.Benchmarks
{
[SimpleJob(RuntimeMoniker.Net70)]
[SimpleJob(RuntimeMoniker.Net462, baseline: true)]
[SimpleJob(RuntimeMoniker.Net472, baseline: true)]
public class GetVersionBenchmarks
{
// You must manually clone these repositories:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFrameworks>net7.0</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">$(TargetFrameworks);net462</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">$(TargetFrameworks);net472</TargetFrameworks>
<OutputType>Exe</OutputType>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down

0 comments on commit 1de484b

Please sign in to comment.