CardSourceGenerator 1.3.5
dotnet add package CardSourceGenerator --version 1.3.5
NuGet\Install-Package CardSourceGenerator -Version 1.3.5
<PackageReference Include="CardSourceGenerator" Version="1.3.5" />
<PackageVersion Include="CardSourceGenerator" Version="1.3.5" />
<PackageReference Include="CardSourceGenerator" />
paket add CardSourceGenerator --version 1.3.5
#r "nuget: CardSourceGenerator, 1.3.5"
#:package CardSourceGenerator@1.3.5
#addin nuget:?package=CardSourceGenerator&version=1.3.5
#tool nuget:?package=CardSourceGenerator&version=1.3.5
CardSourceGenerator
This is an analyzer for generating types based on Yu-Gi-Oh card names. This allows card name errors (e.g., typos) to be detected by the compiler (i.e., using the wrong card name throws a compilation error). You can access these card names via YGOCards.CardNameMap or by going YGOCards.[YourCardName].
Related Repositories
How To Install
This repository is available as a NuGet package.
- Add the analyzer to your project. It can be a project reference or a package (as a package is much easier).
- Then, you need to provide the card data. Currently, the only supported format is the JSON data provided by YGOProDeck.com (no affiliation), available via their API endpoint.
- Add the JSON data to your project by downloading the JSON file from YGOProDeck, then adding it to your project (I usually add a folder called CardData and put it in there).
- Next, you must tell the analyzer where the card data is. This can be done by editing the
.csprojfile with this property:
<ItemGroup>
<AdditionalFiles Include="CardData\*.json" />
</ItemGroup>
- I also include the JSON files in the
.gitignoreby including:
/{Project Folder}/CardData/*.json
- If you want to include the data with your output so you can use it at runtime (e.g., loading attributes, types, attack points, etc.), you can also add this to the
.csproj:
<ItemGroup>
<AdditionalFiles Update="CardData\*.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</AdditionalFiles>
</ItemGroup>
How To Use
Building your project will run the analyzer. If you're using Visual Studio, you can view these files by going Solution Explorer → Your Project Here → Dependencies → Analyzers → CardSourceGenerator → CardSourceGenerator.SourceGenerator. You will have access to the YGOCards static class and the following types:
YGOCards.StartingDeckLocationYGOCards.IYGOCardYGOCards.YGOCardName
You will also have access to properties whose names are based on every Yu-Gi-Oh! card provided in all of the JSON card data files. You can view these in YGOCards.Names.{FileNameHere}.g.cs. These can be accessed by going YGOCards.{CardNameHere}.
Only the names are provided by the source generator, but you can also load more data (e.g., attack points, attributes, etc.) via helpers methods in the YGOCards static class. An example method is YGOCards.LoadCardDataFromYgoPro(string path) located in YGOCards.CardData.g.cs. Where these files are located depends on how you go about it, but I copy the JSON files with my build output (see step 6 in "How To Install") and I use this helper method:
public static class CardDataLoader
{
public static IEnumerable<YGOCards.IYGOCard> LoadCardData()
{
var path = Path.Combine(Environment.CurrentDirectory, "CardData");
var files = Directory.GetFiles(path, "*.json");
return YGOCards
.LoadAllCardDataFromYgoPro(files)
.Values;
}
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.3.5 | 258 | 10/16/2025 |
| 1.3.4 | 232 | 8/30/2025 |
| 1.3.3 | 208 | 8/30/2025 |
| 1.3.3-alpha4 | 179 | 8/19/2025 |
| 1.3.3-alpha3 | 160 | 8/19/2025 |
| 1.3.3-alpha2 | 163 | 8/19/2025 |
| 1.3.2 | 370 | 4/14/2025 |
| 1.3.1 | 312 | 3/23/2025 |
| 1.2.7 | 306 | 3/23/2025 |