From 9bb7cb1a6ce025be1f092dde5fa529d4a4e5621a Mon Sep 17 00:00:00 2001 From: AntonyCorbett Date: Fri, 8 Oct 2021 15:23:53 +0100 Subject: [PATCH] update localisation. Tidy code --- .editorconfig | 6 ++++++ .../Services/CommandLine/CommandLineService.cs | 4 +++- .../Services/WebShortcuts/WebShortcutHelper.cs | 4 +++- OnlyM.CoreSys/GraphicsUtils.cs | 12 ++++++++---- .../Services/MetaDataQueue/MetaDataQueueProducer.cs | 2 +- OnlyM/Services/Pages/PageService.cs | 5 +---- OnlyM/ViewModel/OperatorViewModel.cs | 2 +- OnlyM/ViewModel/SettingsViewModel.cs | 2 ++ OnlyM/Windows/OperatorPage.xaml.cs | 2 +- OnlyMSlideManager/ViewModel/MainViewModel.cs | 8 ++++---- SolutionInfo.cs | 2 +- 11 files changed, 31 insertions(+), 18 deletions(-) diff --git a/.editorconfig b/.editorconfig index 9bd5652f..d3672058 100644 --- a/.editorconfig +++ b/.editorconfig @@ -299,3 +299,9 @@ dotnet_diagnostic.S3928.severity = silent # SA1009: Closing parenthesis should be spaced correctly dotnet_diagnostic.SA1009.severity = silent + +# CC0021: Use nameof +dotnet_diagnostic.CC0021.severity = silent + +# CC0022: Should dispose object +dotnet_diagnostic.CC0022.severity = silent diff --git a/OnlyM.Core/Services/CommandLine/CommandLineService.cs b/OnlyM.Core/Services/CommandLine/CommandLineService.cs index e61bda46..c42eb5c3 100644 --- a/OnlyM.Core/Services/CommandLine/CommandLineService.cs +++ b/OnlyM.Core/Services/CommandLine/CommandLineService.cs @@ -54,11 +54,13 @@ public CommandLineService() } } #pragma warning disable RCS1075 // Avoid empty catch clause that catches System.Exception. +#pragma warning disable CC0004 // Catch block cannot be empty catch (Exception) -#pragma warning restore RCS1075 // Avoid empty catch clause that catches System.Exception. { // ignored } +#pragma warning restore CC0004 // Catch block cannot be empty +#pragma warning restore RCS1075 // Avoid empty catch clause that catches System.Exception. return null; } diff --git a/OnlyM.Core/Services/WebShortcuts/WebShortcutHelper.cs b/OnlyM.Core/Services/WebShortcuts/WebShortcutHelper.cs index ef36547e..d335eda2 100644 --- a/OnlyM.Core/Services/WebShortcuts/WebShortcutHelper.cs +++ b/OnlyM.Core/Services/WebShortcuts/WebShortcutHelper.cs @@ -54,11 +54,13 @@ private void Init() } } #pragma warning disable RCS1075 // Avoid empty catch clause that catches System.Exception. +#pragma warning disable CC0004 // Catch block cannot be empty catch (Exception) -#pragma warning restore RCS1075 // Avoid empty catch clause that catches System.Exception. { // nothing } +#pragma warning restore CC0004 // Catch block cannot be empty +#pragma warning restore RCS1075 // Avoid empty catch clause that catches System.Exception. finally { _initialised = true; diff --git a/OnlyM.CoreSys/GraphicsUtils.cs b/OnlyM.CoreSys/GraphicsUtils.cs index 4bbbc7f2..70c5aecc 100644 --- a/OnlyM.CoreSys/GraphicsUtils.cs +++ b/OnlyM.CoreSys/GraphicsUtils.cs @@ -64,10 +64,14 @@ public static bool AutoRotateIfRequired(string? itemFilePath) { AutoRotateIfRequired(itemFilePath); - var settings = new ProcessImageSettings { Width = width, Height = height }; - settings.ResizeMode = CropScaleMode.Pad; - settings.MatteColor = System.Drawing.Color.Black; - + var settings = new ProcessImageSettings + { + Width = width, + Height = height, + ResizeMode = CropScaleMode.Pad, + MatteColor = System.Drawing.Color.Black + }; + using var outStream = new MemoryStream(); MagicImageProcessor.ProcessImage(itemFilePath, outStream, settings); outStream.Seek(0L, SeekOrigin.Begin); diff --git a/OnlyM/Services/MetaDataQueue/MetaDataQueueProducer.cs b/OnlyM/Services/MetaDataQueue/MetaDataQueueProducer.cs index bde77f47..e1a7c494 100644 --- a/OnlyM/Services/MetaDataQueue/MetaDataQueueProducer.cs +++ b/OnlyM/Services/MetaDataQueue/MetaDataQueueProducer.cs @@ -8,7 +8,7 @@ namespace OnlyM.Services.MetaDataQueue { internal sealed class MetaDataQueueProducer : IDisposable { - public BlockingCollection Queue { get; } = new BlockingCollection(); + public BlockingCollection Queue { get; } = new(); public void Add(MediaItem mediaItem) { diff --git a/OnlyM/Services/Pages/PageService.cs b/OnlyM/Services/Pages/PageService.cs index 19dba657..7a219d4e 100644 --- a/OnlyM/Services/Pages/PageService.cs +++ b/OnlyM/Services/Pages/PageService.cs @@ -119,10 +119,7 @@ public void GotoOperatorPage() public void GotoSettingsPage() { -#pragma warning disable SA1312 // Variable names should begin with lower-case letter - var _ = _settingsPage.Value; // ensure created otherwise doesn't receive navigation event -#pragma warning restore SA1312 // Variable names should begin with lower-case letter - + _ = _settingsPage.Value; // ensure created otherwise doesn't receive navigation event _operatorPageScrollerPosition = ScrollViewer?.VerticalOffset ?? 0.0; OnNavigationEvent(new NavigationEventArgs { PageName = SettingsPageName }); } diff --git a/OnlyM/ViewModel/OperatorViewModel.cs b/OnlyM/ViewModel/OperatorViewModel.cs index a10bb7d3..3a1aa866 100644 --- a/OnlyM/ViewModel/OperatorViewModel.cs +++ b/OnlyM/ViewModel/OperatorViewModel.cs @@ -1200,7 +1200,7 @@ private void HandleAllowMirrorChangedEvent(object? sender, EventArgs e) private static bool IsInDesignMode() { #if DEBUG - DependencyObject dep = new(); + var dep = new DependencyObject(); return DesignerProperties.GetIsInDesignMode(dep); #else return false; diff --git a/OnlyM/ViewModel/SettingsViewModel.cs b/OnlyM/ViewModel/SettingsViewModel.cs index 6ff5c4ff..34984199 100644 --- a/OnlyM/ViewModel/SettingsViewModel.cs +++ b/OnlyM/ViewModel/SettingsViewModel.cs @@ -1215,10 +1215,12 @@ private static LanguageItem[] GetSupportedLanguages() LanguageName = c.EnglishName, }); } +#pragma warning disable CC0004 // Catch block cannot be empty catch (CultureNotFoundException) { // expected } +#pragma warning restore CC0004 // Catch block cannot be empty } } diff --git a/OnlyM/Windows/OperatorPage.xaml.cs b/OnlyM/Windows/OperatorPage.xaml.cs index 45a1ec81..3a01e0c8 100644 --- a/OnlyM/Windows/OperatorPage.xaml.cs +++ b/OnlyM/Windows/OperatorPage.xaml.cs @@ -43,7 +43,7 @@ private static void HandleMirrorCheckBoxChanged(object? sender, bool isChecked) private void OnlyMOperatorPage_SizeChanged(object? sender, SizeChangedEventArgs e) { - OperatorViewModel vm = (OperatorViewModel)DataContext; + var vm = (OperatorViewModel?)DataContext; if (vm == null) { diff --git a/OnlyMSlideManager/ViewModel/MainViewModel.cs b/OnlyMSlideManager/ViewModel/MainViewModel.cs index d220bceb..d375b8d8 100644 --- a/OnlyMSlideManager/ViewModel/MainViewModel.cs +++ b/OnlyMSlideManager/ViewModel/MainViewModel.cs @@ -77,9 +77,7 @@ public MainViewModel( AddDesignTimeItems(); // init options so that UI locale is set (forces lazy init) -#pragma warning disable SA1312 // Variable names should begin with lower-case letter - var _ = _optionsService.Culture; -#pragma warning restore SA1312 // Variable names should begin with lower-case letter + _ = _optionsService.Culture; InitCommands(); WeakReferenceMessenger.Default.Register(this, OnReorderMessage); @@ -1021,10 +1019,12 @@ private static LanguageItem[] GetSupportedLanguages() LanguageName = c.EnglishName, }); } +#pragma warning disable CC0004 // Catch block cannot be empty catch (CultureNotFoundException) { // expected } +#pragma warning restore CC0004 // Catch block cannot be empty } } @@ -1050,7 +1050,7 @@ private string GetStandardStatusText() private static bool IsInDesignMode() { #if DEBUG - DependencyObject dep = new(); + var dep = new DependencyObject(); return DesignerProperties.GetIsInDesignMode(dep); #else return false; diff --git a/SolutionInfo.cs b/SolutionInfo.cs index c2265815..79e0e861 100644 --- a/SolutionInfo.cs +++ b/SolutionInfo.cs @@ -8,4 +8,4 @@ [assembly: AssemblyCulture("")] [assembly: NeutralResourcesLanguage("en-GB")] -[assembly: AssemblyVersion("2.0.0.11")] +[assembly: AssemblyVersion("2.0.0.12")]