File tree Expand file tree Collapse file tree 2 files changed +54
-37
lines changed
Expand file tree Collapse file tree 2 files changed +54
-37
lines changed Original file line number Diff line number Diff line change 11// <auto-generated />
22
3- using System . Runtime . InteropServices ;
4- using System . Text ;
5-
63#pragma warning disable
74
85#if FeatureMemory
96
107namespace Polyfills ;
118
129using System ;
10+ using System . Runtime . InteropServices ;
11+ using System . Text ;
1312
1413static partial class Polyfill
1514{
16- #if NETCOREAPP2_0 || NETFRAMEWORK || NETSTANDARD2_0
17- /// <summary>
18- /// When overridden in a derived class, calculates the number of bytes produced by encoding the characters in the specified character span.
19- /// </summary>
20- /// <param name="encoding"></param>
21- /// <param name="chars">The span of characters to encode.</param>
22- /// <returns>The number of bytes produced by encoding the specified character span.</returns>
23- //Link: https://learn.microsoft.com/en-us/dotnet/api/system.text.encoding.getbytecount#system-text-encoding-getbytecount(system-readonlyspan((system-char)))
24- #if AllowUnsafeBlocks
25- public unsafe static int GetByteCount ( this Encoding target , ReadOnlySpan < char > chars )
26- {
27- if ( target is null )
28- {
29- throw new ArgumentNullException ( nameof ( target ) ) ;
30- }
31-
32- fixed ( char * charsPtr = chars )
33- {
34- return target . GetByteCount ( charsPtr , chars . Length ) ;
35- }
36- }
37- #else
38- public static int GetByteCount ( this Encoding target , ReadOnlySpan < char > chars )
39- {
40- if ( target is null )
41- {
42- throw new ArgumentNullException ( nameof ( target ) ) ;
43- }
44-
45- return target . GetByteCount ( chars . ToArray ( ) ) ;
46- }
47- #endif
48- #endif
49-
5015#if ! NETCOREAPP2_1_OR_GREATER
5116 /// <summary>When overridden in a derived class, encodes into a span of bytes a set of characters from the specified read-only span.</summary>
5217 /// <param name="chars">The span containing the set of characters to encode.</param>
Original file line number Diff line number Diff line change 1+ // <auto-generated />
2+
3+ #pragma warning disable
4+
5+ #if FeatureMemory
6+
7+ namespace Polyfills ;
8+
9+ using System ;
10+
11+ using System . Runtime . InteropServices ;
12+ using System . Text ;
13+
14+ static partial class Polyfill
15+ {
16+ #if NETCOREAPP2_0 || NETFRAMEWORK || NETSTANDARD2_0
17+ /// <summary>
18+ /// When overridden in a derived class, calculates the number of bytes produced by encoding the characters in the specified character span.
19+ /// </summary>
20+ /// <param name="encoding"></param>
21+ /// <param name="chars">The span of characters to encode.</param>
22+ /// <returns>The number of bytes produced by encoding the specified character span.</returns>
23+ //Link: https://learn.microsoft.com/en-us/dotnet/api/system.text.encoding.getbytecount#system-text-encoding-getbytecount(system-readonlyspan((system-char)))
24+ #if AllowUnsafeBlocks
25+ public unsafe static int GetByteCount ( this Encoding target , ReadOnlySpan < char > chars )
26+ {
27+ if ( target is null )
28+ {
29+ throw new ArgumentNullException ( nameof ( target ) ) ;
30+ }
31+
32+ fixed ( char * charsPtr = chars )
33+ {
34+ return target . GetByteCount ( charsPtr , chars . Length ) ;
35+ }
36+ }
37+ #else
38+ public static int GetByteCount ( this Encoding target , ReadOnlySpan < char > chars )
39+ {
40+ if ( target is null )
41+ {
42+ throw new ArgumentNullException ( nameof ( target ) ) ;
43+ }
44+
45+ return target . GetByteCount ( chars . ToArray ( ) ) ;
46+ }
47+ #endif
48+ #endif
49+
50+ }
51+
52+ #endif
You can’t perform that action at this time.
0 commit comments