Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jbe2277 committed Nov 22, 2023
1 parent 6205e25 commit baa1f7f
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 20 deletions.
3 changes: 3 additions & 0 deletions src/MusicManager/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ public SelectionService()

public void Initialize(IEnumerable<MusicFile> musicFiles)
{
MusicFiles = new ObservableListView<MusicFileDataModel>(new SynchronizingCollection<MusicFileDataModel, MusicFile>(musicFiles, x => new MusicFileDataModel(x)));
MusicFiles = new ObservableListView<MusicFileDataModel>(new SynchronizingList<MusicFileDataModel, MusicFile>(musicFiles, x => new MusicFileDataModel(x)));
}
}
2 changes: 1 addition & 1 deletion src/MusicManager/MusicManager.Applications/TaskUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public static TResult GetResult<TResult>(this Task<TResult> 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<Task> tasks)
{
if (tasks == null) throw new ArgumentNullException(nameof(tasks));
ArgumentNullException.ThrowIfNull(tasks);

var tasksArray = tasks.ToArray();
var taskCompletionSource = new TaskCompletionSource<object?>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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] };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>(),
Artists = [],
Title = "",
}, @"C:\Users\Public\Music\Dancefloor\Culture Beat - Mr. Vain.mp3")
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>(),
Artists = [],
Title = "",
}, @"C:\Users\Public\Music\Dancefloor\Culture Beat - Serenity"),
new MusicFile(x => { throw new InvalidOperationException("Sample exception."); }, @"C:\corruptfile.mp3")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>(),
Artists = [],
Title = "",
}, @"C:\Users\Public\Music\Dancefloor\Culture Beat - Serenity.mp4"),
};
Expand Down
Binary file modified src/MusicManager/MusicManager.Presentation/GlobalSuppressions.cs
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ internal static SaveMetadata GetSaveMetadata(string fileExtension)
private static IReadOnlyList<string> AddMoreExtensionsWhenSupported(IReadOnlyList<string> extensions)
{
IEnumerable<string> 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();
}
}

0 comments on commit baa1f7f

Please sign in to comment.