Skip to content

Commit 137bd7f

Browse files
committed
.NET 8 Upgrade, Tests, API Updates
1 parent 4973130 commit 137bd7f

File tree

24 files changed

+816
-377
lines changed

24 files changed

+816
-377
lines changed

ScryfallApi.sln

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,14 @@ EndProject
1212
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{F938EC12-7230-41F9-A93F-44E9D4DCAF02}"
1313
ProjectSection(SolutionItems) = preProject
1414
.gitignore = .gitignore
15+
LICENSE = LICENSE
1516
README.md = README.md
1617
EndProjectSection
1718
EndProject
19+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{B74CFA8C-2018-4BB0-BA22-5FE277A1E430}"
20+
EndProject
21+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScryfallApi.Client.Tests", "tests\ScryfallApi.Client.Tests\ScryfallApi.Client.Tests.csproj", "{8B9E4443-4432-4DE6-B1A4-D27967D04CDA}"
22+
EndProject
1823
Global
1924
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2025
Debug|Any CPU = Debug|Any CPU
@@ -29,12 +34,17 @@ Global
2934
{383BF6C1-47B7-47E8-8428-B3A114EFC3B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
3035
{383BF6C1-47B7-47E8-8428-B3A114EFC3B0}.Release|Any CPU.ActiveCfg = Release|Any CPU
3136
{383BF6C1-47B7-47E8-8428-B3A114EFC3B0}.Release|Any CPU.Build.0 = Release|Any CPU
37+
{8B9E4443-4432-4DE6-B1A4-D27967D04CDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
38+
{8B9E4443-4432-4DE6-B1A4-D27967D04CDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
39+
{8B9E4443-4432-4DE6-B1A4-D27967D04CDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
40+
{8B9E4443-4432-4DE6-B1A4-D27967D04CDA}.Release|Any CPU.Build.0 = Release|Any CPU
3241
EndGlobalSection
3342
GlobalSection(SolutionProperties) = preSolution
3443
HideSolutionNode = FALSE
3544
EndGlobalSection
3645
GlobalSection(NestedProjects) = preSolution
3746
{383BF6C1-47B7-47E8-8428-B3A114EFC3B0} = {C470746D-B24E-4759-B7A3-6C8EDD801544}
47+
{8B9E4443-4432-4DE6-B1A4-D27967D04CDA} = {B74CFA8C-2018-4BB0-BA22-5FE277A1E430}
3848
EndGlobalSection
3949
GlobalSection(ExtensibilityGlobals) = postSolution
4050
SolutionGuid = {4C1168D1-1DC7-410F-9D8C-E23492A1FD2F}

samples/ScryfallApi.WebSample/Pages/Cards.cshtml.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Threading.Tasks;
51
using Microsoft.AspNetCore.Mvc;
62
using Microsoft.AspNetCore.Mvc.RazorPages;
73
using Microsoft.AspNetCore.Mvc.Rendering;
@@ -14,7 +10,7 @@ public class CardsModel : PageModel
1410
{
1511
private readonly ScryfallApiClient _scryfallApi;
1612
public List<SelectListItem> SetList { get; set; }
17-
public ICollection<Card> CardList { get; set; }
13+
public IReadOnlyCollection<Card> CardList { get; set; }
1814

1915
public CardsModel(ScryfallApiClient scryfallApi)
2016
{
@@ -33,7 +29,7 @@ public async Task<IActionResult> OnGet([FromQuery] string set)
3329
CardList = (await _scryfallApi.Cards.Search($"e:{selectedItem.Value}", 1, SearchOptions.CardSort.Name)).Data;
3430
}
3531
else
36-
CardList = new List<Card>();
32+
CardList = [];
3733

3834
return Page();
3935
}

samples/ScryfallApi.WebSample/ScryfallApi.WebSample.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<ImplicitUsings>enable</ImplicitUsings>
77
</PropertyGroup>

src/ScryfallApi.Client/Apis/Cards.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ internal Cards(BaseRestService restService)
1717
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
1818
public Task<ResultList<Card>> Get(int page) => _restService.GetAsync<ResultList<Card>>($"/cards?page={page}");
1919

20-
public Task<Card> GetRandom() => _restService.GetAsync<Card>($"/cards/random", false);
20+
public Task<Card> GetRandom() => _restService.GetAsync<Card>("/cards/random", false);
2121

2222
public Task<ResultList<Card>> Search(string query, int page, CardSort sort) =>
2323
Search(query, page, new SearchOptions { Sort = sort });

src/ScryfallApi.Client/Apis/Catalogs.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ internal Catalogs(BaseRestService restService)
1313
}
1414

1515
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
16-
public async Task<string[]> ListCardNames() => (await _restService.GetAsync<Catalog>("/catalog/card-names").ConfigureAwait(false)).Data;
17-
public async Task<string[]> ListWordBank() => (await _restService.GetAsync<Catalog>("/catalog/word-bank").ConfigureAwait(false)).Data;
18-
public async Task<string[]> ListCreatureTypes() => (await _restService.GetAsync<Catalog>("/catalog/creature-types").ConfigureAwait(false)).Data;
19-
public async Task<string[]> ListPlaneswalkerTypes() => (await _restService.GetAsync<Catalog>("/catalog/planeswalker-types").ConfigureAwait(false)).Data;
20-
public async Task<string[]> ListLandTypes() => (await _restService.GetAsync<Catalog>("/catalog/land-types").ConfigureAwait(false)).Data;
21-
public async Task<string[]> ListSpellTypes() => (await _restService.GetAsync<Catalog>("/catalog/spell-types").ConfigureAwait(false)).Data;
22-
public async Task<string[]> ListEnchantmentTypes() => (await _restService.GetAsync<Catalog>("/catalog/enchantment-types").ConfigureAwait(false)).Data;
23-
public async Task<string[]> ListArtifactTypes() => (await _restService.GetAsync<Catalog>("/catalog/artifact-types").ConfigureAwait(false)).Data;
24-
public async Task<string[]> ListPowers() => (await _restService.GetAsync<Catalog>("/catalog/powers").ConfigureAwait(false)).Data;
25-
public async Task<string[]> ListToughnesses() => (await _restService.GetAsync<Catalog>("/catalog/toughnesses").ConfigureAwait(false)).Data;
26-
public async Task<string[]> ListLoyalties() => (await _restService.GetAsync<Catalog>("/catalog/loyalties").ConfigureAwait(false)).Data;
27-
public async Task<string[]> ListWatermarks() => (await _restService.GetAsync<Catalog>("/catalog/watermarks").ConfigureAwait(false)).Data;
16+
public async Task<IReadOnlyCollection<string>> ListCardNames() => (await _restService.GetAsync<Catalog>("/catalog/card-names").ConfigureAwait(false)).Data;
17+
public async Task<IReadOnlyCollection<string>> ListWordBank() => (await _restService.GetAsync<Catalog>("/catalog/word-bank").ConfigureAwait(false)).Data;
18+
public async Task<IReadOnlyCollection<string>> ListCreatureTypes() => (await _restService.GetAsync<Catalog>("/catalog/creature-types").ConfigureAwait(false)).Data;
19+
public async Task<IReadOnlyCollection<string>> ListPlaneswalkerTypes() => (await _restService.GetAsync<Catalog>("/catalog/planeswalker-types").ConfigureAwait(false)).Data;
20+
public async Task<IReadOnlyCollection<string>> ListLandTypes() => (await _restService.GetAsync<Catalog>("/catalog/land-types").ConfigureAwait(false)).Data;
21+
public async Task<IReadOnlyCollection<string>> ListSpellTypes() => (await _restService.GetAsync<Catalog>("/catalog/spell-types").ConfigureAwait(false)).Data;
22+
public async Task<IReadOnlyCollection<string>> ListEnchantmentTypes() => (await _restService.GetAsync<Catalog>("/catalog/enchantment-types").ConfigureAwait(false)).Data;
23+
public async Task<IReadOnlyCollection<string>> ListArtifactTypes() => (await _restService.GetAsync<Catalog>("/catalog/artifact-types").ConfigureAwait(false)).Data;
24+
public async Task<IReadOnlyCollection<string>> ListPowers() => (await _restService.GetAsync<Catalog>("/catalog/powers").ConfigureAwait(false)).Data;
25+
public async Task<IReadOnlyCollection<string>> ListToughnesses() => (await _restService.GetAsync<Catalog>("/catalog/toughnesses").ConfigureAwait(false)).Data;
26+
public async Task<IReadOnlyCollection<string>> ListLoyalties() => (await _restService.GetAsync<Catalog>("/catalog/loyalties").ConfigureAwait(false)).Data;
27+
public async Task<IReadOnlyCollection<string>> ListWatermarks() => (await _restService.GetAsync<Catalog>("/catalog/watermarks").ConfigureAwait(false)).Data;
2828
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member
2929
}

src/ScryfallApi.Client/Apis/ICatalogs.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,83 +12,83 @@ public interface ICatalogs
1212
/// soon as a new card is entered for spoiler seasons.
1313
/// </summary>
1414
/// <returns></returns>
15-
Task<string[]> ListCardNames();
15+
Task<IReadOnlyCollection<string>> ListCardNames();
1616

1717
/// <summary>
1818
/// Returns a Catalog of all English words, of length 2 or more, that could appear in a card name.
1919
/// Values are drawn from cards currently in Scryfall’s database. Values are updated as soon as a
2020
/// new card is entered for spoiler seasons.
2121
/// </summary>
2222
/// <returns></returns>
23-
Task<string[]> ListWordBank();
23+
Task<IReadOnlyCollection<string>> ListWordBank();
2424

2525
/// <summary>
2626
/// Returns a Catalog of all creature types in Scryfall’s database. Values are updated as soon as
2727
/// a new card is entered for spoiler seasons.
2828
/// </summary>
2929
/// <returns></returns>
30-
Task<string[]> ListCreatureTypes();
30+
Task<IReadOnlyCollection<string>> ListCreatureTypes();
3131

3232
/// <summary>
3333
/// Returns a Catalog of all Planeswalker types in Scryfall’s database. Values are updated as soon as
3434
/// a new card is entered for spoiler seasons.
3535
/// </summary>
3636
/// <returns></returns>
37-
Task<string[]> ListPlaneswalkerTypes();
37+
Task<IReadOnlyCollection<string>> ListPlaneswalkerTypes();
3838

3939
/// <summary>
4040
/// Returns a Catalog of all Land types in Scryfall’s database. Values are updated as soon as a new
4141
/// card is entered for spoiler seasons.
4242
/// </summary>
4343
/// <returns></returns>
44-
Task<string[]> ListLandTypes();
44+
Task<IReadOnlyCollection<string>> ListLandTypes();
4545

4646
/// <summary>
4747
/// Returns a Catalog of all spell types in Scryfall’s database. Values are updated as soon as a new
4848
/// card is entered for spoiler seasons.
4949
/// </summary>
5050
/// <returns></returns>
51-
Task<string[]> ListSpellTypes();
51+
Task<IReadOnlyCollection<string>> ListSpellTypes();
5252

5353
/// <summary>
5454
/// Returns a Catalog of all artifact types in Scryfall’s database. Values are updated as soon as a
5555
/// new card is entered for spoiler seasons.
5656
/// </summary>
5757
/// <returns></returns>
58-
Task<string[]> ListArtifactTypes();
58+
Task<IReadOnlyCollection<string>> ListArtifactTypes();
5959

6060
/// <summary>
6161
/// Returns a Catalog of all enchantment types in Scryfall’s database. Values are updated as soon as a
6262
/// new card is entered for spoiler seasons.
6363
/// </summary>
6464
/// <returns></returns>
65-
Task<string[]> ListEnchantmentTypes();
65+
Task<IReadOnlyCollection<string>> ListEnchantmentTypes();
6666

6767
/// <summary>
6868
/// Returns a Catalog of all possible values for a creature or vehicle’s power in Scryfall’s database.
6969
/// Values are updated as soon as a new card is entered for spoiler seasons.
7070
/// </summary>
7171
/// <returns></returns>
72-
Task<string[]> ListPowers();
72+
Task<IReadOnlyCollection<string>> ListPowers();
7373

7474
/// <summary>
7575
/// Returns a Catalog of all possible values for a creature or vehicle’s toughness in Scryfall’s database.
7676
/// Values are updated as soon as a new card is entered for spoiler seasons.
7777
/// </summary>
7878
/// <returns></returns>
79-
Task<string[]> ListToughnesses();
79+
Task<IReadOnlyCollection<string>> ListToughnesses();
8080

8181
/// <summary>
8282
/// Returns a Catalog of all possible values for a Planeswalker’s loyalty in Scryfall’s database. Values
8383
/// are updated as soon as a new card is entered for spoiler seasons.
8484
/// </summary>
8585
/// <returns></returns>
86-
Task<string[]> ListLoyalties();
86+
Task<IReadOnlyCollection<string>> ListLoyalties();
8787

8888
/// <summary>
8989
/// Returns a Catalog of all card watermarks in Scryfall’s database. Values are updated as soon as a new
9090
/// card is entered for spoiler seasons.
9191
/// </summary>
9292
/// <returns></returns>
93-
Task<string[]> ListWatermarks();
93+
Task<IReadOnlyCollection<string>> ListWatermarks();
9494
}

src/ScryfallApi.Client/Apis/ISymbology.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ public interface ISymbology
1818
/// Parses the given mana cost parameter and returns Scryfall’s interpretation.
1919
/// </summary>
2020
/// <returns></returns>
21-
Task<ManaCost> ParseMana(string cost);
21+
Task<ParsedManaCost> ParseMana(string cost);
2222
}

