TypeInfo.IsAssignableFrom in Roslyn parser

In my Roslyn parser, I get the Microsoft.CodeAnalysis.TypeInfo argument

 var argumentTypeInfo = semanticModel.GetTypeInfo(argumentSyntax.Expression); 

I also have another instance of Microsoft.CodeAnalysis.TypeInfo called targetTypeInfo . Now I want to know if the type described by targetTypeInfo can be assigned from the type described by argumentTypeInfo .

I know that System.Reflection.TypeInfo has its IsAssignableFrom method, which is exactly what I want. But converting between two TypeInfo is a problem. What is the correct way to get type relationships in the analyzer?

+5
source share

Source: https://habr.com/ru/post/1264665/


All Articles