33using System . IO ;
44using System . IO . Pipelines ;
55using System . Linq ;
6- using System . Runtime . CompilerServices ;
76using System . Text ;
8- using System . Threading ;
9- using System . Threading . Tasks ;
107
11- #if ! NETCOREAPP2_1
8+ #if ! NETCOREAPP
129using System . Buffers ;
1310#endif
1411
15- #if NETSTANDARD1_3
16- using System . Reflection ;
17- #endif
18-
1912namespace 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