Skip to content

Commit

Permalink
ConfigureAwait
Browse files Browse the repository at this point in the history
  • Loading branch information
geloczi committed Dec 27, 2021
1 parent acfe7fc commit 71f0282
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 29 deletions.
8 changes: 5 additions & 3 deletions SynologyDotNet.AudioStation/AudioStationClient.Album.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public async Task<ApiListRessponse<AlbumList>> ListAlbumsAsync(int limit, int of
if (!string.IsNullOrWhiteSpace(artist))
args.Add(("artist", artist));

return await Client.QueryListAsync<ApiListRessponse<AlbumList>>(SYNO_AudioStation_Album, "list", limit, offset, args.ToArray());
return await Client.QueryListAsync<ApiListRessponse<AlbumList>>(SYNO_AudioStation_Album, "list", limit, offset, args.ToArray()).ConfigureAwait(false);
}

/// <summary>
Expand All @@ -38,7 +38,8 @@ public async Task<ByteArrayData> GetAlbumCoverAsync(string artist, string album)
{
return await Client.QueryByteArrayAsync(SYNO_AudioStation_Cover, "getcover",
("album_name", album),
("album_artist_name", artist));
("album_artist_name", artist))
.ConfigureAwait(false);
}

/// <summary>
Expand All @@ -54,7 +55,8 @@ public async Task<ApiListRessponse<AlbumList>> SearchAlbumsByNameAsync(int limit
GetLibraryArg(),
("additional", "avg_rating"),
("keyword", keyword),
("filter", keyword));
("filter", keyword))
.ConfigureAwait(false);
}
}
}
10 changes: 6 additions & 4 deletions SynologyDotNet.AudioStation/AudioStationClient.Artist.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public async Task<ApiListRessponse<ArtistList>> ListArtistsAsync(int limit, int
{
return await Client.QueryListAsync<ApiListRessponse<ArtistList>>(SYNO_AudioStation_Artist, "list", limit, offset,
GetLibraryArg(),
("additional", "avg_rating"));
("additional", "avg_rating")).ConfigureAwait(false);
}

/// <summary>
Expand All @@ -32,7 +32,7 @@ public async Task<ApiListRessponse<ArtistList>> SearchArtistsByGenreAsync(int li
return await Client.QueryListAsync<ApiListRessponse<ArtistList>>(SYNO_AudioStation_Artist, "list", limit, offset,
GetLibraryArg(),
("additional", "avg_rating"),
("genre", genre));
("genre", genre)).ConfigureAwait(false);
}

/// <summary>
Expand All @@ -48,7 +48,8 @@ public async Task<ApiListRessponse<ArtistList>> SearchArtistsByNameAsync(int lim
GetLibraryArg(),
("additional", "avg_rating"),
("keyword", keyword),
("filter", keyword));
("filter", keyword))
.ConfigureAwait(false);
}

/// <summary>
Expand All @@ -60,7 +61,8 @@ public async Task<ByteArrayData> GetArtistCoverAsync(string artist)
{
return await Client.QueryByteArrayAsync(SYNO_AudioStation_Cover, "getcover",
GetLibraryArg(),
("artist_name", artist));
("artist_name", artist))
.ConfigureAwait(false);
}
}
}
6 changes: 4 additions & 2 deletions SynologyDotNet.AudioStation/AudioStationClient.Composer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public async Task<ApiListRessponse<ComposerList>> ListComposersAsync(int limit,
{
return await Client.QueryListAsync<ApiListRessponse<ComposerList>>(SYNO_AudioStation_Composer, "list", limit, offset,
GetLibraryArg(),
("additional", "avg_rating"));
("additional", "avg_rating"))
.ConfigureAwait(false);
}

/// <summary>
Expand All @@ -32,7 +33,8 @@ public async Task<ApiListRessponse<ComposerList>> SearchComposersByNameAsync(int
GetLibraryArg(),
("additional", "avg_rating"),
("keyword", keyword),
("filter", keyword));
("filter", keyword))
.ConfigureAwait(false);
}
}
}
6 changes: 4 additions & 2 deletions SynologyDotNet.AudioStation/AudioStationClient.Genre.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public async Task<ApiListRessponse<GenreList>> ListGenresAsync(int limit, int of
{
return await Client.QueryListAsync<ApiListRessponse<GenreList>>(SYNO_AudioStation_Genre, "list", limit, offset,
GetLibraryArg(),
("additional", "avg_rating"));
("additional", "avg_rating"))
.ConfigureAwait(false);
}

