Skip to content

Commit

Permalink
Use latest C# features
Browse files Browse the repository at this point in the history
  • Loading branch information
jerry08 committed Jul 13, 2024
1 parent ce7edd2 commit 0f0c6f5
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion Yosu.Soundcloud.Core/Resolving/QueryResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public async Task<QueryResult> ResolveAsync(

track!.ArtworkUrl ??= track.User?.AvatarUrl;

return new QueryResult(QueryResultKind.Track, track!.Title!, new[] { track });
return new QueryResult(QueryResultKind.Track, track!.Title!, [track]);
}

// Search
Expand Down
6 changes: 3 additions & 3 deletions Yosu.Soundcloud.Core/Tagging/MediaFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ internal partial class MediaFile : IDisposable
public MediaFile(TagFile file) => _file = file;

public void SetThumbnail(byte[] thumbnailData) =>
_file.Tag.Pictures = new IPicture[] { new Picture(thumbnailData) };
_file.Tag.Pictures = [new Picture(thumbnailData)];

public void SetArtist(string artist) => _file.Tag.Performers = new[] { artist };
public void SetArtist(string artist) => _file.Tag.Performers = [artist];

public void SetArtistSort(string artistSort) => _file.Tag.PerformersSort = new[] { artistSort };
public void SetArtistSort(string artistSort) => _file.Tag.PerformersSort = [artistSort];

public void SetTitle(string title) => _file.Tag.Title = title;

Expand Down
2 changes: 1 addition & 1 deletion Yosu.Soundcloud.Core/Tagging/MediaTagInjector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private async Task InjectMusicMetadataAsync(
private static void InjectTrackMetadataAsync(MediaFile mediaFile, Track track)
{
mediaFile.SetTitle(track.Title!);
mediaFile.SetPerformers(new[] { track.User!.Username! });
mediaFile.SetPerformers([track.User!.Username!]);
mediaFile.SetAlbum(track.User.Username!);
}

Expand Down
2 changes: 1 addition & 1 deletion Yosu.Spotify.Core/Resolving/QueryResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ await _spotify.Albums.GetAllTracksAsync(album.Id, cancellationToken)
if (isUrl && TrackId.TryParse(query) is { } trackId)
{
var track = await _spotify.Tracks.GetAsync(trackId, cancellationToken);
return new QueryResult(QueryResultKind.Track, track.Title, new[] { track });
return new QueryResult(QueryResultKind.Track, track.Title, [track]);
}

// Search
Expand Down
6 changes: 3 additions & 3 deletions Yosu.Spotify.Core/Tagging/MediaFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ public void SetThumbnail(byte[] thumbnailData)
Data = thumbnailData
};

_file.Tag.Pictures = new IPicture[] { picture };
_file.Tag.Pictures = [picture];
}

public void SetArtist(string artist) => _file.Tag.Performers = new[] { artist };
public void SetArtist(string artist) => _file.Tag.Performers = [artist];

public void SetArtistSort(string artistSort) => _file.Tag.PerformersSort = new[] { artistSort };
public void SetArtistSort(string artistSort) => _file.Tag.PerformersSort = [artistSort];

public void SetTitle(string title) => _file.Tag.Title = title;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void Apply(Laerdal.FFmpeg.Android.Statistics newStatistics)

public static void Init(IProgress<double>? progress, string filePath)
{
Init(progress, new[] { filePath });
Init(progress, [filePath]);
}

public static void Init(IProgress<double>? progress, IEnumerable<string> filePaths)
Expand Down
2 changes: 1 addition & 1 deletion Yosu.Youtube.Core/Downloading/VideoDownloadOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ IEnumerable<VideoDownloadOption> GetVideoAndAudioOptions()
yield return new VideoDownloadOption(
videoStreamInfo.Container,
false,
new IStreamInfo[] { videoStreamInfo, audioStreamInfo }
[videoStreamInfo, audioStreamInfo]
);
}
}
Expand Down
6 changes: 3 additions & 3 deletions Yosu.Youtube.Core/Tagging/MediaFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ public void SetThumbnail(byte[] thumbnailData)
Data = thumbnailData
};

_file.Tag.Pictures = new IPicture[] { picture };
_file.Tag.Pictures = [picture];
}

public void SetArtist(string artist) => _file.Tag.Performers = new[] { artist };
public void SetArtist(string artist) => _file.Tag.Performers = [artist];

public void SetArtistSort(string artistSort) => _file.Tag.PerformersSort = new[] { artistSort };
public void SetArtistSort(string artistSort) => _file.Tag.PerformersSort = [artistSort];

public void SetTitle(string title) => _file.Tag.Title = title;

