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

Commit e02f7ca

Browse files
committed
Add .NET Standard 2.1 builds to remove ambiguous ext methods
1 parent 628a4a1 commit e02f7ca

15 files changed

+51
-42
lines changed

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
</PropertyGroup>
3434

3535
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
36-
<DefineConstants>$(DefineConstants);NETSTANDARD2_0</DefineConstants>
36+
<DefineConstants>$(DefineConstants);NETSTANDARD;NETSTANDARD2_0</DefineConstants>
3737
</PropertyGroup>
3838

3939
<ItemGroup>

src/ServiceStack.Memory/ServiceStack.Memory.csproj

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>netcoreapp2.1</TargetFramework>
3+
<TargetFrameworks>netcoreapp2.1;netstandard2.1</TargetFrameworks>
44
</PropertyGroup>
55
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.1' ">
6-
<DefineConstants>$(DefineConstants);NETCORE2_1</DefineConstants>
6+
<DefineConstants>$(DefineConstants);NETSTANDARD;NETCORE2_1</DefineConstants>
7+
</PropertyGroup>
8+
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.1' ">
9+
<DefineConstants>$(DefineConstants);NETSTANDARD;NETSTANDARD2_1</DefineConstants>
710
</PropertyGroup>
811
<ItemGroup>
912
<ProjectReference Include="..\ServiceStack.Text\ServiceStack.Text.csproj" />

src/ServiceStack.Text/CharMemoryExtensions.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,9 @@ public static int LastIndexOf(this ReadOnlyMemory<char> value, string needle, in
381381
[MethodImpl(MethodImplOptions.AggressiveInlining)]
382382
public static bool EqualsOrdinal(this ReadOnlyMemory<char> value, ReadOnlyMemory<char> other) => value.Span.Equals(other.Span, StringComparison.Ordinal);
383383

384+
#if !NETSTANDARD2_1
385+
//Ambiguous definitions in .NET Core 3.0 System MemoryExtensions.cs
386+
384387
public static ReadOnlyMemory<char> Trim(this ReadOnlyMemory<char> span)
385388
{
386389
return span.TrimStart().TrimEnd();
@@ -411,6 +414,7 @@ public static ReadOnlyMemory<char> TrimEnd(this ReadOnlyMemory<char> value)
411414
}
412415
return value.Slice(0, end + 1);
413416
}
417+
#endif
414418

415419
[MethodImpl(MethodImplOptions.AggressiveInlining)]
416420
public static ReadOnlyMemory<char> SafeSlice(this ReadOnlyMemory<char> value, int startIndex) => SafeSlice(value, startIndex, value.Length);

src/ServiceStack.Text/Env.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ static Env()
1414
if (PclExport.Instance == null)
1515
throw new ArgumentException("PclExport.Instance needs to be initialized");
1616

17-
#if NETSTANDARD2_0 || NETCORE2_1
17+
#if NETSTANDARD
1818
IsNetStandard = true;
1919
try
2020
{
@@ -64,6 +64,16 @@ static Env()
6464
#if NETCORE2_1
6565
IsNetStandard = false;
6666
IsNetCore = true;
67+
IsNetCore21 = true;
68+
SupportsDynamic = true;
69+
#endif
70+
71+
#if NETSTANDARD2_0
72+
IsNetStandard20 = true;
73+
#endif
74+
75+
#if NETSTANDARD2_1
76+
IsNetStandard21 = true;
6777
SupportsDynamic = true;
6878
#endif
6979

@@ -127,6 +137,10 @@ static Env()
127137

128138
public static bool IsNetStandard { get; set; }
129139

140+
public static bool IsNetCore21 { get; set; }
141+
public static bool IsNetStandard20 { get; set; }
142+
public static bool IsNetStandard21 { get; set; }
143+
130144
public static bool IsNetFramework { get; set; }
131145

132146
public static bool IsNetCore { get; set; }
@@ -203,7 +217,7 @@ public static string ReferenceAssemblyPath
203217
set => referenceAssemblyPath = value;
204218
}
205219

