private ITypeSymbol GetDelegateType(TypeInferenceInfo typeInferenceInfo, Compilation compilation) { ITypeSymbol typeSymbol = typeInferenceInfo.InferredType; if (typeInferenceInfo.IsParams && typeInferenceInfo.InferredType.IsArrayType()) { typeSymbol = ((IArrayTypeSymbol)typeInferenceInfo.InferredType).ElementType; } return typeSymbol.GetDelegateType(compilation); }
private IEnumerable<TypeInferenceInfo> GetTypesSimple(ExpressionSyntax expression) { if (expression != null) { var typeInfo = SemanticModel.GetTypeInfo(expression, CancellationToken); var symbolInfo = SemanticModel.GetSymbolInfo(expression, CancellationToken); if (symbolInfo.CandidateReason != CandidateReason.WrongArity) { var typeInferenceInfo = new TypeInferenceInfo(typeInfo.Type); // If it bound to a method, try to get the Action/Func form of that method. if (typeInferenceInfo.InferredType == null && symbolInfo.GetAllSymbols().Count() == 1 && symbolInfo.GetAllSymbols().First().Kind == SymbolKind.Method) { var method = symbolInfo.GetAllSymbols().First(); typeInferenceInfo = new TypeInferenceInfo(method.ConvertToType(this.Compilation)); } if (IsUsableTypeFunc(typeInferenceInfo)) { return SpecializedCollections.SingletonEnumerable(typeInferenceInfo); } } } return SpecializedCollections.EmptyEnumerable<TypeInferenceInfo>(); }