Expand Down
4 changes: 2 additions & 2 deletions Yosu/Controls/ProgressBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ private void DrawProgress()
progressPaint.Shader = SKShader.CreateLinearGradient(
new SKPoint(_drawRect.Left, _drawRect.MidY),
new SKPoint(_drawRect.Right, _drawRect.MidY),
new[] { GradientColor.ToSKColor(), ProgressColor.ToSKColor() },
new[] { 0.0f, 1.0f },
[GradientColor.ToSKColor(), ProgressColor.ToSKColor()],
[0.0f, 1.0f],
SKShaderTileMode.Clamp
);
}
Expand Down
6 changes: 3 additions & 3 deletions Yosu/Platforms/Android/Extensions/ActivityExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ public static async Task CopyFileAsync(
{
MediaScannerConnection.ScanFile(
context,
new[] { newFilePath },
new[] { mimeType },
[newFilePath],
[mimeType],
null
);
}
Expand Down Expand Up @@ -178,6 +178,6 @@ private static async Task CopyFileUsingMediaStoreAsync(
if (output is not null)
await input.CopyToAsync(output, defaultBufferSize, cancellationToken);

MediaScannerConnection.ScanFile(context, new[] { newFilePath }, new[] { mimeType }, null);
MediaScannerConnection.ScanFile(context, [newFilePath], [mimeType], null);
}
}
22 changes: 11 additions & 11 deletions Yosu/Platforms/Android/MainActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@
namespace Yosu;

[IntentFilter(
actions: new[] { Intent.ActionView },
actions: [Intent.ActionView],
Label = "Download in Yosu",
Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable },
DataSchemes = new[] { "http", "https" },
DataHosts = new[] { "youtube.com", "youtu.be", "on.soundcloud.com" },
DataPathPatterns = new[] { "/.*" }
Categories = [Intent.CategoryDefault, Intent.CategoryBrowsable],
DataSchemes = ["http", "https"],
DataHosts = ["youtube.com", "youtu.be", "on.soundcloud.com"],
DataPathPatterns = ["/.*"]
)]
[IntentFilter(
actions: new[] { Intent.ActionView },
actions: [Intent.ActionView],
Label = "Download in Yosu",
Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable },
DataSchemes = new[] { "http", "https" },
DataHosts = new[] { "soundcloud.com", "www.soundcloud.com", "m.soundcloud.com" },
DataPathPatterns = new[] { "/.*/.*" }
Categories = [Intent.CategoryDefault, Intent.CategoryBrowsable],
DataSchemes = ["http", "https"],
DataHosts = ["soundcloud.com", "www.soundcloud.com", "m.soundcloud.com"],
DataPathPatterns = ["/.*/.*"]
)]
//[IntentFilter(
// actions: new[] { Intent.ActionSend },
Expand Down Expand Up @@ -65,7 +65,7 @@ protected override async void OnCreate(Bundle? savedInstanceState)
{
ActivityCompat.RequestPermissions(
this,
new string[] { Manifest.Permission.PostNotifications },
[Manifest.Permission.PostNotifications],
PostNotificationsRequestCode
);
}
Expand Down
2 changes: 1 addition & 1 deletion Yosu/Utils/ObservableRangeCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public void RemoveRange(
/// <summary>
/// Clears the current collection and replaces it with the specified item.
/// </summary>
public void Replace(T item) => ReplaceRange(new T[] { item });
public void Replace(T item) => ReplaceRange([item]);

/// <summary>
/// Clears the current collection and replaces it with the specified collection.
Expand Down
4 changes: 2 additions & 2 deletions Yosu/ViewModels/MainCollectionViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,11 @@ async Task Download(DownloadViewModelBase entity)
break;

case SoundcloudDownloadViewModel download:
_soundcloudViewModel.EnqueueDownloads(new[] { download });
_soundcloudViewModel.EnqueueDownloads([download]);
break;

case SpotifyDownloadViewModel download:
_spotifyViewModel.EnqueueDownloads(new[] { download });
_spotifyViewModel.EnqueueDownloads([download]);
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Yosu/ViewModels/YoutubeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class YoutubeViewModel
public Container SelectedContainer { get; set; } = Container.Mp4;

public IReadOnlyList<Container> AvailableContainers { get; } =
new[] { Container.Mp4, Container.WebM, Container.Mp3, new Container("ogg") };
[Container.Mp4, Container.WebM, Container.Mp3, new Container("ogg")];

public IReadOnlyList<VideoQualityPreference> AvailableVideoQualityPreferences { get; } =
Enum.GetValues<VideoQualityPreference>().Reverse().ToArray();
Expand Down

0 comments on commit 0f0c6f5

Please sign in to comment.