-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #112 from Cysharp/hadashiA/netstandard20
Add netstandard2.0 to the targets
- Loading branch information
Showing
10 changed files
with
131 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#if NETSTANDARD2_0 | ||
using System.Text; | ||
|
||
namespace ZLogger; | ||
|
||
internal static partial class Shims | ||
{ | ||
public static int GetBytes(this Encoding encoding, ReadOnlySpan<char> chars, ReadOnlySpan<byte> bytes) | ||
{ | ||
unsafe | ||
{ | ||
fixed (char* charsPtr = &chars[0]) | ||
fixed (byte* bytesPtr = &bytes[0]) | ||
{ | ||
return encoding.GetBytes(charsPtr, chars.Length, bytesPtr, bytes.Length); | ||
} | ||
} | ||
} | ||
|
||
public static unsafe Span<T> CreateSpan<T>(ref T value, int length) where T : unmanaged | ||
{ | ||
fixed(T* pointer = &value) | ||
{ | ||
return new Span<T>(pointer, length); | ||
} | ||
} | ||
|
||
public static unsafe ReadOnlySpan<T> CreateReadOnlySpan<T>(ref T value, int length) where T : unmanaged | ||
{ | ||
fixed(T* pointer = &value) | ||
{ | ||
return new ReadOnlySpan<T>(pointer, length); | ||
} | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters