Resolve CA1819

This commit is contained in:
JustArchi 2021-05-07 17:14:22 +02:00
parent 90ff43dc98
commit 804008a5d1
3 changed files with 7 additions and 5 deletions

View file

@ -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

View file

@ -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

View file

@ -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<byte> 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));
}
}
}