From 804008a5d18efee50bdc2aa468eb7cf2619dad70 Mon Sep 17 00:00:00 2001 From: JustArchi Date: Fri, 7 May 2021 17:14:22 +0200 Subject: [PATCH] Resolve CA1819 --- .editorconfig | 1 - ArchiSteamFarm/ASF.cs | 2 +- ArchiSteamFarm/Web/BinaryResponse.cs | 9 ++++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.editorconfig b/.editorconfig index 2d8387a32..3e1d5ecfa 100644 --- a/.editorconfig +++ b/.editorconfig @@ -111,7 +111,6 @@ dotnet_diagnostic.ca1028.severity = silent dotnet_diagnostic.ca1031.severity = silent # TODO - one at a time -dotnet_diagnostic.ca1819.severity = silent dotnet_diagnostic.ca1812.severity = silent dotnet_diagnostic.ca1823.severity = silent dotnet_diagnostic.ca2000.severity = silent diff --git a/ArchiSteamFarm/ASF.cs b/ArchiSteamFarm/ASF.cs index 9e3ec072d..7b31b6fe0 100644 --- a/ArchiSteamFarm/ASF.cs +++ b/ArchiSteamFarm/ASF.cs @@ -347,7 +347,7 @@ namespace ArchiSteamFarm { ArchiLogger.LogGenericWarningException(e); } - MemoryStream memoryStream = new(response.Content); + MemoryStream memoryStream = new(response.Content as byte[] ?? response.Content.ToArray()); try { #if NETFRAMEWORK diff --git a/ArchiSteamFarm/Web/BinaryResponse.cs b/ArchiSteamFarm/Web/BinaryResponse.cs index f2ce636ad..4674036a2 100644 --- a/ArchiSteamFarm/Web/BinaryResponse.cs +++ b/ArchiSteamFarm/Web/BinaryResponse.cs @@ -20,19 +20,22 @@ // limitations under the License. using System; +using System.Collections.Generic; using JetBrains.Annotations; namespace ArchiSteamFarm.Web { public sealed class BinaryResponse : BasicResponse { [PublicAPI] - public byte[] Content { get; } + public IReadOnlyCollection Content => Bytes; - public BinaryResponse(BasicResponse basicResponse, byte[] content) : base(basicResponse) { + private readonly byte[] Bytes; + + public BinaryResponse(BasicResponse basicResponse, byte[] bytes) : base(basicResponse) { if (basicResponse == null) { throw new ArgumentNullException(nameof(basicResponse)); } - Content = content ?? throw new ArgumentNullException(nameof(content)); + Bytes = bytes ?? throw new ArgumentNullException(nameof(bytes)); } } }