From 1873f4a70678e80814f1bdc8f70a715b532a4949 Mon Sep 17 00:00:00 2001 From: shimat Date: Sat, 24 Feb 2024 19:10:14 +0900 Subject: [PATCH] fix warnings --- OpenCvSharp.sln.DotSettings | 2 ++ .../OpenCvSharp.Tests/core/FileStorageTest.cs | 3 +- test/OpenCvSharp.Tests/core/Rect2dTest.cs | 8 ----- test/OpenCvSharp.Tests/core/Rect2fTest.cs | 9 +----- test/OpenCvSharp.Tests/core/RectTest.cs | 8 ----- test/OpenCvSharp.Tests/core/SizeTest.cs | 1 + .../objdetect/HOGDescriptorTest.cs | 20 +++++------- .../OpenCvSharp.Tests/system/AppDomainTest.cs | 12 ++----- .../system/WindowsLibraryLoaderTest.cs | 4 +-- .../wechat_qrcode/WeChatQRCodeTest.cs | 31 +++++++------------ 10 files changed, 29 insertions(+), 69 deletions(-) diff --git a/OpenCvSharp.sln.DotSettings b/OpenCvSharp.sln.DotSettings index a14671ed8..61d2cba2e 100644 --- a/OpenCvSharp.sln.DotSettings +++ b/OpenCvSharp.sln.DotSettings @@ -1,8 +1,10 @@  <NamingElement Priority="6"><Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="Indeterminate" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"><type Name="local variable" /></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></NamingElement> <NamingElement Priority="5"><Descriptor Static="Indeterminate" Constexpr="Indeterminate" Const="Indeterminate" Volatile="Indeterminate" Accessibility="NOT_APPLICABLE"><type Name="parameter" /></Descriptor><Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /></NamingElement> + LTRB LUT PCA + QR RB RNG SURF diff --git a/test/OpenCvSharp.Tests/core/FileStorageTest.cs b/test/OpenCvSharp.Tests/core/FileStorageTest.cs index 0a469bbac..8d26e70fb 100644 --- a/test/OpenCvSharp.Tests/core/FileStorageTest.cs +++ b/test/OpenCvSharp.Tests/core/FileStorageTest.cs @@ -1,5 +1,4 @@ -#nullable enable -using Xunit; +using Xunit; using Xunit.Abstractions; namespace OpenCvSharp.Tests.Core; diff --git a/test/OpenCvSharp.Tests/core/Rect2dTest.cs b/test/OpenCvSharp.Tests/core/Rect2dTest.cs index d308d9ec5..4d6200eb7 100644 --- a/test/OpenCvSharp.Tests/core/Rect2dTest.cs +++ b/test/OpenCvSharp.Tests/core/Rect2dTest.cs @@ -1,17 +1,9 @@ using Xunit; -using Xunit.Abstractions; namespace OpenCvSharp.Tests.Core; public class Rect2dTest { - private readonly ITestOutputHelper testOutputHelper; - - public Rect2dTest(ITestOutputHelper testOutputHelper) - { - this.testOutputHelper = testOutputHelper; - } - [Fact] public void TopLeft() { diff --git a/test/OpenCvSharp.Tests/core/Rect2fTest.cs b/test/OpenCvSharp.Tests/core/Rect2fTest.cs index b3ee5882c..cb223f91e 100644 --- a/test/OpenCvSharp.Tests/core/Rect2fTest.cs +++ b/test/OpenCvSharp.Tests/core/Rect2fTest.cs @@ -1,17 +1,10 @@ using Xunit; -using Xunit.Abstractions; namespace OpenCvSharp.Tests.Core; +// ReSharper disable once InconsistentNaming public class Rect2fTest { - private readonly ITestOutputHelper testOutputHelper; - - public Rect2fTest(ITestOutputHelper testOutputHelper) - { - this.testOutputHelper = testOutputHelper; - } - [Fact] public void TopLeft() { diff --git a/test/OpenCvSharp.Tests/core/RectTest.cs b/test/OpenCvSharp.Tests/core/RectTest.cs index 6a90f04a2..85b829b8d 100644 --- a/test/OpenCvSharp.Tests/core/RectTest.cs +++ b/test/OpenCvSharp.Tests/core/RectTest.cs @@ -1,17 +1,9 @@ using Xunit; -using Xunit.Abstractions; namespace OpenCvSharp.Tests.Core; public class RectTest { - private readonly ITestOutputHelper testOutputHelper; - - public RectTest(ITestOutputHelper testOutputHelper) - { - this.testOutputHelper = testOutputHelper; - } - [Fact] public void TopLeft() { diff --git a/test/OpenCvSharp.Tests/core/SizeTest.cs b/test/OpenCvSharp.Tests/core/SizeTest.cs index 572f01093..5d6effb13 100644 --- a/test/OpenCvSharp.Tests/core/SizeTest.cs +++ b/test/OpenCvSharp.Tests/core/SizeTest.cs @@ -5,6 +5,7 @@ namespace OpenCvSharp.Tests.Core; public class SizeTest { [Fact] + // ReSharper disable once InconsistentNaming public void Size2f() { var obj = new Size2f(0.5, 0.5); diff --git a/test/OpenCvSharp.Tests/objdetect/HOGDescriptorTest.cs b/test/OpenCvSharp.Tests/objdetect/HOGDescriptorTest.cs index ee2d16f70..c29e71e83 100644 --- a/test/OpenCvSharp.Tests/objdetect/HOGDescriptorTest.cs +++ b/test/OpenCvSharp.Tests/objdetect/HOGDescriptorTest.cs @@ -9,22 +9,18 @@ public class HOGDescriptorTest : TestBase [Fact] public void PropertyCellSize() { - using (var obj = new HOGDescriptor()) - { - Size value = new Size(123, 789); - obj.CellSize = value; - Assert.Equal(value, obj.CellSize); - } + using var obj = new HOGDescriptor(); + Size value = new Size(123, 789); + obj.CellSize = value; + Assert.Equal(value, obj.CellSize); } [Fact] public void PropertyWinSize() { - using (var obj = new HOGDescriptor()) - { - Size value = new Size(123, 789); - obj.WinSize = value; - Assert.Equal(value, obj.WinSize); - } + using var obj = new HOGDescriptor(); + Size value = new Size(123, 789); + obj.WinSize = value; + Assert.Equal(value, obj.WinSize); } } diff --git a/test/OpenCvSharp.Tests/system/AppDomainTest.cs b/test/OpenCvSharp.Tests/system/AppDomainTest.cs index a4247e681..f2ee4db65 100644 --- a/test/OpenCvSharp.Tests/system/AppDomainTest.cs +++ b/test/OpenCvSharp.Tests/system/AppDomainTest.cs @@ -1,7 +1,4 @@ -#nullable enable - -#if NET48 -using System; +#if NET48 using System.Globalization; using System.Security.Policy; using Xunit; @@ -12,10 +9,7 @@ namespace OpenCvSharp.Tests; public class MarshalByRefAction : MarshalByRefObject { public Action? Action { get; set; } - public void Run() - { - Action?.Invoke(); - } + public void Run() => Action?.Invoke(); } [Collection(nameof(AppDomainTest))] // should not be run test in parallel @@ -64,7 +58,7 @@ public void Test() } // avoid AppDomainUnloadedException on subsequent tests https://codeday.me/jp/qa/20190609/973822.html - System.Threading.Thread.Sleep(TimeSpan.FromSeconds(2)); + Thread.Sleep(TimeSpan.FromSeconds(2)); } private static void RunAtIsolatedDomain(Evidence securityInfo, AppDomainSetup info, Action action) diff --git a/test/OpenCvSharp.Tests/system/WindowsLibraryLoaderTest.cs b/test/OpenCvSharp.Tests/system/WindowsLibraryLoaderTest.cs index d4eebe35c..5d33bc2b6 100644 --- a/test/OpenCvSharp.Tests/system/WindowsLibraryLoaderTest.cs +++ b/test/OpenCvSharp.Tests/system/WindowsLibraryLoaderTest.cs @@ -1,6 +1,4 @@ -#nullable enable - -using OpenCvSharp.Internal; +using OpenCvSharp.Internal; using Xunit; namespace OpenCvSharp.Tests; diff --git a/test/OpenCvSharp.Tests/wechat_qrcode/WeChatQRCodeTest.cs b/test/OpenCvSharp.Tests/wechat_qrcode/WeChatQRCodeTest.cs index 82e23e376..fe4e94981 100644 --- a/test/OpenCvSharp.Tests/wechat_qrcode/WeChatQRCodeTest.cs +++ b/test/OpenCvSharp.Tests/wechat_qrcode/WeChatQRCodeTest.cs @@ -3,31 +3,24 @@ namespace OpenCvSharp.Tests.WeChatQRCode; -public class WeChatQRCodeTest : TestBase +public class WeChatQRCodeTest(ITestOutputHelper testOutputHelper) : TestBase { - const string _wechat_QCODE_detector_prototxt_path = "_data/wechat_qrcode/detect.prototxt"; - const string _wechat_QCODE_detector_caffe_model_path = "_data/wechat_qrcode/detect.caffemodel"; - const string _wechat_QCODE_super_resolution_prototxt_path = "_data/wechat_qrcode/sr.prototxt"; - const string _wechat_QCODE_super_resolution_caffe_model_path = "_data/wechat_qrcode/sr.caffemodel"; - - private readonly ITestOutputHelper _testOutputHelper; - - public WeChatQRCodeTest(ITestOutputHelper testOutputHelper) - { - _testOutputHelper = testOutputHelper; - } + private const string WechatQcodeDetectorPrototxtPath = "_data/wechat_qrcode/detect.prototxt"; + private const string WechatQcodeDetectorCaffeModelPath = "_data/wechat_qrcode/detect.caffemodel"; + private const string WechatQcodeSuperResolutionPrototxtPath = "_data/wechat_qrcode/sr.prototxt"; + private const string WechatQcodeSuperResolutionCaffeModelPath = "_data/wechat_qrcode/sr.caffemodel"; [Fact] public void WechatQrcodeDecodeRun() { - Assert.True(File.Exists(_wechat_QCODE_detector_prototxt_path), $"DetectorPrototxt '{_wechat_QCODE_detector_prototxt_path}' not found"); - Assert.True(File.Exists(_wechat_QCODE_detector_caffe_model_path), $"DetectorcaffeModel '{_wechat_QCODE_detector_caffe_model_path}' not found"); - Assert.True(File.Exists(_wechat_QCODE_super_resolution_prototxt_path), $"SuperResolutionprototxt '{_wechat_QCODE_super_resolution_prototxt_path}' not found"); - Assert.True(File.Exists(_wechat_QCODE_super_resolution_caffe_model_path), $"SuperResolutionCaffe_model '{_wechat_QCODE_super_resolution_caffe_model_path}' not found"); + Assert.True(File.Exists(WechatQcodeDetectorPrototxtPath), $"DetectorPrototxt '{WechatQcodeDetectorPrototxtPath}' not found"); + Assert.True(File.Exists(WechatQcodeDetectorCaffeModelPath), $"DetectorcaffeModel '{WechatQcodeDetectorCaffeModelPath}' not found"); + Assert.True(File.Exists(WechatQcodeSuperResolutionPrototxtPath), $"SuperResolutionprototxt '{WechatQcodeSuperResolutionPrototxtPath}' not found"); + Assert.True(File.Exists(WechatQcodeSuperResolutionCaffeModelPath), $"SuperResolutionCaffe_model '{WechatQcodeSuperResolutionCaffeModelPath}' not found"); using var wechatQrcode = OpenCvSharp.WeChatQRCode.Create( - _wechat_QCODE_detector_prototxt_path, _wechat_QCODE_detector_caffe_model_path, - _wechat_QCODE_super_resolution_prototxt_path, _wechat_QCODE_super_resolution_caffe_model_path); + WechatQcodeDetectorPrototxtPath, WechatQcodeDetectorCaffeModelPath, + WechatQcodeSuperResolutionPrototxtPath, WechatQcodeSuperResolutionCaffeModelPath); using var src = Cv2.ImRead(@"_data/image/qr_multi.png", ImreadModes.Grayscale); wechatQrcode.DetectAndDecode(src, out var rects, out var texts); @@ -35,7 +28,7 @@ public void WechatQrcodeDecodeRun() Assert.Equal(2, texts.Length); foreach (var item in texts) { - _testOutputHelper.WriteLine(item); + testOutputHelper.WriteLine(item); Assert.NotEmpty(item); } }