-
-
Notifications
You must be signed in to change notification settings - Fork 146
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
feat: support derived type mappings #366
Conversation
This is a really cool addition, I love how elegant the generated code is. I wasn't sure where to put this but after reading the original issue I got thinking about adding generic attributes without breaking anything. Because generic attributes are a C#11 feature it mighr be possible to support them for compatible programs by doing as follows:
// Check is MapDerivedTypeAttribute...
var attrDatas = symbol.GetAttributes().Where(x => x.AttributeClass.TypeArguments.Count() == 2);
foreach (var attrData in attrDatas)
{
var namedSymbol = attrData.AttributeClass;
yield return new MapDerivedType(namedSymbol.TypeArguments[0], namedSymbol.TypeArguments[1]);
} I've hacked together a working version here, it appears to work with ,NET Framework and Core. I've probably overlooked something, perhaps it only works on modern .NET Sdk's or recent versions of Visual Studio. Hopefully this helps 🤞 |
🎉 This PR is included in version 3.0.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Closes #330