Skip to content

Commit c283d4a

Browse files
committed
Remove some obsolete types usage
1 parent 2051029 commit c283d4a

File tree

7 files changed

+7
-27
lines changed

7 files changed

+7
-27
lines changed

Extensions/Xtensive.Orm.Security/Cryptography/MD5HashingService.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ namespace Xtensive.Orm.Security.Cryptography
1717
public class MD5HashingService : GenericHashingService
1818
{
1919
/// <inheritdoc/>
20-
#pragma warning disable SYSLIB0021 // Type or member is obsolete
21-
// direct creation is more efficient than MD5.Create()
22-
protected override HashAlgorithm GetHashAlgorithm() => new MD5CryptoServiceProvider();
23-
#pragma warning restore SYSLIB0021 // Type or member is obsolete
20+
protected override HashAlgorithm GetHashAlgorithm() => MD5.Create();
2421

2522
/// <summary>
2623
/// Initializes a new instance of the <see cref="MD5HashingService"/> class.

Extensions/Xtensive.Orm.Security/Cryptography/SHA1HashingService.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ namespace Xtensive.Orm.Security.Cryptography
1616
public class SHA1HashingService : GenericHashingService
1717
{
1818
/// <inheritdoc/>
19-
#pragma warning disable SYSLIB0021 // Type or member is obsolete
20-
// direct creation is more efficient than SHA1.Create()
21-
protected override HashAlgorithm GetHashAlgorithm() => new SHA1Managed();
22-
#pragma warning restore SYSLIB0021 // Type or member is obsolete
19+
protected override HashAlgorithm GetHashAlgorithm() => SHA1.Create();
2320

2421
/// <summary>
2522
/// Initializes a new instance of the <see cref="SHA1HashingService"/> class.

Extensions/Xtensive.Orm.Security/Cryptography/SHA256HashingService.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ namespace Xtensive.Orm.Security.Cryptography
1616
public class SHA256HashingService : GenericHashingService
1717
{
1818
/// <inheritdoc/>
19-
#pragma warning disable SYSLIB0021 // Type or member is obsolete
20-
// direct creation is more efficient than SHA256.Create()
21-
protected override HashAlgorithm GetHashAlgorithm() => new SHA256Managed();
22-
#pragma warning restore SYSLIB0021 // Type or member is obsolete
19+
protected override HashAlgorithm GetHashAlgorithm() => SHA256.Create();
2320

2421
/// <summary>
2522
/// Initializes a new instance of the <see cref="SHA256HashingService"/> class.

Extensions/Xtensive.Orm.Security/Cryptography/SHA384HashingService.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ namespace Xtensive.Orm.Security.Cryptography
1616
public class SHA384HashingService : GenericHashingService
1717
{
1818
/// <inheritdoc/>
19-
#pragma warning disable SYSLIB0021 // Type or member is obsolete
20-
// direct creation is more efficient than SHA384.Create()
21-
protected override HashAlgorithm GetHashAlgorithm() => new SHA384Managed();
22-
#pragma warning restore SYSLIB0021 // Type or member is obsolete
19+
protected override HashAlgorithm GetHashAlgorithm() => SHA384.Create();
2320

2421
/// <summary>
2522
/// Initializes a new instance of the <see cref="SHA384HashingService"/> class.

Extensions/Xtensive.Orm.Security/Cryptography/SHA512HashingService.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ namespace Xtensive.Orm.Security.Cryptography
1616
public class SHA512HashingService : GenericHashingService
1717
{
1818
/// <inheritdoc/>
19-
#pragma warning disable SYSLIB0021 // Type or member is obsolete
20-
// direct creation is more efficient than SHA512.Create()
21-
protected override HashAlgorithm GetHashAlgorithm() => new SHA512Managed();
22-
#pragma warning restore SYSLIB0021 // Type or member is obsolete
19+
protected override HashAlgorithm GetHashAlgorithm() => SHA512.Create();
2320

2421
/// <summary>
2522
/// Initializes a new instance of the <see cref="SHA512HashingService"/> class.

Orm/Xtensive.Orm.Sqlite/Sql.Drivers.Sqlite/ProviderInitializer.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,14 @@ private static Stream GetLibraryStream()
5353

5454
private static string GetLibraryHash()
5555
{
56-
#pragma warning disable SYSLIB0021 // Type or member is obsolete
57-
// direct creation is more efficient than SHA1.Create()
58-
using (var hashProvider = new System.Security.Cryptography.SHA1Managed()) {
56+
using (var hashProvider = SHA1.Create()) {
5957
//hashProvider.Initialize();
6058
ReadOnlySpan<byte> hashRaw;
6159
using (var stream = GetLibraryStream()) {
6260
hashRaw = hashProvider.ComputeHash(stream);
6361
}
6462
return new StringBuilder().AppendHexArray(hashRaw[..8]).ToString();
6563
}
66-
#pragma warning restore SYSLIB0021 // Type or member is obsolete
6764
}
6865

6966
private static string GetLibraryFileName(string nativeLibraryCacheFolder, string moduleHash)

Orm/Xtensive.Orm/Orm/Providers/NameBuilder.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -579,12 +579,10 @@ public string ApplyNamingRules(string name)
579579
/// <returns>Computed hash.</returns>
580580
private static string GetHash(string name)
581581
{
582-
#pragma warning disable SYSLIB0021 // Type or member is obsolete
583-
using (var hashAlgorithm = new MD5CryptoServiceProvider()) {
582+
using (var hashAlgorithm = MD5.Create()) {
584583
var hash = hashAlgorithm.ComputeHash(Encoding.UTF8.GetBytes(name));
585584
return $"H{hash[0]:x2}{hash[1]:x2}{hash[2]:x2}{hash[3]:x2}";
586585
}
587-
#pragma warning restore SYSLIB0021 // Type or member is obsolete
588586
}
589587

590588
private static string FormatKeyGeneratorName(string database, string name)

0 commit comments

Comments
 (0)