src/ScryfallApi.Client/Apis/Symbology.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ internal Symbology(BaseRestService restService)
2222
/// Parses the given mana cost parameter and returns Scryfall’s interpretation.
2323
/// </summary>
2424
/// <returns></returns>
25-
public Task<ManaCost> ParseMana(string cost) => _restService.GetAsync<ManaCost>("/symbology/parse-mana");
25+
public Task<ParsedManaCost> ParseMana(string cost) => _restService.GetAsync<ParsedManaCost>("/symbology/parse-mana");
2626
}

src/ScryfallApi.Client/Models/BaseItem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ namespace ScryfallApi.Client.Models;
55
public abstract class BaseItem
66
{
77
[JsonPropertyName("object")]
8-
public string ObjectType { get; set; }
8+
public string ObjectType { get; init; }
99
}

src/ScryfallApi.Client/Models/BulkDataItem.cs

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,41 @@
22

33
namespace ScryfallApi.Client.Models;
44

5+
/// <summary>
6+
/// <para>Scryfall provides daily exports of our card data in bulk files. Each of these files is
7+
/// represented as a bulk_data object via the API. URLs for files change their timestamp each day,
8+
/// and can be fetched programmatically.</para>
9+
/// <para>Please note:</para>
10+
/// <para>Card objects in bulk data include price information, but prices should be considered
11+
/// dangerously stale after 24 hours.Only use bulk price information to track trends or provide a
12+
/// general estimate of card value.Prices are not updated frequently enough to power a storefront
13+
/// or sales system. You consume price information at your own risk.</para>
14+
/// <para>Updates to gameplay data (such as card names, Oracle text, mana costs, etc) are much less
15+
/// frequent.If you only need gameplay information, downloading card data once per week or right
16+
/// after set releases would most likely be sufficient.</para>
17+
/// <para>Every card type in every product is included, including planar cards, schemes, Vanguard
18+
/// cards, tokens, emblems, and funny cards.Make sure you’ve reviewed documentation for the Card
19+
/// type.</para>
20+
/// <para>Bulk data is only collected once every 12 hours.You can use the card API methods to
21+
/// retrieve fresh objects instead.</para>
22+
/// </summary>
523
public class BulkDataItem : BaseItem
624
{
7-
/// <summary>The Content-Encoding encoding that will be used to transmit this file when you download it.</summary>
8-
[JsonPropertyName("content_encoding")]
9-
public string ContentEncoding { get; set; }
25+
/// <summary>A unique ID for this bulk item.</summary>
26+
[JsonPropertyName("id")]
27+
public Guid Id { get; set; }
1028

11-
/// <summary>The MIME type of this file.</summary>
12-
[JsonPropertyName("content_type")]
13-
public string ContentType { get; set; }
29+
/// <summary>The Scryfall API URI for this file.</summary>
30+
[JsonPropertyName("uri")]
31+
public Uri Uri { get; set; }
32+
33+
/// <summary>A computer-readable string for the kind of bulk item.</summary>
34+
[JsonPropertyName("type")]
35+
public string Type { get; set; }
36+
37+
/// <summary>A human-readable name for this file.</summary>
38+
[JsonPropertyName("name")]
39+
public string Name { get; set; }
1440

1541
/// <summary>A human-readable description for this file.</summary>
1642
[JsonPropertyName("description")]
@@ -20,27 +46,19 @@ public class BulkDataItem : BaseItem
2046
[JsonPropertyName("download_uri")]
2147
public Uri DownloadUri { get; set; }
2248

23-
/// <summary>The size of this file in integer bytes.</summary>
24-
[JsonPropertyName("compressed_size")]
25-
public long FileSizeInBytes { get; set; }
26-
27-
/// <summary>A unique ID for this bulk item.</summary>
28-
[JsonPropertyName("id")]
29-
public Guid Id { get; set; }
30-
3149
/// <summary>The time when this file was last updated.</summary>
3250
[JsonPropertyName("updated_at")]
3351
public DateTimeOffset LastUpdated { get; set; }
3452

35-
/// <summary>A human-readable name for this file.</summary>
36-
[JsonPropertyName("name")]
37-
public string Name { get; set; }
53+
/// <summary>The size of this file in integer bytes.</summary>
54+
[JsonPropertyName("size")]
55+
public long FileSizeInBytes { get; set; }
3856

39-
/// <summary>A computer-readable string for the kind of bulk item.</summary>
40-
[JsonPropertyName("type")]
41-
public string Type { get; set; }
57+
/// <summary>The MIME type of this file.</summary>
58+
[JsonPropertyName("content_type")]
59+
public string ContentType { get; set; }
4260

43-
/// <summary>The Scryfall API URI for this file.</summary>
44-
[JsonPropertyName("uri")]
45-
public Uri Uri { get; set; }
61+
/// <summary>The Content-Encoding encoding that will be used to transmit this file when you download it.</summary>
62+
[JsonPropertyName("content_encoding")]
63+
public string ContentEncoding { get; set; }
4664
}

0 commit comments

Comments
 (0)