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)
740var previousOriginalType = this.OriginalSemanticModel.GetTypeInfo(previousOriginalNode).Type;
741var previousReplacedType = this.SpeculativeSemanticModel.GetTypeInfo(previousReplacedNode).Type;
780GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
781GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
826var expressionType = this.SpeculativeSemanticModel.GetTypeInfo(newForEachStatementExpression, CancellationToken).ConvertedType;
849var originalThrowExpressionType = this.OriginalSemanticModel.GetTypeInfo(originalThrowExpression).Type;
851var newThrowExpressionType = this.SpeculativeSemanticModel.GetTypeInfo(newThrowExpression).Type;
964var originalTargetType = this.OriginalSemanticModel.GetTypeInfo(originalLeft).Type;
967var newTargetType = this.SpeculativeSemanticModel.GetTypeInfo(newLeft).Type;
1000var newReceiverType = newReceiver != null
1039var receiverType = semanticModel.GetTypeInfo(receiver).Type;
1199ITypeSymbol originalTargetType,
1201ITypeSymbol newTargetType,
1216var originalConvertedTypeSymbol = this.OriginalSemanticModel.GetTypeInfo(originalExpression).ConvertedType;
1222var 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)
38protected abstract ITypeSymbol GetArgumentType(SyntaxNode argumentNode, SemanticModel semanticModel, CancellationToken cancellationToken);
393private async Task<(ITypeSymbol, RefKind)> GetArgumentTypeAndRefKindAsync(Document invocationDocument, TArgumentSyntax argument, CancellationToken cancellationToken)
397var argumentType = GetArgumentType(argument, semanticModel, cancellationToken);
535Compilation 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,
110ITypeSymbol type, string name,
156ITypeSymbol? returnType,
178ITypeSymbol? returnType,
199ITypeSymbol returnType,
224ITypeSymbol toType,
252ITypeSymbol toType,
268public static IParameterSymbol CreateParameterSymbol(ITypeSymbol type, string name)
271public static IParameterSymbol CreateParameterSymbol(RefKind refKind, ITypeSymbol type, string name)
281ImmutableArray<AttributeData> attributes, RefKind refKind, bool isParams, ITypeSymbol type, string name, bool isOptional = false, bool hasDefaultValue = false, object? defaultValue = null)
294ITypeSymbol? type = null,
335ImmutableArray<ITypeSymbol> constraintTypes,
351public static IPointerTypeSymbol CreatePointerTypeSymbol(ITypeSymbol pointedAtType)
357public static IArrayTypeSymbol CreateArrayTypeSymbol(ITypeSymbol elementType, int rank = 1, NullableAnnotation nullableAnnotation = NullableAnnotation.None)
467ITypeSymbol returnType,
524ITypeSymbol? 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\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Simplification\Simplifiers\CastSimplifier.cs (27)
121var castedType = semanticModel.GetTypeInfo(castExpression.Type, cancellationToken).Type;
156var castedType = semanticModel.GetTypeInfo(castExpression.Type, cancellationToken).Type;
160var parentCastType = semanticModel.GetTypeInfo(parentCast.Type, cancellationToken).Type;
307var originalConvertedType = originalSemanticModel.GetTypeInfo(castNode.WalkUpParentheses(), cancellationToken).ConvertedType;
486var castedExpressionType = originalSemanticModel.GetTypeInfo(castedExpressionNode, cancellationToken).Type;
487var isType = originalSemanticModel.GetTypeInfo(isExpression.Right, cancellationToken).Type;
570ITypeSymbol originalConvertedType,
574var castedType = originalSemanticModel.GetTypeInfo(castNode, cancellationToken).Type;
649var castType = semanticModel.GetTypeInfo(castNode, cancellationToken).Type;
769var originalConvertedType = originalConversionOperation.Type;
770var rewrittenBitwiseNotConversionType = rewrittenBitwiseNotConversionOperation.Type;
783private static bool IsSignedIntegralOrIntPtrType(ITypeSymbol? type)
840var castType = originalSemanticModel.GetTypeInfo(castExpression, cancellationToken).Type;
863private static bool IsNullOrErrorType([NotNullWhen(false)] ITypeSymbol? type)
986var castSideType = semanticModel.GetTypeInfo(castSide, cancellationToken).Type;
987var castedExpressionType = semanticModel.GetTypeInfo(castExpression.Expression, cancellationToken).Type;
991var otherSideType = semanticModel.GetTypeInfo(otherSide, cancellationToken).Type;
1009var castType = semanticModel.GetTypeInfo(castNode, cancellationToken).Type;
1010var castedExpressionType = semanticModel.GetTypeInfo(castedExpressionNode, cancellationToken).Type;
1067private static bool IsFloatingPointType(ITypeSymbol? type)
1237var rewrittenType = rewrittenSemanticModel.GetTypeInfo(rewrittenExpression, cancellationToken).Type;
1352private static bool IsIntrinsicOrEnum(ITypeSymbol rewrittenType)
1360ITypeSymbol rewrittenType,
1450private static (ITypeSymbol? rewrittenConvertedType, Conversion rewrittenConversion) GetRewrittenInfo(
1453Conversion originalConversion, ITypeSymbol originalConvertedType,
1464var convertedType = originalConversion.IsIdentity ? originalConvertedType : originalSemanticModel.Compilation.ObjectType;
1468var 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\Analyzers\CSharp\CodeFixes\GenerateMethod\GenerateDeconstructMethodCodeFixProvider.cs (1)
67ITypeSymbol type;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\ExpressionGenerator.cs (9)
35return typedConstant.Value is ITypeSymbol typeSymbol
56ITypeSymbol? type,
77internal static ExpressionSyntax GenerateNonEnumValueExpression(SyntaxGenerator generator, ITypeSymbol? type, object? value, bool canUseFieldReference)
120private static string DetermineSuffix(ITypeSymbol? type, object value)
174private static ExpressionSyntax GenerateDoubleLiteralExpression(ITypeSymbol? type, double value, bool canUseFieldReference)
203private static ExpressionSyntax GenerateSingleLiteralExpression(ITypeSymbol? type, float value, bool canUseFieldReference)
233ITypeSymbol? type, T value, IEnumerable<KeyValuePair<T, string>> constants,
244ITypeSymbol? type, T value, IEnumerable<KeyValuePair<T, string>> constants,
280private 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)
600private static IMethodSymbol Instantiate(IMethodSymbol method, IList<ITypeSymbol> invocationTypes)
624IDictionary<ITypeParameterSymbol, ITypeSymbol> bestMap = null;
625foreach (var type in invocationTypes)
646private static Dictionary<ITypeParameterSymbol, ITypeSymbol> DetermineTypeParameterMapping(ITypeSymbol inferredType, ITypeSymbol returnType)
648var result = new Dictionary<ITypeParameterSymbol, ITypeSymbol>();
653private static void DetermineTypeParameterMapping(ITypeSymbol inferredType, ITypeSymbol returnType, Dictionary<ITypeParameterSymbol, ITypeSymbol> result)
1118static ITypeSymbol MakeNullable(ITypeSymbol symbol, Compilation compilation)
1432var type = this.SemanticModel.GetTypeInfo(recursivePattern).ConvertedType;
1551var elementTypesBuilder = ArrayBuilder<ITypeSymbol>.GetInstance(subPatternCount);
1576private static ImmutableArray<NullableAnnotation> GetNullableAnnotations(ImmutableArray<ITypeSymbol> elementTypes)
1765private ITypeSymbol InferTypeForFirstParameterOfLambda(
1780private ITypeSymbol InferTypeForFirstParameterOfParenthesizedLambda(
1789private ITypeSymbol InferTypeForFirstParameterOfSimpleLambda(
1796private ITypeSymbol InferTypeForFirstParameterOfLambda(
1803private ITypeSymbol InferTypeForFirstParameterOfLambda(
1821var type = InferTypeForFirstParameterOfLambda(parameterName, child.AsNode());
1986private ITypeSymbol UnwrapTaskLike(ITypeSymbol type, bool isAsync)
2255var tupleType = GetTupleType(tupleExpression);
2264private ITypeSymbol GetTupleType(
2278out ImmutableArray<ITypeSymbol> elementTypes,
2284using var _1 = ArrayBuilder<ITypeSymbol>.GetInstance(out var elementTypesBuilder);
2322ArrayBuilder<ITypeSymbol> elementTypesBuilder,
2344ArrayBuilder<ITypeSymbol> elementTypesBuilder,
2347var 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)
57public override bool TryGetExplicitTypeOfLambdaParameter(SyntaxNode lambdaSyntax, int ordinalInLambda, [NotNullWhen(true)] out ITypeSymbol? explicitLambdaParameterType)
485if (name.ShouldNameExpressionBeTreatedAsExpressionInsteadOfType(_context.SemanticModel, out var nameBinding, out var container))
543var container = _context.SemanticModel.GetTypeInfo(identifier, _cancellationToken).Type;
593var container = _context.SemanticModel.GetTypeInfo(expression, _cancellationToken).Type;
603var container = _context.SemanticModel.GetTypeInfo(expression, _cancellationToken).Type;
618var container = _context.SemanticModel.GetTypeInfo(expression, _cancellationToken).Type;
634ITypeSymbol? containerType,
699private RecommendedSymbols GetSymbolsOffOfBoundExpressionWorker(SymbolInfo leftHandBinding, ExpressionSyntax originalExpression, ExpressionSyntax expression, ITypeSymbol? containerType, bool unwrapNullable, bool isForDereference)
807ITypeSymbol? containerType,
815if (symbol.IsStatic || symbol is ITypeSymbol)
844var container = GetContainerForUnnamedSymbols(semanticModel, originalExpression);
863private ITypeSymbol? GetContainerForUnnamedSymbols(SemanticModel semanticModel, ExpressionSyntax originalExpression)
865return originalExpression.ShouldNameExpressionBeTreatedAsExpressionInsteadOfType(_context.SemanticModel, out _, out var container)
870private 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\Simplification\Simplifiers\CastSimplifier.cs (27)
121var castedType = semanticModel.GetTypeInfo(castExpression.Type, cancellationToken).Type;
156var castedType = semanticModel.GetTypeInfo(castExpression.Type, cancellationToken).Type;
160var parentCastType = semanticModel.GetTypeInfo(parentCast.Type, cancellationToken).Type;
307var originalConvertedType = originalSemanticModel.GetTypeInfo(castNode.WalkUpParentheses(), cancellationToken).ConvertedType;
486var castedExpressionType = originalSemanticModel.GetTypeInfo(castedExpressionNode, cancellationToken).Type;
487var isType = originalSemanticModel.GetTypeInfo(isExpression.Right, cancellationToken).Type;
570ITypeSymbol originalConvertedType,
574var castedType = originalSemanticModel.GetTypeInfo(castNode, cancellationToken).Type;
649var castType = semanticModel.GetTypeInfo(castNode, cancellationToken).Type;
769var originalConvertedType = originalConversionOperation.Type;
770var rewrittenBitwiseNotConversionType = rewrittenBitwiseNotConversionOperation.Type;
783private static bool IsSignedIntegralOrIntPtrType(ITypeSymbol? type)
840var castType = originalSemanticModel.GetTypeInfo(castExpression, cancellationToken).Type;
863private static bool IsNullOrErrorType([NotNullWhen(false)] ITypeSymbol? type)
986var castSideType = semanticModel.GetTypeInfo(castSide, cancellationToken).Type;
987var castedExpressionType = semanticModel.GetTypeInfo(castExpression.Expression, cancellationToken).Type;
991var otherSideType = semanticModel.GetTypeInfo(otherSide, cancellationToken).Type;
1009var castType = semanticModel.GetTypeInfo(castNode, cancellationToken).Type;
1010var castedExpressionType = semanticModel.GetTypeInfo(castedExpressionNode, cancellationToken).Type;
1067private static bool IsFloatingPointType(ITypeSymbol? type)
1237var rewrittenType = rewrittenSemanticModel.GetTypeInfo(rewrittenExpression, cancellationToken).Type;
1352private static bool IsIntrinsicOrEnum(ITypeSymbol rewrittenType)
1360ITypeSymbol rewrittenType,
1450private static (ITypeSymbol? rewrittenConvertedType, Conversion rewrittenConversion) GetRewrittenInfo(
1453Conversion originalConversion, ITypeSymbol originalConvertedType,
1464var convertedType = originalConversion.IsIdentity ? originalConvertedType : originalSemanticModel.Compilation.ObjectType;
1468var 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)
35return typedConstant.Value is ITypeSymbol typeSymbol
56ITypeSymbol? type,
77internal static ExpressionSyntax GenerateNonEnumValueExpression(SyntaxGenerator generator, ITypeSymbol? type, object? value, bool canUseFieldReference)
120private static string DetermineSuffix(ITypeSymbol? type, object value)
174private static ExpressionSyntax GenerateDoubleLiteralExpression(ITypeSymbol? type, double value, bool canUseFieldReference)
203private static ExpressionSyntax GenerateSingleLiteralExpression(ITypeSymbol? type, float value, bool canUseFieldReference)
233ITypeSymbol? type, T value, IEnumerable<KeyValuePair<T, string>> constants,
244ITypeSymbol? type, T value, IEnumerable<KeyValuePair<T, string>> constants,
280private 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)
600private static IMethodSymbol Instantiate(IMethodSymbol method, IList<ITypeSymbol> invocationTypes)
624IDictionary<ITypeParameterSymbol, ITypeSymbol> bestMap = null;
625foreach (var type in invocationTypes)
646private static Dictionary<ITypeParameterSymbol, ITypeSymbol> DetermineTypeParameterMapping(ITypeSymbol inferredType, ITypeSymbol returnType)
648var result = new Dictionary<ITypeParameterSymbol, ITypeSymbol>();
653private static void DetermineTypeParameterMapping(ITypeSymbol inferredType, ITypeSymbol returnType, Dictionary<ITypeParameterSymbol, ITypeSymbol> result)
1118static ITypeSymbol MakeNullable(ITypeSymbol symbol, Compilation compilation)
1432var type = this.SemanticModel.GetTypeInfo(recursivePattern).ConvertedType;
1551var elementTypesBuilder = ArrayBuilder<ITypeSymbol>.GetInstance(subPatternCount);
1576private static ImmutableArray<NullableAnnotation> GetNullableAnnotations(ImmutableArray<ITypeSymbol> elementTypes)
1765private ITypeSymbol InferTypeForFirstParameterOfLambda(
1780private ITypeSymbol InferTypeForFirstParameterOfParenthesizedLambda(
1789private ITypeSymbol InferTypeForFirstParameterOfSimpleLambda(
1796private ITypeSymbol InferTypeForFirstParameterOfLambda(
1803private ITypeSymbol InferTypeForFirstParameterOfLambda(
1821var type = InferTypeForFirstParameterOfLambda(parameterName, child.AsNode());
1986private ITypeSymbol UnwrapTaskLike(ITypeSymbol type, bool isAsync)
2255var tupleType = GetTupleType(tupleExpression);
2264private ITypeSymbol GetTupleType(
2278out ImmutableArray<ITypeSymbol> elementTypes,
2284using var _1 = ArrayBuilder<ITypeSymbol>.GetInstance(out var elementTypesBuilder);
2322ArrayBuilder<ITypeSymbol> elementTypesBuilder,
2344ArrayBuilder<ITypeSymbol> elementTypesBuilder,
2347var tupleType = GetTupleType(tuple);
AddImport\SymbolReferenceFinder.cs (9)
196var typeSymbols = OfType<ITypeSymbol>(symbols);
223ITypeSymbol symbol,
380ImmutableArray<SymbolResult<IMethodSymbol>> methodSymbols, ITypeSymbol typeSymbol)
437var type = _owner.GetQueryClauseInfo(_semanticModel, _node, cancellationToken);
461var type = GetAwaitInfo(_semanticModel, _syntaxFacts, _node);
486var type = GetCollectionExpressionType(_semanticModel, _syntaxFacts, _node);
511var type = GetCollectionExpressionType(_semanticModel, _syntaxFacts, _node);
536var type = _owner.GetDeconstructInfo(_semanticModel, _node, cancellationToken);
552SearchScope 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)
1785protected void AddRudeTypeUpdateAroundActiveStatement(ArrayBuilder<RudeEditDiagnostic> diagnostics, SyntaxNode newNode, ITypeSymbol oldType, ITypeSymbol newType)
1968var oldType = oldModel.GetTypeInfo(oldTypedNodes[t], cancellationToken).Type;
1969var newType = newModel.GetTypeInfo(newTypedNodes[t], cancellationToken).Type;
2399protected static bool TypesEquivalent(ITypeSymbol? oldType, ITypeSymbol? newType, bool exact)
2400=> (exact ? s_exactSymbolEqualityComparer : (IEqualityComparer<ITypeSymbol?>)s_runtimeSymbolEqualityComparer.SignatureTypeEquivalenceComparer).Equals(oldType, newType);
2402protected static bool TypesEquivalent<T>(ImmutableArray<T> oldTypes, ImmutableArray<T> newTypes, bool exact) where T : ITypeSymbol
ExtractMethod\MethodExtractor.Analyzer.cs (20)
66protected abstract VariableInfo CreateFromSymbol(Compilation compilation, ISymbol symbol, ITypeSymbol type, VariableStyle variableStyle, bool variableDeclared);
124protected abstract ITypeSymbol GetRangeVariableType(SemanticModel model, IRangeVariableSymbol symbol);
210private (ITypeSymbol typeSymbol, bool hasAnonymousType, bool awaitTaskReturn) AdjustReturnType(SemanticModel model, ITypeSymbol returnType)
231private void UnwrapTaskIfNeeded(SemanticModel model, ref ITypeSymbol returnType)
240var originalDefinition = returnType.OriginalDefinition;
261private void WrapReturnTypeInTask(SemanticModel model, ref ITypeSymbol returnType, out bool awaitTaskReturn)
291private (ImmutableArray<VariableInfo> parameters, ITypeSymbol returnType, bool returnsByRef, VariableInfo? variableToUseAsReturnValue, bool unsafeAddressTakenUsed)
527var type = GetSymbolType(model, symbol);
562ITypeSymbol type,
632private bool SelectionContainsOnlyIdentifierWithSameType(ITypeSymbol type)
650protected virtual ITypeSymbol GetSymbolType(SemanticModel model, ISymbol symbol)
756var type = GetRangeVariableType(model, rangeVariable);
779foreach (var type in constraintTypes)
826var visited = new HashSet<ITypeSymbol>();
838foreach (var type in constraintTypes)
852ITypeSymbol type, HashSet<ITypeSymbol> visited)
902private static IEnumerable<ITypeParameterSymbol> GetMethodTypeParametersInDeclaration(ITypeSymbol returnType, SortedDictionary<int, ITypeParameterSymbol> sortedMap)
941ITypeSymbol type,
ExtractMethod\MethodExtractor.VariableSymbol.cs (7)
24protected VariableSymbol(Compilation compilation, ITypeSymbol type)
51public ITypeSymbol OriginalType { get; }
76private static bool IsCancellationToken(ITypeSymbol originalType)
94protected abstract class NotMovableVariableSymbol(Compilation compilation, ITypeSymbol type) : VariableSymbol(compilation, type)
118public ParameterVariableSymbol(Compilation compilation, IParameterSymbol parameterSymbol, ITypeSymbol type)
197public LocalVariableSymbol(Compilation compilation, ILocalSymbol localSymbol, ITypeSymbol type, HashSet<int> nonNoisySet)
311public QueryVariableSymbol(Compilation compilation, IRangeVariableSymbol symbol, ITypeSymbol type)
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)
38protected abstract ITypeSymbol GetArgumentType(SyntaxNode argumentNode, SemanticModel semanticModel, CancellationToken cancellationToken);
393private async Task<(ITypeSymbol, RefKind)> GetArgumentTypeAndRefKindAsync(Document invocationDocument, TArgumentSyntax argument, CancellationToken cancellationToken)
397var argumentType = GetArgumentType(argument, semanticModel, cancellationToken);
535Compilation compilation, TypeInfo argumentTypeInfo, ITypeSymbol parameterType,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\CodeGeneration\ExpressionGenerator.vb (12)
31If Not TypeOf typedConstant.Value Is 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 Not TypeOf typedConstant.Value Is 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 (21)
338private protected abstract SyntaxNode GenerateExpression(ITypeSymbol? type, object? value, bool canUseFieldReference);
1603/// <see langword="true"/> if the language requires a <see cref="TypeExpression(ITypeSymbol)"/>
1605/// <see cref="LocalDeclarationStatement(ITypeSymbol, string, SyntaxNode, bool)"/>.
1628public SyntaxNode LocalDeclarationStatement(ITypeSymbol type, string name, SyntaxNode? initializer = null, bool isConst = false)
1741public SyntaxNode CatchClause(ITypeSymbol type, string identifier, IEnumerable<SyntaxNode> statements)
1780public abstract SyntaxNode DefaultExpression(ITypeSymbol type);
1848public SyntaxNode GenericName(string identifier, IEnumerable<ITypeSymbol> typeArguments)
1860public SyntaxNode GenericName(string identifier, params ITypeSymbol[] typeArguments)
1861=> GenericName(identifier, (IEnumerable<ITypeSymbol>)typeArguments);
1930public SyntaxNode TypeExpression(ITypeSymbol typeSymbol)
1933private protected abstract SyntaxNode TypeExpression(ITypeSymbol typeSymbol, RefKind refKind);
1940public SyntaxNode TypeExpression(ITypeSymbol typeSymbol, bool addImport)
1992public SyntaxNode TupleTypeExpression(IEnumerable<ITypeSymbol> elementTypes, IEnumerable<string>? elementNames = null)
2021public SyntaxNode TupleElementExpression(ITypeSymbol type, string? name = null)
2205public SyntaxNode ObjectCreationExpression(ITypeSymbol type, IEnumerable<SyntaxNode> arguments)
2217public SyntaxNode ObjectCreationExpression(ITypeSymbol type, params SyntaxNode[] arguments)
2272public SyntaxNode IsTypeExpression(SyntaxNode expression, ITypeSymbol type)
2283public SyntaxNode TryCastExpression(SyntaxNode expression, ITypeSymbol type)
2294public 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);
185private ImmutableArray<ITypeSymbol> GetTypeSymbols(
194using var _ = ArrayBuilder<ITypeSymbol>.GetInstance(out var builder);
200if (!TryGetMatchingParameterTypeForArgument(method, argumentName, ordinalInInvocation, out var type))
238private bool TryGetMatchingParameterTypeForArgument(IMethodSymbol method, string argumentName, int ordinalInInvocation, out ITypeSymbol parameterType)
378if (unwrapNullable && namespaceOrType is ITypeSymbol typeSymbol)
398if (container is not ITypeSymbol containerType)
427static bool MatchesConstraints(ITypeSymbol originalContainerType, ImmutableArray<ITypeSymbol> constraintTypes)
434foreach (var constraintType in constraintTypes)
443static bool MatchesConstraint(ITypeSymbol originalContainerType, ITypeSymbol originalConstraintType)
461foreach (var constraintType in typeParameterContainer.ConstraintTypes)
486foreach (var constrainedType in typeParameterContainer.ConstraintTypes)
511static bool MatchesAnyBaseTypes(ITypeSymbol source, ITypeSymbol matched)
513for (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)
740var previousOriginalType = this.OriginalSemanticModel.GetTypeInfo(previousOriginalNode).Type;
741var previousReplacedType = this.SpeculativeSemanticModel.GetTypeInfo(previousReplacedNode).Type;
780GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
781GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
826var expressionType = this.SpeculativeSemanticModel.GetTypeInfo(newForEachStatementExpression, CancellationToken).ConvertedType;
849var originalThrowExpressionType = this.OriginalSemanticModel.GetTypeInfo(originalThrowExpression).Type;
851var newThrowExpressionType = this.SpeculativeSemanticModel.GetTypeInfo(newThrowExpression).Type;
964var originalTargetType = this.OriginalSemanticModel.GetTypeInfo(originalLeft).Type;
967var newTargetType = this.SpeculativeSemanticModel.GetTypeInfo(newLeft).Type;
1000var newReceiverType = newReceiver != null
1039var receiverType = semanticModel.GetTypeInfo(receiver).Type;
1199ITypeSymbol originalTargetType,
1201ITypeSymbol newTargetType,
1216var originalConvertedTypeSymbol = this.OriginalSemanticModel.GetTypeInfo(originalExpression).ConvertedType;
1222var 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,
110ITypeSymbol type, string name,
156ITypeSymbol? returnType,
178ITypeSymbol? returnType,
199ITypeSymbol returnType,
224ITypeSymbol toType,
252ITypeSymbol toType,
268public static IParameterSymbol CreateParameterSymbol(ITypeSymbol type, string name)
271public static IParameterSymbol CreateParameterSymbol(RefKind refKind, ITypeSymbol type, string name)
281ImmutableArray<AttributeData> attributes, RefKind refKind, bool isParams, ITypeSymbol type, string name, bool isOptional = false, bool hasDefaultValue = false, object? defaultValue = null)
294ITypeSymbol? type = null,
335ImmutableArray<ITypeSymbol> constraintTypes,
351public static IPointerTypeSymbol CreatePointerTypeSymbol(ITypeSymbol pointedAtType)
357public static IArrayTypeSymbol CreateArrayTypeSymbol(ITypeSymbol elementType, int rank = 1, NullableAnnotation nullableAnnotation = NullableAnnotation.None)
467ITypeSymbol returnType,
524ITypeSymbol? 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,