src\Analyzers\Core\Analyzers\RemoveUnusedParametersAndValues\AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.cs (1)
292ITypeSymbol containingType,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\ITypeSymbolExtensions.cs (98)
22public static bool IsIntegralType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
25public static bool IsSignedIntegralType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
28public static bool CanAddNullCheck([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
39public static IList<INamedTypeSymbol> GetAllInterfacesIncludingThis(this ITypeSymbol type)
55public static bool IsAbstractClass([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
58public static bool IsSystemVoid([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
61public static bool IsNullable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
64public static bool IsNonNullableValueType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
68[NotNullWhen(true)] this ITypeSymbol? symbol,
69[NotNullWhen(true)] out ITypeSymbol? underlyingType)
81public static bool IsModuleType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
84public static bool IsInterfaceType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
87public static bool IsDelegateType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
90public static bool IsFunctionPointerType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
93public static bool IsStructType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
100this ITypeSymbol type,
114public static IEnumerable<ITypeSymbol> GetBaseTypesAndThis(this ITypeSymbol? type)
116var current = type;
124public static IEnumerable<INamedTypeSymbol> GetBaseTypes(this ITypeSymbol? type)
134public static IEnumerable<ITypeSymbol> GetContainingTypesAndThis(this ITypeSymbol? type)
136var current = type;
144public static IEnumerable<INamedTypeSymbol> GetContainingTypes(this ITypeSymbol type)
157this ITypeSymbol type, ITypeSymbol baseType, bool includeInterfaces)
170this ITypeSymbol type, ITypeSymbol baseType)
178this ITypeSymbol type, ITypeSymbol baseType)
180var originalBaseType = baseType.OriginalDefinition;
188IEnumerable<ITypeSymbol> baseTypes = (baseType.TypeKind == TypeKind.Interface) ? type.AllInterfaces : type.GetBaseTypes();
195this ITypeSymbol type, ITypeSymbol baseType)
197var originalBaseType = baseType.OriginalDefinition;
217this ITypeSymbol type, ITypeSymbol interfaceType)
219var originalInterfaceType = interfaceType.OriginalDefinition;
224this ITypeSymbol type, ITypeSymbol interfaceType)
229public static bool IsAttribute(this ITypeSymbol symbol)
247public static bool IsFormattableStringOrIFormattable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
256this ITypeSymbol typeSymbol, bool allowDelegateAndEnumConstraints = false)
284public static bool IsNumericType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
310public static Accessibility DetermineMinimalAccessibility(this ITypeSymbol typeSymbol)
313public static bool ContainsAnonymousType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
329foreach (var typeArg in type.GetAllTypeArguments())
338public static string CreateParameterName(this ITypeSymbol type, bool capitalize = false)
359private static string GetParameterName(ITypeSymbol? type)
372public static bool IsSpecialType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
403public static bool CanSupportCollectionInitializer(this ITypeSymbol typeSymbol, ISymbol within)
414public static INamedTypeSymbol? GetDelegateType(this ITypeSymbol? typeSymbol, Compilation compilation)
421var typeArgument = ((INamedTypeSymbol)typeSymbol).TypeArguments[0];
434public static IEnumerable<T> GetAccessibleMembersInBaseTypes<T>(this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol
443public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, ISymbol within) where T : class, ISymbol
453public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, string memberName, ISymbol within) where T : class, ISymbol
463public static bool? AreMoreSpecificThan(this IList<ITypeSymbol> t1, IList<ITypeSymbol> t2)
498public static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, ISymbol within) where T : class, ISymbol
508private static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, string memberName, ISymbol within) where T : class, ISymbol
518private static bool? IsMoreSpecificThan(this ITypeSymbol t1, ITypeSymbol t2)
597public static bool IsOrDerivesFromExceptionType([NotNullWhen(returnValue: true)] this ITypeSymbol? type, Compilation compilation)
604foreach (var baseType in type.GetBaseTypesAndThis())
615foreach (var constraint in ((ITypeParameterSymbol)type).ConstraintTypes)
630public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type)
633public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type, [NotNullWhen(true)] out INamedTypeSymbol? enumType)
645public static bool? IsMutableValueType(this ITypeSymbol type)
647if (type.IsNullable(out var underlyingType))
724public static bool IsDisposable([NotNullWhen(returnValue: true)] this ITypeSymbol? type, [NotNullWhen(returnValue: true)] ITypeSymbol? iDisposableType)
729public static ITypeSymbol WithNullableAnnotationFrom(this ITypeSymbol type, ITypeSymbol symbolForNullableAnnotation)
733public static ITypeSymbol? RemoveNullableIfPresent(this ITypeSymbol? symbol)
735if (symbol.IsNullable(out var underlyingType))
743public static bool IsSpanOrReadOnlySpan([NotNullWhen(true)] this ITypeSymbol? type)
746public static bool IsSpan([NotNullWhen(true)] this ITypeSymbol? type)
762public static bool IsInlineArray([NotNullWhen(true)] this ITypeSymbol? type)
767public static ITypeSymbol? RemoveUnavailableTypeParameters(
768this ITypeSymbol? type,
776private static ITypeSymbol? RemoveUnavailableTypeParameters(
777this ITypeSymbol? type,
785public static ITypeSymbol? RemoveAnonymousTypes(
786this ITypeSymbol? type,
793public static ITypeSymbol? RemoveUnnamedErrorTypes(
794this ITypeSymbol? type,
800this ITypeSymbol? type, IList<ITypeParameterSymbol>? result = null)
808this ITypeSymbol? type, IList<ITypeParameterSymbol>? result = null)
816public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
817this ITypeSymbol? type,
820where TType1 : ITypeSymbol
821where TType2 : ITypeSymbol
827public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
828this ITypeSymbol? type,
831where TType1 : ITypeSymbol
832where TType2 : ITypeSymbol
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (25)
104protected abstract TConversion ClassifyConversion(SemanticModel model, TExpressionSyntax expression, ITypeSymbol targetType);
105protected abstract TConversion ClassifyConversion(SemanticModel model, ITypeSymbol originalType, ITypeSymbol targetType);
107protected abstract bool ConversionsAreCompatible(TExpressionSyntax originalExpression, ITypeSymbol originalTargetType, TExpressionSyntax newExpression, ITypeSymbol newTargetType);
108protected abstract bool IsReferenceConversion(Compilation model, ITypeSymbol sourceType, ITypeSymbol targetType);
114SemanticModel model, TForEachStatementSyntax forEach, out IMethodSymbol getEnumeratorMethod, out ITypeSymbol elementType, out ImmutableArray<ILocalSymbol> localVariables);
304private bool ImplicitConversionsAreCompatible(TExpressionSyntax originalExpression, ITypeSymbol originalTargetType, TExpressionSyntax newExpression, ITypeSymbol newTargetType)
739var previousOriginalType = this.OriginalSemanticModel.GetTypeInfo(previousOriginalNode).Type;
740var previousReplacedType = this.SpeculativeSemanticModel.GetTypeInfo(previousReplacedNode).Type;
779GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
780GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
825var expressionType = this.SpeculativeSemanticModel.GetTypeInfo(newForEachStatementExpression, CancellationToken).ConvertedType;
848var originalThrowExpressionType = this.OriginalSemanticModel.GetTypeInfo(originalThrowExpression).Type;
850var newThrowExpressionType = this.SpeculativeSemanticModel.GetTypeInfo(newThrowExpression).Type;
960var originalTargetType = this.OriginalSemanticModel.GetTypeInfo(originalLeft).Type;
963var newTargetType = this.SpeculativeSemanticModel.GetTypeInfo(newLeft).Type;
996var newReceiverType = newReceiver != null
1035var receiverType = semanticModel.GetTypeInfo(receiver).Type;
1195ITypeSymbol originalTargetType,
1197ITypeSymbol newTargetType,
1212var originalConvertedTypeSymbol = this.OriginalSemanticModel.GetTypeInfo(originalExpression).ConvertedType;
1218var newConvertedTypeSymbol = this.SpeculativeSemanticModel.GetTypeInfo(newExpression).ConvertedType;
src\Analyzers\Core\CodeFixes\AddExplicitCast\AbstractAddExplicitCastCodeFixProvider.cs (11)
30protected abstract TExpressionSyntax Cast(TExpressionSyntax expression, ITypeSymbol type);
48protected ImmutableArray<(TExpressionSyntax node, ITypeSymbol type)> GetPotentialTargetTypes(
52using var _ = ArrayBuilder<(TExpressionSyntax node, ITypeSymbol type)>.GetInstance(out var candidates);
63ArrayBuilder<(TExpressionSyntax node, ITypeSymbol type)> candidates,
120ITypeSymbol conversionType,
143var castType = semanticModel.GetTypeInfo(castTypeNode, cancellationToken).Type;
161protected virtual (SyntaxNode finalTarget, SyntaxNode finalReplacement) Cast(SemanticModel semanticModel, TExpressionSyntax targetNode, ITypeSymbol conversionType)
164private static string GetSubItemName(SemanticModel semanticModel, int position, ITypeSymbol conversionType)
171private static ImmutableArray<(TExpressionSyntax, ITypeSymbol)> FilterValidPotentialConversionTypes(
174ArrayBuilder<(TExpressionSyntax node, ITypeSymbol type)> candidates)
179using var _ = ArrayBuilder<(TExpressionSyntax, ITypeSymbol)>.GetInstance(candidates.Count, out var validPotentialConversionTypes);
src\Analyzers\Core\CodeFixes\AddParameter\AbstractAddParameterCodeFixProvider.cs (4)
46protected abstract ITypeSymbol GetArgumentType(SyntaxNode argumentNode, SemanticModel semanticModel, CancellationToken cancellationToken);
401private async Task<(ITypeSymbol, RefKind)> GetArgumentTypeAndRefKindAsync(Document invocationDocument, TArgumentSyntax argument, CancellationToken cancellationToken)
405var argumentType = GetArgumentType(argument, semanticModel, cancellationToken);
536Compilation compilation, TypeInfo argumentTypeInfo, ITypeSymbol parameterType,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationSymbolFactory.cs (18)
35DeclarationModifiers modifiers, ITypeSymbol type,
52ITypeSymbol type,
84ITypeSymbol type, RefKind refKind, ImmutableArray<IPropertySymbol> explicitInterfaceImplementations, string name,
111ITypeSymbol type, string name,
157ITypeSymbol? returnType,
179ITypeSymbol? returnType,
200ITypeSymbol returnType,
225ITypeSymbol toType,
253ITypeSymbol toType,
269public static IParameterSymbol CreateParameterSymbol(ITypeSymbol type, string name)
272public static IParameterSymbol CreateParameterSymbol(RefKind refKind, ITypeSymbol type, string name)
282ImmutableArray<AttributeData> attributes, RefKind refKind, bool isParams, ITypeSymbol type, string name, bool isOptional = false, bool hasDefaultValue = false, object? defaultValue = null)
295ITypeSymbol? type = null,
336ImmutableArray<ITypeSymbol> constraintTypes,
352public static IPointerTypeSymbol CreatePointerTypeSymbol(ITypeSymbol pointedAtType)
358public static IArrayTypeSymbol CreateArrayTypeSymbol(ITypeSymbol elementType, int rank = 1, NullableAnnotation nullableAnnotation = NullableAnnotation.None)
468ITypeSymbol returnType,
525ITypeSymbol? returnType = null,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationArrayTypeSymbol.cs (2)
10internal sealed class CodeGenerationArrayTypeSymbol(ITypeSymbol elementType, int rank, NullableAnnotation nullableAnnotation) : CodeGenerationTypeSymbol(null, null, default, Accessibility.NotApplicable, default, string.Empty, SpecialType.None, nullableAnnotation), IArrayTypeSymbol
12public ITypeSymbol ElementType { get; } = elementType;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationConversionSymbol.cs (1)
22ITypeSymbol toType,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationOperatorSymbol.cs (1)
23ITypeSymbol returnType,
src\Analyzers\CSharp\CodeFixes\GenerateMethod\GenerateDeconstructMethodCodeFixProvider.cs (1)
67ITypeSymbol type;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\ExpressionGenerator.cs (9)
34return typedConstant.Value is ITypeSymbol typeSymbol
54ITypeSymbol? type,
75internal static ExpressionSyntax GenerateNonEnumValueExpression(ITypeSymbol? type, object? value, bool canUseFieldReference)
118private static string DetermineSuffix(ITypeSymbol? type, object value)
172private static ExpressionSyntax GenerateDoubleLiteralExpression(ITypeSymbol? type, double value, bool canUseFieldReference)
201private static ExpressionSyntax GenerateSingleLiteralExpression(ITypeSymbol? type, float value, bool canUseFieldReference)
231ITypeSymbol? type, T value, IEnumerable<KeyValuePair<T, string>> constants,
242ITypeSymbol? type, T value, IEnumerable<KeyValuePair<T, string>> constants,
278private static ExpressionSyntax? GenerateFieldReference<T>(ITypeSymbol? type, T value, IEnumerable<KeyValuePair<T, string>> constants)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpTypeInferenceService.TypeInferrer.cs (31)
35protected override bool IsUnusableType(ITypeSymbol otherSideType)
616private static IMethodSymbol Instantiate(IMethodSymbol method, IList<ITypeSymbol> invocationTypes)
640IDictionary<ITypeParameterSymbol, ITypeSymbol> bestMap = null;
641foreach (var type in invocationTypes)
662private static Dictionary<ITypeParameterSymbol, ITypeSymbol> DetermineTypeParameterMapping(ITypeSymbol inferredType, ITypeSymbol returnType)
664var result = new Dictionary<ITypeParameterSymbol, ITypeSymbol>();
669private static void DetermineTypeParameterMapping(ITypeSymbol inferredType, ITypeSymbol returnType, Dictionary<ITypeParameterSymbol, ITypeSymbol> result)
1134static ITypeSymbol MakeNullable(ITypeSymbol symbol, Compilation compilation)
1448var type = this.SemanticModel.GetTypeInfo(recursivePattern).ConvertedType;
1567var elementTypesBuilder = ArrayBuilder<ITypeSymbol>.GetInstance(subPatternCount);
1592private static ImmutableArray<NullableAnnotation> GetNullableAnnotations(ImmutableArray<ITypeSymbol> elementTypes)
1781private ITypeSymbol InferTypeForFirstParameterOfLambda(
1796private ITypeSymbol InferTypeForFirstParameterOfParenthesizedLambda(
1805private ITypeSymbol InferTypeForFirstParameterOfSimpleLambda(
1812private ITypeSymbol InferTypeForFirstParameterOfLambda(
1819private ITypeSymbol InferTypeForFirstParameterOfLambda(
1837var type = InferTypeForFirstParameterOfLambda(parameterName, child.AsNode());
2002private ITypeSymbol UnwrapTaskLike(ITypeSymbol type, bool isAsync)
2271var tupleType = GetTupleType(tupleExpression);
2280private ITypeSymbol GetTupleType(
2294out ImmutableArray<ITypeSymbol> elementTypes,
2300using var _1 = ArrayBuilder<ITypeSymbol>.GetInstance(out var elementTypesBuilder);
2338ArrayBuilder<ITypeSymbol> elementTypesBuilder,
2360ArrayBuilder<ITypeSymbol> elementTypesBuilder,
2363var tupleType = GetTupleType(tuple);
Completion\CompletionProviders\PropertySubPatternCompletionProvider.cs (7)
59var propertyPatternType = semanticModel.GetTypeInfo((PatternSyntax)propertyPatternClause.Parent!, cancellationToken).ConvertedType;
63var type = GetMemberAccessType(propertyPatternType, memberAccess, document, semanticModel, position);
99static ITypeSymbol? GetMemberAccessType(ITypeSymbol? type, ExpressionSyntax? expression, Document document, SemanticModel semanticModel, int position)
118static ITypeSymbol? GetMemberType(ITypeSymbol? type, string name, Document document, SemanticModel semanticModel, int position)
135static ImmutableArray<ISymbol> GetCandidatePropertiesAndFields(Document document, SemanticModel semanticModel, int position, ITypeSymbol? type)
src\Analyzers\CSharp\CodeFixes\GenerateMethod\GenerateDeconstructMethodCodeFixProvider.cs (1)
67ITypeSymbol type;
Recommendations\CSharpRecommendationServiceRunner.cs (14)
51public override bool TryGetExplicitTypeOfLambdaParameter(SyntaxNode lambdaSyntax, int ordinalInLambda, [NotNullWhen(true)] out ITypeSymbol? explicitLambdaParameterType)
542if (name.ShouldNameExpressionBeTreatedAsExpressionInsteadOfType(_context.SemanticModel, out var nameBinding, out var container))
600var container = _context.SemanticModel.GetTypeInfo(identifier, _cancellationToken).Type;
650var container = _context.SemanticModel.GetTypeInfo(expression, _cancellationToken).Type;
660var container = _context.SemanticModel.GetTypeInfo(expression, _cancellationToken).Type;
675var container = _context.SemanticModel.GetTypeInfo(expression, _cancellationToken).Type;
691ITypeSymbol? containerType,
756private RecommendedSymbols GetSymbolsOffOfBoundExpressionWorker(SymbolInfo leftHandBinding, ExpressionSyntax originalExpression, ExpressionSyntax expression, ITypeSymbol? containerType, bool unwrapNullable, bool isForDereference)
864ITypeSymbol? containerType,
872if (symbol.IsStatic || symbol is ITypeSymbol)
901var container = GetContainerForUnnamedSymbols(semanticModel, originalExpression);
920private ITypeSymbol? GetContainerForUnnamedSymbols(SemanticModel semanticModel, ExpressionSyntax originalExpression)
922return originalExpression.ShouldNameExpressionBeTreatedAsExpressionInsteadOfType(_context.SemanticModel, out _, out var container)
927private void AddIndexers(ITypeSymbol container, ArrayBuilder<ISymbol> symbols)
Recommendations\CSharpRecommendationServiceRunner_Conversions.cs (12)
135private void AddConversions(ITypeSymbol container, ArrayBuilder<ISymbol> symbols)
145private static ITypeSymbol TryMakeNullable(Compilation compilation, ITypeSymbol container)
153ITypeSymbol container, INamedTypeSymbol containerWithoutNullable, ArrayBuilder<ISymbol> symbols)
201ITypeSymbol container, INamedTypeSymbol containerWithoutNullable, ArrayBuilder<ISymbol> symbols)
210public static ImmutableArray<SpecialType>? GetPredefinedNumericConversions(ITypeSymbol container)
229ITypeSymbol container, INamedTypeSymbol containerWithoutNullable, ArrayBuilder<ISymbol> symbols, ImmutableArray<SpecialType> specialTypes)
245static string CreateConversionDocumentationCommentXml(ITypeSymbol fromType, ITypeSymbol toType)
258private static IMethodSymbol CreateConversion(INamedTypeSymbol containingType, ITypeSymbol fromType, ITypeSymbol toType, string? documentationCommentXml)
266ITypeSymbol container, INamedTypeSymbol containerWithoutNullable, ArrayBuilder<ISymbol> symbols)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ExpressionSyntaxExtensions.cs (24)
907public static ITypeSymbol? GetTargetType(
937bool HasType(ExpressionSyntax expression, [NotNullWhen(true)] out ITypeSymbol? type)
943ITypeSymbol? GetTargetTypeForArgument(ArgumentSyntax argument)
947var tupleType = tupleExpression.GetTargetType(semanticModel, cancellationToken);
962ITypeSymbol? GetTargetTypeForAttributeArgument(AttributeArgumentSyntax argument)
965ITypeSymbol? GetTargetTypeForArrowExpression(ArrowExpressionClauseSyntax arrowExpression)
972ITypeSymbol? GetTargetTypeForReturnStatement(ReturnStatementSyntax returnStatement)
986ITypeSymbol? GetTargetTypeForEqualsValueClause(EqualsValueClauseSyntax equalsValue)
996ITypeSymbol? GetTargetTypedForCastExpression(CastExpressionSyntax castExpression)
999ITypeSymbol? GetTargetTypeForConditionalExpression(ConditionalExpressionSyntax conditionalExpression, ExpressionSyntax expression)
1002return HasType(conditionalExpression.WhenFalse, out var falseType) ? falseType : conditionalExpression.GetTargetType(semanticModel, cancellationToken);
1004return HasType(conditionalExpression.WhenTrue, out var trueType) ? trueType : conditionalExpression.GetTargetType(semanticModel, cancellationToken);
1009ITypeSymbol? GetTargetTypeForLambdaExpression(LambdaExpressionSyntax lambda, ExpressionSyntax expression)
1013ITypeSymbol? GetTargetTypeForSwitchExpressionArm(SwitchExpressionArmSyntax switchExpressionArm)
1020if (arm != switchExpressionArm && HasType(arm.Expression, out var armType))
1028ITypeSymbol? GetTargetTypeForCollectionElement(CollectionElementSyntax collectionElement)
1036var collectionTargetType = collectionExpression.GetTargetType(semanticModel, cancellationToken);
1056ITypeSymbol? GetTargetTypeForInitializerExpression(InitializerExpressionSyntax initializerExpression, ExpressionSyntax expression)
1060return HasType(arrayCreation.Type, out var elementType) ? elementType : null;
1067if (sibling != expression && HasType(sibling, out var siblingType))
1085ITypeSymbol? GetTargetTypeForAssignmentExpression(AssignmentExpressionSyntax assignmentExpression, ExpressionSyntax expression)
1087return expression == assignmentExpression.Right && HasType(assignmentExpression.Left, out var leftType) ? leftType : null;
1090ITypeSymbol? GetTargetTypeForBinaryExpression(BinaryExpressionSyntax binaryExpression, ExpressionSyntax expression)
1092return binaryExpression.Kind() == SyntaxKind.CoalesceExpression && binaryExpression.Right == expression && HasType(binaryExpression.Left, out var leftType) ? leftType : null;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Simplification\Simplifiers\CastSimplifier.cs (31)
128var castedType = semanticModel.GetTypeInfo(castExpression.Type, cancellationToken).Type;
163var castedType = semanticModel.GetTypeInfo(castExpression.Type, cancellationToken).Type;
167var parentCastType = semanticModel.GetTypeInfo(parentCast.Type, cancellationToken).Type;
314var originalConvertedType = originalSemanticModel.GetTypeInfo(castNode.WalkUpParentheses(), cancellationToken).ConvertedType;
506var castedExpressionType = originalSemanticModel.GetTypeInfo(castedExpressionNode, cancellationToken).Type;
507var isType = originalSemanticModel.GetTypeInfo(isExpression.Right, cancellationToken).Type;
543var targetType = castNode.GetTargetType(originalSemanticModel, cancellationToken);
608ITypeSymbol originalConvertedType,
612var castedType = originalSemanticModel.GetTypeInfo(castNode, cancellationToken).Type;
687var castType = semanticModel.GetTypeInfo(castNode, cancellationToken).Type;
807var originalConvertedType = originalConversionOperation.Type;
808var rewrittenBitwiseNotConversionType = rewrittenBitwiseNotConversionOperation.Type;
821private static bool IsSignedIntegralOrIntPtrType(ITypeSymbol? type)
885var castType = originalSemanticModel.GetTypeInfo(castExpression, cancellationToken).Type;
915var otherSideType = originalSemanticModel.GetTypeInfo(otherSide, cancellationToken).Type;
916var thisSideRewrittenType = rewrittenSemanticModel.GetTypeInfo(rewrittenExpression, cancellationToken).Type;
928var rewrittenConditionalConvertedType = rewrittenSemanticModel.GetTypeInfo(rewrittenConditionalExpression, cancellationToken).ConvertedType;
939private static bool IsNullOrErrorType([NotNullWhen(false)] ITypeSymbol? type)
1062var castSideType = semanticModel.GetTypeInfo(castSide, cancellationToken).Type;
1063var castedExpressionType = semanticModel.GetTypeInfo(castExpression.Expression, cancellationToken).Type;
1067var otherSideType = semanticModel.GetTypeInfo(otherSide, cancellationToken).Type;
1085var castType = semanticModel.GetTypeInfo(castNode, cancellationToken).Type;
1086var castedExpressionType = semanticModel.GetTypeInfo(castedExpressionNode, cancellationToken).Type;
1143private static bool IsFloatingPointType(ITypeSymbol? type)
1313var rewrittenType = rewrittenSemanticModel.GetTypeInfo(rewrittenExpression, cancellationToken).Type;
1428private static bool IsIntrinsicOrEnum(ITypeSymbol rewrittenType)
1436ITypeSymbol rewrittenType,
1526private static (ITypeSymbol? rewrittenConvertedType, Conversion rewrittenConversion) GetRewrittenInfo(
1529Conversion originalConversion, ITypeSymbol originalConvertedType,
1540var convertedType = originalConversion.IsIdentity ? originalConvertedType : originalSemanticModel.Compilation.ObjectType;
1544var rewrittenConvertedType = rewrittenSemanticModel.GetTypeInfo(rewrittenExpression, cancellationToken).ConvertedType;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\SpeculationAnalyzer.cs (16)
386var originalExpressionType = originalExpressionTypeInfo.Type;
387var newExpressionType = newExpressionTypeInfo.Type;
435var originalCaseType = this.OriginalSemanticModel.GetTypeInfo(previousOriginalNode, this.CancellationToken).Type;
436var newCaseType = this.SpeculativeSemanticModel.GetTypeInfo(previousReplacedNode, this.CancellationToken).Type;
561var originalExpressionType = this.OriginalSemanticModel.GetTypeInfo(originalAnonymousObjectMemberDeclarator.Expression, this.CancellationToken).Type;
562var newExpressionType = this.SpeculativeSemanticModel.GetTypeInfo(replacedAnonymousObjectMemberDeclarator.Expression, this.CancellationToken).Type;
702var originalConvertedType = this.OriginalSemanticModel.GetTypeInfo(originalIsOrAsExpression.Right).Type;
703var newConvertedType = this.SpeculativeSemanticModel.GetTypeInfo(newIsOrAsExpression.Right).Type;
841protected override bool ConversionsAreCompatible(ExpressionSyntax originalExpression, ITypeSymbol originalTargetType, ExpressionSyntax newExpression, ITypeSymbol newTargetType)
889out ITypeSymbol elementType,
931protected override bool IsReferenceConversion(Compilation compilation, ITypeSymbol sourceType, ITypeSymbol targetType)
934protected override Conversion ClassifyConversion(SemanticModel model, ExpressionSyntax expression, ITypeSymbol targetType)
937protected override Conversion ClassifyConversion(SemanticModel model, ITypeSymbol originalType, ITypeSymbol targetType)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\ExpressionGenerator.cs (9)
34return typedConstant.Value is ITypeSymbol typeSymbol
54ITypeSymbol? type,
75internal static ExpressionSyntax GenerateNonEnumValueExpression(ITypeSymbol? type, object? value, bool canUseFieldReference)
118private static string DetermineSuffix(ITypeSymbol? type, object value)
172private static ExpressionSyntax GenerateDoubleLiteralExpression(ITypeSymbol? type, double value, bool canUseFieldReference)
201private static ExpressionSyntax GenerateSingleLiteralExpression(ITypeSymbol? type, float value, bool canUseFieldReference)
231ITypeSymbol? type, T value, IEnumerable<KeyValuePair<T, string>> constants,
242ITypeSymbol? type, T value, IEnumerable<KeyValuePair<T, string>> constants,
278private static ExpressionSyntax? GenerateFieldReference<T>(ITypeSymbol? type, T value, IEnumerable<KeyValuePair<T, string>> constants)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpTypeInferenceService.TypeInferrer.cs (31)
35protected override bool IsUnusableType(ITypeSymbol otherSideType)
616private static IMethodSymbol Instantiate(IMethodSymbol method, IList<ITypeSymbol> invocationTypes)
640IDictionary<ITypeParameterSymbol, ITypeSymbol> bestMap = null;
641foreach (var type in invocationTypes)
662private static Dictionary<ITypeParameterSymbol, ITypeSymbol> DetermineTypeParameterMapping(ITypeSymbol inferredType, ITypeSymbol returnType)
664var result = new Dictionary<ITypeParameterSymbol, ITypeSymbol>();
669private static void DetermineTypeParameterMapping(ITypeSymbol inferredType, ITypeSymbol returnType, Dictionary<ITypeParameterSymbol, ITypeSymbol> result)
1134static ITypeSymbol MakeNullable(ITypeSymbol symbol, Compilation compilation)
1448var type = this.SemanticModel.GetTypeInfo(recursivePattern).ConvertedType;
1567var elementTypesBuilder = ArrayBuilder<ITypeSymbol>.GetInstance(subPatternCount);
1592private static ImmutableArray<NullableAnnotation> GetNullableAnnotations(ImmutableArray<ITypeSymbol> elementTypes)
1781private ITypeSymbol InferTypeForFirstParameterOfLambda(
1796private ITypeSymbol InferTypeForFirstParameterOfParenthesizedLambda(
1805private ITypeSymbol InferTypeForFirstParameterOfSimpleLambda(
1812private ITypeSymbol InferTypeForFirstParameterOfLambda(
1819private ITypeSymbol InferTypeForFirstParameterOfLambda(
1837var type = InferTypeForFirstParameterOfLambda(parameterName, child.AsNode());
2002private ITypeSymbol UnwrapTaskLike(ITypeSymbol type, bool isAsync)
2271var tupleType = GetTupleType(tupleExpression);
2280private ITypeSymbol GetTupleType(
2294out ImmutableArray<ITypeSymbol> elementTypes,
2300using var _1 = ArrayBuilder<ITypeSymbol>.GetInstance(out var elementTypesBuilder);
2338ArrayBuilder<ITypeSymbol> elementTypesBuilder,
2360ArrayBuilder<ITypeSymbol> elementTypesBuilder,
2363var tupleType = GetTupleType(tuple);
AddImport\SymbolReferenceFinder.cs (9)
206var typeSymbols = OfType<ITypeSymbol>(symbols);
233ITypeSymbol symbol,
390ImmutableArray<SymbolResult<IMethodSymbol>> methodSymbols, ITypeSymbol typeSymbol)
447var type = _owner.GetQueryClauseInfo(_semanticModel, _node, cancellationToken);
471var type = GetAwaitInfo(_semanticModel, _syntaxFacts, _node);
496var type = GetCollectionExpressionType(_semanticModel, _syntaxFacts, _node);
521var type = GetCollectionExpressionType(_semanticModel, _syntaxFacts, _node);
546var type = _owner.GetDeconstructInfo(_semanticModel, _node, cancellationToken);
562SearchScope searchScope, string name, ITypeSymbol type, Func<IMethodSymbol, bool> predicate, CancellationToken cancellationToken)
Completion\Providers\ImportCompletionProvider\AbstractTypeImportCompletionProvider.cs (1)
76Target: ITypeSymbol
Completion\Providers\ImportCompletionProvider\ExtensionMethodImportCompletionHelper.cs (8)
50ITypeSymbol receiverTypeSymbol,
52ImmutableArray<ITypeSymbol> targetTypesSymbols,
105ITypeSymbol receiverTypeSymbol,
107ImmutableArray<ITypeSymbol> targetTypes,
143Compilation compilation, ImmutableArray<IMethodSymbol> extentsionMethodSymbols, ImmutableArray<ITypeSymbol> targetTypeSymbols, CancellationToken cancellationToken)
145Dictionary<ITypeSymbol, bool> typeConvertibilityCache = [];
212Compilation compilation, IMethodSymbol methodSymbol, ImmutableArray<ITypeSymbol> targetTypeSymbols,
213Dictionary<ITypeSymbol, bool> typeConvertibilityCache)
Completion\Providers\ImportCompletionProvider\ExtensionMethodImportCompletionHelper.SymbolComputer.cs (14)
32private readonly ITypeSymbol _receiverTypeSymbol;
40private readonly ConcurrentDictionary<ITypeSymbol, bool> _checkedReceiverTypes = [];
45ITypeSymbol receiverTypeSymbol,
242MultiDictionary<ITypeSymbol, IMethodSymbol> matchingMethodSymbols,
309MultiDictionary<ITypeSymbol, IMethodSymbol> matchingMethodSymbols,
345private MultiDictionary<ITypeSymbol, IMethodSymbol> GetPotentialMatchingSymbolsFromAssembly(
351var builder = new MultiDictionary<ITypeSymbol, IMethodSymbol>();
386if (MatchExtensionMethod(methodSymbol, receiverTypeName, internalsVisible, out var receiverType))
397static bool MatchExtensionMethod(IMethodSymbol method, string filterReceiverTypeName, bool internalsVisible, out ITypeSymbol? receiverType)
478private static ImmutableArray<string> GetReceiverTypeNames(ITypeSymbol receiverTypeSymbol)
484static void AddNamesForTypeWorker(ITypeSymbol receiverTypeSymbol, PooledHashSet<string> builder)
488foreach (var constraintType in typeParameter.ConstraintTypes)
522private static string GetReceiverTypeName(ITypeSymbol typeSymbol)
530var elementType = arrayType.ElementType;
ConvertForEachToFor\AbstractConvertForEachToForCodeRefactoringProvider.cs (14)
133ITypeSymbol castType, SyntaxNode collectionVariable, SyntaxToken indexVariable)
180out var explicitCastInterface, out var collectionNameSuggestion, out var countName);
194out ITypeSymbol? explicitCastInterface, out string? collectionNameSuggestion, out string? countName)
201var foreachType = foreachVariable.Type;
207var collectionType = foreachCollection.Type;
292ITypeSymbol? explicitInterface = null;
340ITypeSymbol type1, ITypeSymbol type2, Compilation compilation)
346private static bool IsNullOrErrorType([NotNullWhen(false)] ITypeSymbol? type)
349private static IMethodSymbol? GetInterfaceMember(ITypeSymbol interfaceType, string memberName)
430ITypeSymbol? explicitCastInterface, ITypeSymbol forEachElementType,
437public ITypeSymbol? ExplicitCastInterface { get; } = explicitCastInterface;
438public ITypeSymbol ForEachElementType { get; } = forEachElementType;
ConvertForToForEach\AbstractConvertForToForEachCodeRefactoringProvider.cs (13)
51TExpressionSyntax collectionExpression, ITypeSymbol iterationVariableType);
119out var iterationType))
232INamedTypeSymbol containingType, ITypeSymbol type, string memberName) where TSymbol : class, ISymbol
239INamedTypeSymbol containingType, ITypeSymbol type, string memberName) where TSymbol : class, ISymbol
245INamedTypeSymbol containingType, ITypeSymbol collectionType,
247[NotNullWhen(true)] out ITypeSymbol? iterationType)
282INamedTypeSymbol ienumeratorType, [NotNullWhen(true)] out ITypeSymbol? iterationType)
284var getEnumeratorReturnType = getEnumeratorMethod.ReturnType;
315ITypeSymbol collectionType,
316ITypeSymbol iterationType,
345var indexerType = GetIndexerType(containingType, collectionType, semanticModel.Compilation.GetSpecialType(SpecialType.System_Collections_Generic_IEnumerable_T));
499private static ITypeSymbol? GetIndexerType(
501ITypeSymbol collectionType,
EditAndContinue\AbstractEditAndContinueAnalyzer.cs (8)
1778protected void AddRudeTypeUpdateAroundActiveStatement(ArrayBuilder<RudeEditDiagnostic> diagnostics, SyntaxNode newNode, ITypeSymbol oldType, ITypeSymbol newType)
1961var oldType = oldModel.GetTypeInfo(oldTypedNodes[t], cancellationToken).Type;
1962var newType = newModel.GetTypeInfo(newTypedNodes[t], cancellationToken).Type;
2392protected static bool TypesEquivalent(ITypeSymbol? oldType, ITypeSymbol? newType, bool exact)
2393=> (exact ? s_exactSymbolEqualityComparer : (IEqualityComparer<ITypeSymbol?>)s_runtimeSymbolEqualityComparer.SignatureTypeEquivalenceComparer).Equals(oldType, newType);
2395protected static bool TypesEquivalent<T>(ImmutableArray<T> oldTypes, ImmutableArray<T> newTypes, bool exact) where T : ITypeSymbol
src\Analyzers\Core\Analyzers\RemoveUnusedParametersAndValues\AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.cs (1)
292ITypeSymbol containingType,
src\Analyzers\Core\CodeFixes\AddExplicitCast\AbstractAddExplicitCastCodeFixProvider.cs (11)
30protected abstract TExpressionSyntax Cast(TExpressionSyntax expression, ITypeSymbol type);
48protected ImmutableArray<(TExpressionSyntax node, ITypeSymbol type)> GetPotentialTargetTypes(
52using var _ = ArrayBuilder<(TExpressionSyntax node, ITypeSymbol type)>.GetInstance(out var candidates);
63ArrayBuilder<(TExpressionSyntax node, ITypeSymbol type)> candidates,
120ITypeSymbol conversionType,
143var castType = semanticModel.GetTypeInfo(castTypeNode, cancellationToken).Type;
161protected virtual (SyntaxNode finalTarget, SyntaxNode finalReplacement) Cast(SemanticModel semanticModel, TExpressionSyntax targetNode, ITypeSymbol conversionType)
164private static string GetSubItemName(SemanticModel semanticModel, int position, ITypeSymbol conversionType)
171private static ImmutableArray<(TExpressionSyntax, ITypeSymbol)> FilterValidPotentialConversionTypes(
174ArrayBuilder<(TExpressionSyntax node, ITypeSymbol type)> candidates)
179using var _ = ArrayBuilder<(TExpressionSyntax, ITypeSymbol)>.GetInstance(candidates.Count, out var validPotentialConversionTypes);
src\Analyzers\Core\CodeFixes\AddParameter\AbstractAddParameterCodeFixProvider.cs (4)
46protected abstract ITypeSymbol GetArgumentType(SyntaxNode argumentNode, SemanticModel semanticModel, CancellationToken cancellationToken);
401private async Task<(ITypeSymbol, RefKind)> GetArgumentTypeAndRefKindAsync(Document invocationDocument, TArgumentSyntax argument, CancellationToken cancellationToken)
405var argumentType = GetArgumentType(argument, semanticModel, cancellationToken);
536Compilation compilation, TypeInfo argumentTypeInfo, ITypeSymbol parameterType,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\CodeGeneration\ExpressionGenerator.vb (12)
31If TypeOf typedConstant.Value IsNot ITypeSymbol Then
35Return SyntaxFactory.GetTypeExpression(DirectCast(typedConstant.Value, ITypeSymbol).GenerateTypeSyntax())
42Friend Function GenerateExpression(generator As SyntaxGenerator, type As ITypeSymbol, value As Object, canUseFieldReference As Boolean) As ExpressionSyntax
58Friend Function GenerateNonEnumValueExpression(type As ITypeSymbol, value As Object, canUseFieldReference As Boolean) As ExpressionSyntax
109Private Function GenerateStringLiteralExpression(type As ITypeSymbol, value As String) As ExpressionSyntax
162type As ITypeSymbol,
178type As ITypeSymbol,
225Private Sub DetermineSuffix(type As ITypeSymbol,
275Private Function GenerateDoubleLiteralExpression(type As ITypeSymbol,
300type As ITypeSymbol,
325type As ITypeSymbol,
373Private Function GenerateDecimalLiteralExpression(type As ITypeSymbol, value As Decimal, canUseFieldReference As Boolean) As ExpressionSyntax
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Utilities\CastAnalyzer.vb (11)
33Private Function CastPassedToParamArrayDefinitelyCantBeRemoved(castType As ITypeSymbol) As Boolean
57Private Shared Function GetOuterCastType(expression As ExpressionSyntax, expressionTypeInfo As TypeInfo, semanticModel As SemanticModel, cancellationToken As CancellationToken) As ITypeSymbol
122Private Shared Function GetSpeculatedExpressionToOuterTypeConversion(speculationAnalyzer As SpeculationAnalyzer, speculatedExpression As ExpressionSyntax, outerSpeculatedExpression As ExpressionSyntax, cancellationToken As CancellationToken, <Out> ByRef speculatedExpressionOuterType As ITypeSymbol) As Conversion
142Private Shared Function AsTypeInVariableDeclarator(node As SyntaxNode, semanticModel As SemanticModel) As ITypeSymbol
206Dim castExpressionType As ITypeSymbol
253Dim speculatedExpressionOuterType As ITypeSymbol = Nothing
319DirectCast(castExpressionType.OriginalDefinition, ITypeSymbol).SpecialType = SpecialType.System_Nullable_T
374Private Shared Function IsRequiredWideningNumericConversion(sourceType As ITypeSymbol, destinationType As ITypeSymbol) As Boolean
394Private Shared Function CastRemovalChangesDefaultValue(castType As ITypeSymbol, outerType As ITypeSymbol) As Boolean
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Utilities\SpeculationAnalyzer.vb (8)
547Protected Overrides Function ConversionsAreCompatible(originalExpression As ExpressionSyntax, originalTargetType As ITypeSymbol, newExpression As ExpressionSyntax, newTargetType As ITypeSymbol) As Boolean
600ByRef elementType As ITypeSymbol,
608Protected Overrides Function IsReferenceConversion(compilation As Compilation, sourceType As ITypeSymbol, targetType As ITypeSymbol) As Boolean
612Protected Overrides Function ClassifyConversion(model As SemanticModel, expression As ExpressionSyntax, targetType As ITypeSymbol) As Conversion
616Protected Overrides Function ClassifyConversion(model As SemanticModel, originalType As ITypeSymbol, targetType As ITypeSymbol) As Conversion
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\CodeGeneration\ExpressionGenerator.vb (12)
31If TypeOf typedConstant.Value IsNot ITypeSymbol Then
35Return SyntaxFactory.GetTypeExpression(DirectCast(typedConstant.Value, ITypeSymbol).GenerateTypeSyntax())
42Friend Function GenerateExpression(generator As SyntaxGenerator, type As ITypeSymbol, value As Object, canUseFieldReference As Boolean) As ExpressionSyntax
58Friend Function GenerateNonEnumValueExpression(type As ITypeSymbol, value As Object, canUseFieldReference As Boolean) As ExpressionSyntax
109Private Function GenerateStringLiteralExpression(type As ITypeSymbol, value As String) As ExpressionSyntax
162type As ITypeSymbol,
178type As ITypeSymbol,
225Private Sub DetermineSuffix(type As ITypeSymbol,
275Private Function GenerateDoubleLiteralExpression(type As ITypeSymbol,
300type As ITypeSymbol,
325type As ITypeSymbol,
373Private Function GenerateDecimalLiteralExpression(type As ITypeSymbol, value As Decimal, canUseFieldReference As Boolean) As ExpressionSyntax
Editing\SyntaxGenerator.cs (20)
337private protected abstract SyntaxNode GenerateExpression(ITypeSymbol? type, object? value, bool canUseFieldReference);
1602/// <see langword="true"/> if the language requires a <see cref="TypeExpression(ITypeSymbol)"/>
1604/// <see cref="LocalDeclarationStatement(ITypeSymbol, string, SyntaxNode, bool)"/>.
1627public SyntaxNode LocalDeclarationStatement(ITypeSymbol type, string name, SyntaxNode? initializer = null, bool isConst = false)
1740public SyntaxNode CatchClause(ITypeSymbol type, string identifier, IEnumerable<SyntaxNode> statements)
1781public SyntaxNode DefaultExpression(ITypeSymbol type)
1850public SyntaxNode GenericName(string identifier, IEnumerable<ITypeSymbol> typeArguments)
1862public SyntaxNode GenericName(string identifier, params ITypeSymbol[] typeArguments)
1863=> GenericName(identifier, (IEnumerable<ITypeSymbol>)typeArguments);
1931public SyntaxNode TypeExpression(ITypeSymbol typeSymbol)
1939public SyntaxNode TypeExpression(ITypeSymbol typeSymbol, bool addImport)
1991public SyntaxNode TupleTypeExpression(IEnumerable<ITypeSymbol> elementTypes, IEnumerable<string>? elementNames = null)
2020public SyntaxNode TupleElementExpression(ITypeSymbol type, string? name = null)
2203public SyntaxNode ObjectCreationExpression(ITypeSymbol type, IEnumerable<SyntaxNode> arguments)
2215public SyntaxNode ObjectCreationExpression(ITypeSymbol type, params SyntaxNode[] arguments)
2270public SyntaxNode IsTypeExpression(SyntaxNode expression, ITypeSymbol type)
2281public SyntaxNode TryCastExpression(SyntaxNode expression, ITypeSymbol type)
2293public SyntaxNode CastExpression(ITypeSymbol type, SyntaxNode expression)
2305public SyntaxNode ConvertExpression(ITypeSymbol type, SyntaxNode expression)
2384public SyntaxNode LambdaParameter(string identifier, ITypeSymbol type)
Recommendations\AbstractRecommendationServiceRunner.cs (24)
44public abstract bool TryGetExplicitTypeOfLambdaParameter(SyntaxNode lambdaSyntax, int ordinalInLambda, [NotNullWhen(returnValue: true)] out ITypeSymbol explicitLambdaParameterType);
96var parameterTypeSymbols = ImmutableArray<ITypeSymbol>.Empty;
98if (TryGetExplicitTypeOfLambdaParameter(lambdaSyntax, parameter.Ordinal, out var explicitLambdaParameterType))
134private ImmutableArray<ITypeSymbol> SubstituteTypeParameters(ImmutableArray<ITypeSymbol> parameterTypeSymbols, SyntaxNode invocationExpression)
147using var _ = ArrayBuilder<ITypeSymbol>.GetInstance(out var concreteTypes);
153foreach (var parameterTypeSymbol in parameterTypeSymbols)
160var concreteType = typeArguments.ElementAtOrDefault(index);
184private ImmutableArray<ITypeSymbol> GetTypeSymbols(
193using var _ = ArrayBuilder<ITypeSymbol>.GetInstance(out var builder);
199if (!TryGetMatchingParameterTypeForArgument(method, argumentName, ordinalInInvocation, out var type))
237private bool TryGetMatchingParameterTypeForArgument(IMethodSymbol method, string argumentName, int ordinalInInvocation, out ITypeSymbol parameterType)
377if (unwrapNullable && namespaceOrType is ITypeSymbol typeSymbol)
397if (container is not ITypeSymbol containerType)
426static bool MatchesConstraints(ITypeSymbol originalContainerType, ImmutableArray<ITypeSymbol> constraintTypes)
433foreach (var constraintType in constraintTypes)
442static bool MatchesConstraint(ITypeSymbol originalContainerType, ITypeSymbol originalConstraintType)
460foreach (var constraintType in typeParameterContainer.ConstraintTypes)
485foreach (var constrainedType in typeParameterContainer.ConstraintTypes)
510static bool MatchesAnyBaseTypes(ITypeSymbol source, ITypeSymbol matched)
512for (var current = source; current != null; current = current.BaseType)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\ITypeSymbolExtensions.cs (98)
22public static bool IsIntegralType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
25public static bool IsSignedIntegralType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
28public static bool CanAddNullCheck([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
39public static IList<INamedTypeSymbol> GetAllInterfacesIncludingThis(this ITypeSymbol type)
55public static bool IsAbstractClass([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
58public static bool IsSystemVoid([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
61public static bool IsNullable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
64public static bool IsNonNullableValueType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
68[NotNullWhen(true)] this ITypeSymbol? symbol,
69[NotNullWhen(true)] out ITypeSymbol? underlyingType)
81public static bool IsModuleType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
84public static bool IsInterfaceType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
87public static bool IsDelegateType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
90public static bool IsFunctionPointerType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
93public static bool IsStructType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
100this ITypeSymbol type,
114public static IEnumerable<ITypeSymbol> GetBaseTypesAndThis(this ITypeSymbol? type)
116var current = type;
124public static IEnumerable<INamedTypeSymbol> GetBaseTypes(this ITypeSymbol? type)
134public static IEnumerable<ITypeSymbol> GetContainingTypesAndThis(this ITypeSymbol? type)
136var current = type;
144public static IEnumerable<INamedTypeSymbol> GetContainingTypes(this ITypeSymbol type)
157this ITypeSymbol type, ITypeSymbol baseType, bool includeInterfaces)
170this ITypeSymbol type, ITypeSymbol baseType)
178this ITypeSymbol type, ITypeSymbol baseType)
180var originalBaseType = baseType.OriginalDefinition;
188IEnumerable<ITypeSymbol> baseTypes = (baseType.TypeKind == TypeKind.Interface) ? type.AllInterfaces : type.GetBaseTypes();
195this ITypeSymbol type, ITypeSymbol baseType)
197var originalBaseType = baseType.OriginalDefinition;
217this ITypeSymbol type, ITypeSymbol interfaceType)
219var originalInterfaceType = interfaceType.OriginalDefinition;
224this ITypeSymbol type, ITypeSymbol interfaceType)
229public static bool IsAttribute(this ITypeSymbol symbol)
247public static bool IsFormattableStringOrIFormattable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
256this ITypeSymbol typeSymbol, bool allowDelegateAndEnumConstraints = false)
284public static bool IsNumericType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
310public static Accessibility DetermineMinimalAccessibility(this ITypeSymbol typeSymbol)
313public static bool ContainsAnonymousType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
329foreach (var typeArg in type.GetAllTypeArguments())
338public static string CreateParameterName(this ITypeSymbol type, bool capitalize = false)
359private static string GetParameterName(ITypeSymbol? type)
372public static bool IsSpecialType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
403public static bool CanSupportCollectionInitializer(this ITypeSymbol typeSymbol, ISymbol within)
414public static INamedTypeSymbol? GetDelegateType(this ITypeSymbol? typeSymbol, Compilation compilation)
421var typeArgument = ((INamedTypeSymbol)typeSymbol).TypeArguments[0];
434public static IEnumerable<T> GetAccessibleMembersInBaseTypes<T>(this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol
443public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, ISymbol within) where T : class, ISymbol
453public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, string memberName, ISymbol within) where T : class, ISymbol
463public static bool? AreMoreSpecificThan(this IList<ITypeSymbol> t1, IList<ITypeSymbol> t2)
498public static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, ISymbol within) where T : class, ISymbol
508private static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, string memberName, ISymbol within) where T : class, ISymbol
518private static bool? IsMoreSpecificThan(this ITypeSymbol t1, ITypeSymbol t2)
597public static bool IsOrDerivesFromExceptionType([NotNullWhen(returnValue: true)] this ITypeSymbol? type, Compilation compilation)
604foreach (var baseType in type.GetBaseTypesAndThis())
615foreach (var constraint in ((ITypeParameterSymbol)type).ConstraintTypes)
630public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type)
633public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type, [NotNullWhen(true)] out INamedTypeSymbol? enumType)
645public static bool? IsMutableValueType(this ITypeSymbol type)
647if (type.IsNullable(out var underlyingType))
724public static bool IsDisposable([NotNullWhen(returnValue: true)] this ITypeSymbol? type, [NotNullWhen(returnValue: true)] ITypeSymbol? iDisposableType)
729public static ITypeSymbol WithNullableAnnotationFrom(this ITypeSymbol type, ITypeSymbol symbolForNullableAnnotation)
733public static ITypeSymbol? RemoveNullableIfPresent(this ITypeSymbol? symbol)
735if (symbol.IsNullable(out var underlyingType))
743public static bool IsSpanOrReadOnlySpan([NotNullWhen(true)] this ITypeSymbol? type)
746public static bool IsSpan([NotNullWhen(true)] this ITypeSymbol? type)
762public static bool IsInlineArray([NotNullWhen(true)] this ITypeSymbol? type)
767public static ITypeSymbol? RemoveUnavailableTypeParameters(
768this ITypeSymbol? type,
776private static ITypeSymbol? RemoveUnavailableTypeParameters(
777this ITypeSymbol? type,
785public static ITypeSymbol? RemoveAnonymousTypes(
786this ITypeSymbol? type,
793public static ITypeSymbol? RemoveUnnamedErrorTypes(
794this ITypeSymbol? type,
800this ITypeSymbol? type, IList<ITypeParameterSymbol>? result = null)
808this ITypeSymbol? type, IList<ITypeParameterSymbol>? result = null)
816public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
817this ITypeSymbol? type,
820where TType1 : ITypeSymbol
821where TType2 : ITypeSymbol
827public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
828this ITypeSymbol? type,
831where TType1 : ITypeSymbol
832where TType2 : ITypeSymbol
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (25)
104protected abstract TConversion ClassifyConversion(SemanticModel model, TExpressionSyntax expression, ITypeSymbol targetType);
105protected abstract TConversion ClassifyConversion(SemanticModel model, ITypeSymbol originalType, ITypeSymbol targetType);
107protected abstract bool ConversionsAreCompatible(TExpressionSyntax originalExpression, ITypeSymbol originalTargetType, TExpressionSyntax newExpression, ITypeSymbol newTargetType);
108protected abstract bool IsReferenceConversion(Compilation model, ITypeSymbol sourceType, ITypeSymbol targetType);
114SemanticModel model, TForEachStatementSyntax forEach, out IMethodSymbol getEnumeratorMethod, out ITypeSymbol elementType, out ImmutableArray<ILocalSymbol> localVariables);
304private bool ImplicitConversionsAreCompatible(TExpressionSyntax originalExpression, ITypeSymbol originalTargetType, TExpressionSyntax newExpression, ITypeSymbol newTargetType)
739var previousOriginalType = this.OriginalSemanticModel.GetTypeInfo(previousOriginalNode).Type;
740var previousReplacedType = this.SpeculativeSemanticModel.GetTypeInfo(previousReplacedNode).Type;
779GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
780GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
825var expressionType = this.SpeculativeSemanticModel.GetTypeInfo(newForEachStatementExpression, CancellationToken).ConvertedType;
848var originalThrowExpressionType = this.OriginalSemanticModel.GetTypeInfo(originalThrowExpression).Type;
850var newThrowExpressionType = this.SpeculativeSemanticModel.GetTypeInfo(newThrowExpression).Type;
960var originalTargetType = this.OriginalSemanticModel.GetTypeInfo(originalLeft).Type;
963var newTargetType = this.SpeculativeSemanticModel.GetTypeInfo(newLeft).Type;
996var newReceiverType = newReceiver != null
1035var receiverType = semanticModel.GetTypeInfo(receiver).Type;
1195ITypeSymbol originalTargetType,
1197ITypeSymbol newTargetType,
1212var originalConvertedTypeSymbol = this.OriginalSemanticModel.GetTypeInfo(originalExpression).ConvertedType;
1218var newConvertedTypeSymbol = this.SpeculativeSemanticModel.GetTypeInfo(newExpression).ConvertedType;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationSymbolFactory.cs (18)
35DeclarationModifiers modifiers, ITypeSymbol type,
52ITypeSymbol type,
84ITypeSymbol type, RefKind refKind, ImmutableArray<IPropertySymbol> explicitInterfaceImplementations, string name,
111ITypeSymbol type, string name,
157ITypeSymbol? returnType,
179ITypeSymbol? returnType,
200ITypeSymbol returnType,
225ITypeSymbol toType,
253ITypeSymbol toType,
269public static IParameterSymbol CreateParameterSymbol(ITypeSymbol type, string name)
272public static IParameterSymbol CreateParameterSymbol(RefKind refKind, ITypeSymbol type, string name)
282ImmutableArray<AttributeData> attributes, RefKind refKind, bool isParams, ITypeSymbol type, string name, bool isOptional = false, bool hasDefaultValue = false, object? defaultValue = null)
295ITypeSymbol? type = null,
336ImmutableArray<ITypeSymbol> constraintTypes,
352public static IPointerTypeSymbol CreatePointerTypeSymbol(ITypeSymbol pointedAtType)
358public static IArrayTypeSymbol CreateArrayTypeSymbol(ITypeSymbol elementType, int rank = 1, NullableAnnotation nullableAnnotation = NullableAnnotation.None)
468ITypeSymbol returnType,
525ITypeSymbol? returnType = null,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationArrayTypeSymbol.cs (2)
10internal sealed class CodeGenerationArrayTypeSymbol(ITypeSymbol elementType, int rank, NullableAnnotation nullableAnnotation) : CodeGenerationTypeSymbol(null, null, default, Accessibility.NotApplicable, default, string.Empty, SpecialType.None, nullableAnnotation), IArrayTypeSymbol
12public ITypeSymbol ElementType { get; } = elementType;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationConversionSymbol.cs (1)
22ITypeSymbol toType,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationOperatorSymbol.cs (1)
23ITypeSymbol returnType,