Skip to content

Commit 22c0eea

Browse files
committed
Add .NET Core 3.0 target and remove .NET Standard 1.3 support
This means .NET 4.7.2 is minimum supported version. Technically 4.6.1 is supported, but not recommended.
1 parent 002a95b commit 22c0eea

File tree

6 files changed

+25
-37
lines changed

6 files changed

+25
-37
lines changed

BencodeNET.Tests/BencodeNET.Tests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net46;netcoreapp2.0;netcoreapp2.2</TargetFrameworks>
4+
<TargetFrameworks>net472;netcoreapp2.0;netcoreapp2.2;netcoreapp3.0</TargetFrameworks>
55
<LangVersion>7.3</LangVersion>
66
</PropertyGroup>
77

BencodeNET/BencodeNET.csproj

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard1.3;netstandard2.0;netcoreapp2.1</TargetFrameworks>
4+
<TargetFrameworks>netstandard2.0;netcoreapp2.1;netcoreapp3.0</TargetFrameworks>
55
<LangVersion>7.3</LangVersion>
66
<GenerateDocumentationFile>True</GenerateDocumentationFile>
77
<CodeAnalysisRuleSet>BencodeNET.ruleset</CodeAnalysisRuleSet>
@@ -35,17 +35,18 @@
3535
<None Include="../Assets/icon.png" Pack="true" PackagePath="/" />
3636
</ItemGroup>
3737

38+
<!--Dev dependencies -->
3839
<ItemGroup>
39-
<PackageReference Include="System.IO.Pipelines" Version="4.5.3" />
40-
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="16.3.52" PrivateAssets="All" />
40+
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="16.4.16" PrivateAssets="All" />
4141
</ItemGroup>
4242

43-
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
44-
<PackageReference Include="System.Reflection" Version="4.3.0" />
45-
<PackageReference Include="System.Security.Cryptography.Algorithms" Version="4.3.0" />
43+
<!-- Shared dependencies -->
44+
<ItemGroup>
45+
<PackageReference Include="System.IO.Pipelines" Version="4.6.0" />
4646
</ItemGroup>
4747

48-
<ItemGroup Condition=" '$(TargetFramework)' != 'netcoreapp2.1'">
48+
<!-- .NET Standard 2.0 dependencies -->
49+
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
4950
<PackageReference Include="System.Buffers" Version="4.5.0" />
5051
</ItemGroup>
5152

BencodeNET/Objects/BNumber.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ protected override void EncodeObject(PipeWriter writer)
6464
buffer[0] = (byte) 'i';
6565
buffer = buffer.Slice(1);
6666

67-
#if NETCOREAPP2_1
67+
#if NETCOREAPP
6868
Encoding.ASCII.GetBytes(Value.ToString().AsSpan(), buffer);
6969
#else
7070
var bytes = Encoding.ASCII.GetBytes(Value.ToString());

BencodeNET/Objects/BObjectExtensions.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
#if NETCOREAPP2_1
2-
using System;
3-
#endif
4-
using System.Buffers;
1+
using System.Buffers;
52
using System.IO;
63
using System.Text;
74

5+
#if NETCOREAPP
6+
using System;
7+
#endif
8+
89
namespace BencodeNET.Objects
910
{
1011
/// <summary>
@@ -40,7 +41,7 @@ public static string EncodeAsString(this IBObject bobject, Encoding encoding)
4041
using (var stream = new MemoryStream(buffer))
4142
{
4243
bobject.EncodeTo(stream);
43-
#if NETCOREAPP2_1
44+
#if NETCOREAPP
4445
return encoding.GetString(buffer.AsSpan().Slice(0, size));
4546
#else
4647
return encoding.GetString(buffer, 0, size);

BencodeNET/Objects/BString.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ protected override void EncodeObject(PipeWriter writer)
9898
var size = GetSizeInBytes();
9999
var buffer = writer.GetSpan(size);
100100

101-
#if NETCOREAPP2_1
101+
#if NETCOREAPP
102102
// Write length
103103
var writtenBytes = Encoding.GetBytes(_value.Length.ToString().AsSpan(), buffer);
104104

@@ -189,7 +189,7 @@ public int CompareTo(BString other)
189189
/// </returns>
190190
public override string ToString()
191191
{
192-
#if NETCOREAPP2_1
192+
#if NETCOREAPP
193193
return _encoding.GetString(_value.AsSpan());
194194
#else
195195
return _encoding.GetString(_value);
@@ -206,7 +206,7 @@ public override string ToString()
206206
public string ToString(Encoding encoding)
207207
{
208208
encoding = encoding ?? _encoding;
209-
#if NETCOREAPP2_1
209+
#if NETCOREAPP
210210
return encoding.GetString(_value.AsSpan());
211211
#else
212212
return encoding.GetString(_value);

BencodeNET/UtilityExtensions.cs

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,12 @@
33
using System.IO;
44
using System.IO.Pipelines;
55
using System.Linq;
6-
using System.Runtime.CompilerServices;
76
using System.Text;
8-
using System.Threading;
9-
using System.Threading.Tasks;
107

11-
#if !NETCOREAPP2_1
8+
#if !NETCOREAPP
129
using System.Buffers;
1310
#endif
1411

15-
#if NETSTANDARD1_3
16-
using System.Reflection;
17-
#endif
18-
1912
namespace BencodeNET
2013
{
2114
internal static class UtilityExtensions
@@ -112,7 +105,7 @@ public static bool TrySetLength(this Stream stream, long length)
112105

113106
public static void Write(this Stream stream, int number)
114107
{
115-
#if NETCOREAPP2_1
108+
#if NETCOREAPP
116109
Span<byte> buffer = stackalloc byte[11];
117110
var bytesRead = Encoding.ASCII.GetBytes(number.ToString().AsSpan(), buffer);
118111
stream.Write(buffer.Slice(0, bytesRead));
@@ -127,7 +120,7 @@ public static void Write(this Stream stream, int number)
127120

128121
public static void Write(this Stream stream, long number)
129122
{
130-
#if NETCOREAPP2_1
123+
#if NETCOREAPP
131124
Span<byte> buffer = stackalloc byte[20];
132125
var bytesRead = Encoding.ASCII.GetBytes(number.ToString().AsSpan(), buffer);
133126
stream.Write(buffer.Slice(0, bytesRead));
@@ -145,20 +138,13 @@ public static void Write(this Stream stream, char c)
145138
stream.WriteByte((byte) c);
146139
}
147140

148-
#if !NETCOREAPP2_1
141+
#if !NETCOREAPP
149142
public static void Write(this Stream stream, byte[] bytes)
150143
{
151144
stream.Write(bytes, 0, bytes.Length);
152145
}
153146
#endif
154147

155-
#if NETSTANDARD1_3
156-
public static bool IsAssignableFrom(this Type type, Type otherType)
157-
{
158-
return type.GetTypeInfo().IsAssignableFrom(otherType.GetTypeInfo());
159-
}
160-
#endif
161-
162148
public static void WriteChar(this PipeWriter writer, char c)
163149
{
164150
writer.GetSpan(1)[0] = (byte) c;
@@ -170,7 +156,7 @@ public static void WriteCharAt(this Span<byte> bytes, char c, int index)
170156
bytes[index] = (byte) c;
171157
}
172158

173-
#if NETCOREAPP2_1
159+
#if NETCOREAPP
174160
public static string AsString(this ReadOnlySpan<char> chars)
175161
{
176162
return new string(chars);

0 commit comments

Comments
 (0)