public void ClassifyConversionFromOneTypeSymbolToAnother()
{
var tree = SyntaxTree.ParseText(@"
class Program
{
static void Main() { }
}");
var mscorlib = MetadataReference.CreateAssemblyReference("mscorlib");
var compilation = Compilation.Create("MyCompilation",
syntaxTrees: new[] { tree }, references: new[] { mscorlib });
TypeSymbol int32Type = compilation.GetSpecialType(SpecialType.System_Int32);
TypeSymbol int16Type = compilation.GetSpecialType(SpecialType.System_Int16);
TypeSymbol stringType = compilation.GetSpecialType(SpecialType.System_String);
TypeSymbol int64Type = compilation.GetSpecialType(SpecialType.System_Int64);
Assert.IsTrue(compilation.ClassifyConversion(int32Type, int32Type).IsIdentity);
var conversion1 = compilation.ClassifyConversion(int16Type, int32Type);
Assert.IsTrue(conversion1.IsImplicit && conversion1.IsNumeric);
Assert.IsFalse(compilation.ClassifyConversion(stringType, int32Type).Exists);
var conversion2 = compilation.ClassifyConversion(int64Type, int32Type);
Assert.IsTrue(conversion2.IsExplicit && conversion2.IsNumeric);
}