From 4ab601a2608d1cd0f4e0b90dde882784635ebb2e Mon Sep 17 00:00:00 2001 From: Sebastian Stehle Date: Tue, 30 Jan 2024 15:37:00 +0100 Subject: [PATCH] Fix warnings --- assets/Squidex.Assets.S3/AmazonS3AssetStore.cs | 6 +++--- assets/Squidex.Assets.Tests/AssetStoreTests.cs | 12 +++++++----- log/Squidex.Log/Internal/ConsoleLogProcessor.cs | 2 +- .../ChatBots/OpenAI/OpenAIChatBotService.cs | 2 +- text/Squidex.Text/SvgExtensions.cs | 2 -- text/Squidex.Text/SvgMetadata.cs | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/assets/Squidex.Assets.S3/AmazonS3AssetStore.cs b/assets/Squidex.Assets.S3/AmazonS3AssetStore.cs index bb80a23..5bc1905 100644 --- a/assets/Squidex.Assets.S3/AmazonS3AssetStore.cs +++ b/assets/Squidex.Assets.S3/AmazonS3AssetStore.cs @@ -22,7 +22,7 @@ public sealed class AmazonS3AssetStore : IAssetStore, IInitializable private const int BufferSize = 81920; private readonly AmazonS3AssetOptions options; private TransferUtility s3Transfer; - private IAmazonS3 s3Client; + private AmazonS3Client s3Client; private bool canCopy = true; public AmazonS3AssetStore(IOptions options) @@ -158,7 +158,7 @@ private async Task CopyViaDownloadAsync(string sourceFileName, string targetFile BucketName = options.Bucket, Key = keyTarget, DisablePayloadSigning = options.DisablePayloadSigning, - DisableMD5Stream = false, + DisableDefaultChecksumValidation = false, InputStream = teamStream }; @@ -255,7 +255,7 @@ public async Task UploadAsync(string fileName, Stream stream, bool overwri BucketName = options.Bucket, Key = key, DisablePayloadSigning = options.DisablePayloadSigning, - DisableMD5Stream = false + DisableDefaultChecksumValidation = false }; if (stream.GetLengthOrZero() <= 0) diff --git a/assets/Squidex.Assets.Tests/AssetStoreTests.cs b/assets/Squidex.Assets.Tests/AssetStoreTests.cs index 44eeb41..424f0f5 100644 --- a/assets/Squidex.Assets.Tests/AssetStoreTests.cs +++ b/assets/Squidex.Assets.Tests/AssetStoreTests.cs @@ -8,6 +8,8 @@ using System.IO.Compression; using Xunit; +#pragma warning disable RECS0108 // Warns about static fields in generic types + namespace Squidex.Assets; public abstract class AssetStoreTests where T : IAssetStore @@ -41,12 +43,12 @@ public enum TestCase FolderLinux } - public static IEnumerable FolderCases() + public static readonly TheoryData FolderCases = new TheoryData { - yield return new object[] { TestCase.NoFolder }; - yield return new object[] { TestCase.FolderWindows }; - yield return new object[] { TestCase.FolderLinux }; - } + TestCase.NoFolder, + TestCase.FolderWindows, + TestCase.FolderLinux + }; [Theory] [InlineData("../{file}.png")] diff --git a/log/Squidex.Log/Internal/ConsoleLogProcessor.cs b/log/Squidex.Log/Internal/ConsoleLogProcessor.cs index d8d99f9..2694f8a 100644 --- a/log/Squidex.Log/Internal/ConsoleLogProcessor.cs +++ b/log/Squidex.Log/Internal/ConsoleLogProcessor.cs @@ -22,7 +22,7 @@ public sealed class ConsoleLogProcessor : IDisposable public ConsoleLogProcessor() { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + if (OperatingSystem.IsWindows()) { console = new WindowsLogConsole(true); } diff --git a/text/Squidex.Text/ChatBots/OpenAI/OpenAIChatBotService.cs b/text/Squidex.Text/ChatBots/OpenAI/OpenAIChatBotService.cs index 513657d..d36e4e8 100644 --- a/text/Squidex.Text/ChatBots/OpenAI/OpenAIChatBotService.cs +++ b/text/Squidex.Text/ChatBots/OpenAI/OpenAIChatBotService.cs @@ -62,7 +62,7 @@ public async Task AskQuestionAsync(string prompt, return new ChatBotResult { - Choices = response.Choices.Select(x => x.Message.Content).ToList(), + Choices = response.Choices.Select(x => x.Message.Content).Where(x => x != null).ToList()!, EstimatedCostsInEUR = (numTokensInput * options.PricePerInputTokenInEUR) + (numTokensOutput * options.PricePerOutputTokenInEUR) diff --git a/text/Squidex.Text/SvgExtensions.cs b/text/Squidex.Text/SvgExtensions.cs index 407e332..db274a3 100644 --- a/text/Squidex.Text/SvgExtensions.cs +++ b/text/Squidex.Text/SvgExtensions.cs @@ -7,7 +7,6 @@ using HtmlPerformanceKit; using Squidex.Text.Svg; -using System.Security.Principal; namespace Squidex.Text; @@ -55,7 +54,6 @@ public static SvgMetadata GetSvgMetadata(this string html) else if (string.Equals(attributeName, "viewBox", StringComparison.OrdinalIgnoreCase)) { viewBox = attributeValue.Trim(); - } } } diff --git a/text/Squidex.Text/SvgMetadata.cs b/text/Squidex.Text/SvgMetadata.cs index 5b44ebf..811b889 100644 --- a/text/Squidex.Text/SvgMetadata.cs +++ b/text/Squidex.Text/SvgMetadata.cs @@ -5,8 +5,8 @@ // All rights reserved. Licensed under the MIT license. // ========================================================================== -namespace Squidex.Text; - #pragma warning disable SA1313 // Parameter names should begin with lower-case letter +namespace Squidex.Text; + public record struct SvgMetadata(string Width, string Height, string ViewBox);