/// <summary>
Expand All @@ -32,7 +33,8 @@ public async Task<ApiListRessponse<GenreList>> SearchGenresByNameAsync(int limit
GetLibraryArg(),
("additional", "avg_rating"),
("keyword", keyword),
("filter", keyword));
("filter", keyword))
.ConfigureAwait(false);
}
}
}
4 changes: 2 additions & 2 deletions SynologyDotNet.AudioStation/AudioStationClient.Management.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public async Task<ApiResponse> StartReIndex()
{
var req = new RequestBuilder().SetEndpoint(UsermanEndpoint);
req["action"] = "do_reindex";
return await Client.QueryObjectAsync<ApiResponse>(req);
return await Client.QueryObjectAsync<ApiResponse>(req).ConfigureAwait(false);
}

/// <summary>
Expand All @@ -28,7 +28,7 @@ public async Task<ReIndexStateResponse> GetReIndexState()
{
var req = new RequestBuilder().SetEndpoint(UsermanEndpoint);
req["action"] = "load_reindex";
return await Client.QueryObjectAsync<ReIndexStateResponse>(req);
return await Client.QueryObjectAsync<ReIndexStateResponse>(req).ConfigureAwait(false);
}
}
}
10 changes: 5 additions & 5 deletions SynologyDotNet.AudioStation/AudioStationClient.Playlist.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public partial class AudioStationClient
public async Task<ApiListRessponse<PlaylistList>> ListPlaylistsAsync(int limit, int offset)
{
var result = await Client.QueryListAsync<ApiListRessponse<PlaylistList>>(SYNO_AudioStation_Playlist, "list", limit, offset,
GetLibraryArg());
GetLibraryArg()).ConfigureAwait(false);
return result;
}

Expand Down Expand Up @@ -53,10 +53,10 @@ public async Task<ApiDataResponse<Playlist>> GetPlaylistAsync(int limit, int off
}
args.Add(("additional", string.Join(",", additionalFieldNames)));

var test = await Client.QueryByteArrayAsync(SYNO_AudioStation_Playlist, "getinfo", args.ToArray());
var test = await Client.QueryByteArrayAsync(SYNO_AudioStation_Playlist, "getinfo", args.ToArray()).ConfigureAwait(false);
string json = Encoding.UTF8.GetString(test.Data);

var playlists = await Client.QueryListAsync<ApiListRessponse<PlaylistList>>(SYNO_AudioStation_Playlist, "getinfo", limit, offset, args.ToArray());
var playlists = await Client.QueryListAsync<ApiListRessponse<PlaylistList>>(SYNO_AudioStation_Playlist, "getinfo", limit, offset, args.ToArray()).ConfigureAwait(false);
return new ApiDataResponse<Playlist>(playlists, playlists.Data?.Playlists?.FirstOrDefault() ?? default);
}

Expand All @@ -73,7 +73,7 @@ public async Task<ApiResponse> AddSongsToPlaylist(string id, params string[] son
("offset", -1),
("limit", 0),
("songs", string.Join(",", songIds))
);
).ConfigureAwait(false);
}

/// <summary>
Expand All @@ -90,7 +90,7 @@ public async Task<ApiResponse> RemoveSongsFromPlaylist(string id, int startIndex
("offset", startIndex),
("limit", count),
("songs", string.Empty)
);
).ConfigureAwait(false);
}
}
}
10 changes: 5 additions & 5 deletions SynologyDotNet.AudioStation/AudioStationClient.Song.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public async Task<ApiListRessponse<SongList>> ListSongsAsync(int limit, int offs
.Where(x => additionalFields.HasFlag(x))
.Select(x => x.ToString()))));
}
return await Client.QueryListAsync<ApiListRessponse<SongList>>(SYNO_AudioStation_Song, "list", limit, offset, args.ToArray());
return await Client.QueryListAsync<ApiListRessponse<SongList>>(SYNO_AudioStation_Song, "list", limit, offset, args.ToArray()).ConfigureAwait(false);
}

/// <summary>
Expand All @@ -62,7 +62,7 @@ public async Task<ApiListRessponse<SongList>> SearchSongsByTitleAsync(int limit,
.Where(x => additionalFields.HasFlag(x))
.Select(x => x.ToString()))));
}
return await Client.QueryListAsync<ApiListRessponse<SongList>>(SYNO_AudioStation_Song, "search", limit, offset, args.ToArray());
return await Client.QueryListAsync<ApiListRessponse<SongList>>(SYNO_AudioStation_Song, "search", limit, offset, args.ToArray()).ConfigureAwait(false);
}

/// <summary>
Expand All @@ -75,7 +75,7 @@ public async Task<ApiListRessponse<SongList>> GetSongByIdAsync(string id)
var args = new List<(string, object)>();
args.Add(("id", id));
args.Add(("additional", "song_tag, song_audio, song_rating")); // request detailed song info
return await Client.QueryObjectAsync<ApiListRessponse<SongList>>(SYNO_AudioStation_Song, "getinfo", args.ToArray());
return await Client.QueryObjectAsync<ApiListRessponse<SongList>>(SYNO_AudioStation_Song, "getinfo", args.ToArray()).ConfigureAwait(false);
}

/// <summary>
Expand All @@ -90,7 +90,7 @@ public async Task<ApiResponse> RateSongAsync(string songId, int rating)
throw new ArgumentOutOfRangeException(nameof(rating), "Value range: 0 - 5");
return await Client.QueryObjectAsync<ApiResponse>(SYNO_AudioStation_Song, "setrating",
("id", songId),
("rating", rating));
("rating", rating)).ConfigureAwait(false);
}

/// <summary>
Expand All @@ -110,7 +110,7 @@ public async Task StreamSongAsync(
Action<StreamResult> readStreamAction)
{
var req = CreateSongStreamRequest(SYNO_AudioStation_Stream, transcode, songId, positionSeconds);
await Client.QueryStreamAsync(req, readStreamAction, cancellationToken);
await Client.QueryStreamAsync(req, readStreamAction, cancellationToken).ConfigureAwait(false);
}

private RequestBuilder CreateSongStreamRequest(string apiName, TranscodeMode transcode, string songId, double positionInSeconds)
Expand Down
4 changes: 2 additions & 2 deletions SynologyDotNet.AudioStation/AudioStationClient.Tag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public async Task<FileTags> GetSongFileTags(params string[] paths)
var req = new RequestBuilder().SetEndpoint(TagEditorEndpoint).Action("load");
req["audioInfos"] = JsonConvert.SerializeObject(paths.Select(p => new { path = p }));
req["requestFrom"] = string.Empty;
var result = await Client.QueryObjectAsync<FileTags>(req);
var result = await Client.QueryObjectAsync<FileTags>(req).ConfigureAwait(false);
return result;
}

Expand All @@ -46,7 +46,7 @@ public async Task<ApiResponse> SetSongFileTags(FileTagChange change)

var req = new RequestBuilder().SetEndpoint(TagEditorEndpoint).Action("apply");
req["data"] = JsonConvert.SerializeObject(new object[] { change });
var result = await Client.QueryObjectAsync<ApiResponse>(req);
var result = await Client.QueryObjectAsync<ApiResponse>(req).ConfigureAwait(false);
return result;
}

Expand Down
4 changes: 2 additions & 2 deletions SynologyDotNet.AudioStation/AudioStationClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public async Task<ApiDataResponse<SearchResults>> SearchAsync(string keyword)
args.Add(GetLibraryArg());
args.Add(("additional", "song_tag,song_audio,song_rating"));
args.Add(("keyword", keyword));
return await Client.QueryObjectAsync<ApiDataResponse<SearchResults>>(SYNO_AudioStation_Search, "list", args.ToArray());
return await Client.QueryObjectAsync<ApiDataResponse<SearchResults>>(SYNO_AudioStation_Search, "list", args.ToArray()).ConfigureAwait(false);
}

/// <summary>
Expand All @@ -96,7 +96,7 @@ public async Task<ApiListRessponse<FolderList>> ListFoldersAsync(int limit, int
if (!string.IsNullOrEmpty(folderId))
args.Add(("id", folderId));

return await Client.QueryListAsync<ApiListRessponse<FolderList>>(SYNO_AudioStation_Folder, "list", limit, offset, args.ToArray());
return await Client.QueryListAsync<ApiListRessponse<FolderList>>(SYNO_AudioStation_Folder, "list", limit, offset, args.ToArray()).ConfigureAwait(false);
}

// Use tageditor instead!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<!-- General -->
<PropertyGroup>
<Product>SynologyDotNet.AudioStation</Product>
<Version>0.4.1</Version>
<Version>0.4.2</Version>
<Description>SynologyDotNet.AudioStation</Description>
<RepositoryUrl>https://github.com/geloczigeri/synologydotnet-audiostation</RepositoryUrl>
<Authors>Gergő Gelóczi</Authors>
Expand Down Expand Up @@ -60,7 +60,7 @@
</When>
<Otherwise>
<ItemGroup>
<PackageReference Include="SynologyDotNet.Core" Version="0.4.2" />
<PackageReference Include="SynologyDotNet.Core" Version="0.4.3" />
</ItemGroup>
</Otherwise>
</Choose>
Expand Down

0 comments on commit 71f0282

Please sign in to comment.