Skip to content

Commit cd60539

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

File tree

22 files changed

+792
-353
lines changed

22 files changed

+792
-353
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/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)