From 00ba44163ea08994fa6f4bb802f3dee343bbc4da Mon Sep 17 00:00:00 2001 From: Martijn van Dijk Date: Wed, 2 Aug 2023 21:37:36 +0200 Subject: [PATCH] Fixes --- Minio.Examples/Cases/RetryPolicyHelper.cs | 2 +- Minio/Credentials/AssumeRoleProvider.cs | 2 +- .../WebIdentityClientGrantsProvider.cs | 2 +- .../Args/CompleteMultipartUploadArgs.cs | 2 +- Minio/DataModel/Args/PutObjectPartArgs.cs | 3 +- .../DataModel/Select/SelectResponseStream.cs | 2 +- Minio/DataModel/Tags/Tagging.cs | 4 +-- Minio/Helper/S3utils.cs | 2 +- Minio/ResponseResult.cs | 34 +++++++------------ 9 files changed, 22 insertions(+), 31 deletions(-) diff --git a/Minio.Examples/Cases/RetryPolicyHelper.cs b/Minio.Examples/Cases/RetryPolicyHelper.cs index 7f67285aa..5a532e860 100644 --- a/Minio.Examples/Cases/RetryPolicyHelper.cs +++ b/Minio.Examples/Cases/RetryPolicyHelper.cs @@ -67,7 +67,7 @@ public static RetryPolicyHandler AsRetryDelegate(this AsyncPolicy await policy.ExecuteAsync(executeCallback).ConfigureAwait(false); + : policy.ExecuteAsync; } public static MinioClient WithRetryPolicy(this MinioClient client, AsyncPolicy policy) diff --git a/Minio/Credentials/AssumeRoleProvider.cs b/Minio/Credentials/AssumeRoleProvider.cs index 9306e5f88..022da4158 100644 --- a/Minio/Credentials/AssumeRoleProvider.cs +++ b/Minio/Credentials/AssumeRoleProvider.cs @@ -88,7 +88,7 @@ public override async ValueTask GetCredentialsAsync() } } - throw new ArgumentNullException(nameof(Client) + " should have been assigned for the operation to continue."); + throw new ArgumentNullException(nameof(Client), "Client should have been assigned for the operation to continue."); } internal override async Task BuildRequest() diff --git a/Minio/Credentials/WebIdentityClientGrantsProvider.cs b/Minio/Credentials/WebIdentityClientGrantsProvider.cs index ab4cab61d..6a0711c2d 100644 --- a/Minio/Credentials/WebIdentityClientGrantsProvider.cs +++ b/Minio/Credentials/WebIdentityClientGrantsProvider.cs @@ -75,7 +75,7 @@ internal override AccessCredentials ParseResponse(HttpResponseMessage response) protected void Validate() { if (JWTSupplier is null) - throw new ArgumentNullException(nameof(JWTSupplier) + " JWT Token supplier cannot be null."); + throw new ArgumentNullException(nameof(JWTSupplier), " JWT Token supplier cannot be null."); if (STSEndpoint is null || string.IsNullOrWhiteSpace(STSEndpoint.AbsoluteUri)) throw new InvalidOperationException(nameof(STSEndpoint) + " value is invalid."); } diff --git a/Minio/DataModel/Args/CompleteMultipartUploadArgs.cs b/Minio/DataModel/Args/CompleteMultipartUploadArgs.cs index 3aa9b488e..b79712105 100644 --- a/Minio/DataModel/Args/CompleteMultipartUploadArgs.cs +++ b/Minio/DataModel/Args/CompleteMultipartUploadArgs.cs @@ -47,7 +47,7 @@ internal override void Validate() { base.Validate(); if (string.IsNullOrWhiteSpace(UploadId)) - throw new ArgumentNullException(nameof(UploadId) + " cannot be empty.", nameof(UploadId)); + throw new ArgumentNullException(nameof(UploadId), nameof(UploadId) + " cannot be empty."); if (ETags is null || ETags.Count <= 0) throw new InvalidOperationException(nameof(ETags) + " dictionary cannot be empty."); } diff --git a/Minio/DataModel/Args/PutObjectPartArgs.cs b/Minio/DataModel/Args/PutObjectPartArgs.cs index 1c9e11fd0..8d4c03a85 100644 --- a/Minio/DataModel/Args/PutObjectPartArgs.cs +++ b/Minio/DataModel/Args/PutObjectPartArgs.cs @@ -29,8 +29,7 @@ internal override void Validate() { base.Validate(); if (string.IsNullOrWhiteSpace(UploadId)) - throw new ArgumentNullException(nameof(UploadId) + " not assigned for PutObjectPart operation.", - nameof(UploadId)); + throw new ArgumentNullException(nameof(UploadId), nameof(UploadId) + " not assigned for PutObjectPart operation."); } public new PutObjectPartArgs WithBucket(string bkt) diff --git a/Minio/DataModel/Select/SelectResponseStream.cs b/Minio/DataModel/Select/SelectResponseStream.cs index 9692d5dd8..7fac5ecfe 100644 --- a/Minio/DataModel/Select/SelectResponseStream.cs +++ b/Minio/DataModel/Select/SelectResponseStream.cs @@ -54,7 +54,7 @@ public SelectResponseStream(Stream stream) Start(); } - public Stream Payload { get; set; } + public Stream Payload { get; private set; } [XmlElement("Stats", IsNullable = false)] public StatsMessage Stats { get; set; } diff --git a/Minio/DataModel/Tags/Tagging.cs b/Minio/DataModel/Tags/Tagging.cs index a76b657db..9cd9a9b41 100644 --- a/Minio/DataModel/Tags/Tagging.cs +++ b/Minio/DataModel/Tags/Tagging.cs @@ -55,8 +55,8 @@ public Tagging(IDictionary tags, bool isObjects) foreach (var tag in tags) { - if (!ValidateTagKey(tag.Key)) throw new ArgumentException("Invalid Tagging key " + tag.Key); - if (!ValidateTagValue(tag.Value)) throw new ArgumentException("Invalid Tagging value " + tag.Value); + if (!ValidateTagKey(tag.Key)) throw new ArgumentException("Invalid Tagging key " + tag.Key, nameof(tag.Key)); + if (!ValidateTagValue(tag.Value)) throw new ArgumentException("Invalid Tagging value " + tag.Value, nameof(tag.Value)); } TaggingSet = new TagSet(tags); diff --git a/Minio/Helper/S3utils.cs b/Minio/Helper/S3utils.cs index 155f516bd..eee5e2f19 100644 --- a/Minio/Helper/S3utils.cs +++ b/Minio/Helper/S3utils.cs @@ -66,7 +66,7 @@ internal static string GetPath(string p1, string p2) } catch (Exception ex) { - throw new ArgumentException(ex.Message); + throw new ArgumentException(ex.Message, nameof(ex)); } } diff --git a/Minio/ResponseResult.cs b/Minio/ResponseResult.cs index 24f1edbcc..ecadc0dbf 100644 --- a/Minio/ResponseResult.cs +++ b/Minio/ResponseResult.cs @@ -20,14 +20,13 @@ namespace Minio; -public class ResponseResult : IDisposable +public sealed class ResponseResult : IDisposable { private readonly Dictionary headers = new(StringComparer.Ordinal); private string content; private ReadOnlyMemory contentBytes; - private bool disposedValue; - private Stream stream; + private bool disposed; public ResponseResult(HttpRequestMessage request, HttpResponseMessage response) { @@ -125,26 +124,19 @@ public IDictionary Headers public void Dispose() { - Dispose(true); - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) - { - if (!disposedValue) + if (disposed) { - if (disposing) - { - stream?.Dispose(); - Request?.Dispose(); - Response?.Dispose(); + return; + } - content = null; - contentBytes = null; - stream = null; - } + stream?.Dispose(); + Request?.Dispose(); + Response?.Dispose(); - disposedValue = true; - } + content = null; + contentBytes = null; + stream = null; + + disposed = true; } }