Skip to content

Commit

Permalink
Updates for .NET 5.0 (#168)
Browse files Browse the repository at this point in the history
* Update to .NET 5.0

* Updated package references

* Some code styling
  • Loading branch information
gfoidl authored Apr 10, 2021
1 parent 2c801fd commit ba46a9d
Show file tree
Hide file tree
Showing 32 changed files with 76 additions and 196 deletions.
2 changes: 1 addition & 1 deletion .azure/pipelines/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ variables:
CI_BUILD_NUMBER: $(Build.BuildId)
BRANCH_NAME: $(Build.SourceBranchName)
TAG_NAME: $(Build.SourceBranchName)
SDK_VERSION: 3.x
#SDK_VERSION: 3.x

trigger:
- master
Expand Down
2 changes: 1 addition & 1 deletion .azure/pipelines/fuzz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ variables:
CI_BUILD_NUMBER: $(Build.BuildId)
BRANCH_NAME: $(Build.SourceBranchName)
TAG_NAME: $(Build.SourceBranchName)
SDK_VERSION: 3.x
#SDK_VERSION: 3.x

trigger:
branches:
Expand Down
4 changes: 2 additions & 2 deletions .azure/pipelines/jobs/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
release-build:
BUILD_CONFIG: Release
steps:
# .NET Core 3 SDK is pre-installed
# .NET 5.0 SDK is pre-installed
#- task: UseDotNet@2
# displayName: 'Use dotnet sdk 3.x'
# displayName: 'Use dotnet sdk 5.x'
# inputs:
# version: $(SDK_VERSION)
# includePreviewVersions: true
Expand Down
4 changes: 2 additions & 2 deletions .azure/pipelines/jobs/build_and_test_intrinsics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
SSE_disabled:
COMPlus_EnableSSE: 0
steps:
# .NET Core 3 SDK is pre-installed
# .NET 5.0 SDK is pre-installed
#- task: UseDotNet@2
# displayName: 'Use dotnet sdk 3.x'
# displayName: 'Use dotnet sdk 5.x'
# inputs:
# version: $(SDK_VERSION)
# includePreviewVersions: true
Expand Down
4 changes: 2 additions & 2 deletions .azure/pipelines/jobs/demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ jobs:
pool:
vmImage: ${{ parameters.vmImage }}
steps:
# .NET Core 3 SDK is pre-installed
# .NET 5.0 SDK is pre-installed
#- task: UseDotNet@2
# displayName: 'Use dotnet sdk 3.x'
# displayName: 'Use dotnet sdk 5.x'
# inputs:
# version: $(SDK_VERSION)
# includePreviewVersions: true
Expand Down
4 changes: 2 additions & 2 deletions .azure/pipelines/jobs/fuzzing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
SSE_disabled:
COMPlus_EnableSSE: 0
steps:
# .NET Core 3 SDK is pre-installed
# .NET 5.0 SDK is pre-installed
#- task: UseDotNet@2
# displayName: 'Use dotnet sdk 3.x'
# displayName: 'Use dotnet sdk 5.x'
# inputs:
# version: $(SDK_VERSION)
# includePreviewVersions: true
Expand Down
37 changes: 0 additions & 37 deletions .github/workflows/automerge.yml

This file was deleted.

8 changes: 4 additions & 4 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<Authors>gfoidl</Authors>
<Company>Foidl Günther</Company>
<Product>Base64</Product>
<Copyright>Copyright © Foidl Günther 2018-2020</Copyright>
<Copyright>Copyright © Foidl Günther 2018-2021</Copyright>
<VersionPrefix>$(VersionMajor).$(VersionMinor).$(VersionPatch)</VersionPrefix>
<AssemblyVersion>$(VersionMajor).$(VersionMinor).$(BuildNumber).$(VersionPatch)</AssemblyVersion>
</PropertyGroup>
Expand All @@ -20,11 +20,11 @@
</PropertyGroup>

<PropertyGroup>
<LangVersion>latest</LangVersion>
<StandardTfms>netcoreapp3.0;netstandard2.1;netstandard2.0</StandardTfms>
<LangVersion>9</LangVersion>
<StandardTfms>net5.0;netstandard2.1;netstandard2.0</StandardTfms>
<StandardTfms Condition="'$(OS)' == 'Windows_NT'">$(StandardTfms);net45</StandardTfms>

<ExeTfm>netcoreapp3.1</ExeTfm>
<ExeTfm>net5.0</ExeTfm>
</PropertyGroup>

<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion demo/gfoidl.Base64.Demo/gfoidl.Base64.Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="System.IO.Pipelines" Version="4.6.0" />
<PackageReference Include="System.IO.Pipelines" Version="5.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
26 changes: 11 additions & 15 deletions demo/gfoidl.Base64.WebDemo/Program.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
using System.Threading.Tasks;
using gfoidl.Base64.WebDemo;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;

namespace gfoidl.Base64.WebDemo
{
public static class Program
{
public static Task Main(string[] args) => CreateHostBuilder(args).Build().RunAsync();
//---------------------------------------------------------------------
public static IHostBuilder CreateHostBuilder(string[] args)
=> Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}
await CreateHostBuilder(args)
.Build()
.RunAsync();

static IHostBuilder CreateHostBuilder(string[] args)
=> Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
5 changes: 1 addition & 4 deletions demo/gfoidl.Base64.WebDemo/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)

app.UseEndpoints(endpoints =>
{
endpoints.MapGet("/", async context =>
{
await context.Response.WriteAsync("POST data");
});
endpoints.MapGet("/", async context => await context.Response.WriteAsync("POST data"));

endpoints.MapPost("/", async context =>
{
Expand Down
2 changes: 1 addition & 1 deletion demo/gfoidl.Base64.WebDemo/gfoidl.Base64.WebDemo.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
3 changes: 1 addition & 2 deletions fuzz/gfoidl.Base64.FuzzTests/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ static void Main(string[] args)
Environment.Exit(2);
throw null;
}

}
//---------------------------------------------------------------------
private static void Base64_Default_Decode(Stream stream) => Base64_Decode(stream, Base64.Default);
Expand All @@ -50,7 +49,7 @@ private static void Base64_Decode(Stream stream, Base64 encoder)

while (true)
{
ReadResult readResult = pipeReader.ReadAsync().GetAwaiter().GetResult();
ReadResult readResult = pipeReader.ReadAsync().AsTask().GetAwaiter().GetResult();

if (readResult.IsCompleted || readResult.IsCanceled)
break;
Expand Down
6 changes: 3 additions & 3 deletions fuzz/gfoidl.Base64.FuzzTests/gfoidl.Base64.FuzzTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="SharpFuzz" Version="1.6.1" />
<PackageReference Include="Sigil" Version="4.7.0" />
<PackageReference Include="System.IO.Pipelines" Version="4.6.0" />
<PackageReference Include="SharpFuzz" Version="1.6.2" />
<PackageReference Include="Sigil" Version="5.0.0" />
<PackageReference Include="System.IO.Pipelines" Version="5.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
10 changes: 1 addition & 9 deletions gfoidl.Base64.sln
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{CD033330-6EDE-4E8E-976C-5CB7C58217E8}"
ProjectSection(SolutionItems) = preProject
.github\CODEOWNERS = .github\CODEOWNERS
.github\FUNDING.yml = .github\FUNDING.yml
.github\pull_request_template.md = .github\pull_request_template.md
EndProjectSection
EndProject
Expand All @@ -92,13 +93,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{6920
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "gfoidl.Base64.WebDemo", "demo\gfoidl.Base64.WebDemo\gfoidl.Base64.WebDemo.csproj", "{66E1E4B6-BD9B-40FF-85A9-070B0D497E59}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{BD59807B-C788-497A-9E78-BFD789BB7639}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{F8CF9ED3-55C6-4C71-87B1-2BF860B1A9C9}"
ProjectSection(SolutionItems) = preProject
.github\workflows\automerge.yml = .github\workflows\automerge.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "api-doc", "api-doc", "{B064262E-B0CE-464E-922D-3A7563A49FB6}"
ProjectSection(SolutionItems) = preProject
api-doc\.gitignore = api-doc\.gitignore
Expand Down Expand Up @@ -181,8 +175,6 @@ Global
{3F0FD9C1-1B52-4BC6-9BD8-8FD3B0162E88} = {CD033330-6EDE-4E8E-976C-5CB7C58217E8}
{692006B6-CD1B-4A91-97C5-0A98C25EAD23} = {89ADD037-F9FC-4ADE-99B8-D89307057409}
{66E1E4B6-BD9B-40FF-85A9-070B0D497E59} = {A52BCD9C-4216-42E5-AB37-FD5F6C46A9E7}
{BD59807B-C788-497A-9E78-BFD789BB7639} = {E4259BCE-EA4C-434C-8896-CEBBEC38222D}
{F8CF9ED3-55C6-4C71-87B1-2BF860B1A9C9} = {BD59807B-C788-497A-9E78-BFD789BB7639}
{B064262E-B0CE-464E-922D-3A7563A49FB6} = {403238BD-BE8A-4E78-924A-C841CD8C7955}
{C83936D6-A39A-49F3-A386-71376149E1C8} = {B064262E-B0CE-464E-922D-3A7563A49FB6}
{6830EE14-70FC-4DDA-8370-4E3EE7A1076E} = {B064262E-B0CE-464E-922D-3A7563A49FB6}
Expand Down
3 changes: 0 additions & 3 deletions perf/gfoidl.Base64.Benchmarks/FodyWeavers.xml

This file was deleted.

34 changes: 0 additions & 34 deletions perf/gfoidl.Base64.Benchmarks/FodyWeavers.xsd

This file was deleted.

17 changes: 6 additions & 11 deletions perf/gfoidl.Base64.Benchmarks/Program.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using BenchmarkDotNet.Running;
using gfoidl.Base64;

namespace gfoidl.Base64.Benchmarks
{
static class Program
{
static void Main(string[] args)
{
SimdInfo.PrintSimdInfo(Console.Out);
[module: SkipLocalsInit]

BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);
}
}
}
SimdInfo.PrintSimdInfo(Console.Out);
BenchmarkSwitcher.FromAssembly(Assembly.GetExecutingAssembly()).Run(args);
9 changes: 2 additions & 7 deletions perf/gfoidl.Base64.Benchmarks/gfoidl.Base64.Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.12.0" />
<PackageReference Include="Fody" Version="6.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="LocalsInit.Fody" Version="1.1.0" />
<PackageReference Include="System.IO.Pipelines" Version="4.6.0" />
<PackageReference Include="BenchmarkDotNet" Version="0.12.1" />
<PackageReference Include="System.IO.Pipelines" Version="5.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion source/SimdInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public static class SimdInfo
{
public static void PrintSimdInfo(TextWriter writer)
{
string separator = new string('-', 20);
string separator = new('-', 20);

writer.WriteLine(separator);
#if NETCOREAPP
Expand Down
4 changes: 2 additions & 2 deletions source/gfoidl.Base64/Base64.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public abstract class Base64 : IBase64
/// </remarks>
public const int MaximumEncodeLength = int.MaxValue / 4 * 3; // 1610612733
//---------------------------------------------------------------------
private static readonly Base64Encoder s_default = new Base64Encoder();
private static readonly Base64UrlEncoder s_url = new Base64UrlEncoder();
private static readonly Base64Encoder s_default = new();
private static readonly Base64UrlEncoder s_url = new();
//---------------------------------------------------------------------
#pragma warning disable RCS1085 // Use auto-implemented property.
#pragma warning disable PUB0001 // Pubternal type in public API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ private static void EncodeMultiSegment(
long totalWritten = 0;
bool isFinalSegment;

Span<byte> tmpBuffer = stackalloc byte[3];

do
{
isFinalSegment = data.IsSingleSegment;
Expand All @@ -104,7 +106,6 @@ private static void EncodeMultiSegment(
{
Debug.Assert(!isFinalSegment);

Span<byte> tmpBuffer = stackalloc byte[3];
firstSpan[^remainingFromIteration..].CopyTo(tmpBuffer);

int dataNeeded = tmpBuffer.Length - remainingFromIteration;
Expand Down
3 changes: 0 additions & 3 deletions source/gfoidl.Base64/FodyWeavers.xml

This file was deleted.

Loading

0 comments on commit ba46a9d

Please sign in to comment.