diff --git a/src/MusicManager/.editorconfig b/src/MusicManager/.editorconfig index 416f72c..7fecf02 100644 --- a/src/MusicManager/.editorconfig +++ b/src/MusicManager/.editorconfig @@ -6,6 +6,9 @@ dotnet_diagnostic.CA1031.severity = none # CA1062: Validate arguments of public methods dotnet_diagnostic.CA1062.severity = none +# CA1860: Avoid using 'Enumerable.Any()' extension method +dotnet_diagnostic.CA1860.severity = none + # CA2007: Consider calling ConfigureAwait on the awaited task dotnet_diagnostic.CA2007.severity = none diff --git a/src/MusicManager/MusicManager.Applications/Services/SelectionService.cs b/src/MusicManager/MusicManager.Applications/Services/SelectionService.cs index edae6e0..2d9d043 100644 --- a/src/MusicManager/MusicManager.Applications/Services/SelectionService.cs +++ b/src/MusicManager/MusicManager.Applications/Services/SelectionService.cs @@ -20,6 +20,6 @@ public SelectionService() public void Initialize(IEnumerable musicFiles) { - MusicFiles = new ObservableListView(new SynchronizingCollection(musicFiles, x => new MusicFileDataModel(x))); + MusicFiles = new ObservableListView(new SynchronizingList(musicFiles, x => new MusicFileDataModel(x))); } } diff --git a/src/MusicManager/MusicManager.Applications/TaskUtility.cs b/src/MusicManager/MusicManager.Applications/TaskUtility.cs index be0e0cb..7850a6a 100644 --- a/src/MusicManager/MusicManager.Applications/TaskUtility.cs +++ b/src/MusicManager/MusicManager.Applications/TaskUtility.cs @@ -11,7 +11,7 @@ public static TResult GetResult(this Task task) // Similar as Task.WhenAll but the task completes after the first one throws an exception (does not wait for all other tasks to complete). public static Task WhenAllFast(IEnumerable tasks) { - if (tasks == null) throw new ArgumentNullException(nameof(tasks)); + ArgumentNullException.ThrowIfNull(tasks); var tasksArray = tasks.ToArray(); var taskCompletionSource = new TaskCompletionSource(); diff --git a/src/MusicManager/MusicManager.Applications/ViewModels/MusicPropertiesViewModel.cs b/src/MusicManager/MusicManager.Applications/ViewModels/MusicPropertiesViewModel.cs index 1d1e377..3cb2d13 100644 --- a/src/MusicManager/MusicManager.Applications/ViewModels/MusicPropertiesViewModel.cs +++ b/src/MusicManager/MusicManager.Applications/ViewModels/MusicPropertiesViewModel.cs @@ -62,7 +62,7 @@ private bool CanAutoFillFromFileName() private void AutoFillFromFileName() { var fileName = Path.GetFileNameWithoutExtension(MusicFile?.FileName) ?? throw new InvalidOperationException("MusicFile?.FileName must not be null"); - var metadata = fileName.Split(new[] { '-' }, 2).Select(x => x.Trim()).ToArray(); + var metadata = fileName.Split(['-'], 2).Select(x => x.Trim()).ToArray(); if (metadata.Length == 2) { MusicFile!.Metadata!.Artists = new[] { metadata[0] }; diff --git a/src/MusicManager/MusicManager.Presentation/Controls/ToolTipBehavior.cs b/src/MusicManager/MusicManager.Presentation/Controls/ToolTipBehavior.cs index 2968d78..b49456c 100644 --- a/src/MusicManager/MusicManager.Presentation/Controls/ToolTipBehavior.cs +++ b/src/MusicManager/MusicManager.Presentation/Controls/ToolTipBehavior.cs @@ -11,13 +11,13 @@ public static class ToolTipBehavior [AttachedPropertyBrowsableForType(typeof(TextBlock))] public static bool GetAutoToolTip(DependencyObject element) { - if (element == null) throw new ArgumentNullException(nameof(element)); + ArgumentNullException.ThrowIfNull(element); return (bool)element.GetValue(AutoToolTipProperty); } public static void SetAutoToolTip(DependencyObject element, bool value) { - if (element == null) throw new ArgumentNullException(nameof(element)); + ArgumentNullException.ThrowIfNull(element); element.SetValue(AutoToolTipProperty, value); } diff --git a/src/MusicManager/MusicManager.Presentation/DesignData/SampleManagerViewModel.cs b/src/MusicManager/MusicManager.Presentation/DesignData/SampleManagerViewModel.cs index 325f4e9..5673155 100644 --- a/src/MusicManager/MusicManager.Presentation/DesignData/SampleManagerViewModel.cs +++ b/src/MusicManager/MusicManager.Presentation/DesignData/SampleManagerViewModel.cs @@ -14,18 +14,18 @@ public class SampleManagerViewModel : ManagerViewModel { new SampleMusicFile(new MusicMetadata(new TimeSpan(0, 3, 45), 320) { - Artists = new[] { @"Culture Beat" }, + Artists = [ @"Culture Beat" ], Title = @"Serenity (Epilog)", }, @"C:\Users\Public\Music\Dancefloor\Culture Beat - Serenity.mp3"), new SampleMusicFile(new MusicMetadata(new TimeSpan(0, 2, 2), 320) { - Artists = new[] { "First artist", "Second artist" }, + Artists = [ "First artist", "Second artist" ], Title = "", }, ""), new SampleMusicFile(new MusicMetadata(new TimeSpan(1, 33, 0), 320) { - Artists = Array.Empty(), + Artists = [], Title = "", }, @"C:\Users\Public\Music\Dancefloor\Culture Beat - Mr. Vain.mp3") }; diff --git a/src/MusicManager/MusicManager.Presentation/DesignData/SampleMusicPropertiesViewModel.cs b/src/MusicManager/MusicManager.Presentation/DesignData/SampleMusicPropertiesViewModel.cs index ab8422e..d2670c3 100644 --- a/src/MusicManager/MusicManager.Presentation/DesignData/SampleMusicPropertiesViewModel.cs +++ b/src/MusicManager/MusicManager.Presentation/DesignData/SampleMusicPropertiesViewModel.cs @@ -10,9 +10,9 @@ public SampleMusicPropertiesViewModel() : base(new MockMusicPropertiesView(), nu { MusicFile = new SampleMusicFile(new MusicMetadata(new TimeSpan(0, 3, 45), 320000) { - Artists = new[] { @"Culture Beat" }, + Artists = [ @"Culture Beat" ], Title = @"Serenity (Epilog)", - Genre = new[] { "Electronic", "Dance" } + Genre = [ "Electronic", "Dance" ] }, @"C:\Users\Public\Music\Dancefloor\Culture Beat - Serenity"); } diff --git a/src/MusicManager/MusicManager.Presentation/DesignData/SamplePlayerViewModel.cs b/src/MusicManager/MusicManager.Presentation/DesignData/SamplePlayerViewModel.cs index cde877e..f01369b 100644 --- a/src/MusicManager/MusicManager.Presentation/DesignData/SamplePlayerViewModel.cs +++ b/src/MusicManager/MusicManager.Presentation/DesignData/SamplePlayerViewModel.cs @@ -13,9 +13,9 @@ public SamplePlayerViewModel() : base(new MockPlayerView(), null!, null!) { CurrentItem = new PlaylistItem(new SampleMusicFile(new MusicMetadata(new TimeSpan(0, 3, 45), 320) { - Artists = new[] { @"Culture Beat" }, + Artists = [ @"Culture Beat" ], Title = @"Serenity (Epilog)", - Genre = new[] { "Electronic", "Dance" } + Genre = [ "Electronic", "Dance" ] }, @"C:\Users\Public\Music\Dancefloor\Culture Beat - Serenity")) }; } diff --git a/src/MusicManager/MusicManager.Presentation/DesignData/SamplePlaylistViewModel.cs b/src/MusicManager/MusicManager.Presentation/DesignData/SamplePlaylistViewModel.cs index dc44cfb..f135f9f 100644 --- a/src/MusicManager/MusicManager.Presentation/DesignData/SamplePlaylistViewModel.cs +++ b/src/MusicManager/MusicManager.Presentation/DesignData/SamplePlaylistViewModel.cs @@ -13,17 +13,17 @@ public SamplePlaylistViewModel() : base(new MockPlaylistView()) { new SampleMusicFile(new MusicMetadata(new TimeSpan(0, 3, 45), 320000) { - Artists = new[] { @"Culture Beat" }, + Artists = [ @"Culture Beat" ], Title = @"Serenity (Epilog)", }, @"C:\Users\Public\Music\Dancefloor\Culture Beat - Serenity"), new SampleMusicFile(new MusicMetadata(new TimeSpan(0, 2, 2), 320000) { - Artists = new[] { "First artist", "Second artist" }, + Artists = [ "First artist", "Second artist" ], Title = "This track has a very long title. Let's see how the UI handles this.", }, ""), new SampleMusicFile(new MusicMetadata(new TimeSpan(1, 33, 0), 320000) { - Artists = Array.Empty(), + Artists = [], Title = "", }, @"C:\Users\Public\Music\Dancefloor\Culture Beat - Serenity"), new MusicFile(x => { throw new InvalidOperationException("Sample exception."); }, @"C:\corruptfile.mp3") diff --git a/src/MusicManager/MusicManager.Presentation/DesignData/SampleTranscodingListViewModel.cs b/src/MusicManager/MusicManager.Presentation/DesignData/SampleTranscodingListViewModel.cs index c079566..12f4dcb 100644 --- a/src/MusicManager/MusicManager.Presentation/DesignData/SampleTranscodingListViewModel.cs +++ b/src/MusicManager/MusicManager.Presentation/DesignData/SampleTranscodingListViewModel.cs @@ -13,17 +13,17 @@ public SampleTranscodingListViewModel() : base(new MockTranscodingListView(), nu { new SampleMusicFile(new MusicMetadata(new TimeSpan(0, 3, 45), 320000) { - Artists = new[] { @"Culture Beat" }, + Artists = [ @"Culture Beat" ], Title = @"Serenity (Epilog)", }, @"C:\Users\Public\Music\Dancefloor\Culture Beat - Serenity.waf"), new SampleMusicFile(new MusicMetadata(new TimeSpan(0, 2, 2), 320000) { - Artists = new[] { "First artist", "Second artist" }, + Artists = [ "First artist", "Second artist" ], Title = "This track has a very long title. Let's see how the UI handles this.", }, @"C:\Users\Public\Music\test.m4a"), new SampleMusicFile(new MusicMetadata(new TimeSpan(1, 33, 0), 320000) { - Artists = Array.Empty(), + Artists = [], Title = "", }, @"C:\Users\Public\Music\Dancefloor\Culture Beat - Serenity.mp4"), }; diff --git a/src/MusicManager/MusicManager.Presentation/GlobalSuppressions.cs b/src/MusicManager/MusicManager.Presentation/GlobalSuppressions.cs index c155262..4a39766 100644 Binary files a/src/MusicManager/MusicManager.Presentation/GlobalSuppressions.cs and b/src/MusicManager/MusicManager.Presentation/GlobalSuppressions.cs differ diff --git a/src/MusicManager/MusicManager.Presentation/Services/SupportedFileTypes.cs b/src/MusicManager/MusicManager.Presentation/Services/SupportedFileTypes.cs index 4190a96..fb3bd7a 100644 --- a/src/MusicManager/MusicManager.Presentation/Services/SupportedFileTypes.cs +++ b/src/MusicManager/MusicManager.Presentation/Services/SupportedFileTypes.cs @@ -106,8 +106,8 @@ internal static SaveMetadata GetSaveMetadata(string fileExtension) private static IReadOnlyList AddMoreExtensionsWhenSupported(IReadOnlyList extensions) { IEnumerable result = extensions; - if (IsFlacSupported) result = result.Concat(new[] { ".flac" }); - if (IsMkvSupported) result = result.Concat(new[] { ".mkv" }); + if (IsFlacSupported) result = result.Concat([ ".flac" ]); + if (IsMkvSupported) result = result.Concat([ ".mkv" ]); return result.ToArray(); } }