-
-
Notifications
You must be signed in to change notification settings - Fork 960
Add .NET 10 target and make use of C#14 extension members #1672
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
mus65
wants to merge
18
commits into
sshnet:develop
Choose a base branch
from
mus65:net10
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
8ca64e6
Add .NET 10 target
mus65 cd391cb
fix IDE0031
mus65 fddb6e3
fix ca5399
mus65 bffe6a1
fix ca1515
mus65 c8fd34f
fix ca2002
mus65 4d1351a
fix ca1508
mus65 d2f660d
fix ca2000
mus65 6e9e74a
fix ca2025
mus65 76383f5
fix ca1849
mus65 d1b7291
fix Reverse() overloads
mus65 c0b525f
supress CA2002
mus65 a0a67e0
Use extension members for ThrowHelpers
mus65 6f8a60e
use extension members for CryptoAbstractions
mus65 b70f75e
use extension member for DateTime.UnixEpoch
mus65 7bc2828
use extension members for string.Join etc
mus65 7a836ae
use extension members for Convert.To/FromHexString
mus65 4211159
disable CA1508
mus65 8d5f47b
Merge remote-tracking branch 'upstream/develop' into net10
mus65 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
"sdk": { | ||
"version": "9.0.300", | ||
"version": "10.0.100-rc.1.25451.107", | ||
"allowPrerelease": true, | ||
"rollForward": "latestFeature" | ||
} | ||
} |
This file contains hidden or 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,34 @@ | ||
#nullable enable | ||
#if !NET | ||
using System.Text; | ||
#endif | ||
|
||
namespace System | ||
{ | ||
internal static class ConvertExtensions | ||
{ | ||
extension(Convert) | ||
{ | ||
#if !NET | ||
public static byte[] FromHexString(string s) | ||
{ | ||
return Org.BouncyCastle.Utilities.Encoders.Hex.Decode(s); | ||
} | ||
|
||
public static string ToHexString(byte[] inArray) | ||
{ | ||
ArgumentNullException.ThrowIfNull(inArray); | ||
|
||
var builder = new StringBuilder(inArray.Length * 2); | ||
|
||
foreach (var b in inArray) | ||
{ | ||
builder.Append(b.ToString("X2")); | ||
} | ||
|
||
return builder.ToString(); | ||
} | ||
#endif | ||
} | ||
} | ||
} |
This file contains hidden or 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 hidden or 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,19 @@ | ||
#nullable enable | ||
namespace System | ||
{ | ||
internal static class DateTimeExtensions | ||
{ | ||
extension(DateTime) | ||
{ | ||
#if !NET | ||
public static DateTime UnixEpoch | ||
{ | ||
get | ||
{ | ||
return new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); | ||
} | ||
} | ||
#endif | ||
} | ||
} | ||
} |
This file contains hidden or 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,19 @@ | ||
#nullable enable | ||
namespace System.Security.Cryptography | ||
{ | ||
internal static class MD5Extensions | ||
{ | ||
extension(MD5) | ||
{ | ||
#if !NET | ||
public static byte[] HashData(byte[] source) | ||
{ | ||
using (var md5 = MD5.Create()) | ||
{ | ||
return md5.ComputeHash(source); | ||
} | ||
} | ||
#endif | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/Renci.SshNet/Abstractions/RandomNumberGeneratorExtensions.cs
This file contains hidden or 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,22 @@ | ||
#nullable enable | ||
namespace System.Security.Cryptography | ||
{ | ||
internal static class RandomNumberGeneratorExtensions | ||
{ | ||
#if !NET | ||
private static readonly RandomNumberGenerator Randomizer = RandomNumberGenerator.Create(); | ||
#endif | ||
|
||
extension(RandomNumberGenerator) | ||
{ | ||
#if !NET | ||
public static byte[] GetBytes(int length) | ||
{ | ||
var random = new byte[length]; | ||
Randomizer.GetBytes(random); | ||
return random; | ||
} | ||
#endif | ||
} | ||
} | ||
} |
This file contains hidden or 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,18 @@ | ||
namespace System.Security.Cryptography | ||
{ | ||
internal static class SHA1Extensions | ||
{ | ||
extension(SHA1) | ||
{ | ||
#if !NET | ||
public static byte[] HashData(byte[] source) | ||
{ | ||
using (var sha1 = SHA1.Create()) | ||
{ | ||
return sha1.ComputeHash(source); | ||
} | ||
} | ||
#endif | ||
} | ||
} | ||
} |
This file contains hidden or 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,19 @@ | ||
#nullable enable | ||
namespace System.Security.Cryptography | ||
{ | ||
internal static class SHA256Extensions | ||
{ | ||
extension(SHA256) | ||
{ | ||
#if !NET | ||
public static byte[] HashData(byte[] source) | ||
{ | ||
using (var sha256 = SHA256.Create()) | ||
{ | ||
return sha256.ComputeHash(source); | ||
} | ||
} | ||
#endif | ||
} | ||
} | ||
} |
This file contains hidden or 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,19 @@ | ||
#nullable enable | ||
namespace System.Security.Cryptography | ||
{ | ||
internal static class SHA384Extensions | ||
{ | ||
extension(SHA384) | ||
{ | ||
#if !NET | ||
public static byte[] HashData(byte[] source) | ||
{ | ||
using (var sha384 = SHA384.Create()) | ||
{ | ||
return sha384.ComputeHash(source); | ||
} | ||
} | ||
#endif | ||
} | ||
} | ||
} |
This file contains hidden or 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,19 @@ | ||
#nullable enable | ||
namespace System.Security.Cryptography | ||
{ | ||
internal static class SHA512Extensions | ||
{ | ||
extension(SHA512) | ||
{ | ||
#if !NET | ||
public static byte[] HashData(byte[] source) | ||
{ | ||
using (var sha512 = SHA512.Create()) | ||
{ | ||
return sha512.ComputeHash(source); | ||
} | ||
} | ||
#endif | ||
} | ||
} | ||
} |
This file contains hidden or 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,35 @@ | ||
#nullable enable | ||
#if NETSTANDARD2_0 || NETFRAMEWORK | ||
using System.Collections.Generic; | ||
#endif | ||
|
||
namespace System | ||
{ | ||
internal static class StringExtensions | ||
{ | ||
extension(string text) | ||
{ | ||
#if NETSTANDARD2_0 || NETFRAMEWORK | ||
public static string Join(char separator, params string?[] value) | ||
{ | ||
return string.Join(separator.ToString(), value); | ||
} | ||
|
||
public static string Join(char separator, IEnumerable<string?> value) | ||
{ | ||
return string.Join(separator.ToString(), value); | ||
} | ||
|
||
public static string Join(char separator, string?[] value, int startIndex, int count) | ||
{ | ||
return string.Join(separator.ToString(), value, startIndex, count); | ||
} | ||
|
||
public int IndexOf(char value, StringComparison comparisonType) | ||
{ | ||
return text.IndexOf(value.ToString(), comparisonType); | ||
} | ||
#endif | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.