206-
#if NETSTANDARD2_0
220+
#if NETSTANDARD
207221
private static bool IsRunningAsUwp()
208222
{
209223
try

src/ServiceStack.Text/JsConfigScope.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public sealed class JsConfigScope : Config, IDisposable
1313
bool disposed;
1414
readonly JsConfigScope parent;
1515

16-
#if NETSTANDARD2_0
16+
#if NETSTANDARD
1717
private static AsyncLocal<JsConfigScope> head = new AsyncLocal<JsConfigScope>();
1818
#else
1919
[ThreadStatic] private static JsConfigScope head;
@@ -23,7 +23,7 @@ internal JsConfigScope()
2323
{
2424
PclExport.Instance.BeginThreadAffinity();
2525

26-
#if NETSTANDARD2_0
26+
#if NETSTANDARD
2727
parent = head.Value;
2828
head.Value = this;
2929
#else
@@ -33,7 +33,7 @@ internal JsConfigScope()
3333
}
3434

3535
internal static JsConfigScope Current =>
36-
#if NETSTANDARD2_0
36+
#if NETSTANDARD
3737
head.Value;
3838
#else
3939
head;
@@ -44,7 +44,7 @@ public void Dispose()
4444
if (!disposed)
4545
{
4646
disposed = true;
47-
#if NETSTANDARD2_0
47+
#if NETSTANDARD
4848
head.Value = parent;
4949
#else
5050
head = parent;

src/ServiceStack.Text/NetCoreMemory.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 || NETSTANDARD2_1
22

33
using System;
44
using System.Buffers.Text;

src/ServiceStack.Text/PathUtils.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public static string MapAbsolutePath(this string relativePath)
6666
public static string MapHostAbsolutePath(this string relativePath)
6767
{
6868
var sep = PclExport.Instance.DirSep;
69-
#if !NETSTANDARD2_0
69+
#if !NETSTANDARD
7070
return PclExport.Instance.MapAbsolutePath(relativePath, $"{sep}..");
7171
#else
7272
return PclExport.Instance.MapAbsolutePath(relativePath, $"{sep}..{sep}..{sep}..");

src/ServiceStack.Text/Pcl.Dynamic.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
//Copyright (c) ServiceStack, Inc. All Rights Reserved.
22
//License: https://raw.github.com/ServiceStack/ServiceStack/master/license.txt
33

4-
#if NET45 || NETCORE2_1
5-
64
using System;
75
using System.Collections.Generic;
86
using System.Dynamic;
@@ -90,8 +88,6 @@ private static int VerifyAndGetStartIndex(ReadOnlySpan<char> value, Type createM
9088
}
9189
}
9290

93-
//TODO: Workout how to fix broken CoreCLR SL5 build that uses dynamic
94-
9591
public class DynamicJson : DynamicObject
9692
{
9793
private readonly IDictionary<string, object> _hash = new Dictionary<string, object>();
@@ -184,6 +180,4 @@ internal static string Underscored(IEnumerable<char> pascalCase)
184180
return StringBuilderCache.ReturnAndFree(sb).ToLowerInvariant();
185181
}
186182
}
187-
188183
}
189-
#endif

src/ServiceStack.Text/PclExport.NetStandard.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//Copyright (c) ServiceStack, Inc. All Rights Reserved.
22
//License: https://raw.github.com/ServiceStack/ServiceStack/master/license.txt
33

4-
#if NETSTANDARD2_0
4+
#if NETSTANDARD
55
using System;
66
using System.Collections.Generic;
77
using System.IO;

src/ServiceStack.Text/ReflectionOptimizer.Emit.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ static string ProxyName(Type targetType)
320320
static DynamicProxy()
321321
{
322322
var assemblyName = new AssemblyName("DynImpl");
323-
#if NETSTANDARD2_0
323+
#if NETSTANDARD
324324
DynamicAssembly = AssemblyBuilder.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run);
325325
#else
326326
DynamicAssembly = AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.RunAndSave);
@@ -344,7 +344,7 @@ static Type GetConstructedType(Type targetType)
344344
foreach (var face in targetType.GetInterfaces())
345345
IncludeType(face, typeBuilder);
346346

347-
#if NETSTANDARD2_0
347+
#if NETSTANDARD
348348
return typeBuilder.CreateTypeInfo().AsType();
349349
#else
350350
return typeBuilder.CreateType();

0 commit comments

Comments
 (0)