Hi,
I have a customer who is consuming our provided ServiceStack API as part of their own web site using Azure Redis for some aspects.
They’ve asked me if the generated C# classes from /types/csharp can include a [Serializable] attribute, as apparently Azure Redis requires this for their purposes (I must stress this Redis instance is not used by the ServiceStack aspect, but their own independent web site which consumes our ServiceStack API).
I’ve taken a look at CSharpGenerator.cs and can see where that would be possible to do (lines 227 to 234).
Now, I know there are some perils involved in this, as in my tinkering I found any class inheriting from QueryDb that has the [Serializable] attribute will cause the XSD generation to throw an error because QueryDb does not - so some reflection would need to be done to omit that attribute from such classes that inherit from something without [Serializable]
My question is: Would you consider accepting a PR with a new option for the generated C# classes to include a list of definable attributes to adorn generated classes with?
I can see there are already some options for including [DataContract] and [Generated] attributes - but it looks like this was deliberately and carefully crafted to limit what attributes can be included - and not a generic “add whatever you like” approach like I propose - probably to keep things simple and clean.
Perhaps there is another way of a consumer of the API being able to add an attribute to the generated classes?
Thanks,
Mike