How to find out the conversion associated with a CastExpressionSyntax?

Topics: APIs
Aug 26, 2014 at 4:09 PM
Currently I'm using
var conversion = _semanticModel.ClassifyConversion(node.Expression, _semanticModel.GetTypeInfo(node).Type, true);
var fromType = _semanticModel.GetTypeInfo(node.Expression).Type;
var toType = _semanticModel.GetTypeInfo(node).Type;
DoSomething(conversion, fromType, toType);
but there has to be a better way. How is this supposed to be done?
Nov 18, 2014 at 6:44 AM
Nov 18, 2014 at 8:13 PM
@erikkallen, I submitted an issue about this:, although I haven't yet received any feedback on it. Looking back on it now, my original assumption of being able to use GetConversion probably wouldn't work anyway since you wouldn't be able to differentiate between the conversion for the cast and the conversion for the result of the cast (if it is being implicitly converted to something else). But it does seem like there should be a better way than using ClassifyConversion in the way you have described above.