Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Would it be nice to use code generator to parse a json with all card's data and add a generation step? #50

Open
aloisdg opened this issue Oct 22, 2021 · 7 comments
Labels
question Further information is requested

Comments

@aloisdg
Copy link
Member

aloisdg commented Oct 22, 2021

.NET 5.0 adds Source Code Generator to the C# world: https://devblogs.microsoft.com/dotnet/introducing-c-source-generators/

The goal would be to move all the data into a json data file and to generate all the classes, the enum, etc. with source generator.

@aloisdg aloisdg added the question Further information is requested label Oct 22, 2021
@aloisdg aloisdg changed the title Use code generator to parse a json with all card's data and generate the object hierarchy, the enum, etc. Would it be nice to use code generator to parse a json with all card's data and generate the object hierarchy, the enum, etc. ? Oct 22, 2021
@aloisdg aloisdg changed the title Would it be nice to use code generator to parse a json with all card's data and generate the object hierarchy, the enum, etc. ? Would it be nice to use code generator to parse a json with all card's data and add a generation step? Oct 22, 2021
@hey24sheep
Copy link
Contributor

hey24sheep commented Oct 27, 2021

I think that's a great idea. I created a scraper for the data here, it's github pages hosted.

I created this cuz I want to add all other cards as well easily. If it helps you with source-gen. I am thinking of doing a simple placeholder replace like (won't source gen will be overkill?)

internal record {{provider}} : {{base)}}
{
    public {{provider}}() : base(CardType.{{provider}}, {{range}}, {{length}}) { }
}

Obviously for base, length and IINrange I will use logic to determine which/how to put data according to current implementation. But, if you could use source-gens I will be curious to see how they work.

@aloisdg
Copy link
Member Author

aloisdg commented Oct 27, 2021

Source gen may be a bit overkill, but is is nice way to experiment with it and it will be more contributor friendly.

I create a bot on Cardizer to create issues on update of the page. We could go further but I think it was a nice first step.

Your tool could be very useful to get from html to json. We wont write the C# directly though thanks to source code generator. I think I will handle the source gen issue. At least, I will start a POC in a branch.

@hey24sheep
Copy link
Contributor

I changed my code to Wiki API now (I started getting CORS error otherwise) so now it is accessible.

I usually use Reflection to generate C# or transpile C# to other stuff like we generate .dart files from our C# models. So, source-gen will be a pretty intresting thing for me.

@aloisdg
Copy link
Member Author

aloisdg commented Oct 27, 2021

Here we are talking about compile time generation not runtime generation like reflection. I would like to transpile C# to js too btw (see #36).

@hey24sheep
Copy link
Contributor

I know, compile time generation was possible too with Rosyln Compiler but it was a lot of work, let's see how good is source-code generators.

I did checkout C# to JS, but I H5 doesn't have any documentation. I will give it a try later this week, hopefully will be able to work it up.

@aloisdg
Copy link
Member Author

aloisdg commented Oct 29, 2021

Yeah. I plan to try it myself later on. If you want to try out before, go for it :)

C# to js is not quite needed. It is a nice to have :)

@hey24sheep
Copy link
Contributor

It's okay, you can go for it, I don't want to hang you guys up.

H5 itself is a good to know library. I might try that up.

I'm thinking of doing a Flutter wrapper of Cardidy though (as I work a lot on Flutter) not sure if dart-wise feasible because Flutter is bad in serialisation of data, but we'll see 🙈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants