private TypeSyntax GetDeclarationType( TypeSyntax type, bool useVarWhenDeclaringLocals, bool useImplicitTypeForIntrinsicTypes) { if (useVarWhenDeclaringLocals) { if (useImplicitTypeForIntrinsicTypes || !TypeStyleHelper.IsPredefinedType(type)) { return(SyntaxFactory.IdentifierName("var")); } } return(type); }
/// <summary> /// checks if the type represented by the given symbol is one of the /// simple types defined in the compiler. /// </summary> /// <remarks> /// From the IDE perspective, we also include object and string to be simplified /// to var. <see cref="SyntaxFacts.IsPredefinedType(SyntaxKind)"/> considers string /// and object but the compiler's implementation of IsIntrinsicType does not. /// </remarks> private bool IsPredefinedTypeInDeclaration(SyntaxNode declarationStatement) { return(TypeStyleHelper.IsPredefinedType( GetTypeSyntaxFromDeclaration(declarationStatement))); }