Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 93fc32e

Browse files
committed
Add new .NET 6 TFM build
1 parent 32bedd7 commit 93fc32e

10 files changed

+30
-18
lines changed

src/ServiceStack.Text/Env.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,14 @@ static Env()
6464
SupportsDynamic = true;
6565
#endif
6666

67-
#if NETCORE2_1
67+
#if NETCORE2_1 || NET6_0
6868
IsNetStandard = false;
6969
IsNetCore = true;
70-
IsNetCore21 = true;
7170
SupportsDynamic = true;
71+
IsNetCore21 = true;
72+
#endif
73+
#if NET6_0
74+
IsNet6 = true;
7275
#endif
7376

7477
#if NETSTANDARD2_0
@@ -136,6 +139,7 @@ static Env()
136139
public static bool IsNetStandard { get; set; }
137140

138141
public static bool IsNetCore21 { get; set; }
142+
public static bool IsNet6 { get; set; }
139143
public static bool IsNetStandard20 { get; set; }
140144

141145
public static bool IsNetFramework { get; set; }
@@ -311,7 +315,7 @@ public static ConfiguredTaskAwaitable ConfigAwait(this Task task) =>
311315
public static ConfiguredTaskAwaitable<T> ConfigAwait<T>(this Task<T> task) =>
312316
task.ConfigureAwait(ContinueOnCapturedContext);
313317

314-
#if NETSTANDARD || NETCORE2_1
318+
#if NETSTANDARD || NETCORE2_1 || NET6_0
315319
[MethodImpl(MethodImplOptions.AggressiveInlining)]
316320
public static ConfiguredValueTaskAwaitable ConfigAwait(this ValueTask task) =>
317321
task.ConfigureAwait(ContinueOnCapturedContext);

