aspeckt112
aspeckt112
CC#
Created by aspeckt112 on 11/29/2023 in #help
Testing the output of source generators
Hey all. Has anyone got advice about how to test the output of source generators? I've got a project that uses attributes that are added to assemblies in the project to work out what it needs to generate. There's the potential for it to spit out quite a lot of code if someone chooses to make use of all the attributes. It's cool, it's all working well. But what I'd like is some sort of automated test to run in a pipeline as part of the build so I know if I've introduced errors without needing to manaully check the output everytime - which is tedious and error prone. Right now, the only thing I can think to do is essentially write unit tests with all the expected output hard coded and compare it each time. It'll work, but it feels like there has to be a better way?
3 replies