Skip to content

Commit 5b5bac9

Browse files
authored
Apply suggestions from code review
1 parent 0ca8ae3 commit 5b5bac9

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/Microsoft.OpenApi/Models/OpenApiDocument.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -524,17 +524,15 @@ public void SetReferenceHostDocument()
524524
/// <returns>The hash value.</returns>
525525
public async Task<string> GetHashCodeAsync(CancellationToken cancellationToken = default)
526526
{
527-
byte[]? hash;
528-
529-
#if NET
527+
#if NET7_OR_GREATER
530528
using var memoryStream = new MemoryStream();
531529
using var streamWriter = new StreamWriter(memoryStream);
532530

533531
await WriteDocumentAsync(streamWriter, cancellationToken).ConfigureAwait(false);
534532

535533
memoryStream.Seek(0, SeekOrigin.Begin);
536534

537-
hash = await SHA512.HashDataAsync(memoryStream, cancellationToken).ConfigureAwait(false);
535+
var hash = await SHA512.HashDataAsync(memoryStream, cancellationToken).ConfigureAwait(false);
538536
#else
539537
using HashAlgorithm sha = SHA512.Create();
540538
using var cryptoStream = new CryptoStream(Stream.Null, sha, CryptoStreamMode.Write);
@@ -544,7 +542,7 @@ public async Task<string> GetHashCodeAsync(CancellationToken cancellationToken =
544542

545543
cryptoStream.FlushFinalBlock();
546544

547-
hash = sha.Hash;
545+
var hash = sha.Hash;
548546
#endif
549547

550548
return ConvertByteArrayToString(hash ?? []);

0 commit comments

Comments
 (0)