src/ServiceStack.Text/LicenseUtils.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ public static bool VerifySignedHash(byte[] DataToVerify, byte[] SignedData, Syst
499499

500500
public static LicenseKey VerifyLicenseKeyText(string licenseKeyText)
501501
{
502-
#if NET45 || NETCORE2_1
502+
#if NET45 || NETCORE2_1 || NET6_0
503503
LicenseKey key;
504504
try
505505
{

src/ServiceStack.Text/MemoryProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace ServiceStack.Text
1212
public abstract class MemoryProvider
1313
{
1414
public static MemoryProvider Instance =
15-
#if NETCORE2_1
15+
#if NETCORE2_1 || NET6_0
1616
ServiceStack.Memory.NetCoreMemory.Provider;
1717
#else
1818
DefaultMemory.Provider;

src/ServiceStack.Text/NetCoreMemory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if NETCORE2_1
1+
#if NETCORE2_1 || NET6_0
22

33
using System;
44
using System.Buffers.Text;
@@ -16,7 +16,7 @@ namespace ServiceStack.Memory
1616
public sealed class NetCoreMemory : MemoryProvider
1717
{
1818
private static NetCoreMemory provider;
19-
public static NetCoreMemory Provider => provider ?? (provider = new NetCoreMemory());
19+
public static NetCoreMemory Provider => provider ??= new NetCoreMemory();
2020
private NetCoreMemory() { }
2121

2222
public static void Configure() => Instance = Provider;

src/ServiceStack.Text/PclExport.NetCore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if NETCORE2_1
1+
#if NETCORE2_1 || NET6_0
22

33
using System;
44
using ServiceStack.Text;

src/ServiceStack.Text/PclExport.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public static class Platforms
2929
public static PclExport Instance
3030
#if NET45
3131
= new Net45PclExport()
32-
#elif NETCORE2_1
32+
#elif NETCORE2_1 || NET6_0
3333
= new NetCorePclExport()
3434
#else
3535
= new NetStandardPclExport()

src/ServiceStack.Text/ReflectionOptimizer.Emit.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if NET45 || NETCORE2_1
1+
#if NET45 || NETCORE2_1 || NET6_0
22

33
using System;
44
using System.Linq;

src/ServiceStack.Text/ReflectionOptimizer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace ServiceStack.Text
88
public abstract class ReflectionOptimizer
99
{
1010
public static ReflectionOptimizer Instance =
11-
#if NET45 || NETCORE2_1
11+
#if NET45 || NETCORE2_1 || NET6_0
1212
EmitReflectionOptimizer.Provider
1313
#else
1414
ExpressionReflectionOptimizer.Provider

src/ServiceStack.Text/ServiceStack.Text.csproj

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<PropertyGroup>
33
<PackageId>ServiceStack.Text</PackageId>
44
<AssemblyName>ServiceStack.Text</AssemblyName>
5-
<TargetFrameworks>net45;netstandard2.0;netcoreapp2.1</TargetFrameworks>
5+
<TargetFrameworks>net45;netstandard2.0;netcoreapp2.1;net6.0</TargetFrameworks>
66
<Title>.NET's fastest JSON Serializer by ServiceStack</Title>
77
<PackageDescription>
88
.NET's fastest JSON, JSV and CSV Text Serializers. Fast, Light, Resilient.
@@ -14,6 +14,9 @@
1414
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.1' ">
1515
<DefineConstants>$(DefineConstants);NETSTANDARD;NETCORE2_1</DefineConstants>
1616
</PropertyGroup>
17+
<PropertyGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
18+
<DefineConstants>$(DefineConstants);NETSTANDARD;NET6_0</DefineConstants>
19+
</PropertyGroup>
1720
<ItemGroup>
1821
<PackageReference Include="System.Memory" Version="4.5.4" />
1922
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
@@ -30,4 +33,9 @@
3033
<PackageReference Include="System.Reflection.Emit" Version="4.7.0" />
3134
<PackageReference Include="System.Reflection.Emit.LightWeight" Version="4.7.0" />
3235
</ItemGroup>
36+
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
37+
<PackageReference Include="System.Runtime" Version="4.3.1" />
38+
<PackageReference Include="System.Reflection.Emit" Version="4.7.0" />
39+
<PackageReference Include="System.Reflection.Emit.LightWeight" Version="4.7.0" />
40+
</ItemGroup>
3341
</Project>

src/ServiceStack.Text/StreamExtensions.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ public static string ReadToEnd(this MemoryStream ms, Encoding encoding)
481481
{
482482
ms.Position = 0;
483483

484-
#if NETSTANDARD || NETCORE2_1
484+
#if NETSTANDARD || NETCORE2_1 || NET6_0
485485
if (ms.TryGetBuffer(out var buffer))
486486
{
487487
return encoding.GetString(buffer.Array, buffer.Offset, buffer.Count);
@@ -504,7 +504,7 @@ public static string ReadToEnd(this MemoryStream ms, Encoding encoding)
504504

505505
public static ReadOnlyMemory<byte> GetBufferAsMemory(this MemoryStream ms)
506506
{
507-
#if NETSTANDARD || NETCORE2_1
507+
#if NETSTANDARD || NETCORE2_1 || NET6_0
508508
if (ms.TryGetBuffer(out var buffer))
509509
{
510510
return new ReadOnlyMemory<byte>(buffer.Array, buffer.Offset, buffer.Count);
@@ -525,7 +525,7 @@ public static ReadOnlyMemory<byte> GetBufferAsMemory(this MemoryStream ms)
525525

526526
public static ReadOnlySpan<byte> GetBufferAsSpan(this MemoryStream ms)
527527
{
528-
#if NETSTANDARD || NETCORE2_1
528+
#if NETSTANDARD || NETCORE2_1 || NET6_0
529529
if (ms.TryGetBuffer(out var buffer))
530530
{
531531
return new ReadOnlySpan<byte>(buffer.Array, buffer.Offset, buffer.Count);
@@ -546,7 +546,7 @@ public static ReadOnlySpan<byte> GetBufferAsSpan(this MemoryStream ms)
546546

547547
public static byte[] GetBufferAsBytes(this MemoryStream ms)
548548
{
549-
#if NETSTANDARD || NETCORE2_1
549+
#if NETSTANDARD || NETCORE2_1 || NET6_0
550550
if (ms.TryGetBuffer(out var buffer))
551551
{
552552
return buffer.Array;
@@ -570,7 +570,7 @@ public static Task<string> ReadToEndAsync(this MemoryStream ms, Encoding encodin
570570
{
571571
ms.Position = 0;
572572

573-
#if NETSTANDARD || NETCORE2_1
573+
#if NETSTANDARD || NETCORE2_1 || NET6_0
574574
if (ms.TryGetBuffer(out var buffer))
575575
{
576576
return encoding.GetString(buffer.Array, buffer.Offset, buffer.Count).InTask();
@@ -626,7 +626,7 @@ public static Task WriteToAsync(this MemoryStream stream, Stream output, Cancell
626626

627627
public static async Task WriteToAsync(this MemoryStream stream, Stream output, Encoding encoding, CancellationToken token)
628628
{
629-
#if NETSTANDARD || NETCORE2_1
629+
#if NETSTANDARD || NETCORE2_1 || NET6_0
630630
if (stream.TryGetBuffer(out var buffer))
631631
{
632632
await output.WriteAsync(buffer.Array, buffer.Offset, buffer.Count, token).ConfigAwait();

0 commit comments

Comments
 (0)