Roslyn Check Type of an Attribute

旧街凉风 提交于 2019-12-02 04:06:07
Matt Warren

AttributeData.AttributeClass gives you the Roslyn symbol for the attribute. But you've got a CLR runtime Type you are trying to compare against. You can either just compare the type names, etc, to see if they are the probably the same type, or get a Roslyn type symbol for MyAttributeType, which is more correct. This is typically done via

var desiredSymbol = sematicModel.Compilation.GetTypeByMetadataName(typeof(MyAttributeType).FullName)
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!