1
0
mirror of https://github.com/chylex/.NET-Community-Toolkit.git synced 2025-04-10 11:15:45 +02:00

Remove .NET Core 2.1 targets

This commit is contained in:
Sergio Pedri 2021-11-01 17:48:32 +01:00
parent 20f8ed1a59
commit 941098338f
4 changed files with 4 additions and 45 deletions
CommunityToolkit.HighPerformance
CommunityToolkit.Mvvm.SourceGenerators/ComponentModel
tests/CommunityToolkit.HighPerformance.UnitTests

View File

@ -3,7 +3,7 @@
<PropertyGroup>
<Nullable>Enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFrameworks>netstandard1.4;netstandard2.0;netstandard2.1;netcoreapp2.1;netcoreapp3.1;net5.0</TargetFrameworks>
<TargetFrameworks>netstandard1.4;netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0</TargetFrameworks>
</PropertyGroup>
<PropertyGroup>
@ -104,15 +104,6 @@
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
</ItemGroup>
</When>
<When Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
<PropertyGroup>
<DefineConstants>SPAN_RUNTIME_SUPPORT;NETCORE_RUNTIME</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
</ItemGroup>
</When>
</Choose>
</Project>

View File

@ -5,7 +5,7 @@
using System;
using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
#if NETCOREAPP2_1 || NETSTANDARD
#if NETSTANDARD
using System.Runtime.InteropServices;
#endif
using CommunityToolkit.HighPerformance.Enumerables;
@ -30,10 +30,6 @@ public static ref char DangerousGetReference(this string text)
{
#if NETCOREAPP3_1 || NET5_0
return ref Unsafe.AsRef(text.GetPinnableReference());
#elif NETCOREAPP2_1
var stringData = Unsafe.As<RawStringData>(text)!;
return ref stringData.Data;
#else
return ref MemoryMarshal.GetReference(text.AsSpan());
#endif
@ -52,8 +48,6 @@ public static ref char DangerousGetReferenceAt(this string text, int i)
{
#if NETCOREAPP3_1 || NET5_0
ref char r0 = ref Unsafe.AsRef(text.GetPinnableReference());
#elif NETCOREAPP2_1
ref char r0 = ref Unsafe.As<RawStringData>(text)!.Data;
#else
ref char r0 = ref MemoryMarshal.GetReference(text.AsSpan());
#endif
@ -62,27 +56,6 @@ public static ref char DangerousGetReferenceAt(this string text, int i)
return ref ri;
}
#if NETCOREAPP2_1
// Description adapted from CoreCLR: see https://source.dot.net/#System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.CoreCLR.cs,285.
// CLR strings are laid out in memory as follows:
// [ sync block || pMethodTable || length || string data .. ]
// ^ ^
// | \-- ref Unsafe.As<RawStringData>(text).Data
// \-- string
// The reference to RawStringData.Data points to the first character in the
// string, skipping over the sync block, method table and string length.
[StructLayout(LayoutKind.Explicit)]
private sealed class RawStringData
{
#pragma warning disable CS0649 // Unassigned fields
#pragma warning disable SA1401 // Fields should be private
[FieldOffset(4)]
public char Data;
#pragma warning restore CS0649
#pragma warning restore SA1401
}
#endif
/// <summary>
/// Counts the number of occurrences of a given character into a target <see cref="string"/> instance.
/// </summary>

View File

@ -121,7 +121,7 @@ private SyntaxTree LoadSourceSyntaxTree()
/// <param name="attributeData">The <see cref="AttributeData"/> for the current attribute being processed.</param>
/// <param name="classDeclaration">The <see cref="ClassDeclarationSyntax"/> node to process.</param>
/// <param name="classDeclarationSymbol">The <see cref="INamedTypeSymbol"/> for <paramref name="classDeclaration"/>.</param>
/// <param name="sourceSyntaxTree">The <see cref="CodeAnalysis.SyntaxTree"/> for the target parsed source.</param>
/// <param name="sourceSyntaxTree">The <see cref="Microsoft.CodeAnalysis.SyntaxTree"/> for the target parsed source.</param>
private void OnExecute(
GeneratorExecutionContext context,
AttributeData attributeData,

View File

@ -2,7 +2,7 @@
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetFrameworks>netcoreapp2.1;netcoreapp3.1;net5.0</TargetFrameworks>
<TargetFrameworks>netcoreapp3.1;net5.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
@ -15,9 +15,4 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
</ItemGroup>
<!-- .NET Core 2.1 doesn't have the Unsafe type -->
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="5.0.0" />
</ItemGroup>
</Project>