✅ ɹoʇɐɹǝuǝƃ ǝɔɹnos lɐʇuǝɯǝɹɔuı uɐ ʇɐ ʎɹʇ ʇsɹıɟ

Had a go at writing an SG but I’m not very experienced with Roslyn so would appreciate some feedback. I’ve tried to apply the things I’ve overheard in the Roslyn file about enabling caching/incrementality but I’m not sure how to test it’s properly incremental. Main sgen project: https://github.com/SapiensAnatis/Dawnshard/tree/1c04fb2944fc69dc706eb02aa8ab96fbf8eaf7c0/DragaliaAPI/DragaliaAPI.Shared.SourceGenerator Sgen tests: https://github.com/SapiensAnatis/Dawnshard/tree/1c04fb2944fc69dc706eb02aa8ab96fbf8eaf7c0/DragaliaAPI/DragaliaAPI.Shared.SourceGenerator.Test The goal of the sgen is to generate some deserialisation code for a static class, which is here https://github.com/SapiensAnatis/Dawnshard/blob/1c04fb2944fc69dc706eb02aa8ab96fbf8eaf7c0/DragaliaAPI/DragaliaAPI.Shared/MasterAsset/MasterAsset.cs The code it actually generates is here: https://github.com/SapiensAnatis/Dawnshard/blob/1c04fb2944fc69dc706eb02aa8ab96fbf8eaf7c0/DragaliaAPI/DragaliaAPI.Shared/Generated/DragaliaAPI.Shared.SourceGenerator/DragaliaAPI.Shared.SourceGenerator.MasterAssetGenerator/MasterAsset.g.cs
GitHub
Dawnshard/DragaliaAPI/DragaliaAPI.Shared.SourceGenerator at 1c04fb2...
Server emulator for Dragalia Lost. Contribute to SapiensAnatis/Dawnshard development by creating an account on GitHub.
GitHub
Dawnshard/DragaliaAPI/DragaliaAPI.Shared.SourceGenerator.Test at 1c...
Server emulator for Dragalia Lost. Contribute to SapiensAnatis/Dawnshard development by creating an account on GitHub.
GitHub
Dawnshard/DragaliaAPI/DragaliaAPI.Shared/MasterAsset/MasterAsset.cs...
Server emulator for Dragalia Lost. Contribute to SapiensAnatis/Dawnshard development by creating an account on GitHub.
GitHub
Dawnshard/DragaliaAPI/DragaliaAPI.Shared/Generated/DragaliaAPI.Shar...
Server emulator for Dragalia Lost. Contribute to SapiensAnatis/Dawnshard development by creating an account on GitHub.
4 Replies
Angius
Angius4mo ago
Not a master at writing SGs, mostly repeating the advice I got when writing mine Actually... nevermind, LGTM
dreadfullydistinct
Thanks for looking 😁 good to know it’s not total jank I think I could improve it by making it generate into the class you actually declare it on but this wasn’t required for the initial use case I may split the attributes up into subclasses later though Oops just realised I posted this in the wrong channel I meant to go #code-review
333fred
333fred4mo ago
Congratulations, this is like the first time someone has come out of the woodwork with a source generator and I haven't hung my head in my hands and contemplated my life choiced Like, actually, good job
dreadfullydistinct
Thanks 😊 all that lurking in #roslyn paid off