Skip to content

Commit

Permalink
Fix nullability for 10.10 (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
crobibero authored Oct 26, 2024
1 parent cbf76f7 commit e1d1b24
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,13 @@ public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(BookInfo sea
{
cancellationToken.ThrowIfCancellationRequested();

Func<BookResult, RemoteSearchResult> getSearchResultFromBook = (BookResult info) =>
Func<BookResult, RemoteSearchResult?> getSearchResultFromBook = (BookResult info) =>
{
if (string.IsNullOrEmpty(info.Id))
{
return null;
}

var remoteSearchResult = new RemoteSearchResult();

remoteSearchResult.SetProviderId(GoogleBooksConstants.ProviderId, info.Id);
Expand Down Expand Up @@ -76,7 +81,8 @@ public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(BookInfo sea
return Enumerable.Empty<RemoteSearchResult>();
}

return new[] { getSearchResultFromBook(bookData) };
var searchResult = getSearchResultFromBook(bookData);
return searchResult is null ? [] : [searchResult];
}
else
{
Expand All @@ -94,7 +100,11 @@ public async Task<IEnumerable<RemoteSearchResult>> GetSearchResults(BookInfo sea
continue;
}

list.Add(getSearchResultFromBook(result));
var searchResult = getSearchResultFromBook(result);
if (searchResult is not null)
{
list.Add(searchResult);
}
}

return list;
Expand Down

0 comments on commit e1d1b24

Please sign in to comment.