In my Roslyn analyzer I get Microsoft.CodeAnalysis.TypeInfo
of an argument by
var argumentTypeInfo = semanticModel.GetTypeInfo(argumentSyntax.Expression);
also I have another instance of Microsoft.CodeAnalysis.TypeInfo
called targetTypeInfo
. Now I want to know if the type describled by targetTypeInfo
is assignable from the type describled by argumentTypeInfo
.
I know System.Reflection.TypeInfo
has its IsAssignableFrom
method, which is exactly what I want. But the convertion between the two TypeInfo
s is a problem. What's the correct way to get type relationships in an analyzer?
ITypeSymbol
inTypeInfo
in question. But this might be cumbersome. Another approach which might work is to use theCompilation.ClassifyConversion
and check the returnedConversionKind
. A third option is to check how Roslyn binds theis
operator: source.roslyn.io/#Microsoft.CodeAnalysis.CSharp/Binder/…, but I guess it uses theClassifyConversion
. Let me know if any of these worked. – Corinthian