6 interfaces inheriting from ITypeSymbol
Microsoft.CodeAnalysis (6)
10 implementations of ITypeSymbol
GenerateDocumentationAndConfigFiles (1)
Microsoft.CodeAnalysis.Analyzers (1)
Microsoft.CodeAnalysis.BannedApiAnalyzers (1)
Microsoft.CodeAnalysis.CodeStyle.Fixes (1)
Microsoft.CodeAnalysis.CSharp (1)
Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers (1)
Microsoft.CodeAnalysis.VisualBasic (1)
Microsoft.CodeAnalysis.Workspaces (1)
Roslyn.Diagnostics.Analyzers (1)
Text.Analyzers (1)
9847 references to ITypeSymbol
Aspire.Hosting.Analyzers (5)
ConfigurationSchemaGenerator (69)
RuntimeSource\Configuration.Binder\ConfigurationBindingGenerator.Parser.cs (31)
26private readonly Dictionary<ITypeSymbol, TypeSpec> _createdTypeSpecs = new(SymbolEqualityComparer.Default);
64private bool IsValidRootConfigType([NotNullWhen(true)] ITypeSymbol? type)
110ITypeSymbol typeSymbol = typeParseInfo.TypeSymbol;
145private void EnqueueTargetTypeForRootInvocation(ITypeSymbol? typeSymbol, MethodsToGen overload, BinderInvocation invocation)
159private TypeRef EnqueueTransitiveType(TypeParseInfo containingTypeParseInfo, ITypeSymbol memberTypeSymbol, DiagnosticDescriptor diagDescriptor, string? memberName = null)
175ITypeSymbol type = typeParseInfo.TypeSymbol;
178if (IsNullable(type, out ITypeSymbol? underlyingType))
219private static bool IsNullable(ITypeSymbol type, [NotNullWhen(true)] out ITypeSymbol? underlyingType)
233private bool IsParsableFromString(ITypeSymbol type, out StringParsableTypeKind typeKind)
367if (IsCandidateDictionary(type, out ITypeSymbol? keyType, out ITypeSymbol? elementType))
381private TypeSpec CreateDictionarySpec(TypeParseInfo typeParseInfo, ITypeSymbol keyTypeSymbol, ITypeSymbol elementTypeSymbol)
447if (!TryGetElementType(type, out ITypeSymbol? elementType))
525private bool IsAssignableTo(ITypeSymbol source, ITypeSymbol dest)
531private bool IsUnsupportedType(ITypeSymbol type, int recursionDepth = 0)
566if (IsCandidateDictionary(collectionType, out ITypeSymbol? keyType, out ITypeSymbol? elementType))
753private bool TryGetElementType(INamedTypeSymbol type, [NotNullWhen(true)] out ITypeSymbol? elementType)
767private bool IsCandidateDictionary(INamedTypeSymbol type, [NotNullWhen(true)] out ITypeSymbol? keyType, [NotNullWhen(true)] out ITypeSymbol? elementType)
790private bool IsCollection(ITypeSymbol type) =>
832private static bool ContainsGenericParameters(ITypeSymbol type)
839foreach (ITypeSymbol typeArg in genericType.TypeArguments)
854private static bool HasAddMethod(INamedTypeSymbol type, ITypeSymbol element)
870private static bool HasAddMethod(INamedTypeSymbol type, ITypeSymbol key, ITypeSymbol element)
887private static bool IsEnum(ITypeSymbol type) => type is INamedTypeSymbol { EnumUnderlyingType: INamedTypeSymbol { } };
937foreach (var typeSymbol in _createdTypeSpecs.Keys)
GenerateDocumentationAndConfigFiles (428)
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\Compiler\Extensions\Symbols\ITypeSymbolExtensions.cs (100)
26public static bool IsIntegralType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
29public static bool IsSignedIntegralType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
32public static bool CanAddNullCheck([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
43public static ImmutableArray<INamedTypeSymbol> GetAllInterfacesIncludingThis(this ITypeSymbol type)
51public static bool IsAbstractClass([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
54public static bool IsSystemVoid([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
57public static bool IsNullable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
60public static bool IsNonNullableValueType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
64[NotNullWhen(true)] this ITypeSymbol? symbol,
65[NotNullWhen(true)] out ITypeSymbol? underlyingType)
77public static bool IsModuleType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
80public static bool IsInterfaceType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
83public static bool IsDelegateType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
86public static bool IsFunctionPointerType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
89public static bool IsStructType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
96this ITypeSymbol type,
110public static IEnumerable<ITypeSymbol> GetBaseTypesAndThis(this ITypeSymbol? type)
112var current = type;
120public static IEnumerable<INamedTypeSymbol> GetBaseTypes(this ITypeSymbol? type)
130public static IEnumerable<ITypeSymbol> GetContainingTypesAndThis(this ITypeSymbol? type)
132var current = type;
140public static IEnumerable<INamedTypeSymbol> GetContainingTypes(this ITypeSymbol type)
153this ITypeSymbol type, ITypeSymbol baseType, bool includeInterfaces)
166this ITypeSymbol type, ITypeSymbol baseType)
174this ITypeSymbol type, ITypeSymbol baseType)
176var originalBaseType = baseType.OriginalDefinition;
184IEnumerable<ITypeSymbol> baseTypes = (baseType.TypeKind == TypeKind.Interface) ? type.AllInterfaces : type.GetBaseTypes();
191this ITypeSymbol type, ITypeSymbol baseType)
193var originalBaseType = baseType.OriginalDefinition;
213this ITypeSymbol type, ITypeSymbol interfaceType)
215var originalInterfaceType = interfaceType.OriginalDefinition;
220this ITypeSymbol type, ITypeSymbol interfaceType)
225public static bool IsAttribute(this ITypeSymbol symbol)
243public static bool IsFormattableStringOrIFormattable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
252this ITypeSymbol typeSymbol, bool allowDelegateAndEnumConstraints = false)
280public static bool IsNumericType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
306public static Accessibility DetermineMinimalAccessibility(this ITypeSymbol typeSymbol)
309public static bool ContainsAnonymousType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
325foreach (var typeArg in type.GetAllTypeArguments())
334public static string CreateParameterName(this ITypeSymbol type, bool capitalize = false)
355private static string GetParameterName(ITypeSymbol? type)
368public static bool IsSpecialType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
399public static bool CanSupportCollectionInitializer(this ITypeSymbol typeSymbol, ISymbol within)
410public static INamedTypeSymbol? GetDelegateType(this ITypeSymbol? typeSymbol, Compilation compilation)
417var typeArgument = ((INamedTypeSymbol)typeSymbol).TypeArguments[0];
430public static IEnumerable<T> GetAccessibleMembersInBaseTypes<T>(this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol
439public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, ISymbol within) where T : class, ISymbol
449public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, string memberName, ISymbol within) where T : class, ISymbol
459public static bool? AreMoreSpecificThan(this IList<ITypeSymbol> t1, IList<ITypeSymbol> t2)
494public static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, ISymbol within) where T : class, ISymbol
504private static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, string memberName, ISymbol within) where T : class, ISymbol
514private static bool? IsMoreSpecificThan(this ITypeSymbol t1, ITypeSymbol t2)
592public static bool IsOrDerivesFromExceptionType([NotNullWhen(returnValue: true)] this ITypeSymbol? type, Compilation compilation)
599foreach (var baseType in type.GetBaseTypesAndThis())
610foreach (var constraint in ((ITypeParameterSymbol)type).ConstraintTypes)
625public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type)
628public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type, [NotNullWhen(true)] out INamedTypeSymbol? enumType)
640public static bool? IsMutableValueType(this ITypeSymbol type)
642if (type.IsNullable(out var underlyingType))
719public static bool IsDisposable([NotNullWhen(returnValue: true)] this ITypeSymbol? type, [NotNullWhen(returnValue: true)] ITypeSymbol? iDisposableType)
724public static ITypeSymbol WithNullableAnnotationFrom(this ITypeSymbol type, ITypeSymbol symbolForNullableAnnotation)
728public static ITypeSymbol? RemoveNullableIfPresent(this ITypeSymbol? symbol)
730if (symbol.IsNullable(out var underlyingType))
738public static bool IsSpanOrReadOnlySpan([NotNullWhen(true)] this ITypeSymbol? type)
741public static bool IsSpan([NotNullWhen(true)] this ITypeSymbol? type)
757public static bool IsInlineArray([NotNullWhen(true)] this ITypeSymbol? type)
762public static ITypeSymbol? RemoveUnavailableTypeParameters(
763this ITypeSymbol? type,
771private static ITypeSymbol? RemoveUnavailableTypeParameters(
772this ITypeSymbol? type,
780public static ITypeSymbol? RemoveAnonymousTypes(
781this ITypeSymbol? type,
788public static ITypeSymbol? RemoveUnnamedErrorTypes(
789this ITypeSymbol? type,
796this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
802this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
808this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result, bool onlyMethodTypeParameters)
817public static IList<ITypeParameterSymbol> GetReferencedTypeParameters(this ITypeSymbol? type)
825public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
826this ITypeSymbol? type,
829where TType1 : ITypeSymbol
830where TType2 : ITypeSymbol
836public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
837this ITypeSymbol? type,
840where TType1 : ITypeSymbol
841where TType2 : ITypeSymbol
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationSymbolFactory.cs (18)
30DeclarationModifiers modifiers, ITypeSymbol type,
47ITypeSymbol type,
79ITypeSymbol type, RefKind refKind, ImmutableArray<IPropertySymbol> explicitInterfaceImplementations, string name,
106ITypeSymbol type, string name,
152ITypeSymbol? returnType,
174ITypeSymbol? returnType,
195ITypeSymbol returnType,
220ITypeSymbol toType,
248ITypeSymbol toType,
264public static IParameterSymbol CreateParameterSymbol(ITypeSymbol type, string name)
267public static IParameterSymbol CreateParameterSymbol(RefKind refKind, ITypeSymbol type, string name)
277ImmutableArray<AttributeData> attributes, RefKind refKind, bool isParams, ITypeSymbol type, string name, bool isOptional = false, bool hasDefaultValue = false, object? defaultValue = null)
290ITypeSymbol? type = null,
331ImmutableArray<ITypeSymbol> constraintTypes,
347public static IPointerTypeSymbol CreatePointerTypeSymbol(ITypeSymbol pointedAtType)
353public static IArrayTypeSymbol CreateArrayTypeSymbol(ITypeSymbol elementType, int rank = 1, NullableAnnotation nullableAnnotation = NullableAnnotation.None)
463ITypeSymbol returnType,
520ITypeSymbol? 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)
15ITypeSymbol toType,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationOperatorSymbol.cs (1)
15ITypeSymbol returnType,
ILLink.RoslynAnalyzer (73)
DataFlow\DynamicallyAccessedMembersBinder.cs (33)
17public static IEnumerable<ISymbol> GetDynamicallyAccessedMembers(this ITypeSymbol typeDefinition, DynamicallyAccessedMemberTypes memberTypes, bool declaredOnly = false)
82foreach (var nested in typeDefinition.ApplyIncludeInherited(t => t.GetNestedTypesOnType(filter: null, bindingFlags: BindingFlags.NonPublic), withInherited))
95foreach (var nested in typeDefinition.ApplyIncludeInherited(t => t.GetNestedTypesOnType(filter: null, bindingFlags: BindingFlags.Public), withInherited))
133foreach (var i in typeDefinition.GetAllInterfaceImplementations(declaredOnly))
137public static IEnumerable<IMethodSymbol> GetConstructorsOnType(this ITypeSymbol type, Func<IMethodSymbol, bool>? filter, BindingFlags? bindingFlags = null)
164public static IEnumerable<IMethodSymbol> GetMethodsOnTypeHierarchy(this ITypeSymbol thisType, Func<IMethodSymbol, bool>? filter, BindingFlags? bindingFlags = null)
166ITypeSymbol? type = thisType;
209public static IEnumerable<IFieldSymbol> GetFieldsOnTypeHierarchy(this ITypeSymbol thisType, Func<IFieldSymbol, bool>? filter, BindingFlags? bindingFlags = BindingFlags.Default)
211ITypeSymbol? type = thisType;
250public static IEnumerable<ITypeSymbol> GetNestedTypesOnType(this ITypeSymbol type, Func<ITypeSymbol, bool>? filter, BindingFlags? bindingFlags = BindingFlags.Default)
252foreach (var nestedType in type.GetTypeMembers().OfType<ITypeSymbol>())
273public static IEnumerable<IPropertySymbol> GetPropertiesOnTypeHierarchy(this ITypeSymbol thisType, Func<IPropertySymbol, bool>? filter, BindingFlags? bindingFlags = BindingFlags.Default)
275ITypeSymbol? type = thisType;
328public static IEnumerable<IEventSymbol> GetEventsOnTypeHierarchy(this ITypeSymbol thisType, Func<IEventSymbol, bool>? filter, BindingFlags? bindingFlags = BindingFlags.Default)
330ITypeSymbol? type = thisType;
386public static IEnumerable<ITypeSymbol> GetAllInterfaceImplementations(this ITypeSymbol thisType, bool declaredOnly)
388ITypeSymbol? type = thisType;
395ITypeSymbol? interfaceType = i;
399foreach (var innerInterface in interfaceType.GetAllInterfaceImplementations(declaredOnly: true))
415public static void GetAllOnType(this ITypeSymbol type, bool declaredOnly, List<ISymbol> members) => GetAllOnType(type, declaredOnly, members, new HashSet<ITypeSymbol>(SymbolEqualityComparer.Default));
418private static void GetAllOnType(ITypeSymbol type, bool declaredOnly, List<ISymbol> members, HashSet<ITypeSymbol> types)
423foreach (var nestedType in type.GetTypeMembers().OfType<ITypeSymbol>())
441foreach (var iface in type.GetAllInterfaceImplementations(declaredOnly: true))
470private static IEnumerable<T> ApplyIncludeInherited<T>(this ITypeSymbol thisType, Func<ITypeSymbol, IEnumerable<T>> selector, bool includeBases)
472ITypeSymbol? type = thisType;
TrimAnalysis\ReflectionAccessAnalyzer.cs (6)
27internal void GetReflectionAccessDiagnostics(Location location, ITypeSymbol typeSymbol, DynamicallyAccessedMemberTypes requiredMemberTypes, bool declaredOnly = false)
58internal void GetReflectionAccessDiagnosticsForEventsOnTypeHierarchy(Location location, ITypeSymbol typeSymbol, string name, BindingFlags? bindingFlags)
64internal void GetReflectionAccessDiagnosticsForFieldsOnTypeHierarchy(Location location, ITypeSymbol typeSymbol, string name, BindingFlags? bindingFlags)
70internal void GetReflectionAccessDiagnosticsForPropertiesOnTypeHierarchy(Location location, ITypeSymbol typeSymbol, string name, BindingFlags? bindingFlags)
76internal void GetReflectionAccessDiagnosticsForConstructorsOnType(Location location, ITypeSymbol typeSymbol, BindingFlags? bindingFlags, int? parameterCount)
82internal void GetReflectionAccessDiagnosticsForPublicParameterlessConstructor(Location location, ITypeSymbol typeSymbol)
Metrics (304)
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\Compiler\Extensions\Symbols\ITypeSymbolExtensions.cs (100)
26public static bool IsIntegralType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
29public static bool IsSignedIntegralType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
32public static bool CanAddNullCheck([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
43public static ImmutableArray<INamedTypeSymbol> GetAllInterfacesIncludingThis(this ITypeSymbol type)
51public static bool IsAbstractClass([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
54public static bool IsSystemVoid([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
57public static bool IsNullable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
60public static bool IsNonNullableValueType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
64[NotNullWhen(true)] this ITypeSymbol? symbol,
65[NotNullWhen(true)] out ITypeSymbol? underlyingType)
77public static bool IsModuleType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
80public static bool IsInterfaceType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
83public static bool IsDelegateType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
86public static bool IsFunctionPointerType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
89public static bool IsStructType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
96this ITypeSymbol type,
110public static IEnumerable<ITypeSymbol> GetBaseTypesAndThis(this ITypeSymbol? type)
112var current = type;
120public static IEnumerable<INamedTypeSymbol> GetBaseTypes(this ITypeSymbol? type)
130public static IEnumerable<ITypeSymbol> GetContainingTypesAndThis(this ITypeSymbol? type)
132var current = type;
140public static IEnumerable<INamedTypeSymbol> GetContainingTypes(this ITypeSymbol type)
153this ITypeSymbol type, ITypeSymbol baseType, bool includeInterfaces)
166this ITypeSymbol type, ITypeSymbol baseType)
174this ITypeSymbol type, ITypeSymbol baseType)
176var originalBaseType = baseType.OriginalDefinition;
184IEnumerable<ITypeSymbol> baseTypes = (baseType.TypeKind == TypeKind.Interface) ? type.AllInterfaces : type.GetBaseTypes();
191this ITypeSymbol type, ITypeSymbol baseType)
193var originalBaseType = baseType.OriginalDefinition;
213this ITypeSymbol type, ITypeSymbol interfaceType)
215var originalInterfaceType = interfaceType.OriginalDefinition;
220this ITypeSymbol type, ITypeSymbol interfaceType)
225public static bool IsAttribute(this ITypeSymbol symbol)
243public static bool IsFormattableStringOrIFormattable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
252this ITypeSymbol typeSymbol, bool allowDelegateAndEnumConstraints = false)
280public static bool IsNumericType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
306public static Accessibility DetermineMinimalAccessibility(this ITypeSymbol typeSymbol)
309public static bool ContainsAnonymousType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
325foreach (var typeArg in type.GetAllTypeArguments())
334public static string CreateParameterName(this ITypeSymbol type, bool capitalize = false)
355private static string GetParameterName(ITypeSymbol? type)
368public static bool IsSpecialType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
399public static bool CanSupportCollectionInitializer(this ITypeSymbol typeSymbol, ISymbol within)
410public static INamedTypeSymbol? GetDelegateType(this ITypeSymbol? typeSymbol, Compilation compilation)
417var typeArgument = ((INamedTypeSymbol)typeSymbol).TypeArguments[0];
430public static IEnumerable<T> GetAccessibleMembersInBaseTypes<T>(this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol
439public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, ISymbol within) where T : class, ISymbol
449public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, string memberName, ISymbol within) where T : class, ISymbol
459public static bool? AreMoreSpecificThan(this IList<ITypeSymbol> t1, IList<ITypeSymbol> t2)
494public static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, ISymbol within) where T : class, ISymbol
504private static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, string memberName, ISymbol within) where T : class, ISymbol
514private static bool? IsMoreSpecificThan(this ITypeSymbol t1, ITypeSymbol t2)
592public static bool IsOrDerivesFromExceptionType([NotNullWhen(returnValue: true)] this ITypeSymbol? type, Compilation compilation)
599foreach (var baseType in type.GetBaseTypesAndThis())
610foreach (var constraint in ((ITypeParameterSymbol)type).ConstraintTypes)
625public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type)
628public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type, [NotNullWhen(true)] out INamedTypeSymbol? enumType)
640public static bool? IsMutableValueType(this ITypeSymbol type)
642if (type.IsNullable(out var underlyingType))
719public static bool IsDisposable([NotNullWhen(returnValue: true)] this ITypeSymbol? type, [NotNullWhen(returnValue: true)] ITypeSymbol? iDisposableType)
724public static ITypeSymbol WithNullableAnnotationFrom(this ITypeSymbol type, ITypeSymbol symbolForNullableAnnotation)
728public static ITypeSymbol? RemoveNullableIfPresent(this ITypeSymbol? symbol)
730if (symbol.IsNullable(out var underlyingType))
738public static bool IsSpanOrReadOnlySpan([NotNullWhen(true)] this ITypeSymbol? type)
741public static bool IsSpan([NotNullWhen(true)] this ITypeSymbol? type)
757public static bool IsInlineArray([NotNullWhen(true)] this ITypeSymbol? type)
762public static ITypeSymbol? RemoveUnavailableTypeParameters(
763this ITypeSymbol? type,
771private static ITypeSymbol? RemoveUnavailableTypeParameters(
772this ITypeSymbol? type,
780public static ITypeSymbol? RemoveAnonymousTypes(
781this ITypeSymbol? type,
788public static ITypeSymbol? RemoveUnnamedErrorTypes(
789this ITypeSymbol? type,
796this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
802this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
808this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result, bool onlyMethodTypeParameters)
817public static IList<ITypeParameterSymbol> GetReferencedTypeParameters(this ITypeSymbol? type)
825public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
826this ITypeSymbol? type,
829where TType1 : ITypeSymbol
830where TType2 : ITypeSymbol
836public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
837this ITypeSymbol? type,
840where TType1 : ITypeSymbol
841where TType2 : ITypeSymbol
Metrics.Legacy (304)
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\Compiler\Extensions\Symbols\ITypeSymbolExtensions.cs (100)
26public static bool IsIntegralType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
29public static bool IsSignedIntegralType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
32public static bool CanAddNullCheck([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
43public static ImmutableArray<INamedTypeSymbol> GetAllInterfacesIncludingThis(this ITypeSymbol type)
51public static bool IsAbstractClass([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
54public static bool IsSystemVoid([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
57public static bool IsNullable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
60public static bool IsNonNullableValueType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
64[NotNullWhen(true)] this ITypeSymbol? symbol,
65[NotNullWhen(true)] out ITypeSymbol? underlyingType)
77public static bool IsModuleType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
80public static bool IsInterfaceType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
83public static bool IsDelegateType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
86public static bool IsFunctionPointerType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
89public static bool IsStructType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
96this ITypeSymbol type,
110public static IEnumerable<ITypeSymbol> GetBaseTypesAndThis(this ITypeSymbol? type)
112var current = type;
120public static IEnumerable<INamedTypeSymbol> GetBaseTypes(this ITypeSymbol? type)
130public static IEnumerable<ITypeSymbol> GetContainingTypesAndThis(this ITypeSymbol? type)
132var current = type;
140public static IEnumerable<INamedTypeSymbol> GetContainingTypes(this ITypeSymbol type)
153this ITypeSymbol type, ITypeSymbol baseType, bool includeInterfaces)
166this ITypeSymbol type, ITypeSymbol baseType)
174this ITypeSymbol type, ITypeSymbol baseType)
176var originalBaseType = baseType.OriginalDefinition;
184IEnumerable<ITypeSymbol> baseTypes = (baseType.TypeKind == TypeKind.Interface) ? type.AllInterfaces : type.GetBaseTypes();
191this ITypeSymbol type, ITypeSymbol baseType)
193var originalBaseType = baseType.OriginalDefinition;
213this ITypeSymbol type, ITypeSymbol interfaceType)
215var originalInterfaceType = interfaceType.OriginalDefinition;
220this ITypeSymbol type, ITypeSymbol interfaceType)
225public static bool IsAttribute(this ITypeSymbol symbol)
243public static bool IsFormattableStringOrIFormattable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
252this ITypeSymbol typeSymbol, bool allowDelegateAndEnumConstraints = false)
280public static bool IsNumericType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
306public static Accessibility DetermineMinimalAccessibility(this ITypeSymbol typeSymbol)
309public static bool ContainsAnonymousType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
325foreach (var typeArg in type.GetAllTypeArguments())
334public static string CreateParameterName(this ITypeSymbol type, bool capitalize = false)
355private static string GetParameterName(ITypeSymbol? type)
368public static bool IsSpecialType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
399public static bool CanSupportCollectionInitializer(this ITypeSymbol typeSymbol, ISymbol within)
410public static INamedTypeSymbol? GetDelegateType(this ITypeSymbol? typeSymbol, Compilation compilation)
417var typeArgument = ((INamedTypeSymbol)typeSymbol).TypeArguments[0];
430public static IEnumerable<T> GetAccessibleMembersInBaseTypes<T>(this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol
439public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, ISymbol within) where T : class, ISymbol
449public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, string memberName, ISymbol within) where T : class, ISymbol
459public static bool? AreMoreSpecificThan(this IList<ITypeSymbol> t1, IList<ITypeSymbol> t2)
494public static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, ISymbol within) where T : class, ISymbol
504private static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, string memberName, ISymbol within) where T : class, ISymbol
514private static bool? IsMoreSpecificThan(this ITypeSymbol t1, ITypeSymbol t2)
592public static bool IsOrDerivesFromExceptionType([NotNullWhen(returnValue: true)] this ITypeSymbol? type, Compilation compilation)
599foreach (var baseType in type.GetBaseTypesAndThis())
610foreach (var constraint in ((ITypeParameterSymbol)type).ConstraintTypes)
625public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type)
628public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type, [NotNullWhen(true)] out INamedTypeSymbol? enumType)
640public static bool? IsMutableValueType(this ITypeSymbol type)
642if (type.IsNullable(out var underlyingType))
719public static bool IsDisposable([NotNullWhen(returnValue: true)] this ITypeSymbol? type, [NotNullWhen(returnValue: true)] ITypeSymbol? iDisposableType)
724public static ITypeSymbol WithNullableAnnotationFrom(this ITypeSymbol type, ITypeSymbol symbolForNullableAnnotation)
728public static ITypeSymbol? RemoveNullableIfPresent(this ITypeSymbol? symbol)
730if (symbol.IsNullable(out var underlyingType))
738public static bool IsSpanOrReadOnlySpan([NotNullWhen(true)] this ITypeSymbol? type)
741public static bool IsSpan([NotNullWhen(true)] this ITypeSymbol? type)
757public static bool IsInlineArray([NotNullWhen(true)] this ITypeSymbol? type)
762public static ITypeSymbol? RemoveUnavailableTypeParameters(
763this ITypeSymbol? type,
771private static ITypeSymbol? RemoveUnavailableTypeParameters(
772this ITypeSymbol? type,
780public static ITypeSymbol? RemoveAnonymousTypes(
781this ITypeSymbol? type,
788public static ITypeSymbol? RemoveUnnamedErrorTypes(
789this ITypeSymbol? type,
796this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
802this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
808this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result, bool onlyMethodTypeParameters)
817public static IList<ITypeParameterSymbol> GetReferencedTypeParameters(this ITypeSymbol? type)
825public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
826this ITypeSymbol? type,
829where TType1 : ITypeSymbol
830where TType2 : ITypeSymbol
836public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
837this ITypeSymbol? type,
840where TType1 : ITypeSymbol
841where TType2 : ITypeSymbol
Microsoft.Analyzers.Extra (24)
Microsoft.Analyzers.Local (3)
Microsoft.AspNetCore.App.Analyzers (53)
src\Shared\Roslyn\CodeAnalysisExtensions.cs (15)
15public static bool HasAttribute(this ITypeSymbol typeSymbol, ITypeSymbol attribute, bool inherit)
18public static bool HasAttribute(this IMethodSymbol methodSymbol, ITypeSymbol attribute, bool inherit)
21public static IEnumerable<AttributeData> GetAttributes(this ISymbol symbol, ITypeSymbol attribute)
32public static IEnumerable<AttributeData> GetAttributes(this IMethodSymbol methodSymbol, ITypeSymbol attribute, bool inherit)
54public static IEnumerable<AttributeData> GetAttributes(this ITypeSymbol typeSymbol, ITypeSymbol attribute, bool inherit)
59foreach (var type in GetTypeHierarchy(typeSymbol))
73public static bool HasAttribute(this IPropertySymbol propertySymbol, ITypeSymbol attribute, bool inherit)
97public static bool IsAssignableFrom(this ITypeSymbol source, ITypeSymbol target)
120foreach (var type in target.GetTypeHierarchy())
131public static bool HasAttribute(this ISymbol symbol, ITypeSymbol attribute)
144public static IEnumerable<ITypeSymbol> GetTypeHierarchy(this ITypeSymbol? typeSymbol)
src\Shared\RoslynUtils\ParsabilityHelper.cs (12)
20private static readonly BoundedCacheWithFactory<ITypeSymbol, (BindabilityMethod?, IMethodSymbol?)> BindabilityCache = new();
21private static readonly BoundedCacheWithFactory<ITypeSymbol, (Parsability, ParsabilityMethod?)> ParsabilityCache = new();
23private static bool IsTypeAlwaysParsable(ITypeSymbol typeSymbol, WellKnownTypes wellKnownTypes, [NotNullWhen(true)] out ParsabilityMethod? parsabilityMethod)
50internal static Parsability GetParsability(ITypeSymbol typeSymbol, WellKnownTypes wellKnownTypes)
55internal static Parsability GetParsability(ITypeSymbol typeSymbol, WellKnownTypes wellKnownTypes, [NotNullWhen(false)] out ParsabilityMethod? parsabilityMethod)
115internal static bool IsParsableViaIParsable(ITypeSymbol typeSymbol, WellKnownTypes wellKnownTypes)
124private static bool IsBindableViaIBindableFromHttpContext(ITypeSymbol typeSymbol, WellKnownTypes wellKnownTypes)
134private static bool IsBindAsync(IMethodSymbol methodSymbol, ITypeSymbol typeSymbol, WellKnownTypes wellKnownTypes)
145private static bool IsBindAsyncWithParameter(IMethodSymbol methodSymbol, ITypeSymbol typeSymbol, WellKnownTypes wellKnownTypes)
156private static bool IsReturningValueTaskOfTOrNullableT(INamedTypeSymbol returnType, ITypeSymbol containingType, WellKnownTypes wellKnownTypes)
162internal static Bindability GetBindability(ITypeSymbol typeSymbol, WellKnownTypes wellKnownTypes, out BindabilityMethod? bindabilityMethod, out IMethodSymbol? bindMethodSymbol)
180foreach (var candidate in searchCandidates)
Microsoft.AspNetCore.App.CodeFixes (4)
Microsoft.AspNetCore.Http.RequestDelegateGenerator (57)
src\Shared\RoslynUtils\ParsabilityHelper.cs (12)
20private static readonly BoundedCacheWithFactory<ITypeSymbol, (BindabilityMethod?, IMethodSymbol?)> BindabilityCache = new();
21private static readonly BoundedCacheWithFactory<ITypeSymbol, (Parsability, ParsabilityMethod?)> ParsabilityCache = new();
23private static bool IsTypeAlwaysParsable(ITypeSymbol typeSymbol, WellKnownTypes wellKnownTypes, [NotNullWhen(true)] out ParsabilityMethod? parsabilityMethod)
50internal static Parsability GetParsability(ITypeSymbol typeSymbol, WellKnownTypes wellKnownTypes)
55internal static Parsability GetParsability(ITypeSymbol typeSymbol, WellKnownTypes wellKnownTypes, [NotNullWhen(false)] out ParsabilityMethod? parsabilityMethod)
115internal static bool IsParsableViaIParsable(ITypeSymbol typeSymbol, WellKnownTypes wellKnownTypes)
124private static bool IsBindableViaIBindableFromHttpContext(ITypeSymbol typeSymbol, WellKnownTypes wellKnownTypes)
134private static bool IsBindAsync(IMethodSymbol methodSymbol, ITypeSymbol typeSymbol, WellKnownTypes wellKnownTypes)
145private static bool IsBindAsyncWithParameter(IMethodSymbol methodSymbol, ITypeSymbol typeSymbol, WellKnownTypes wellKnownTypes)
156private static bool IsReturningValueTaskOfTOrNullableT(INamedTypeSymbol returnType, ITypeSymbol containingType, WellKnownTypes wellKnownTypes)
162internal static Bindability GetBindability(ITypeSymbol typeSymbol, WellKnownTypes wellKnownTypes, out BindabilityMethod? bindabilityMethod, out IMethodSymbol? bindMethodSymbol)
180foreach (var candidate in searchCandidates)
StaticRouteHandlerModel\EndpointParameter.cs (13)
54private EndpointParameter(Endpoint endpoint, ITypeSymbol typeSymbol, string parameterName, WellKnownTypes wellKnownTypes)
60IsArray = TryGetArrayElementType(typeSymbol, out var elementType);
267private static bool ImplementsIEndpointMetadataProvider(ITypeSymbol type, WellKnownTypes wellKnownTypes)
270private static bool ImplementsIEndpointParameterMetadataProvider(ITypeSymbol type, WellKnownTypes wellKnownTypes)
273public ITypeSymbol Type { get; }
274public ITypeSymbol ElementType { get; }
304private static bool HasBindAsync(ITypeSymbol typeSymbol, WellKnownTypes wellKnownTypes, [NotNullWhen(true)] out BindabilityMethod? bindMethod, [NotNullWhen(true)] out IMethodSymbol? bindMethodSymbol)
306var parameterType = typeSymbol.UnwrapTypeSymbol(unwrapArray: true, unwrapNullable: true);
310private static bool TryGetArrayElementType(ITypeSymbol type, [NotNullWhen(true)] out ITypeSymbol elementType)
324private bool TryGetParsability(ITypeSymbol typeSymbol, WellKnownTypes wellKnownTypes, [NotNullWhen(true)] out Func<string, string, string>? preferredTryParseInvocation)
326var parameterType = typeSymbol.UnwrapTypeSymbol(unwrapArray: true, unwrapNullable: true);
381private static bool TryGetSpecialTypeAssigningCode(ITypeSymbol type, WellKnownTypes wellKnownTypes, [NotNullWhen(true)] out string? callingCode)
Microsoft.AspNetCore.Mvc.Analyzers (17)
src\Shared\Roslyn\CodeAnalysisExtensions.cs (15)
15public static bool HasAttribute(this ITypeSymbol typeSymbol, ITypeSymbol attribute, bool inherit)
18public static bool HasAttribute(this IMethodSymbol methodSymbol, ITypeSymbol attribute, bool inherit)
21public static IEnumerable<AttributeData> GetAttributes(this ISymbol symbol, ITypeSymbol attribute)
32public static IEnumerable<AttributeData> GetAttributes(this IMethodSymbol methodSymbol, ITypeSymbol attribute, bool inherit)
54public static IEnumerable<AttributeData> GetAttributes(this ITypeSymbol typeSymbol, ITypeSymbol attribute, bool inherit)
59foreach (var type in GetTypeHierarchy(typeSymbol))
73public static bool HasAttribute(this IPropertySymbol propertySymbol, ITypeSymbol attribute, bool inherit)
97public static bool IsAssignableFrom(this ITypeSymbol source, ITypeSymbol target)
120foreach (var type in target.GetTypeHierarchy())
131public static bool HasAttribute(this ISymbol symbol, ITypeSymbol attribute)
144public static IEnumerable<ITypeSymbol> GetTypeHierarchy(this ITypeSymbol? typeSymbol)
Microsoft.AspNetCore.Mvc.Api.Analyzers (44)
src\Shared\Roslyn\CodeAnalysisExtensions.cs (15)
15public static bool HasAttribute(this ITypeSymbol typeSymbol, ITypeSymbol attribute, bool inherit)
18public static bool HasAttribute(this IMethodSymbol methodSymbol, ITypeSymbol attribute, bool inherit)
21public static IEnumerable<AttributeData> GetAttributes(this ISymbol symbol, ITypeSymbol attribute)
32public static IEnumerable<AttributeData> GetAttributes(this IMethodSymbol methodSymbol, ITypeSymbol attribute, bool inherit)
54public static IEnumerable<AttributeData> GetAttributes(this ITypeSymbol typeSymbol, ITypeSymbol attribute, bool inherit)
59foreach (var type in GetTypeHierarchy(typeSymbol))
73public static bool HasAttribute(this IPropertySymbol propertySymbol, ITypeSymbol attribute, bool inherit)
97public static bool IsAssignableFrom(this ITypeSymbol source, ITypeSymbol target)
120foreach (var type in target.GetTypeHierarchy())
131public static bool HasAttribute(this ISymbol symbol, ITypeSymbol attribute)
144public static IEnumerable<ITypeSymbol> GetTypeHierarchy(this ITypeSymbol? typeSymbol)
Microsoft.AspNetCore.OpenApi.SourceGenerators (4)
Microsoft.AspNetCore.SignalR.Client.SourceGenerator (5)
Microsoft.CodeAnalysis (445)
Compilation\Compilation.cs (39)
1007internal abstract bool IsAttributeType(ITypeSymbol type);
1020public ITypeSymbol DynamicType { get { return CommonDynamicType; } }
1021protected abstract ITypeSymbol CommonDynamicType { get; }
1026internal ITypeSymbol? ScriptGlobalsType => CommonScriptGlobalsType;
1027protected abstract ITypeSymbol? CommonScriptGlobalsType { get; }
1085public IArrayTypeSymbol CreateArrayTypeSymbol(ITypeSymbol elementType, int rank = 1, NullableAnnotation elementNullableAnnotation = NullableAnnotation.None)
1095public IArrayTypeSymbol CreateArrayTypeSymbol(ITypeSymbol elementType, int rank)
1100protected abstract IArrayTypeSymbol CommonCreateArrayTypeSymbol(ITypeSymbol elementType, int rank, NullableAnnotation elementNullableAnnotation);
1107public IPointerTypeSymbol CreatePointerTypeSymbol(ITypeSymbol pointedAtType)
1112protected abstract IPointerTypeSymbol CommonCreatePointerTypeSymbol(ITypeSymbol elementType);
1128ITypeSymbol returnType,
1130ImmutableArray<ITypeSymbol> parameterTypes,
1139ITypeSymbol returnType,
1141ImmutableArray<ITypeSymbol> parameterTypes,
1297ImmutableArray<ITypeSymbol> elementTypes,
1338ImmutableArray<ITypeSymbol> elementTypes,
1402ImmutableArray<ITypeSymbol> elementTypes,
1454ImmutableArray<ITypeSymbol> memberTypes,
1523ImmutableArray<ITypeSymbol> memberTypes,
1532ImmutableArray<ITypeSymbol> memberTypes,
1548public IMethodSymbol CreateBuiltinOperator(string name, ITypeSymbol returnType, ITypeSymbol leftType, ITypeSymbol rightType)
1564protected abstract IMethodSymbol CommonCreateBuiltinOperator(string name, ITypeSymbol returnType, ITypeSymbol leftType, ITypeSymbol rightType);
1575public IMethodSymbol CreateBuiltinOperator(string name, ITypeSymbol returnType, ITypeSymbol operandType)
1588protected abstract IMethodSymbol CommonCreateBuiltinOperator(string name, ITypeSymbol returnType, ITypeSymbol operandType);
1598public abstract CommonConversion ClassifyCommonConversion(ITypeSymbol source, ITypeSymbol destination);
1606public bool HasImplicitConversion(ITypeSymbol? fromType, ITypeSymbol? toType)
1629ITypeSymbol? throughType = null)
1758ITypeSymbol? throughType);
1760internal abstract IConvertibleConversion ClassifyConvertibleConversion(IOperation source, ITypeSymbol destination, out ConstantValue? constantValue);
3696internal string GetMessage(ITypeSymbol source, ITypeSymbol destination)
DocumentationCommentId.cs (14)
864private static ITypeSymbol? ParseTypeSymbol(string id, ref int index, Compilation compilation, ISymbol? typeParameterContext)
876return (ITypeSymbol)results[0];
918results.AddRange(contexts.OfType<ITypeSymbol>());
944var typeSymbol = (ITypeSymbol)results[i];
1022List<ITypeSymbol>? typeArguments = null;
1028typeArguments = new List<ITypeSymbol>();
1121private static bool ParseTypeArguments(string id, ref int index, Compilation compilation, ISymbol? typeParameterContext, List<ITypeSymbol> typeArguments)
1127var type = ParseTypeSymbol(id, ref index, compilation, typeParameterContext);
1261ITypeSymbol? returnType = ParseTypeSymbol(id, ref index, compilation, methodSymbol);
1405var parameterType = parameterInfo.Type;
1441internal readonly ITypeSymbol Type;
1444public ParameterInfo(ITypeSymbol type, bool isRefOrOut)
1498var type = ParseTypeSymbol(id, ref index, compilation, typeParameterContext);
Generated\Operations.Generated.cs (273)
718ITypeSymbol? ConstrainedToType { get; }
781ITypeSymbol? ConstrainedToType { get; }
911ITypeSymbol? ConstrainedToType { get; }
1081ITypeSymbol? ConstrainedToType { get; }
1140ITypeSymbol? ConstrainedToType { get; }
1401ITypeSymbol TypeOperand { get; }
1533ITypeSymbol? ConstrainedToType { get; }
1838ITypeSymbol? NaturalType { get; }
1900ImmutableArray<ITypeSymbol> TypeArguments { get; }
1904ITypeSymbol? ContainingType { get; }
2076ITypeSymbol TypeOperand { get; }
2100ITypeSymbol TypeOperand { get; }
2203ITypeSymbol? ConstrainedToType { get; }
2612ITypeSymbol ExceptionType { get; }
2889ITypeSymbol InputType { get; }
2893ITypeSymbol NarrowedType { get; }
2941ITypeSymbol? MatchedType { get; }
3221ITypeSymbol MatchedType { get; }
3565ITypeSymbol MatchedType { get; }
3989ITypeSymbol? ElementType { get; }
4050public override ITypeSymbol? Type => null;
4105public override ITypeSymbol? Type => null;
4175public override ITypeSymbol? Type => null;
4281public override ITypeSymbol? Type => null;
4373public override ITypeSymbol? Type => null;
4485public override ITypeSymbol? Type => null;
4509public override ITypeSymbol? Type => null;
4562public override ITypeSymbol? Type => null;
4582public override ITypeSymbol? Type => null;
4596public override ITypeSymbol? Type => null;
4648public override ITypeSymbol? Type => null;
4712public override ITypeSymbol? Type => null;
4791public override ITypeSymbol? Type => null;
4859public override ITypeSymbol? Type => null;
4910public override ITypeSymbol? Type => null;
4974public override ITypeSymbol? Type => null;
4988public override ITypeSymbol? Type => null;
5002public override ITypeSymbol? Type => null;
5068public override ITypeSymbol? Type => null;
5076internal LiteralOperation(SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit)
5086public override ITypeSymbol? Type { get; }
5094internal ConversionOperation(IOperation operand, IConvertibleConversion conversion, bool isTryCast, bool isChecked, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit)
5146public override ITypeSymbol? Type { get; }
5154internal InvocationOperation(IMethodSymbol targetMethod, ITypeSymbol? constrainedToType, IOperation? instance, bool isVirtual, ImmutableArray<IArgumentOperation> arguments, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
5165public ITypeSymbol? ConstrainedToType { get; }
5219public override ITypeSymbol? Type { get; }
5227internal ArrayElementReferenceOperation(IOperation arrayReference, ImmutableArray<IOperation> indices, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
5286public override ITypeSymbol? Type { get; }
5294internal LocalReferenceOperation(ILocalSymbol local, bool isDeclaration, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit)
5308public override ITypeSymbol? Type { get; }
5316internal ParameterReferenceOperation(IParameterSymbol parameter, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
5327public override ITypeSymbol? Type { get; }
5341public abstract ITypeSymbol? ConstrainedToType { get; }
5345internal FieldReferenceOperation(IFieldSymbol field, bool isDeclaration, IOperation? instance, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit)
5392public override ITypeSymbol? Type { get; }
5400internal MethodReferenceOperation(IMethodSymbol method, ITypeSymbol? constrainedToType, bool isVirtual, IOperation? instance, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
5409public override ITypeSymbol? ConstrainedToType { get; }
5448public override ITypeSymbol? Type { get; }
5456internal PropertyReferenceOperation(IPropertySymbol property, ITypeSymbol? constrainedToType, ImmutableArray<IArgumentOperation> arguments, IOperation? instance, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
5465public override ITypeSymbol? ConstrainedToType { get; }
5517public override ITypeSymbol? Type { get; }
5525internal EventReferenceOperation(IEventSymbol @event, ITypeSymbol? constrainedToType, IOperation? instance, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
5533public override ITypeSymbol? ConstrainedToType { get; }
5571public override ITypeSymbol? Type { get; }
5579internal UnaryOperation(UnaryOperatorKind operatorKind, IOperation operand, bool isLifted, bool isChecked, IMethodSymbol? operatorMethod, ITypeSymbol? constrainedToType, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit)
5596public ITypeSymbol? ConstrainedToType { get; }
5634public override ITypeSymbol? Type { get; }
5642internal BinaryOperation(BinaryOperatorKind operatorKind, IOperation leftOperand, IOperation rightOperand, bool isLifted, bool isChecked, bool isCompareText, IMethodSymbol? operatorMethod, ITypeSymbol? constrainedToType, IMethodSymbol? unaryOperatorMethod, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit)
5664public ITypeSymbol? ConstrainedToType { get; }
5712public override ITypeSymbol? Type { get; }
5720internal ConditionalOperation(IOperation condition, IOperation whenTrue, IOperation? whenFalse, bool isRef, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit)
5789public override ITypeSymbol? Type { get; }
5797internal CoalesceOperation(IOperation value, IOperation whenNull, IConvertibleConversion valueConversion, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit)
5856public override ITypeSymbol? Type { get; }
5909public override ITypeSymbol? Type => null;
5917internal ObjectCreationOperation(IMethodSymbol? constructor, IObjectOrCollectionInitializerOperation? initializer, ImmutableArray<IArgumentOperation> arguments, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit)
5979public override ITypeSymbol? Type { get; }
5987internal TypeParameterObjectCreationOperation(IObjectOrCollectionInitializerOperation? initializer, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
6031public override ITypeSymbol? Type { get; }
6039internal ArrayCreationOperation(ImmutableArray<IOperation> dimensionSizes, IArrayInitializerOperation? initializer, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
6098public override ITypeSymbol? Type { get; }
6106internal InstanceReferenceOperation(InstanceReferenceKind referenceKind, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
6117public override ITypeSymbol? Type { get; }
6125internal IsTypeOperation(IOperation valueOperand, ITypeSymbol typeOperand, bool isNegated, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
6134public ITypeSymbol TypeOperand { get; }
6173public override ITypeSymbol? Type { get; }
6181internal AwaitOperation(IOperation operation, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
6225public override ITypeSymbol? Type { get; }
6244internal SimpleAssignmentOperation(bool isRef, IOperation target, IOperation value, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit)
6298public override ITypeSymbol? Type { get; }
6306internal CompoundAssignmentOperation(IConvertibleConversion inConversion, IConvertibleConversion outConversion, BinaryOperatorKind operatorKind, bool isLifted, bool isChecked, IMethodSymbol? operatorMethod, ITypeSymbol? constrainedToType, IOperation target, IOperation value, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
6326public ITypeSymbol? ConstrainedToType { get; }
6373public override ITypeSymbol? Type { get; }
6381internal ParenthesizedOperation(IOperation operand, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit)
6426public override ITypeSymbol? Type { get; }
6434internal EventAssignmentOperation(IOperation eventReference, IOperation handlerValue, bool adds, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
6491public override ITypeSymbol? Type { get; }
6499internal ConditionalAccessOperation(IOperation operation, IOperation whenNotNull, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
6554public override ITypeSymbol? Type { get; }
6562internal ConditionalAccessInstanceOperation(SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
6571public override ITypeSymbol? Type { get; }
6579internal InterpolatedStringOperation(ImmutableArray<IInterpolatedStringContentOperation> parts, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit)
6628public override ITypeSymbol? Type { get; }
6636internal AnonymousObjectCreationOperation(ImmutableArray<IOperation> initializers, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
6684public override ITypeSymbol? Type { get; }
6692internal ObjectOrCollectionInitializerOperation(ImmutableArray<IOperation> initializers, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
6740public override ITypeSymbol? Type { get; }
6748internal MemberInitializerOperation(IOperation initializedMember, IObjectOrCollectionInitializerOperation initializer, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
6803public override ITypeSymbol? Type { get; }
6811internal NameOfOperation(IOperation argument, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit)
6856public override ITypeSymbol? Type { get; }
6864internal TupleOperation(ImmutableArray<IOperation> elements, ITypeSymbol? naturalType, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
6872public ITypeSymbol? NaturalType { get; }
6914public override ITypeSymbol? Type { get; }
6922internal DynamicMemberReferenceOperation(IOperation? instance, string memberName, ImmutableArray<ITypeSymbol> typeArguments, ITypeSymbol? containingType, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
6933public ImmutableArray<ITypeSymbol> TypeArguments { get; }
6934public ITypeSymbol? ContainingType { get; }
6972public override ITypeSymbol? Type { get; }
6980internal TranslatedQueryOperation(IOperation operation, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
7024public override ITypeSymbol? Type { get; }
7032internal DelegateCreationOperation(IOperation target, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
7076public override ITypeSymbol? Type { get; }
7084internal DefaultValueOperation(SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit)
7094public override ITypeSymbol? Type { get; }
7102internal TypeOfOperation(ITypeSymbol typeOperand, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
7108public ITypeSymbol TypeOperand { get; }
7113public override ITypeSymbol? Type { get; }
7121internal SizeOfOperation(ITypeSymbol typeOperand, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit)
7128public ITypeSymbol TypeOperand { get; }
7133public override ITypeSymbol? Type { get; }
7141internal AddressOfOperation(IOperation reference, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
7185public override ITypeSymbol? Type { get; }
7193internal IsPatternOperation(IOperation value, IPatternOperation pattern, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
7248public override ITypeSymbol? Type { get; }
7256internal IncrementOrDecrementOperation(bool isPostfix, bool isLifted, bool isChecked, IOperation target, IMethodSymbol? operatorMethod, ITypeSymbol? constrainedToType, OperationKind kind, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
7273public ITypeSymbol? ConstrainedToType { get; }
7311public override ITypeSymbol? Type { get; }
7319internal ThrowOperation(IOperation? exception, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
7363public override ITypeSymbol? Type { get; }
7371internal DeconstructionAssignmentOperation(IOperation target, IOperation value, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
7422public override ITypeSymbol? Type { get; }
7430internal DeclarationExpressionOperation(IOperation expression, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
7474public override ITypeSymbol? Type { get; }
7482internal OmittedArgumentOperation(SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
7491public override ITypeSymbol? Type { get; }
7553public override ITypeSymbol? Type => null;
7600public override ITypeSymbol? Type => null;
7651public override ITypeSymbol? Type => null;
7702public override ITypeSymbol? Type => null;
7757public override ITypeSymbol? Type => null;
7825public override ITypeSymbol? Type => null;
7906public override ITypeSymbol? Type => null;
7967public override ITypeSymbol? Type => null;
7975internal CatchClauseOperation(IOperation? exceptionDeclarationOrExpression, ITypeSymbol exceptionType, ImmutableArray<ILocalSymbol> locals, IOperation? filter, IBlockOperation handler, SemanticModel? semanticModel, SyntaxNode syntax, bool isImplicit)
7985public ITypeSymbol ExceptionType { get; }
8044public override ITypeSymbol? Type => null;
8118public override ITypeSymbol? Type => null;
8142public override ITypeSymbol? Type => null;
8205public override ITypeSymbol? Type => null;
8267public override ITypeSymbol? Type => null;
8320public override ITypeSymbol? Type => null;
8371public override ITypeSymbol? Type => null;
8427public override ITypeSymbol? Type => null;
8500public override ITypeSymbol? Type => null;
8508protected BasePatternOperation(ITypeSymbol inputType, ITypeSymbol narrowedType, SemanticModel? semanticModel, SyntaxNode syntax, bool isImplicit)
8514public ITypeSymbol InputType { get; }
8515public ITypeSymbol NarrowedType { get; }
8519internal ConstantPatternOperation(IOperation value, ITypeSymbol inputType, ITypeSymbol narrowedType, SemanticModel? semanticModel, SyntaxNode syntax, bool isImplicit)
8562public override ITypeSymbol? Type => null;
8570internal DeclarationPatternOperation(ITypeSymbol? matchedType, bool matchesNull, ISymbol? declaredSymbol, ITypeSymbol inputType, ITypeSymbol narrowedType, SemanticModel? semanticModel, SyntaxNode syntax, bool isImplicit)
8577public ITypeSymbol? MatchedType { get; }
8584public override ITypeSymbol? Type => null;
8592internal TupleBinaryOperation(BinaryOperatorKind operatorKind, IOperation leftOperand, IOperation rightOperand, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
8649public override ITypeSymbol? Type { get; }
8716public override ITypeSymbol? Type => null;
8787public override ITypeSymbol? Type => null;
8795internal DiscardOperation(IDiscardSymbol discardSymbol, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
8806public override ITypeSymbol? Type { get; }
8859public override ITypeSymbol? Type => null;
8867internal FlowCaptureReferenceOperation(CaptureId id, bool isInitialization, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit)
8881public override ITypeSymbol? Type { get; }
8889internal IsNullOperation(IOperation operand, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit)
8934public override ITypeSymbol? Type { get; }
8942internal CaughtExceptionOperation(SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
8951public override ITypeSymbol? Type { get; }
8959internal StaticLocalInitializationSemaphoreOperation(ILocalSymbol local, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
8970public override ITypeSymbol? Type { get; }
8978internal CoalesceAssignmentOperation(IOperation target, IOperation value, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
9029public override ITypeSymbol? Type { get; }
9037internal RangeOperation(IOperation? leftOperand, IOperation? rightOperand, bool isLifted, IMethodSymbol? method, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
9096public override ITypeSymbol? Type { get; }
9153public override ITypeSymbol? Type => null;
9219public override ITypeSymbol? Type => null;
9227internal RecursivePatternOperation(ITypeSymbol matchedType, ISymbol? deconstructSymbol, ImmutableArray<IPatternOperation> deconstructionSubpatterns, ImmutableArray<IPropertySubpatternOperation> propertySubpatterns, ISymbol? declaredSymbol, ITypeSymbol inputType, ITypeSymbol narrowedType, SemanticModel? semanticModel, SyntaxNode syntax, bool isImplicit)
9236public ITypeSymbol MatchedType { get; }
9295public override ITypeSymbol? Type => null;
9303internal DiscardPatternOperation(ITypeSymbol inputType, ITypeSymbol narrowedType, SemanticModel? semanticModel, SyntaxNode syntax, bool isImplicit)
9309public override ITypeSymbol? Type => null;
9317internal SwitchExpressionOperation(IOperation value, ImmutableArray<ISwitchExpressionArmOperation> arms, bool isExhaustive, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
9378public override ITypeSymbol? Type { get; }
9453public override ITypeSymbol? Type => null;
9515public override ITypeSymbol? Type => null;
9523internal AggregateQueryOperation(IOperation group, IOperation aggregation, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
9578public override ITypeSymbol? Type { get; }
9642public override ITypeSymbol? Type => null;
9650internal NoPiaObjectCreationOperation(IObjectOrCollectionInitializerOperation? initializer, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
9694public override ITypeSymbol? Type { get; }
9702internal PlaceholderOperation(PlaceholderKind placeholderKind, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
9713public override ITypeSymbol? Type { get; }
9775public override ITypeSymbol? Type => null;
9830public override ITypeSymbol? Type => null;
9838internal NegatedPatternOperation(IPatternOperation pattern, ITypeSymbol inputType, ITypeSymbol narrowedType, SemanticModel? semanticModel, SyntaxNode syntax, bool isImplicit)
9881public override ITypeSymbol? Type => null;
9889internal BinaryPatternOperation(BinaryOperatorKind operatorKind, IPatternOperation leftPattern, IPatternOperation rightPattern, ITypeSymbol inputType, ITypeSymbol narrowedType, SemanticModel? semanticModel, SyntaxNode syntax, bool isImplicit)
9945public override ITypeSymbol? Type => null;
9953internal TypePatternOperation(ITypeSymbol matchedType, ITypeSymbol inputType, ITypeSymbol narrowedType, SemanticModel? semanticModel, SyntaxNode syntax, bool isImplicit)
9958public ITypeSymbol MatchedType { get; }
9963public override ITypeSymbol? Type => null;
9971internal RelationalPatternOperation(BinaryOperatorKind operatorKind, IOperation value, ITypeSymbol inputType, ITypeSymbol narrowedType, SemanticModel? semanticModel, SyntaxNode syntax, bool isImplicit)
10016public override ITypeSymbol? Type => null;
10024internal WithOperation(IOperation operand, IMethodSymbol? cloneMethod, IObjectOrCollectionInitializerOperation initializer, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
10081public override ITypeSymbol? Type { get; }
10089internal InterpolatedStringHandlerCreationOperation(IOperation handlerCreation, bool handlerCreationHasSuccessParameter, bool handlerAppendCallsReturnBool, IOperation content, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
10148public override ITypeSymbol? Type { get; }
10210public override ITypeSymbol? Type => null;
10262public override ITypeSymbol? Type => null;
10282public override ITypeSymbol? Type => null;
10290internal FunctionPointerInvocationOperation(IOperation target, ImmutableArray<IArgumentOperation> arguments, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
10349public override ITypeSymbol? Type { get; }
10357internal ListPatternOperation(ISymbol? lengthSymbol, ISymbol? indexerSymbol, ImmutableArray<IPatternOperation> patterns, ISymbol? declaredSymbol, ITypeSymbol inputType, ITypeSymbol narrowedType, SemanticModel? semanticModel, SyntaxNode syntax, bool isImplicit)
10410public override ITypeSymbol? Type => null;
10418internal SlicePatternOperation(ISymbol? sliceSymbol, IPatternOperation? pattern, ITypeSymbol inputType, ITypeSymbol narrowedType, SemanticModel? semanticModel, SyntaxNode syntax, bool isImplicit)
10463public override ITypeSymbol? Type => null;
10471internal ImplicitIndexerReferenceOperation(IOperation instance, IOperation argument, ISymbol lengthSymbol, ISymbol indexerSymbol, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
10530public override ITypeSymbol? Type { get; }
10538internal Utf8StringOperation(string value, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
10549public override ITypeSymbol? Type { get; }
10600public override ITypeSymbol? Type => null;
10608internal InlineArrayAccessOperation(IOperation instance, IOperation argument, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
10663public override ITypeSymbol? Type { get; }
10671internal CollectionExpressionOperation(IMethodSymbol? constructMethod, ImmutableArray<IOperation> elements, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
10721public override ITypeSymbol? Type { get; }
10729internal SpreadOperation(IOperation operand, ITypeSymbol? elementType, IConvertibleConversion elementConversion, SemanticModel? semanticModel, SyntaxNode syntax, bool isImplicit)
10737public ITypeSymbol? ElementType { get; }
10777public override ITypeSymbol? Type => null;
Operations\ControlFlowGraphBuilder.cs (21)
2456private IOperation CreateConversion(IOperation operand, ITypeSymbol type)
2988ITypeSymbol? valueTypeOpt = operationValue.Type;
3288private static IOperation MakeInvalidOperation(ITypeSymbol? type, IOperation child)
3295private static IOperation MakeInvalidOperation(SyntaxNode syntax, ITypeSymbol? type, IOperation child1, IOperation child2)
3300private static IOperation MakeInvalidOperation(SyntaxNode syntax, ITypeSymbol? type, ImmutableArray<IOperation> children)
3312private static IsNullOperation MakeIsNullOperation(IOperation operand, ITypeSymbol booleanType)
3330ITypeSymbol? valueType = value.Type;
3531ITypeSymbol? testExpressionType = testExpression.Type;
3785private void AddExceptionStore(ITypeSymbol exceptionType, IOperation? exceptionDeclarationOrExpression)
3961ITypeSymbol iDisposable = isAsynchronous
4112private void AddDisposingFinally(IOperation resource, bool requiresRuntimeConversion, ITypeSymbol iDisposable, IMethodSymbol? disposeMethod, ImmutableArray<IArgumentOperation> disposeArguments, bool isAsynchronous)
4204bool isNotNullableValueType([NotNullWhen(true)] ITypeSymbol? type)
4210private IOperation ConvertToIDisposable(IOperation operand, ITypeSymbol iDisposable, bool isTryCast = false)
4273ITypeSymbol objectType = _compilation.GetSpecialType(SpecialType.System_Object);
4537var iDisposable = isAsynchronous
4559IOperation applyConversion(IConvertibleConversion? conversionOpt, IOperation operand, ITypeSymbol? targetType)
4742ITypeSymbol booleanType = _compilation.GetSpecialType(SpecialType.System_Boolean);
4755ITypeSymbol? stepEnumUnderlyingTypeOrSelf = ITypeSymbolHelpers.GetEnumUnderlyingTypeOrSelf(operation.StepValue.Type);
4926ITypeSymbol? stepValueEnumUnderlyingTypeOrSelf = ITypeSymbolHelpers.GetEnumUnderlyingTypeOrSelf(stepValue.Type);
5662private IOperation MakeNullable(IOperation operand, ITypeSymbol type)
5832ITypeSymbol booleanType = _compilation.GetSpecialType(SpecialType.System_Boolean);
Operations\OperationNodes.cs (16)
18public NoneOperation(ImmutableArray<IOperation> children, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) :
64public override ITypeSymbol? Type { get; }
82public ITypeSymbol? ConstrainedToType => Conversion.ConstrainedToType;
87public InvalidOperation(ImmutableArray<IOperation> children, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit) :
135public override ITypeSymbol? Type { get; }
169public override ITypeSymbol? Type => null;
205public override ITypeSymbol? ConstrainedToType => null;
235protected HasDynamicArgumentsExpression(ImmutableArray<IOperation> arguments, ImmutableArray<string?> argumentNames, ImmutableArray<RefKind> argumentRefKinds, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit) :
247public override ITypeSymbol? Type { get; }
252public DynamicObjectCreationOperation(IObjectOrCollectionInitializerOperation? initializer, ImmutableArray<IOperation> arguments, ImmutableArray<string?> argumentNames, ImmutableArray<RefKind> argumentRefKinds, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit) :
334public DynamicInvocationOperation(IOperation operation, ImmutableArray<IOperation> arguments, ImmutableArray<string?> argumentNames, ImmutableArray<RefKind> argumentRefKinds, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit) :
416public DynamicIndexerAccessOperation(IOperation operation, ImmutableArray<IOperation> arguments, ImmutableArray<string?> argumentNames, ImmutableArray<RefKind> argumentRefKinds, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit) :
641public FlowCaptureReferenceOperation(int id, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isInitialization = false) :
658public IsNullOperation(SyntaxNode syntax, IOperation operand, ITypeSymbol type, ConstantValue? constantValue) :
667public CaughtExceptionOperation(SyntaxNode syntax, ITypeSymbol type) :
675public StaticLocalInitializationSemaphoreOperation(ILocalSymbol local, SyntaxNode syntax, ITypeSymbol type) :
Microsoft.CodeAnalysis.Analyzers (448)
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\Compiler\Extensions\Symbols\ITypeSymbolExtensions.cs (100)
26public static bool IsIntegralType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
29public static bool IsSignedIntegralType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
32public static bool CanAddNullCheck([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
43public static ImmutableArray<INamedTypeSymbol> GetAllInterfacesIncludingThis(this ITypeSymbol type)
51public static bool IsAbstractClass([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
54public static bool IsSystemVoid([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
57public static bool IsNullable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
60public static bool IsNonNullableValueType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
64[NotNullWhen(true)] this ITypeSymbol? symbol,
65[NotNullWhen(true)] out ITypeSymbol? underlyingType)
77public static bool IsModuleType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
80public static bool IsInterfaceType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
83public static bool IsDelegateType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
86public static bool IsFunctionPointerType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
89public static bool IsStructType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
96this ITypeSymbol type,
110public static IEnumerable<ITypeSymbol> GetBaseTypesAndThis(this ITypeSymbol? type)
112var current = type;
120public static IEnumerable<INamedTypeSymbol> GetBaseTypes(this ITypeSymbol? type)
130public static IEnumerable<ITypeSymbol> GetContainingTypesAndThis(this ITypeSymbol? type)
132var current = type;
140public static IEnumerable<INamedTypeSymbol> GetContainingTypes(this ITypeSymbol type)
153this ITypeSymbol type, ITypeSymbol baseType, bool includeInterfaces)
166this ITypeSymbol type, ITypeSymbol baseType)
174this ITypeSymbol type, ITypeSymbol baseType)
176var originalBaseType = baseType.OriginalDefinition;
184IEnumerable<ITypeSymbol> baseTypes = (baseType.TypeKind == TypeKind.Interface) ? type.AllInterfaces : type.GetBaseTypes();
191this ITypeSymbol type, ITypeSymbol baseType)
193var originalBaseType = baseType.OriginalDefinition;
213this ITypeSymbol type, ITypeSymbol interfaceType)
215var originalInterfaceType = interfaceType.OriginalDefinition;
220this ITypeSymbol type, ITypeSymbol interfaceType)
225public static bool IsAttribute(this ITypeSymbol symbol)
243public static bool IsFormattableStringOrIFormattable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
252this ITypeSymbol typeSymbol, bool allowDelegateAndEnumConstraints = false)
280public static bool IsNumericType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
306public static Accessibility DetermineMinimalAccessibility(this ITypeSymbol typeSymbol)
309public static bool ContainsAnonymousType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
325foreach (var typeArg in type.GetAllTypeArguments())
334public static string CreateParameterName(this ITypeSymbol type, bool capitalize = false)
355private static string GetParameterName(ITypeSymbol? type)
368public static bool IsSpecialType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
399public static bool CanSupportCollectionInitializer(this ITypeSymbol typeSymbol, ISymbol within)
410public static INamedTypeSymbol? GetDelegateType(this ITypeSymbol? typeSymbol, Compilation compilation)
417var typeArgument = ((INamedTypeSymbol)typeSymbol).TypeArguments[0];
430public static IEnumerable<T> GetAccessibleMembersInBaseTypes<T>(this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol
439public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, ISymbol within) where T : class, ISymbol
449public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, string memberName, ISymbol within) where T : class, ISymbol
459public static bool? AreMoreSpecificThan(this IList<ITypeSymbol> t1, IList<ITypeSymbol> t2)
494public static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, ISymbol within) where T : class, ISymbol
504private static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, string memberName, ISymbol within) where T : class, ISymbol
514private static bool? IsMoreSpecificThan(this ITypeSymbol t1, ITypeSymbol t2)
592public static bool IsOrDerivesFromExceptionType([NotNullWhen(returnValue: true)] this ITypeSymbol? type, Compilation compilation)
599foreach (var baseType in type.GetBaseTypesAndThis())
610foreach (var constraint in ((ITypeParameterSymbol)type).ConstraintTypes)
625public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type)
628public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type, [NotNullWhen(true)] out INamedTypeSymbol? enumType)
640public static bool? IsMutableValueType(this ITypeSymbol type)
642if (type.IsNullable(out var underlyingType))
719public static bool IsDisposable([NotNullWhen(returnValue: true)] this ITypeSymbol? type, [NotNullWhen(returnValue: true)] ITypeSymbol? iDisposableType)
724public static ITypeSymbol WithNullableAnnotationFrom(this ITypeSymbol type, ITypeSymbol symbolForNullableAnnotation)
728public static ITypeSymbol? RemoveNullableIfPresent(this ITypeSymbol? symbol)
730if (symbol.IsNullable(out var underlyingType))
738public static bool IsSpanOrReadOnlySpan([NotNullWhen(true)] this ITypeSymbol? type)
741public static bool IsSpan([NotNullWhen(true)] this ITypeSymbol? type)
757public static bool IsInlineArray([NotNullWhen(true)] this ITypeSymbol? type)
762public static ITypeSymbol? RemoveUnavailableTypeParameters(
763this ITypeSymbol? type,
771private static ITypeSymbol? RemoveUnavailableTypeParameters(
772this ITypeSymbol? type,
780public static ITypeSymbol? RemoveAnonymousTypes(
781this ITypeSymbol? type,
788public static ITypeSymbol? RemoveUnnamedErrorTypes(
789this ITypeSymbol? type,
796this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
802this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
808this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result, bool onlyMethodTypeParameters)
817public static IList<ITypeParameterSymbol> GetReferencedTypeParameters(this ITypeSymbol? type)
825public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
826this ITypeSymbol? type,
829where TType1 : ITypeSymbol
830where TType2 : ITypeSymbol
836public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
837this ITypeSymbol? type,
840where TType1 : ITypeSymbol
841where TType2 : ITypeSymbol
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationSymbolFactory.cs (18)
30DeclarationModifiers modifiers, ITypeSymbol type,
47ITypeSymbol type,
79ITypeSymbol type, RefKind refKind, ImmutableArray<IPropertySymbol> explicitInterfaceImplementations, string name,
106ITypeSymbol type, string name,
152ITypeSymbol? returnType,
174ITypeSymbol? returnType,
195ITypeSymbol returnType,
220ITypeSymbol toType,
248ITypeSymbol toType,
264public static IParameterSymbol CreateParameterSymbol(ITypeSymbol type, string name)
267public static IParameterSymbol CreateParameterSymbol(RefKind refKind, ITypeSymbol type, string name)
277ImmutableArray<AttributeData> attributes, RefKind refKind, bool isParams, ITypeSymbol type, string name, bool isOptional = false, bool hasDefaultValue = false, object? defaultValue = null)
290ITypeSymbol? type = null,
331ImmutableArray<ITypeSymbol> constraintTypes,
347public static IPointerTypeSymbol CreatePointerTypeSymbol(ITypeSymbol pointedAtType)
353public static IArrayTypeSymbol CreateArrayTypeSymbol(ITypeSymbol elementType, int rank = 1, NullableAnnotation nullableAnnotation = NullableAnnotation.None)
463ITypeSymbol returnType,
520ITypeSymbol? 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)
15ITypeSymbol toType,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationOperatorSymbol.cs (1)
15ITypeSymbol returnType,
Microsoft.CodeAnalysis.Analyzers.UnitTests (2)
Microsoft.CodeAnalysis.AnalyzerUtilities (404)
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\PointsToAnalysis\PointsToAnalysis.PointsToDataFlowOperationVisitor.cs (8)
171protected override PointsToAbstractValue GetAbstractDefaultValue(ITypeSymbol? type) => !PointsToAnalysis.ShouldBeTracked(type, IsDisposable) ? PointsToAbstractValue.NoLocation : PointsToAbstractValue.NullLocation;
439ITypeSymbol targetType,
445Func<ITypeSymbol?, bool> isDisposable,
505ITypeSymbol targetType,
740protected override void SetAbstractValueForArrayElementInitializer(IArrayCreationOperation arrayCreation, ImmutableArray<AbstractIndex> indices, ITypeSymbol elementType, IOperation initializer, PointsToAbstractValue value)
1052private NullAbstractValue GetNullStateBasedOnInstanceOrReferenceValue(IOperation? referenceOrInstance, ITypeSymbol? operationType, NullAbstractValue defaultValue)
1253public override PointsToAbstractValue ComputeValueForCompoundAssignment(ICompoundAssignmentOperation operation, PointsToAbstractValue targetValue, PointsToAbstractValue assignedValue, ITypeSymbol? targetType, ITypeSymbol? assignedValueType)
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\PointsToAnalysis\PointsToAnalysisData.cs (6)
20private readonly Func<ITypeSymbol?, bool> _isDisposable;
22internal PointsToAnalysisData(Func<ITypeSymbol?, bool> isDisposable)
27internal PointsToAnalysisData(IDictionary<AnalysisEntity, PointsToAbstractValue> fromData, Func<ITypeSymbol?, bool> isDisposable)
41Func<ITypeSymbol?, bool> isDisposable)
122internal static void AssertValidPointsToAnalysisData(IDictionary<AnalysisEntity, PointsToAbstractValue> map, Func<ITypeSymbol?, bool> isDisposable)
139Func<ITypeSymbol?, bool> isDisposable)
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Analysis\ValueContentAnalysis\ValueContentAbstractValue.cs (9)
43internal static ValueContentAbstractValue Create(object literal, ITypeSymbol type)
120internal static bool IsSupportedType(ITypeSymbol type, [NotNullWhen(returnValue: true)] out ITypeSymbol? valueTypeSymbol)
256ITypeSymbol? leftType,
257ITypeSymbol? rightType,
258ITypeSymbol? resultType)
289private static bool TryMerge(object? value1, object? value2, BinaryOperatorKind binaryOperatorKind, ITypeSymbol? type1, ITypeSymbol? type2, ITypeSymbol? resultType, [NotNullWhen(returnValue: true)] out object? result)
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Framework\DataFlow\AbstractLocation.cs (8)
22/// 1. An allocation or an object creation operation (<see cref="CreateAllocationLocation(IOperation, ITypeSymbol, PointsToAnalysisContext)"/>).
26/// See <see cref="CreateFlowCaptureLocation(InterproceduralCaptureId, ITypeSymbol, ImmutableStack{IOperation})"/>
35private AbstractLocation(IOperation? creation, ImmutableStack<IOperation>? creationCallStack, AnalysisEntity? analysisEntity, ISymbol? symbol, InterproceduralCaptureId? captureId, ITypeSymbol? locationType, bool isSpecialSingleton)
48private static AbstractLocation Create(IOperation? creation, ImmutableStack<IOperation>? creationCallStack, AnalysisEntity? analysisEntity, ISymbol? symbol, InterproceduralCaptureId? captureId, ITypeSymbol? locationType)
56public static AbstractLocation CreateAllocationLocation(IOperation creation, ITypeSymbol locationType, PointsToAnalysisContext analysisContext)
58internal static AbstractLocation CreateAllocationLocation(IOperation creation, ITypeSymbol locationType, ImmutableStack<IOperation>? callStack)
66public static AbstractLocation CreateFlowCaptureLocation(InterproceduralCaptureId captureId, ITypeSymbol locationType, ImmutableStack<IOperation>? creationCallStack)
89public ITypeSymbol? LocationType { get; }
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Framework\DataFlow\AnalysisEntity.cs (6)
44ITypeSymbol type,
69private AnalysisEntity(ISymbol? symbol, ImmutableArray<AbstractIndex> indices, PointsToAbstractValue location, ITypeSymbol type, AnalysisEntity? parent, AnalysisEntity? entityForInstanceLocation)
82private AnalysisEntity(InterproceduralCaptureId captureId, ITypeSymbol capturedType, PointsToAbstractValue location)
95ITypeSymbol type, PointsToAbstractValue instanceLocation, AnalysisEntity? parent, AnalysisEntity? entityForInstanceLocation)
111ITypeSymbol type,
202public ITypeSymbol Type { get; }
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis\Framework\DataFlow\AnalysisEntityFactory.cs (7)
136ITypeSymbol? type = operation.Type;
317var type = symbol.GetMemberOrLocalOrParameterType();
347var underlyingValueTupleType = tupleType.GetUnderlyingValueTupleTypeOrThis()!;
397public bool TryCreateForArrayElementInitializer(IArrayCreationOperation arrayCreation, ImmutableArray<AbstractIndex> indices, ITypeSymbol elementType, [NotNullWhen(returnValue: true)] out AnalysisEntity? analysisEntity)
413private AnalysisEntity GetOrCreateForFlowCapture(CaptureId captureId, ITypeSymbol? type, IOperation flowCaptureOrReference, bool isLValueFlowCapture)
440ITypeSymbol type, IOperation? instance, [NotNullWhen(returnValue: true)] out AnalysisEntity? analysisEntity)
554private AnalysisEntity Create(ISymbol? symbol, ImmutableArray<AbstractIndex> indices, ITypeSymbol type, PointsToAbstractValue? instanceLocation, AnalysisEntity? parent, AnalysisEntity? entityForInstanceLocation)
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\Compiler\Extensions\Symbols\ITypeSymbolExtensions.cs (100)
26public static bool IsIntegralType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
29public static bool IsSignedIntegralType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
32public static bool CanAddNullCheck([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
43public static ImmutableArray<INamedTypeSymbol> GetAllInterfacesIncludingThis(this ITypeSymbol type)
51public static bool IsAbstractClass([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
54public static bool IsSystemVoid([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
57public static bool IsNullable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
60public static bool IsNonNullableValueType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
64[NotNullWhen(true)] this ITypeSymbol? symbol,
65[NotNullWhen(true)] out ITypeSymbol? underlyingType)
77public static bool IsModuleType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
80public static bool IsInterfaceType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
83public static bool IsDelegateType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
86public static bool IsFunctionPointerType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
89public static bool IsStructType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
96this ITypeSymbol type,
110public static IEnumerable<ITypeSymbol> GetBaseTypesAndThis(this ITypeSymbol? type)
112var current = type;
120public static IEnumerable<INamedTypeSymbol> GetBaseTypes(this ITypeSymbol? type)
130public static IEnumerable<ITypeSymbol> GetContainingTypesAndThis(this ITypeSymbol? type)
132var current = type;
140public static IEnumerable<INamedTypeSymbol> GetContainingTypes(this ITypeSymbol type)
153this ITypeSymbol type, ITypeSymbol baseType, bool includeInterfaces)
166this ITypeSymbol type, ITypeSymbol baseType)
174this ITypeSymbol type, ITypeSymbol baseType)
176var originalBaseType = baseType.OriginalDefinition;
184IEnumerable<ITypeSymbol> baseTypes = (baseType.TypeKind == TypeKind.Interface) ? type.AllInterfaces : type.GetBaseTypes();
191this ITypeSymbol type, ITypeSymbol baseType)
193var originalBaseType = baseType.OriginalDefinition;
213this ITypeSymbol type, ITypeSymbol interfaceType)
215var originalInterfaceType = interfaceType.OriginalDefinition;
220this ITypeSymbol type, ITypeSymbol interfaceType)
225public static bool IsAttribute(this ITypeSymbol symbol)
243public static bool IsFormattableStringOrIFormattable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
252this ITypeSymbol typeSymbol, bool allowDelegateAndEnumConstraints = false)
280public static bool IsNumericType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
306public static Accessibility DetermineMinimalAccessibility(this ITypeSymbol typeSymbol)
309public static bool ContainsAnonymousType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
325foreach (var typeArg in type.GetAllTypeArguments())
334public static string CreateParameterName(this ITypeSymbol type, bool capitalize = false)
355private static string GetParameterName(ITypeSymbol? type)
368public static bool IsSpecialType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
399public static bool CanSupportCollectionInitializer(this ITypeSymbol typeSymbol, ISymbol within)
410public static INamedTypeSymbol? GetDelegateType(this ITypeSymbol? typeSymbol, Compilation compilation)
417var typeArgument = ((INamedTypeSymbol)typeSymbol).TypeArguments[0];
430public static IEnumerable<T> GetAccessibleMembersInBaseTypes<T>(this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol
439public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, ISymbol within) where T : class, ISymbol
449public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, string memberName, ISymbol within) where T : class, ISymbol
459public static bool? AreMoreSpecificThan(this IList<ITypeSymbol> t1, IList<ITypeSymbol> t2)
494public static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, ISymbol within) where T : class, ISymbol
504private static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, string memberName, ISymbol within) where T : class, ISymbol
514private static bool? IsMoreSpecificThan(this ITypeSymbol t1, ITypeSymbol t2)
592public static bool IsOrDerivesFromExceptionType([NotNullWhen(returnValue: true)] this ITypeSymbol? type, Compilation compilation)
599foreach (var baseType in type.GetBaseTypesAndThis())
610foreach (var constraint in ((ITypeParameterSymbol)type).ConstraintTypes)
625public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type)
628public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type, [NotNullWhen(true)] out INamedTypeSymbol? enumType)
640public static bool? IsMutableValueType(this ITypeSymbol type)
642if (type.IsNullable(out var underlyingType))
719public static bool IsDisposable([NotNullWhen(returnValue: true)] this ITypeSymbol? type, [NotNullWhen(returnValue: true)] ITypeSymbol? iDisposableType)
724public static ITypeSymbol WithNullableAnnotationFrom(this ITypeSymbol type, ITypeSymbol symbolForNullableAnnotation)
728public static ITypeSymbol? RemoveNullableIfPresent(this ITypeSymbol? symbol)
730if (symbol.IsNullable(out var underlyingType))
738public static bool IsSpanOrReadOnlySpan([NotNullWhen(true)] this ITypeSymbol? type)
741public static bool IsSpan([NotNullWhen(true)] this ITypeSymbol? type)
757public static bool IsInlineArray([NotNullWhen(true)] this ITypeSymbol? type)
762public static ITypeSymbol? RemoveUnavailableTypeParameters(
763this ITypeSymbol? type,
771private static ITypeSymbol? RemoveUnavailableTypeParameters(
772this ITypeSymbol? type,
780public static ITypeSymbol? RemoveAnonymousTypes(
781this ITypeSymbol? type,
788public static ITypeSymbol? RemoveUnnamedErrorTypes(
789this ITypeSymbol? type,
796this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
802this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
808this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result, bool onlyMethodTypeParameters)
817public static IList<ITypeParameterSymbol> GetReferencedTypeParameters(this ITypeSymbol? type)
825public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
826this ITypeSymbol? type,
829where TType1 : ITypeSymbol
830where TType2 : ITypeSymbol
836public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
837this ITypeSymbol? type,
840where TType1 : ITypeSymbol
841where TType2 : ITypeSymbol
Microsoft.CodeAnalysis.BannedApiAnalyzers (437)
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\Compiler\Extensions\Symbols\ITypeSymbolExtensions.cs (100)
26public static bool IsIntegralType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
29public static bool IsSignedIntegralType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
32public static bool CanAddNullCheck([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
43public static ImmutableArray<INamedTypeSymbol> GetAllInterfacesIncludingThis(this ITypeSymbol type)
51public static bool IsAbstractClass([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
54public static bool IsSystemVoid([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
57public static bool IsNullable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
60public static bool IsNonNullableValueType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
64[NotNullWhen(true)] this ITypeSymbol? symbol,
65[NotNullWhen(true)] out ITypeSymbol? underlyingType)
77public static bool IsModuleType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
80public static bool IsInterfaceType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
83public static bool IsDelegateType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
86public static bool IsFunctionPointerType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
89public static bool IsStructType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
96this ITypeSymbol type,
110public static IEnumerable<ITypeSymbol> GetBaseTypesAndThis(this ITypeSymbol? type)
112var current = type;
120public static IEnumerable<INamedTypeSymbol> GetBaseTypes(this ITypeSymbol? type)
130public static IEnumerable<ITypeSymbol> GetContainingTypesAndThis(this ITypeSymbol? type)
132var current = type;
140public static IEnumerable<INamedTypeSymbol> GetContainingTypes(this ITypeSymbol type)
153this ITypeSymbol type, ITypeSymbol baseType, bool includeInterfaces)
166this ITypeSymbol type, ITypeSymbol baseType)
174this ITypeSymbol type, ITypeSymbol baseType)
176var originalBaseType = baseType.OriginalDefinition;
184IEnumerable<ITypeSymbol> baseTypes = (baseType.TypeKind == TypeKind.Interface) ? type.AllInterfaces : type.GetBaseTypes();
191this ITypeSymbol type, ITypeSymbol baseType)
193var originalBaseType = baseType.OriginalDefinition;
213this ITypeSymbol type, ITypeSymbol interfaceType)
215var originalInterfaceType = interfaceType.OriginalDefinition;
220this ITypeSymbol type, ITypeSymbol interfaceType)
225public static bool IsAttribute(this ITypeSymbol symbol)
243public static bool IsFormattableStringOrIFormattable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
252this ITypeSymbol typeSymbol, bool allowDelegateAndEnumConstraints = false)
280public static bool IsNumericType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
306public static Accessibility DetermineMinimalAccessibility(this ITypeSymbol typeSymbol)
309public static bool ContainsAnonymousType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
325foreach (var typeArg in type.GetAllTypeArguments())
334public static string CreateParameterName(this ITypeSymbol type, bool capitalize = false)
355private static string GetParameterName(ITypeSymbol? type)
368public static bool IsSpecialType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
399public static bool CanSupportCollectionInitializer(this ITypeSymbol typeSymbol, ISymbol within)
410public static INamedTypeSymbol? GetDelegateType(this ITypeSymbol? typeSymbol, Compilation compilation)
417var typeArgument = ((INamedTypeSymbol)typeSymbol).TypeArguments[0];
430public static IEnumerable<T> GetAccessibleMembersInBaseTypes<T>(this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol
439public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, ISymbol within) where T : class, ISymbol
449public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, string memberName, ISymbol within) where T : class, ISymbol
459public static bool? AreMoreSpecificThan(this IList<ITypeSymbol> t1, IList<ITypeSymbol> t2)
494public static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, ISymbol within) where T : class, ISymbol
504private static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, string memberName, ISymbol within) where T : class, ISymbol
514private static bool? IsMoreSpecificThan(this ITypeSymbol t1, ITypeSymbol t2)
592public static bool IsOrDerivesFromExceptionType([NotNullWhen(returnValue: true)] this ITypeSymbol? type, Compilation compilation)
599foreach (var baseType in type.GetBaseTypesAndThis())
610foreach (var constraint in ((ITypeParameterSymbol)type).ConstraintTypes)
625public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type)
628public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type, [NotNullWhen(true)] out INamedTypeSymbol? enumType)
640public static bool? IsMutableValueType(this ITypeSymbol type)
642if (type.IsNullable(out var underlyingType))
719public static bool IsDisposable([NotNullWhen(returnValue: true)] this ITypeSymbol? type, [NotNullWhen(returnValue: true)] ITypeSymbol? iDisposableType)
724public static ITypeSymbol WithNullableAnnotationFrom(this ITypeSymbol type, ITypeSymbol symbolForNullableAnnotation)
728public static ITypeSymbol? RemoveNullableIfPresent(this ITypeSymbol? symbol)
730if (symbol.IsNullable(out var underlyingType))
738public static bool IsSpanOrReadOnlySpan([NotNullWhen(true)] this ITypeSymbol? type)
741public static bool IsSpan([NotNullWhen(true)] this ITypeSymbol? type)
757public static bool IsInlineArray([NotNullWhen(true)] this ITypeSymbol? type)
762public static ITypeSymbol? RemoveUnavailableTypeParameters(
763this ITypeSymbol? type,
771private static ITypeSymbol? RemoveUnavailableTypeParameters(
772this ITypeSymbol? type,
780public static ITypeSymbol? RemoveAnonymousTypes(
781this ITypeSymbol? type,
788public static ITypeSymbol? RemoveUnnamedErrorTypes(
789this ITypeSymbol? type,
796this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
802this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
808this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result, bool onlyMethodTypeParameters)
817public static IList<ITypeParameterSymbol> GetReferencedTypeParameters(this ITypeSymbol? type)
825public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
826this ITypeSymbol? type,
829where TType1 : ITypeSymbol
830where TType2 : ITypeSymbol
836public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
837this ITypeSymbol? type,
840where TType1 : ITypeSymbol
841where TType2 : ITypeSymbol
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationSymbolFactory.cs (18)
30DeclarationModifiers modifiers, ITypeSymbol type,
47ITypeSymbol type,
79ITypeSymbol type, RefKind refKind, ImmutableArray<IPropertySymbol> explicitInterfaceImplementations, string name,
106ITypeSymbol type, string name,
152ITypeSymbol? returnType,
174ITypeSymbol? returnType,
195ITypeSymbol returnType,
220ITypeSymbol toType,
248ITypeSymbol toType,
264public static IParameterSymbol CreateParameterSymbol(ITypeSymbol type, string name)
267public static IParameterSymbol CreateParameterSymbol(RefKind refKind, ITypeSymbol type, string name)
277ImmutableArray<AttributeData> attributes, RefKind refKind, bool isParams, ITypeSymbol type, string name, bool isOptional = false, bool hasDefaultValue = false, object? defaultValue = null)
290ITypeSymbol? type = null,
331ImmutableArray<ITypeSymbol> constraintTypes,
347public static IPointerTypeSymbol CreatePointerTypeSymbol(ITypeSymbol pointedAtType)
353public static IArrayTypeSymbol CreateArrayTypeSymbol(ITypeSymbol elementType, int rank = 1, NullableAnnotation nullableAnnotation = NullableAnnotation.None)
463ITypeSymbol returnType,
520ITypeSymbol? 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)
15ITypeSymbol toType,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationOperatorSymbol.cs (1)
15ITypeSymbol returnType,
Microsoft.CodeAnalysis.CodeStyle (318)
src\Analyzers\Core\Analyzers\RemoveUnusedParametersAndValues\AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.cs (1)
292ITypeSymbol containingType,
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\Compiler\Extensions\Symbols\ITypeSymbolExtensions.cs (100)
26public static bool IsIntegralType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
29public static bool IsSignedIntegralType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
32public static bool CanAddNullCheck([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
43public static ImmutableArray<INamedTypeSymbol> GetAllInterfacesIncludingThis(this ITypeSymbol type)
51public static bool IsAbstractClass([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
54public static bool IsSystemVoid([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
57public static bool IsNullable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
60public static bool IsNonNullableValueType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
64[NotNullWhen(true)] this ITypeSymbol? symbol,
65[NotNullWhen(true)] out ITypeSymbol? underlyingType)
77public static bool IsModuleType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
80public static bool IsInterfaceType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
83public static bool IsDelegateType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
86public static bool IsFunctionPointerType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
89public static bool IsStructType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
96this ITypeSymbol type,
110public static IEnumerable<ITypeSymbol> GetBaseTypesAndThis(this ITypeSymbol? type)
112var current = type;
120public static IEnumerable<INamedTypeSymbol> GetBaseTypes(this ITypeSymbol? type)
130public static IEnumerable<ITypeSymbol> GetContainingTypesAndThis(this ITypeSymbol? type)
132var current = type;
140public static IEnumerable<INamedTypeSymbol> GetContainingTypes(this ITypeSymbol type)
153this ITypeSymbol type, ITypeSymbol baseType, bool includeInterfaces)
166this ITypeSymbol type, ITypeSymbol baseType)
174this ITypeSymbol type, ITypeSymbol baseType)
176var originalBaseType = baseType.OriginalDefinition;
184IEnumerable<ITypeSymbol> baseTypes = (baseType.TypeKind == TypeKind.Interface) ? type.AllInterfaces : type.GetBaseTypes();
191this ITypeSymbol type, ITypeSymbol baseType)
193var originalBaseType = baseType.OriginalDefinition;
213this ITypeSymbol type, ITypeSymbol interfaceType)
215var originalInterfaceType = interfaceType.OriginalDefinition;
220this ITypeSymbol type, ITypeSymbol interfaceType)
225public static bool IsAttribute(this ITypeSymbol symbol)
243public static bool IsFormattableStringOrIFormattable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
252this ITypeSymbol typeSymbol, bool allowDelegateAndEnumConstraints = false)
280public static bool IsNumericType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
306public static Accessibility DetermineMinimalAccessibility(this ITypeSymbol typeSymbol)
309public static bool ContainsAnonymousType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
325foreach (var typeArg in type.GetAllTypeArguments())
334public static string CreateParameterName(this ITypeSymbol type, bool capitalize = false)
355private static string GetParameterName(ITypeSymbol? type)
368public static bool IsSpecialType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
399public static bool CanSupportCollectionInitializer(this ITypeSymbol typeSymbol, ISymbol within)
410public static INamedTypeSymbol? GetDelegateType(this ITypeSymbol? typeSymbol, Compilation compilation)
417var typeArgument = ((INamedTypeSymbol)typeSymbol).TypeArguments[0];
430public static IEnumerable<T> GetAccessibleMembersInBaseTypes<T>(this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol
439public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, ISymbol within) where T : class, ISymbol
449public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, string memberName, ISymbol within) where T : class, ISymbol
459public static bool? AreMoreSpecificThan(this IList<ITypeSymbol> t1, IList<ITypeSymbol> t2)
494public static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, ISymbol within) where T : class, ISymbol
504private static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, string memberName, ISymbol within) where T : class, ISymbol
514private static bool? IsMoreSpecificThan(this ITypeSymbol t1, ITypeSymbol t2)
592public static bool IsOrDerivesFromExceptionType([NotNullWhen(returnValue: true)] this ITypeSymbol? type, Compilation compilation)
599foreach (var baseType in type.GetBaseTypesAndThis())
610foreach (var constraint in ((ITypeParameterSymbol)type).ConstraintTypes)
625public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type)
628public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type, [NotNullWhen(true)] out INamedTypeSymbol? enumType)
640public static bool? IsMutableValueType(this ITypeSymbol type)
642if (type.IsNullable(out var underlyingType))
719public static bool IsDisposable([NotNullWhen(returnValue: true)] this ITypeSymbol? type, [NotNullWhen(returnValue: true)] ITypeSymbol? iDisposableType)
724public static ITypeSymbol WithNullableAnnotationFrom(this ITypeSymbol type, ITypeSymbol symbolForNullableAnnotation)
728public static ITypeSymbol? RemoveNullableIfPresent(this ITypeSymbol? symbol)
730if (symbol.IsNullable(out var underlyingType))
738public static bool IsSpanOrReadOnlySpan([NotNullWhen(true)] this ITypeSymbol? type)
741public static bool IsSpan([NotNullWhen(true)] this ITypeSymbol? type)
757public static bool IsInlineArray([NotNullWhen(true)] this ITypeSymbol? type)
762public static ITypeSymbol? RemoveUnavailableTypeParameters(
763this ITypeSymbol? type,
771private static ITypeSymbol? RemoveUnavailableTypeParameters(
772this ITypeSymbol? type,
780public static ITypeSymbol? RemoveAnonymousTypes(
781this ITypeSymbol? type,
788public static ITypeSymbol? RemoveUnnamedErrorTypes(
789this ITypeSymbol? type,
796this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
802this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
808this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result, bool onlyMethodTypeParameters)
817public static IList<ITypeParameterSymbol> GetReferencedTypeParameters(this ITypeSymbol? type)
825public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
826this ITypeSymbol? type,
829where TType1 : ITypeSymbol
830where TType2 : ITypeSymbol
836public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
837this ITypeSymbol? type,
840where TType1 : ITypeSymbol
841where TType2 : ITypeSymbol
Microsoft.CodeAnalysis.CodeStyle.Fixes (244)
src\Analyzers\Core\CodeFixes\AddExplicitCast\AbstractAddExplicitCastCodeFixProvider.cs (11)
31protected abstract TExpressionSyntax Cast(TExpressionSyntax expression, ITypeSymbol type);
49protected ImmutableArray<(TExpressionSyntax node, ITypeSymbol type)> GetPotentialTargetTypes(
53using var _ = ArrayBuilder<(TExpressionSyntax node, ITypeSymbol type)>.GetInstance(out var candidates);
64ArrayBuilder<(TExpressionSyntax node, ITypeSymbol type)> candidates,
121ITypeSymbol conversionType,
144var castType = semanticModel.GetTypeInfo(castTypeNode, cancellationToken).Type;
162protected virtual (SyntaxNode finalTarget, SyntaxNode finalReplacement) Cast(SemanticModel semanticModel, TExpressionSyntax targetNode, ITypeSymbol conversionType)
165private static string GetSubItemName(SemanticModel semanticModel, int position, ITypeSymbol conversionType)
172private static ImmutableArray<(TExpressionSyntax, ITypeSymbol)> FilterValidPotentialConversionTypes(
175ArrayBuilder<(TExpressionSyntax node, ITypeSymbol type)> candidates)
180using var _ = ArrayBuilder<(TExpressionSyntax, ITypeSymbol)>.GetInstance(candidates.Count, out var validPotentialConversionTypes);
src\Analyzers\Core\CodeFixes\AddParameter\AbstractAddParameterCodeFixProvider.cs (4)
47protected abstract ITypeSymbol GetArgumentType(SyntaxNode argumentNode, SemanticModel semanticModel, CancellationToken cancellationToken);
402private async Task<(ITypeSymbol, RefKind)> GetArgumentTypeAndRefKindAsync(Document invocationDocument, TArgumentSyntax argument, CancellationToken cancellationToken)
406var argumentType = GetArgumentType(argument, semanticModel, cancellationToken);
537Compilation compilation, TypeInfo argumentTypeInfo, ITypeSymbol parameterType,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationSymbolFactory.cs (18)
30DeclarationModifiers modifiers, ITypeSymbol type,
47ITypeSymbol type,
79ITypeSymbol type, RefKind refKind, ImmutableArray<IPropertySymbol> explicitInterfaceImplementations, string name,
106ITypeSymbol type, string name,
152ITypeSymbol? returnType,
174ITypeSymbol? returnType,
195ITypeSymbol returnType,
220ITypeSymbol toType,
248ITypeSymbol toType,
264public static IParameterSymbol CreateParameterSymbol(ITypeSymbol type, string name)
267public static IParameterSymbol CreateParameterSymbol(RefKind refKind, ITypeSymbol type, string name)
277ImmutableArray<AttributeData> attributes, RefKind refKind, bool isParams, ITypeSymbol type, string name, bool isOptional = false, bool hasDefaultValue = false, object? defaultValue = null)
290ITypeSymbol? type = null,
331ImmutableArray<ITypeSymbol> constraintTypes,
347public static IPointerTypeSymbol CreatePointerTypeSymbol(ITypeSymbol pointedAtType)
353public static IArrayTypeSymbol CreateArrayTypeSymbol(ITypeSymbol elementType, int rank = 1, NullableAnnotation nullableAnnotation = NullableAnnotation.None)
463ITypeSymbol returnType,
520ITypeSymbol? 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)
15ITypeSymbol toType,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationOperatorSymbol.cs (1)
15ITypeSymbol returnType,
Microsoft.CodeAnalysis.CSharp (256)
Compilation\CSharpCompilation.cs (22)
1783protected override ITypeSymbol? CommonScriptGlobalsType
2315public Conversion ClassifyConversion(ITypeSymbol source, ITypeSymbol destination)
2349public override CommonConversion ClassifyCommonConversion(ITypeSymbol source, ITypeSymbol destination)
2355internal override IConvertibleConversion ClassifyConvertibleConversion(IOperation source, ITypeSymbol? destination, out ConstantValue? constantValue)
2364ITypeSymbol? sourceType = source.Type;
2423ITypeSymbol? throughType)
2439ITypeSymbol? throughType = null)
4077protected override IArrayTypeSymbol CommonCreateArrayTypeSymbol(ITypeSymbol elementType, int rank, CodeAnalysis.NullableAnnotation elementNullableAnnotation)
4082protected override IPointerTypeSymbol CommonCreatePointerTypeSymbol(ITypeSymbol elementType)
4088ITypeSymbol returnType,
4090ImmutableArray<ITypeSymbol> parameterTypes,
4185ImmutableArray<ITypeSymbol> elementTypes,
4193ITypeSymbol typeSymbol = elementTypes[i];
4240ImmutableArray<ITypeSymbol> memberTypes,
4274ITypeSymbol returnType,
4275ITypeSymbol leftType,
4276ITypeSymbol rightType)
4500ITypeSymbol returnType,
4501ITypeSymbol operandType)
4574protected override ITypeSymbol CommonDynamicType
Compilation\CSharpSemanticModel.cs (5)
578private static SymbolInfo GetSymbolInfoFromSymbolOrNone(ITypeSymbol type)
592private (ITypeSymbol Type, CodeAnalysis.NullableAnnotation Annotation) TypeFromVariable(SingleVariableDesignationSyntax variableDesignation, CancellationToken cancellationToken)
966var (declarationType, annotation) = ((ITypeSymbol, CodeAnalysis.NullableAnnotation))TypeFromVariable((SingleVariableDesignationSyntax)parent.Designation, cancellationToken);
2819public abstract Conversion ClassifyConversion(ExpressionSyntax expression, ITypeSymbol destination, bool isExplicitInSource = false);
2837public Conversion ClassifyConversion(int position, ExpressionSyntax expression, ITypeSymbol destination, bool isExplicitInSource = false)
Symbols\TypeSymbol.cs (8)
677return SymbolDisplay.ToDisplayString((ITypeSymbol)ISymbol, topLevelNullability, format);
682return SymbolDisplay.ToDisplayParts((ITypeSymbol)ISymbol, topLevelNullability, format);
691return SymbolDisplay.ToMinimalDisplayString((ITypeSymbol)ISymbol, topLevelNullability, semanticModel, position, format);
700return SymbolDisplay.ToMinimalDisplayParts((ITypeSymbol)ISymbol, topLevelNullability, semanticModel, position, format);
2504internal ITypeSymbol GetITypeSymbol(CodeAnalysis.NullableAnnotation nullableAnnotation)
2508return (ITypeSymbol)this.ISymbol;
2516protected abstract ITypeSymbol CreateITypeSymbol(CodeAnalysis.NullableAnnotation nullableAnnotation);
2526ITypeSymbol ITypeSymbolInternal.GetITypeSymbol()
Microsoft.CodeAnalysis.CSharp.Analyzers (3)
Microsoft.CodeAnalysis.CSharp.CodeStyle (133)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ExpressionSyntaxExtensions.cs (24)
906public static ITypeSymbol? GetTargetType(
936bool HasType(ExpressionSyntax expression, [NotNullWhen(true)] out ITypeSymbol? type)
942ITypeSymbol? GetTargetTypeForArgument(ArgumentSyntax argument)
946var tupleType = tupleExpression.GetTargetType(semanticModel, cancellationToken);
961ITypeSymbol? GetTargetTypeForAttributeArgument(AttributeArgumentSyntax argument)
964ITypeSymbol? GetTargetTypeForArrowExpression(ArrowExpressionClauseSyntax arrowExpression)
971ITypeSymbol? GetTargetTypeForReturnStatement(ReturnStatementSyntax returnStatement)
985ITypeSymbol? GetTargetTypeForEqualsValueClause(EqualsValueClauseSyntax equalsValue)
995ITypeSymbol? GetTargetTypedForCastExpression(CastExpressionSyntax castExpression)
998ITypeSymbol? GetTargetTypeForConditionalExpression(ConditionalExpressionSyntax conditionalExpression, ExpressionSyntax expression)
1001return HasType(conditionalExpression.WhenFalse, out var falseType) ? falseType : conditionalExpression.GetTargetType(semanticModel, cancellationToken);
1003return HasType(conditionalExpression.WhenTrue, out var trueType) ? trueType : conditionalExpression.GetTargetType(semanticModel, cancellationToken);
1008ITypeSymbol? GetTargetTypeForLambdaExpression(LambdaExpressionSyntax lambda, ExpressionSyntax expression)
1012ITypeSymbol? GetTargetTypeForSwitchExpressionArm(SwitchExpressionArmSyntax switchExpressionArm)
1019if (arm != switchExpressionArm && HasType(arm.Expression, out var armType))
1027ITypeSymbol? GetTargetTypeForCollectionElement(CollectionElementSyntax collectionElement)
1035var collectionTargetType = collectionExpression.GetTargetType(semanticModel, cancellationToken);
1055ITypeSymbol? GetTargetTypeForInitializerExpression(InitializerExpressionSyntax initializerExpression, ExpressionSyntax expression)
1059return HasType(arrayCreation.Type, out var elementType) ? elementType : null;
1066if (sibling != expression && HasType(sibling, out var siblingType))
1084ITypeSymbol? GetTargetTypeForAssignmentExpression(AssignmentExpressionSyntax assignmentExpression, ExpressionSyntax expression)
1086return expression == assignmentExpression.Right && HasType(assignmentExpression.Left, out var leftType) ? leftType : null;
1089ITypeSymbol? GetTargetTypeForBinaryExpression(BinaryExpressionSyntax binaryExpression, ExpressionSyntax expression)
1091return 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;
943private static bool IsNullOrErrorType([NotNullWhen(false)] ITypeSymbol? type)
1066var castSideType = semanticModel.GetTypeInfo(castSide, cancellationToken).Type;
1067var castedExpressionType = semanticModel.GetTypeInfo(castExpression.Expression, cancellationToken).Type;
1071var otherSideType = semanticModel.GetTypeInfo(otherSide, cancellationToken).Type;
1089var castType = semanticModel.GetTypeInfo(castNode, cancellationToken).Type;
1090var castedExpressionType = semanticModel.GetTypeInfo(castedExpressionNode, cancellationToken).Type;
1147private static bool IsFloatingPointType(ITypeSymbol? type)
1317var rewrittenType = rewrittenSemanticModel.GetTypeInfo(rewrittenExpression, cancellationToken).Type;
1432private static bool IsIntrinsicOrEnum(ITypeSymbol rewrittenType)
1440ITypeSymbol rewrittenType,
1530private static (ITypeSymbol? rewrittenConvertedType, Conversion rewrittenConversion) GetRewrittenInfo(
1533Conversion originalConversion, ITypeSymbol originalConvertedType,
1544var convertedType = originalConversion.IsIdentity ? originalConvertedType : originalSemanticModel.Compilation.ObjectType;
1548var 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)
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (152)
src\Analyzers\CSharp\CodeFixes\GenerateMethod\GenerateDeconstructMethodCodeFixProvider.cs (1)
57ITypeSymbol? type;
src\Analyzers\CSharp\CodeFixes\Iterator\CSharpAddYieldCodeFixProvider.cs (10)
54if (!TryGetMethodReturnType(node, model, cancellationToken, out var methodReturnType))
59if (!TryGetExpressionType(model, returnStatement.Expression, out var returnExpressionType))
89SemanticModel model, ExpressionSyntax? expression, [NotNullWhen(true)] out ITypeSymbol? returnExpressionType)
104[NotNullWhen(true)] out ITypeSymbol? methodReturnType)
117private static bool IsCorrectTypeForYieldReturn(ITypeSymbol typeArgument, ITypeSymbol returnExpressionType, ITypeSymbol methodReturnType, SemanticModel model)
151private static bool CanConvertTypes(ITypeSymbol typeArgument, ITypeSymbol returnExpressionType, SemanticModel model)
190private static bool IsCorrectTypeForYieldReturn(ITypeSymbol methodReturnType, SemanticModel model)
src\Analyzers\CSharp\CodeFixes\UseImplicitOrExplicitType\UseExplicitTypeCodeFixProvider.cs (10)
94var tupleTypeSymbol = GetConvertedType(semanticModel, typeSyntax.Parent, cancellationToken);
105var typeSymbol = GetConvertedType(semanticModel, typeSyntax, cancellationToken);
140var typeSymbol = GetConvertedType(semanticModel, typeSyntax, cancellationToken);
152private static ITypeSymbol AdjustNullabilityOfTypeSymbol(
155ITypeSymbol typeSymbol,
174private static ExpressionSyntax GenerateTupleDeclaration(ITypeSymbol typeSymbol, ParenthesizedVariableDesignationSyntax parensDesignation)
184var type = elements[i].Type;
216private static SyntaxNode GenerateTypeDeclaration(TypeSyntax typeSyntax, ITypeSymbol newTypeSymbol)
227private static ITypeSymbol GetConvertedType(SemanticModel semanticModel, SyntaxNode typeSyntax, CancellationToken cancellationToken)
229var typeSymbol = semanticModel.GetTypeInfo(typeSyntax, cancellationToken).ConvertedType;
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);
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (11)
Microsoft.CodeAnalysis.CSharp.Emit.UnitTests (73)
CodeGen\CodeGenTupleTest.cs (52)
6210ITypeSymbol intType = comp.GetSpecialType(SpecialType.System_Int32);
6328var vbType = (ITypeSymbol)vbComp.GlobalNamespace.GetMembers("C").Single();
6341Assert.Throws<ArgumentNullException>(() => comp.CreateTupleTypeSymbol(default(ImmutableArray<ITypeSymbol>), default(ImmutableArray<string>)));
6344Assert.Throws<ArgumentException>(() => comp.CreateTupleTypeSymbol(ImmutableArray<ITypeSymbol>.Empty, default(ImmutableArray<string>)));
6581ITypeSymbol vbType = (ITypeSymbol)vbComp.GlobalNamespace.GetMembers("C").Single();
6610var tuple3 = comp.CreateTupleTypeSymbol(ImmutableArray.Create<ITypeSymbol>(intType, intType, intType, intType, intType, intType, intType, stringType, stringType),
6927private static bool TypeEquals(ITypeSymbol a, ITypeSymbol b, TypeCompareKind compareKind) =>
13977Assert.True(((ITypeSymbol)nameofArgSymbolInfo.Symbol).IsTupleType);
14333var m5Tuple = ((IMethodSymbol)symbolInfo.Symbol).TypeParameters[0].ConstraintTypes.Single();
14343var m6Tuple = m6Method.ReturnType;
14456var v1Type = ((ILocalSymbol)symbolInfo.Symbol).Type;
14466var v2Type = ((ILocalSymbol)symbolInfo.Symbol).Type;
18861ITypeSymbol intType = comp.GetSpecialType(SpecialType.System_Int32);
18862ITypeSymbol stringType = comp.GetSpecialType(SpecialType.System_String);
18881ITypeSymbol intType = comp.GetSpecialType(SpecialType.System_Int32);
18882ITypeSymbol stringType = comp.GetSpecialType(SpecialType.System_String);
18921ITypeSymbol intType = comp.GetSpecialType(SpecialType.System_Int32);
18922ITypeSymbol stringType = comp.GetSpecialType(SpecialType.System_String);
18923ITypeSymbol objectType = comp.GetSpecialType(SpecialType.System_Object);
18947ITypeSymbol intType = comp.GetSpecialType(SpecialType.System_Int32);
18948ITypeSymbol stringType = comp.GetSpecialType(SpecialType.System_String);
18949ITypeSymbol objectType = comp.GetSpecialType(SpecialType.System_Object);
18972ITypeSymbol intType = comp.GetSpecialType(SpecialType.System_Int32);
18973ITypeSymbol stringType = comp.GetSpecialType(SpecialType.System_String);
18974ITypeSymbol objectType = comp.GetSpecialType(SpecialType.System_Object);
18997ITypeSymbol intType = comp.GetSpecialType(SpecialType.System_Int32);
18998ITypeSymbol stringType = comp.GetSpecialType(SpecialType.System_String);
18999ITypeSymbol objectType = comp.GetSpecialType(SpecialType.System_Object);
19023ITypeSymbol intType = comp.GetSpecialType(SpecialType.System_Int32);
19024ITypeSymbol stringType = comp.GetSpecialType(SpecialType.System_String);
19025ITypeSymbol objectType = comp.GetSpecialType(SpecialType.System_Object);
19065ITypeSymbol intType = comp.GetSpecialType(SpecialType.System_Int32);
19066ITypeSymbol stringType = comp.GetSpecialType(SpecialType.System_String);
19067ITypeSymbol objectType = comp.GetSpecialType(SpecialType.System_Object);
19104ITypeSymbol intType = comp.GetSpecialType(SpecialType.System_Int32);
19105ITypeSymbol stringType = comp.GetSpecialType(SpecialType.System_String);
19106ITypeSymbol objectType = comp.GetSpecialType(SpecialType.System_Object);
19143ITypeSymbol intType = comp.GetSpecialType(SpecialType.System_Int32);
19144ITypeSymbol stringType = comp.GetSpecialType(SpecialType.System_String);
19145ITypeSymbol objectType = comp.GetSpecialType(SpecialType.System_Object);
19182ITypeSymbol intType = comp.GetSpecialType(SpecialType.System_Int32);
19183ITypeSymbol stringType = comp.GetSpecialType(SpecialType.System_String);
19184ITypeSymbol objectType = comp.GetSpecialType(SpecialType.System_Object);
22858var xSymbol = ((ILocalSymbol)model.GetDeclaredSymbol(x)).Type;
24397var collectionSymbol = (model.GetDeclaredSymbol(collection) as ILocalSymbol)?.Type;
24470var collectionSymbol = (model.GetDeclaredSymbol(collection) as ILocalSymbol)?.Type;
24543var collectionSymbol = (model.GetDeclaredSymbol(collection) as ILocalSymbol)?.Type;
24617var collectionSymbol = (model.GetDeclaredSymbol(collection) as ILocalSymbol)?.Type;
25026var xSymbol = ((ILocalSymbol)model.GetDeclaredSymbol(x)).Type;
Microsoft.CodeAnalysis.CSharp.Emit2.UnitTests (1)
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (21)
Microsoft.CodeAnalysis.CSharp.EndToEnd.UnitTests (1)
Microsoft.CodeAnalysis.CSharp.Features (233)
Completion\CompletionProviders\PropertySubPatternCompletionProvider.cs (7)
58var propertyPatternType = semanticModel.GetTypeInfo((PatternSyntax)propertyPatternClause.Parent!, cancellationToken).ConvertedType;
62var type = GetMemberAccessType(propertyPatternType, memberAccess, document, semanticModel, position);
98static ITypeSymbol? GetMemberAccessType(ITypeSymbol? type, ExpressionSyntax? expression, Document document, SemanticModel semanticModel, int position)
117static ITypeSymbol? GetMemberType(ITypeSymbol? type, string name, Document document, SemanticModel semanticModel, int position)
134static ImmutableArray<ISymbol> GetCandidatePropertiesAndFields(Document document, SemanticModel semanticModel, int position, ITypeSymbol? type)
src\Analyzers\CSharp\CodeFixes\GenerateMethod\GenerateDeconstructMethodCodeFixProvider.cs (1)
57ITypeSymbol? type;
src\Analyzers\CSharp\CodeFixes\Iterator\CSharpAddYieldCodeFixProvider.cs (10)
54if (!TryGetMethodReturnType(node, model, cancellationToken, out var methodReturnType))
59if (!TryGetExpressionType(model, returnStatement.Expression, out var returnExpressionType))
89SemanticModel model, ExpressionSyntax? expression, [NotNullWhen(true)] out ITypeSymbol? returnExpressionType)
104[NotNullWhen(true)] out ITypeSymbol? methodReturnType)
117private static bool IsCorrectTypeForYieldReturn(ITypeSymbol typeArgument, ITypeSymbol returnExpressionType, ITypeSymbol methodReturnType, SemanticModel model)
151private static bool CanConvertTypes(ITypeSymbol typeArgument, ITypeSymbol returnExpressionType, SemanticModel model)
190private static bool IsCorrectTypeForYieldReturn(ITypeSymbol methodReturnType, SemanticModel model)
src\Analyzers\CSharp\CodeFixes\UseImplicitOrExplicitType\UseExplicitTypeCodeFixProvider.cs (10)
94var tupleTypeSymbol = GetConvertedType(semanticModel, typeSyntax.Parent, cancellationToken);
105var typeSymbol = GetConvertedType(semanticModel, typeSyntax, cancellationToken);
140var typeSymbol = GetConvertedType(semanticModel, typeSyntax, cancellationToken);
152private static ITypeSymbol AdjustNullabilityOfTypeSymbol(
155ITypeSymbol typeSymbol,
174private static ExpressionSyntax GenerateTupleDeclaration(ITypeSymbol typeSymbol, ParenthesizedVariableDesignationSyntax parensDesignation)
184var type = elements[i].Type;
216private static SyntaxNode GenerateTypeDeclaration(TypeSyntax typeSyntax, ITypeSymbol newTypeSymbol)
227private static ITypeSymbol GetConvertedType(SemanticModel semanticModel, SyntaxNode typeSyntax, CancellationToken cancellationToken)
229var typeSymbol = semanticModel.GetTypeInfo(typeSyntax, cancellationToken).ConvertedType;
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (68)
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (202)
Compilation\CompilationAPITests.cs (28)
2509ImmutableArray.Create((ITypeSymbol)null),
2519ImmutableArray.Create((ITypeSymbol)compilation.GetSpecialType(SpecialType.System_Int32),
2520(ITypeSymbol)compilation.GetSpecialType(SpecialType.System_Int32)),
2531ImmutableArray.Create((ITypeSymbol)compilation.GetSpecialType(SpecialType.System_Int32),
2532(ITypeSymbol)compilation.GetSpecialType(SpecialType.System_Int32)),
2543ImmutableArray.Create((ITypeSymbol)compilation.GetSpecialType(SpecialType.System_Int32),
2544(ITypeSymbol)compilation.GetSpecialType(SpecialType.System_Int32)),
2555ImmutableArray.Create((ITypeSymbol)compilation.GetSpecialType(SpecialType.System_Int32),
2556(ITypeSymbol)compilation.GetSpecialType(SpecialType.System_Int32)),
2567default(ImmutableArray<ITypeSymbol>),
2577ImmutableArray.Create((ITypeSymbol)null),
2587ImmutableArray.Create((ITypeSymbol)null),
2597ImmutableArray.Create((ITypeSymbol)compilation.GetSpecialType(SpecialType.System_Int32)),
2606ImmutableArray.Create<ITypeSymbol>(compilation.GetSpecialType(SpecialType.System_Int32)),
2625ImmutableArray.Create<ITypeSymbol>(compilation.GetSpecialType(SpecialType.System_Int32),
2642ImmutableArray.Create<ITypeSymbol>(compilation.GetSpecialType(SpecialType.System_Int32), compilation.GetSpecialType(SpecialType.System_Boolean)),
2657var memberTypes = ImmutableArray.Create<ITypeSymbol>(comp.GetSpecialType(SpecialType.System_Object), comp.GetSpecialType(SpecialType.System_String));
2687var type = comp.CreateAnonymousTypeSymbol(ImmutableArray<ITypeSymbol>.Empty, ImmutableArray<string>.Empty, memberNullableAnnotations: ImmutableArray<CodeAnalysis.NullableAnnotation>.Empty);
2697var memberTypes = ImmutableArray.Create<ITypeSymbol>(comp.GetSpecialType(SpecialType.System_Object), comp.GetSpecialType(SpecialType.System_String));
2711private static ImmutableArray<CodeAnalysis.NullableAnnotation> GetAnonymousTypeNullableAnnotations(ITypeSymbol type)
3031var typeArguments = ImmutableArray.Create<ITypeSymbol>(comp.GetSpecialType(SpecialType.System_Object), comp.GetSpecialType(SpecialType.System_String));
3033Assert.Throws<ArgumentException>(() => genericType.Construct(default(ImmutableArray<ITypeSymbol>), default(ImmutableArray<CodeAnalysis.NullableAnnotation>)));
3042Assert.Throws<ArgumentException>(() => genericType.Construct(ImmutableArray.Create<ITypeSymbol>(null, null), default));
3051typeArguments = ImmutableArray.Create<ITypeSymbol>(comp.GetSpecialType(SpecialType.System_Object), comp.GetSpecialType(SpecialType.System_String));
3066var typeArguments = ImmutableArray.Create<ITypeSymbol>(comp.GetSpecialType(SpecialType.System_Object), comp.GetSpecialType(SpecialType.System_String));
3068Assert.Throws<ArgumentException>(() => genericMethod.Construct(default(ImmutableArray<ITypeSymbol>), default(ImmutableArray<CodeAnalysis.NullableAnnotation>)));
3077Assert.Throws<ArgumentException>(() => genericMethod.Construct(ImmutableArray.Create<ITypeSymbol>(null, null), default));
3086typeArguments = ImmutableArray.Create<ITypeSymbol>(comp.GetSpecialType(SpecialType.System_Object), comp.GetSpecialType(SpecialType.System_String));
Symbols\FunctionPointerTypeSymbolTests.cs (23)
1534Assert.Throws<ArgumentNullException>("returnType", () => comp.CreateFunctionPointerTypeSymbol(returnType: null!, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty));
1536Assert.Throws<ArgumentNullException>("parameterTypes[0]", () => comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray.Create((ITypeSymbol?)null)!, parameterRefKinds: ImmutableArray.Create(RefKind.None)));
1537Assert.Throws<ArgumentNullException>("parameterRefKinds", () => comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: default));
1538Assert.Throws<ArgumentNullException>("callingConventionTypes[0]", () => comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty, callingConvention: SignatureCallingConvention.Unmanaged, ImmutableArray.Create((INamedTypeSymbol)null!)));
1539Assert.Throws<ArgumentException>(() => comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray.Create(RefKind.None)));
1540Assert.Throws<ArgumentException>(() => comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.Out, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty));
1541Assert.Throws<ArgumentOutOfRangeException>(() => comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty, callingConvention: (SignatureCallingConvention)10));
1542Assert.Throws<ArgumentException>(() => comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty, callingConvention: SignatureCallingConvention.Default, callingConventionTypes: ImmutableArray.Create(cdeclType)!));
1543Assert.Throws<ArgumentException>(() => comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty, callingConvention: SignatureCallingConvention.StdCall, callingConventionTypes: ImmutableArray.Create(cdeclType)!));
1544Assert.Throws<ArgumentException>(() => comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty, callingConvention: SignatureCallingConvention.FastCall, callingConventionTypes: ImmutableArray.Create(cdeclType)!));
1545Assert.Throws<ArgumentException>(() => comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty, callingConvention: SignatureCallingConvention.CDecl, callingConventionTypes: ImmutableArray.Create(cdeclType)!));
1546Assert.Throws<ArgumentException>(() => comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty, callingConvention: SignatureCallingConvention.ThisCall, callingConventionTypes: ImmutableArray.Create(cdeclType)!));
1547Assert.Throws<ArgumentException>(() => comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty, callingConvention: SignatureCallingConvention.Unmanaged, callingConventionTypes: ImmutableArray.Create(@string)!));
1555var ptr = comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty, callingConvention: SignatureCallingConvention.VarArgs);
1587ImmutableArray.Create((ITypeSymbol)@string),
1604ImmutableArray.Create((ITypeSymbol)@string),
1622ImmutableArray.Create((ITypeSymbol)@string),
1640var ptr = comp.CreateFunctionPointerTypeSymbol(@string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty, convention);
1642ptr = comp.CreateFunctionPointerTypeSymbol(@string, returnRefKind: RefKind.RefReadOnly, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty, convention);
1655var ptr = comp.CreateFunctionPointerTypeSymbol(@string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty, SignatureCallingConvention.Unmanaged, ImmutableArray.Create(cdeclType, stdcallType)!);
1657ptr = comp.CreateFunctionPointerTypeSymbol(@string, returnRefKind: RefKind.RefReadOnly, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty, SignatureCallingConvention.Unmanaged, ImmutableArray.Create(cdeclType, stdcallType)!);
1660ptr = comp.CreateFunctionPointerTypeSymbol(@string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty, SignatureCallingConvention.Unmanaged, ImmutableArray.Create(cdeclType)!);
1970parameterTypes: ImmutableArray<ITypeSymbol>.Empty,
Symbols\Source\NullablePublicAPITests.cs (11)
4369Assert.Equal(PublicNullableAnnotation.NotAnnotated, ((ITypeSymbol)symbol2.Symbol).NullableAnnotation);
4397Assert.Equal(PublicNullableAnnotation.None, ((ITypeSymbol)symbol2.Symbol).NullableAnnotation);
4427Assert.Equal(PublicNullableAnnotation.None, ((ITypeSymbol)symbol2.Symbol).NullableAnnotation);
4457Assert.Equal(PublicNullableAnnotation.NotAnnotated, ((ITypeSymbol)symbol2.Symbol).NullableAnnotation);
4487Assert.Equal(PublicNullableAnnotation.NotAnnotated, ((ITypeSymbol)symbol2.Symbol).NullableAnnotation);
4519Assert.Equal(PublicNullableAnnotation.NotAnnotated, ((ITypeSymbol)symbol2.Symbol).NullableAnnotation);
4552Assert.Equal(PublicNullableAnnotation.None, ((ITypeSymbol)symbol2.Symbol).NullableAnnotation);
4580Assert.Equal(PublicNullableAnnotation.NotAnnotated, ((ITypeSymbol)symbol2.Symbol).NullableAnnotation);
4610Assert.Equal(PublicNullableAnnotation.None, ((ITypeSymbol)symbol2.Symbol).NullableAnnotation);
4641Assert.Equal(PublicNullableAnnotation.NotAnnotated, ((ITypeSymbol)symbol2.Symbol).NullableAnnotation);
4674Assert.Equal(PublicNullableAnnotation.None, ((ITypeSymbol)symbol2.Symbol).NullableAnnotation);
Microsoft.CodeAnalysis.CSharp.Test.Utilities (22)
Microsoft.CodeAnalysis.CSharp.WinRT.UnitTests (1)
Microsoft.CodeAnalysis.CSharp.Workspaces (216)
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)
906public static ITypeSymbol? GetTargetType(
936bool HasType(ExpressionSyntax expression, [NotNullWhen(true)] out ITypeSymbol? type)
942ITypeSymbol? GetTargetTypeForArgument(ArgumentSyntax argument)
946var tupleType = tupleExpression.GetTargetType(semanticModel, cancellationToken);
961ITypeSymbol? GetTargetTypeForAttributeArgument(AttributeArgumentSyntax argument)
964ITypeSymbol? GetTargetTypeForArrowExpression(ArrowExpressionClauseSyntax arrowExpression)
971ITypeSymbol? GetTargetTypeForReturnStatement(ReturnStatementSyntax returnStatement)
985ITypeSymbol? GetTargetTypeForEqualsValueClause(EqualsValueClauseSyntax equalsValue)
995ITypeSymbol? GetTargetTypedForCastExpression(CastExpressionSyntax castExpression)
998ITypeSymbol? GetTargetTypeForConditionalExpression(ConditionalExpressionSyntax conditionalExpression, ExpressionSyntax expression)
1001return HasType(conditionalExpression.WhenFalse, out var falseType) ? falseType : conditionalExpression.GetTargetType(semanticModel, cancellationToken);
1003return HasType(conditionalExpression.WhenTrue, out var trueType) ? trueType : conditionalExpression.GetTargetType(semanticModel, cancellationToken);
1008ITypeSymbol? GetTargetTypeForLambdaExpression(LambdaExpressionSyntax lambda, ExpressionSyntax expression)
1012ITypeSymbol? GetTargetTypeForSwitchExpressionArm(SwitchExpressionArmSyntax switchExpressionArm)
1019if (arm != switchExpressionArm && HasType(arm.Expression, out var armType))
1027ITypeSymbol? GetTargetTypeForCollectionElement(CollectionElementSyntax collectionElement)
1035var collectionTargetType = collectionExpression.GetTargetType(semanticModel, cancellationToken);
1055ITypeSymbol? GetTargetTypeForInitializerExpression(InitializerExpressionSyntax initializerExpression, ExpressionSyntax expression)
1059return HasType(arrayCreation.Type, out var elementType) ? elementType : null;
1066if (sibling != expression && HasType(sibling, out var siblingType))
1084ITypeSymbol? GetTargetTypeForAssignmentExpression(AssignmentExpressionSyntax assignmentExpression, ExpressionSyntax expression)
1086return expression == assignmentExpression.Right && HasType(assignmentExpression.Left, out var leftType) ? leftType : null;
1089ITypeSymbol? GetTargetTypeForBinaryExpression(BinaryExpressionSyntax binaryExpression, ExpressionSyntax expression)
1091return 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;
943private static bool IsNullOrErrorType([NotNullWhen(false)] ITypeSymbol? type)
1066var castSideType = semanticModel.GetTypeInfo(castSide, cancellationToken).Type;
1067var castedExpressionType = semanticModel.GetTypeInfo(castExpression.Expression, cancellationToken).Type;
1071var otherSideType = semanticModel.GetTypeInfo(otherSide, cancellationToken).Type;
1089var castType = semanticModel.GetTypeInfo(castNode, cancellationToken).Type;
1090var castedExpressionType = semanticModel.GetTypeInfo(castedExpressionNode, cancellationToken).Type;
1147private static bool IsFloatingPointType(ITypeSymbol? type)
1317var rewrittenType = rewrittenSemanticModel.GetTypeInfo(rewrittenExpression, cancellationToken).Type;
1432private static bool IsIntrinsicOrEnum(ITypeSymbol rewrittenType)
1440ITypeSymbol rewrittenType,
1530private static (ITypeSymbol? rewrittenConvertedType, Conversion rewrittenConversion) GetRewrittenInfo(
1533Conversion originalConversion, ITypeSymbol originalConvertedType,
1544var convertedType = originalConversion.IsIdentity ? originalConvertedType : originalSemanticModel.Compilation.ObjectType;
1548var 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);
Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests (2)
Microsoft.CodeAnalysis.EditorFeatures (3)
Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities (1)
Microsoft.CodeAnalysis.EditorFeatures.UnitTests (57)
Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler (3)
Microsoft.CodeAnalysis.Extensions.Package (210)
Symbols\ITypeSymbolExtensions.cs (100)
26public static bool IsIntegralType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
29public static bool IsSignedIntegralType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
32public static bool CanAddNullCheck([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
43public static ImmutableArray<INamedTypeSymbol> GetAllInterfacesIncludingThis(this ITypeSymbol type)
51public static bool IsAbstractClass([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
54public static bool IsSystemVoid([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
57public static bool IsNullable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
60public static bool IsNonNullableValueType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
64[NotNullWhen(true)] this ITypeSymbol? symbol,
65[NotNullWhen(true)] out ITypeSymbol? underlyingType)
77public static bool IsModuleType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
80public static bool IsInterfaceType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
83public static bool IsDelegateType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
86public static bool IsFunctionPointerType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
89public static bool IsStructType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
96this ITypeSymbol type,
110public static IEnumerable<ITypeSymbol> GetBaseTypesAndThis(this ITypeSymbol? type)
112var current = type;
120public static IEnumerable<INamedTypeSymbol> GetBaseTypes(this ITypeSymbol? type)
130public static IEnumerable<ITypeSymbol> GetContainingTypesAndThis(this ITypeSymbol? type)
132var current = type;
140public static IEnumerable<INamedTypeSymbol> GetContainingTypes(this ITypeSymbol type)
153this ITypeSymbol type, ITypeSymbol baseType, bool includeInterfaces)
166this ITypeSymbol type, ITypeSymbol baseType)
174this ITypeSymbol type, ITypeSymbol baseType)
176var originalBaseType = baseType.OriginalDefinition;
184IEnumerable<ITypeSymbol> baseTypes = (baseType.TypeKind == TypeKind.Interface) ? type.AllInterfaces : type.GetBaseTypes();
191this ITypeSymbol type, ITypeSymbol baseType)
193var originalBaseType = baseType.OriginalDefinition;
213this ITypeSymbol type, ITypeSymbol interfaceType)
215var originalInterfaceType = interfaceType.OriginalDefinition;
220this ITypeSymbol type, ITypeSymbol interfaceType)
225public static bool IsAttribute(this ITypeSymbol symbol)
243public static bool IsFormattableStringOrIFormattable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
252this ITypeSymbol typeSymbol, bool allowDelegateAndEnumConstraints = false)
280public static bool IsNumericType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
306public static Accessibility DetermineMinimalAccessibility(this ITypeSymbol typeSymbol)
309public static bool ContainsAnonymousType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
325foreach (var typeArg in type.GetAllTypeArguments())
334public static string CreateParameterName(this ITypeSymbol type, bool capitalize = false)
355private static string GetParameterName(ITypeSymbol? type)
368public static bool IsSpecialType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
399public static bool CanSupportCollectionInitializer(this ITypeSymbol typeSymbol, ISymbol within)
410public static INamedTypeSymbol? GetDelegateType(this ITypeSymbol? typeSymbol, Compilation compilation)
417var typeArgument = ((INamedTypeSymbol)typeSymbol).TypeArguments[0];
430public static IEnumerable<T> GetAccessibleMembersInBaseTypes<T>(this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol
439public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, ISymbol within) where T : class, ISymbol
449public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, string memberName, ISymbol within) where T : class, ISymbol
459public static bool? AreMoreSpecificThan(this IList<ITypeSymbol> t1, IList<ITypeSymbol> t2)
494public static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, ISymbol within) where T : class, ISymbol
504private static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, string memberName, ISymbol within) where T : class, ISymbol
514private static bool? IsMoreSpecificThan(this ITypeSymbol t1, ITypeSymbol t2)
592public static bool IsOrDerivesFromExceptionType([NotNullWhen(returnValue: true)] this ITypeSymbol? type, Compilation compilation)
599foreach (var baseType in type.GetBaseTypesAndThis())
610foreach (var constraint in ((ITypeParameterSymbol)type).ConstraintTypes)
625public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type)
628public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type, [NotNullWhen(true)] out INamedTypeSymbol? enumType)
640public static bool? IsMutableValueType(this ITypeSymbol type)
642if (type.IsNullable(out var underlyingType))
719public static bool IsDisposable([NotNullWhen(returnValue: true)] this ITypeSymbol? type, [NotNullWhen(returnValue: true)] ITypeSymbol? iDisposableType)
724public static ITypeSymbol WithNullableAnnotationFrom(this ITypeSymbol type, ITypeSymbol symbolForNullableAnnotation)
728public static ITypeSymbol? RemoveNullableIfPresent(this ITypeSymbol? symbol)
730if (symbol.IsNullable(out var underlyingType))
738public static bool IsSpanOrReadOnlySpan([NotNullWhen(true)] this ITypeSymbol? type)
741public static bool IsSpan([NotNullWhen(true)] this ITypeSymbol? type)
757public static bool IsInlineArray([NotNullWhen(true)] this ITypeSymbol? type)
762public static ITypeSymbol? RemoveUnavailableTypeParameters(
763this ITypeSymbol? type,
771private static ITypeSymbol? RemoveUnavailableTypeParameters(
772this ITypeSymbol? type,
780public static ITypeSymbol? RemoveAnonymousTypes(
781this ITypeSymbol? type,
788public static ITypeSymbol? RemoveUnnamedErrorTypes(
789this ITypeSymbol? type,
796this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
802this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
808this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result, bool onlyMethodTypeParameters)
817public static IList<ITypeParameterSymbol> GetReferencedTypeParameters(this ITypeSymbol? type)
825public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
826this ITypeSymbol? type,
829where TType1 : ITypeSymbol
830where TType2 : ITypeSymbol
836public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
837this ITypeSymbol? type,
840where TType1 : ITypeSymbol
841where TType2 : ITypeSymbol
Microsoft.CodeAnalysis.Features (446)
AddImport\SymbolReferenceFinder.cs (9)
207var typeSymbols = OfType<ITypeSymbol>(symbols);
234ITypeSymbol symbol,
393ImmutableArray<SymbolResult<IMethodSymbol>> methodSymbols, ITypeSymbol typeSymbol)
450var type = _owner.GetQueryClauseInfo(_semanticModel, _node, cancellationToken);
474var type = GetAwaitInfo(_semanticModel, _syntaxFacts, _node);
499var type = GetCollectionExpressionType(_semanticModel, _syntaxFacts, _node);
524var type = GetCollectionExpressionType(_semanticModel, _syntaxFacts, _node);
549var type = _owner.GetDeconstructInfo(_semanticModel, _node, cancellationToken);
565SearchScope 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)
57ITypeSymbol receiverTypeSymbol,
59ImmutableArray<ITypeSymbol> targetTypesSymbols,
97ITypeSymbol receiverTypeSymbol,
99ImmutableArray<ITypeSymbol> targetTypes,
127Compilation compilation, ImmutableArray<IMethodSymbol> extentsionMethodSymbols, ImmutableArray<ITypeSymbol> targetTypeSymbols, CancellationToken cancellationToken)
129Dictionary<ITypeSymbol, bool> typeConvertibilityCache = [];
196Compilation compilation, IMethodSymbol methodSymbol, ImmutableArray<ITypeSymbol> targetTypeSymbols,
197Dictionary<ITypeSymbol, bool> typeConvertibilityCache)
Completion\Providers\ImportCompletionProvider\ExtensionMethodImportCompletionHelper.SymbolComputer.cs (15)
33private readonly ITypeSymbol _receiverTypeSymbol;
40private readonly ConcurrentDictionary<ITypeSymbol, bool> _checkedReceiverTypes = [];
45ITypeSymbol receiverTypeSymbol,
224MultiDictionary<ITypeSymbol, IMethodSymbol> matchingMethodSymbols,
291MultiDictionary<ITypeSymbol, IMethodSymbol> matchingMethodSymbols,
327private static IMethodSymbol? TryReduceExtensionMethod(IMethodSymbol methodSymbol, ITypeSymbol receiverTypeSymbol)
346private MultiDictionary<ITypeSymbol, IMethodSymbol> GetPotentialMatchingSymbolsFromAssembly(
352var builder = new MultiDictionary<ITypeSymbol, IMethodSymbol>();
387if (MatchExtensionMethod(methodSymbol, receiverTypeName, internalsVisible, out var receiverType))
398static bool MatchExtensionMethod(IMethodSymbol method, string filterReceiverTypeName, bool internalsVisible, out ITypeSymbol? receiverType)
479private static ImmutableArray<string> GetReceiverTypeNames(ITypeSymbol receiverTypeSymbol)
485static void AddNamesForTypeWorker(ITypeSymbol receiverTypeSymbol, PooledHashSet<string> builder)
489foreach (var constraintType in typeParameter.ConstraintTypes)
523private static string GetReceiverTypeName(ITypeSymbol typeSymbol)
531var elementType = arrayType.ElementType;
Completion\Providers\ImportCompletionProvider\ExtensionMethodImportCompletionHelper.SymbolComputer_Constraints.cs (15)
16private static bool CheckConstraints(ITypeSymbol receiverTypeSymbol, ITypeParameterSymbol typeParameter)
30private static bool SatisfiesInterfaceConstraint(ITypeSymbol receiverTypeSymbol, ITypeParameterSymbol typeParameter)
33private static bool SatisfiesBaseTypeConstraint(ITypeSymbol receiverTypeSymbol, ITypeParameterSymbol typeParameter)
36private static IEnumerable<ITypeSymbol> GetAllTypeParameterConstraintTypes(
39Func<ITypeSymbol, IEnumerable<ITypeSymbol>> getInheritanceTypes)
58foreach (var baseType in GetAllTypes(constraintType, typeKind, getInheritanceTypes))
66ITypeSymbol receiverTypeSymbol,
69Func<ITypeSymbol, IEnumerable<ITypeSymbol>> getInheritanceTypes)
89foreach (var type in GetAllTypes(receiverTypeSymbol, constraintTypeKind, getInheritanceTypes))
104private static IEnumerable<ITypeSymbol> GetAllTypes(
105ITypeSymbol type, TypeKind typeKind, Func<ITypeSymbol, IEnumerable<ITypeSymbol>> getInheritanceTypes)
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 (13)
1843protected void AddRudeTypeUpdateAroundActiveStatement(RudeEditDiagnosticsBuilder diagnostics, SyntaxNode newNode, ITypeSymbol oldType, ITypeSymbol newType)
2026var oldType = oldModel.GetTypeInfo(oldTypedNodes[t], cancellationToken).Type;
2027var newType = newModel.GetTypeInfo(newTypedNodes[t], cancellationToken).Type;
2457protected static bool TypesEquivalent(ITypeSymbol? oldType, ITypeSymbol? newType, bool exact)
2458=> (exact ? s_exactSymbolEqualityComparer : (IEqualityComparer<ITypeSymbol?>)s_runtimeSymbolEqualityComparer.SignatureTypeEquivalenceComparer).Equals(oldType, newType);
2460protected static bool TypesEquivalent<T>(ImmutableArray<T> oldTypes, ImmutableArray<T> newTypes, bool exact) where T : ITypeSymbol
6406var oldType = GetType(oldSymbol);
6407var newType = GetType(newSymbol);
6490private static ITypeSymbol GetType(ISymbol localOrParameter)
6735TypedConstantKind.Type => TypesEquivalent((ITypeSymbol?)x.Value, (ITypeSymbol?)y.Value, exact: false),
src\Analyzers\Core\Analyzers\RemoveUnusedParametersAndValues\AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.cs (1)
292ITypeSymbol containingType,
src\Analyzers\Core\CodeFixes\AddExplicitCast\AbstractAddExplicitCastCodeFixProvider.cs (11)
31protected abstract TExpressionSyntax Cast(TExpressionSyntax expression, ITypeSymbol type);
49protected ImmutableArray<(TExpressionSyntax node, ITypeSymbol type)> GetPotentialTargetTypes(
53using var _ = ArrayBuilder<(TExpressionSyntax node, ITypeSymbol type)>.GetInstance(out var candidates);
64ArrayBuilder<(TExpressionSyntax node, ITypeSymbol type)> candidates,
121ITypeSymbol conversionType,
144var castType = semanticModel.GetTypeInfo(castTypeNode, cancellationToken).Type;
162protected virtual (SyntaxNode finalTarget, SyntaxNode finalReplacement) Cast(SemanticModel semanticModel, TExpressionSyntax targetNode, ITypeSymbol conversionType)
165private static string GetSubItemName(SemanticModel semanticModel, int position, ITypeSymbol conversionType)
172private static ImmutableArray<(TExpressionSyntax, ITypeSymbol)> FilterValidPotentialConversionTypes(
175ArrayBuilder<(TExpressionSyntax node, ITypeSymbol type)> candidates)
180using var _ = ArrayBuilder<(TExpressionSyntax, ITypeSymbol)>.GetInstance(candidates.Count, out var validPotentialConversionTypes);
src\Analyzers\Core\CodeFixes\AddParameter\AbstractAddParameterCodeFixProvider.cs (4)
47protected abstract ITypeSymbol GetArgumentType(SyntaxNode argumentNode, SemanticModel semanticModel, CancellationToken cancellationToken);
402private async Task<(ITypeSymbol, RefKind)> GetArgumentTypeAndRefKindAsync(Document invocationDocument, TArgumentSyntax argument, CancellationToken cancellationToken)
406var argumentType = GetArgumentType(argument, semanticModel, cancellationToken);
537Compilation compilation, TypeInfo argumentTypeInfo, ITypeSymbol parameterType,
Microsoft.CodeAnalysis.Features.Test.Utilities (2)
Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers (431)
Microsoft.CodeAnalysis.PublicApiAnalyzers (311)
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\Compiler\Extensions\Symbols\ITypeSymbolExtensions.cs (100)
26public static bool IsIntegralType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
29public static bool IsSignedIntegralType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
32public static bool CanAddNullCheck([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
43public static ImmutableArray<INamedTypeSymbol> GetAllInterfacesIncludingThis(this ITypeSymbol type)
51public static bool IsAbstractClass([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
54public static bool IsSystemVoid([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
57public static bool IsNullable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
60public static bool IsNonNullableValueType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
64[NotNullWhen(true)] this ITypeSymbol? symbol,
65[NotNullWhen(true)] out ITypeSymbol? underlyingType)
77public static bool IsModuleType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
80public static bool IsInterfaceType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
83public static bool IsDelegateType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
86public static bool IsFunctionPointerType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
89public static bool IsStructType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
96this ITypeSymbol type,
110public static IEnumerable<ITypeSymbol> GetBaseTypesAndThis(this ITypeSymbol? type)
112var current = type;
120public static IEnumerable<INamedTypeSymbol> GetBaseTypes(this ITypeSymbol? type)
130public static IEnumerable<ITypeSymbol> GetContainingTypesAndThis(this ITypeSymbol? type)
132var current = type;
140public static IEnumerable<INamedTypeSymbol> GetContainingTypes(this ITypeSymbol type)
153this ITypeSymbol type, ITypeSymbol baseType, bool includeInterfaces)
166this ITypeSymbol type, ITypeSymbol baseType)
174this ITypeSymbol type, ITypeSymbol baseType)
176var originalBaseType = baseType.OriginalDefinition;
184IEnumerable<ITypeSymbol> baseTypes = (baseType.TypeKind == TypeKind.Interface) ? type.AllInterfaces : type.GetBaseTypes();
191this ITypeSymbol type, ITypeSymbol baseType)
193var originalBaseType = baseType.OriginalDefinition;
213this ITypeSymbol type, ITypeSymbol interfaceType)
215var originalInterfaceType = interfaceType.OriginalDefinition;
220this ITypeSymbol type, ITypeSymbol interfaceType)
225public static bool IsAttribute(this ITypeSymbol symbol)
243public static bool IsFormattableStringOrIFormattable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
252this ITypeSymbol typeSymbol, bool allowDelegateAndEnumConstraints = false)
280public static bool IsNumericType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
306public static Accessibility DetermineMinimalAccessibility(this ITypeSymbol typeSymbol)
309public static bool ContainsAnonymousType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
325foreach (var typeArg in type.GetAllTypeArguments())
334public static string CreateParameterName(this ITypeSymbol type, bool capitalize = false)
355private static string GetParameterName(ITypeSymbol? type)
368public static bool IsSpecialType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
399public static bool CanSupportCollectionInitializer(this ITypeSymbol typeSymbol, ISymbol within)
410public static INamedTypeSymbol? GetDelegateType(this ITypeSymbol? typeSymbol, Compilation compilation)
417var typeArgument = ((INamedTypeSymbol)typeSymbol).TypeArguments[0];
430public static IEnumerable<T> GetAccessibleMembersInBaseTypes<T>(this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol
439public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, ISymbol within) where T : class, ISymbol
449public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, string memberName, ISymbol within) where T : class, ISymbol
459public static bool? AreMoreSpecificThan(this IList<ITypeSymbol> t1, IList<ITypeSymbol> t2)
494public static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, ISymbol within) where T : class, ISymbol
504private static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, string memberName, ISymbol within) where T : class, ISymbol
514private static bool? IsMoreSpecificThan(this ITypeSymbol t1, ITypeSymbol t2)
592public static bool IsOrDerivesFromExceptionType([NotNullWhen(returnValue: true)] this ITypeSymbol? type, Compilation compilation)
599foreach (var baseType in type.GetBaseTypesAndThis())
610foreach (var constraint in ((ITypeParameterSymbol)type).ConstraintTypes)
625public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type)
628public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type, [NotNullWhen(true)] out INamedTypeSymbol? enumType)
640public static bool? IsMutableValueType(this ITypeSymbol type)
642if (type.IsNullable(out var underlyingType))
719public static bool IsDisposable([NotNullWhen(returnValue: true)] this ITypeSymbol? type, [NotNullWhen(returnValue: true)] ITypeSymbol? iDisposableType)
724public static ITypeSymbol WithNullableAnnotationFrom(this ITypeSymbol type, ITypeSymbol symbolForNullableAnnotation)
728public static ITypeSymbol? RemoveNullableIfPresent(this ITypeSymbol? symbol)
730if (symbol.IsNullable(out var underlyingType))
738public static bool IsSpanOrReadOnlySpan([NotNullWhen(true)] this ITypeSymbol? type)
741public static bool IsSpan([NotNullWhen(true)] this ITypeSymbol? type)
757public static bool IsInlineArray([NotNullWhen(true)] this ITypeSymbol? type)
762public static ITypeSymbol? RemoveUnavailableTypeParameters(
763this ITypeSymbol? type,
771private static ITypeSymbol? RemoveUnavailableTypeParameters(
772this ITypeSymbol? type,
780public static ITypeSymbol? RemoveAnonymousTypes(
781this ITypeSymbol? type,
788public static ITypeSymbol? RemoveUnnamedErrorTypes(
789this ITypeSymbol? type,
796this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
802this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
808this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result, bool onlyMethodTypeParameters)
817public static IList<ITypeParameterSymbol> GetReferencedTypeParameters(this ITypeSymbol? type)
825public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
826this ITypeSymbol? type,
829where TType1 : ITypeSymbol
830where TType2 : ITypeSymbol
836public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
837this ITypeSymbol? type,
840where TType1 : ITypeSymbol
841where TType2 : ITypeSymbol
Microsoft.CodeAnalysis.Remote.ServiceHub (2)
Microsoft.CodeAnalysis.ResxSourceGenerator (304)
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\Compiler\Extensions\Symbols\ITypeSymbolExtensions.cs (100)
26public static bool IsIntegralType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
29public static bool IsSignedIntegralType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
32public static bool CanAddNullCheck([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
43public static ImmutableArray<INamedTypeSymbol> GetAllInterfacesIncludingThis(this ITypeSymbol type)
51public static bool IsAbstractClass([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
54public static bool IsSystemVoid([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
57public static bool IsNullable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
60public static bool IsNonNullableValueType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
64[NotNullWhen(true)] this ITypeSymbol? symbol,
65[NotNullWhen(true)] out ITypeSymbol? underlyingType)
77public static bool IsModuleType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
80public static bool IsInterfaceType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
83public static bool IsDelegateType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
86public static bool IsFunctionPointerType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
89public static bool IsStructType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
96this ITypeSymbol type,
110public static IEnumerable<ITypeSymbol> GetBaseTypesAndThis(this ITypeSymbol? type)
112var current = type;
120public static IEnumerable<INamedTypeSymbol> GetBaseTypes(this ITypeSymbol? type)
130public static IEnumerable<ITypeSymbol> GetContainingTypesAndThis(this ITypeSymbol? type)
132var current = type;
140public static IEnumerable<INamedTypeSymbol> GetContainingTypes(this ITypeSymbol type)
153this ITypeSymbol type, ITypeSymbol baseType, bool includeInterfaces)
166this ITypeSymbol type, ITypeSymbol baseType)
174this ITypeSymbol type, ITypeSymbol baseType)
176var originalBaseType = baseType.OriginalDefinition;
184IEnumerable<ITypeSymbol> baseTypes = (baseType.TypeKind == TypeKind.Interface) ? type.AllInterfaces : type.GetBaseTypes();
191this ITypeSymbol type, ITypeSymbol baseType)
193var originalBaseType = baseType.OriginalDefinition;
213this ITypeSymbol type, ITypeSymbol interfaceType)
215var originalInterfaceType = interfaceType.OriginalDefinition;
220this ITypeSymbol type, ITypeSymbol interfaceType)
225public static bool IsAttribute(this ITypeSymbol symbol)
243public static bool IsFormattableStringOrIFormattable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
252this ITypeSymbol typeSymbol, bool allowDelegateAndEnumConstraints = false)
280public static bool IsNumericType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
306public static Accessibility DetermineMinimalAccessibility(this ITypeSymbol typeSymbol)
309public static bool ContainsAnonymousType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
325foreach (var typeArg in type.GetAllTypeArguments())
334public static string CreateParameterName(this ITypeSymbol type, bool capitalize = false)
355private static string GetParameterName(ITypeSymbol? type)
368public static bool IsSpecialType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
399public static bool CanSupportCollectionInitializer(this ITypeSymbol typeSymbol, ISymbol within)
410public static INamedTypeSymbol? GetDelegateType(this ITypeSymbol? typeSymbol, Compilation compilation)
417var typeArgument = ((INamedTypeSymbol)typeSymbol).TypeArguments[0];
430public static IEnumerable<T> GetAccessibleMembersInBaseTypes<T>(this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol
439public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, ISymbol within) where T : class, ISymbol
449public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, string memberName, ISymbol within) where T : class, ISymbol
459public static bool? AreMoreSpecificThan(this IList<ITypeSymbol> t1, IList<ITypeSymbol> t2)
494public static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, ISymbol within) where T : class, ISymbol
504private static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, string memberName, ISymbol within) where T : class, ISymbol
514private static bool? IsMoreSpecificThan(this ITypeSymbol t1, ITypeSymbol t2)
592public static bool IsOrDerivesFromExceptionType([NotNullWhen(returnValue: true)] this ITypeSymbol? type, Compilation compilation)
599foreach (var baseType in type.GetBaseTypesAndThis())
610foreach (var constraint in ((ITypeParameterSymbol)type).ConstraintTypes)
625public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type)
628public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type, [NotNullWhen(true)] out INamedTypeSymbol? enumType)
640public static bool? IsMutableValueType(this ITypeSymbol type)
642if (type.IsNullable(out var underlyingType))
719public static bool IsDisposable([NotNullWhen(returnValue: true)] this ITypeSymbol? type, [NotNullWhen(returnValue: true)] ITypeSymbol? iDisposableType)
724public static ITypeSymbol WithNullableAnnotationFrom(this ITypeSymbol type, ITypeSymbol symbolForNullableAnnotation)
728public static ITypeSymbol? RemoveNullableIfPresent(this ITypeSymbol? symbol)
730if (symbol.IsNullable(out var underlyingType))
738public static bool IsSpanOrReadOnlySpan([NotNullWhen(true)] this ITypeSymbol? type)
741public static bool IsSpan([NotNullWhen(true)] this ITypeSymbol? type)
757public static bool IsInlineArray([NotNullWhen(true)] this ITypeSymbol? type)
762public static ITypeSymbol? RemoveUnavailableTypeParameters(
763this ITypeSymbol? type,
771private static ITypeSymbol? RemoveUnavailableTypeParameters(
772this ITypeSymbol? type,
780public static ITypeSymbol? RemoveAnonymousTypes(
781this ITypeSymbol? type,
788public static ITypeSymbol? RemoveUnnamedErrorTypes(
789this ITypeSymbol? type,
796this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
802this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
808this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result, bool onlyMethodTypeParameters)
817public static IList<ITypeParameterSymbol> GetReferencedTypeParameters(this ITypeSymbol? type)
825public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
826this ITypeSymbol? type,
829where TType1 : ITypeSymbol
830where TType2 : ITypeSymbol
836public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
837this ITypeSymbol? type,
840where TType1 : ITypeSymbol
841where TType2 : ITypeSymbol
Microsoft.CodeAnalysis.Test.Utilities (24)
Diagnostics\CouldHaveMoreSpecificTypeAnalyzer.cs (9)
67ITypeSymbol type = increment.Type;
162private static bool HasMoreSpecificSourceType<SymbolType>(SymbolType symbol, ITypeSymbol symbolType, Dictionary<SymbolType, HashSet<INamedTypeSymbol>> symbolsSourceTypes, out INamedTypeSymbol commonSourceType)
237private static void AssignTo(IOperation target, Dictionary<ILocalSymbol, HashSet<INamedTypeSymbol>> localsSourceTypes, Dictionary<IFieldSymbol, HashSet<INamedTypeSymbol>> fieldsSourceTypes, ITypeSymbol sourceType)
252private static void AssignTo<SymbolType>(SymbolType target, ITypeSymbol targetType, Dictionary<SymbolType, HashSet<INamedTypeSymbol>> sourceTypes, IOperation sourceValue)
257private static void AssignTo<SymbolType>(SymbolType target, ITypeSymbol targetType, Dictionary<SymbolType, HashSet<INamedTypeSymbol>> sourceTypes, ITypeSymbol sourceType)
279private static ITypeSymbol OriginalType(IOperation value)
293private void Report(OperationBlockAnalysisContext context, ILocalSymbol local, ITypeSymbol moreSpecificType, DiagnosticDescriptor descriptor)
298private void Report(CompilationAnalysisContext context, IFieldSymbol field, ITypeSymbol moreSpecificType, DiagnosticDescriptor descriptor)
Microsoft.CodeAnalysis.UnitTests (2)
Microsoft.CodeAnalysis.VisualBasic (153)
Compilation\VisualBasicCompilation.vb (21)
866Protected Overrides ReadOnly Property CommonScriptGlobalsType As ITypeSymbol
1876Public Shadows Function ClassifyConversion(source As ITypeSymbol, destination As ITypeSymbol) As Conversion
1895Public Overrides Function ClassifyCommonConversion(source As ITypeSymbol, destination As ITypeSymbol) As CommonConversion
1899Friend Overrides Function ClassifyConvertibleConversion(source As IOperation, destination As ITypeSymbol, ByRef constantValue As ConstantValue) As IConvertibleConversion
1906Dim sourceType As ITypeSymbol = source.Type
2019Private Protected Overrides Function IsSymbolAccessibleWithinCore(symbol As ISymbol, within As ISymbol, throughType As ITypeSymbol) As Boolean
2029Friend Shadows Function IsSymbolAccessibleWithin(symbol As ISymbol, within As ISymbol, Optional throughType As ITypeSymbol = Nothing) As Boolean
2864Protected Overrides Function CommonCreateArrayTypeSymbol(elementType As ITypeSymbol, rank As Integer, elementNullableAnnotation As NullableAnnotation) As IArrayTypeSymbol
2868Protected Overrides Function CommonCreateTupleTypeSymbol(elementTypes As ImmutableArray(Of ITypeSymbol),
2909Protected Overrides Function CommonCreatePointerTypeSymbol(elementType As ITypeSymbol) As IPointerTypeSymbol
2914returnType As ITypeSymbol,
2916parameterTypes As ImmutableArray(Of ITypeSymbol),
2928memberTypes As ImmutableArray(Of ITypeSymbol),
2958returnType As ITypeSymbol,
2959leftType As ITypeSymbol,
2960rightType As ITypeSymbol) As IMethodSymbol
3042returnType As ITypeSymbol,
3043operandType As ITypeSymbol) As IMethodSymbol
3092Protected Overrides ReadOnly Property CommonDynamicType As ITypeSymbol
Symbols\TypeSymbol.vb (27)
239Public MustOverride ReadOnly Property IsReferenceType As Boolean Implements ITypeSymbol.IsReferenceType, ITypeSymbolInternal.IsReferenceType
246Public MustOverride ReadOnly Property IsValueType As Boolean Implements ITypeSymbol.IsValueType, ITypeSymbolInternal.IsValueType
251Public Overridable ReadOnly Property IsAnonymousType As Boolean Implements ITypeSymbol.IsAnonymousType
287Public ReadOnly Property SpecialType As SpecialType Implements ITypeSymbol.SpecialType, ITypeSymbolInternal.SpecialType
539Private Function ITypeSymbol_FindImplementationForInterfaceMember(interfaceMember As ISymbol) As ISymbol Implements ITypeSymbol.FindImplementationForInterfaceMember
545Private ReadOnly Property ITypeSymbol_AllInterfaces As ImmutableArray(Of INamedTypeSymbol) Implements ITypeSymbol.AllInterfaces
551Private ReadOnly Property ITypeSymbol_BaseType As INamedTypeSymbol Implements ITypeSymbol.BaseType
557Private ReadOnly Property ITypeSymbol_Interfaces As ImmutableArray(Of INamedTypeSymbol) Implements ITypeSymbol.Interfaces
563Private ReadOnly Property ITypeSymbol_OriginalDefinition As ITypeSymbol Implements ITypeSymbol.OriginalDefinition
569Private ReadOnly Property ITypeSymbol_IsTupleSymbol As Boolean Implements ITypeSymbol.IsTupleType
575Private ReadOnly Property ITypeSymbol_IsNativeIntegerType As Boolean Implements ITypeSymbol.IsNativeIntegerType
581Private ReadOnly Property ITypeSymbol_TypeKind As TypeKind Implements ITypeSymbol.TypeKind, ITypeSymbolInternal.TypeKind
587Private ReadOnly Property ITypeSymbol_IsRefLikeType As Boolean Implements ITypeSymbol.IsRefLikeType
594Private ReadOnly Property ITypeSymbol_IsUnmanagedType As Boolean Implements ITypeSymbol.IsUnmanagedType
600Private ReadOnly Property ITypeSymbol_IsReadOnly As Boolean Implements ITypeSymbol.IsReadOnly
607Private ReadOnly Property ITypeSymbol_IsRecord As Boolean Implements ITypeSymbol.IsRecord
614Private Function ITypeSymbol_ToDisplayString(topLevelNullability As NullableFlowState, Optional format As SymbolDisplayFormat = Nothing) As String Implements ITypeSymbol.ToDisplayString
618Private Function ITypeSymbol_ToDisplayParts(topLevelNullability As NullableFlowState, Optional format As SymbolDisplayFormat = Nothing) As ImmutableArray(Of SymbolDisplayPart) Implements ITypeSymbol.ToDisplayParts
622Private Function ITypeSymbol_ToMinimalDisplayString(semanticModel As SemanticModel, topLevelNullability As NullableFlowState, position As Integer, Optional format As SymbolDisplayFormat = Nothing) As String Implements ITypeSymbol.ToMinimalDisplayString
626Private Function ITypeSymbol_ToMinimalDisplayParts(semanticModel As SemanticModel, topLevelNullability As NullableFlowState, position As Integer, Optional format As SymbolDisplayFormat = Nothing) As ImmutableArray(Of SymbolDisplayPart) Implements ITypeSymbol.ToMinimalDisplayParts
772Private ReadOnly Property ITypeSymbol_NullableAnnotation As NullableAnnotation Implements ITypeSymbol.NullableAnnotation
778Private Function ITypeSymbol_WithNullability(nullableAnnotation As NullableAnnotation) As ITypeSymbol Implements ITypeSymbol.WithNullableAnnotation
782Private Function ITypeSymbolInternal_GetITypeSymbol() As ITypeSymbol Implements ITypeSymbolInternal.GetITypeSymbol
786Public ReadOnly Property IsExtension As Boolean Implements ITypeSymbol.IsExtension
792Public ReadOnly Property ExtensionParameter As IParameterSymbol Implements ITypeSymbol.ExtensionParameter
Microsoft.CodeAnalysis.VisualBasic.Analyzers (3)
Microsoft.CodeAnalysis.VisualBasic.CodeStyle (30)
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
Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes (57)
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
Microsoft.CodeAnalysis.VisualBasic.Emit.UnitTests (25)
CodeGen\CodeGenTuples.vb (25)
7218Dim intType As ITypeSymbol = comp.GetSpecialType(SpecialType.System_Int32)
7223Assert.Throws(Of ArgumentException)(Sub() comp.CreateTupleTypeSymbol(elementTypes:=ImmutableArray(Of ITypeSymbol).Empty, elementNames:=Nothing))
7244Dim intType As ITypeSymbol = comp.GetSpecialType(SpecialType.System_Int32)
7245Dim stringType As ITypeSymbol = comp.GetSpecialType(SpecialType.System_String)
7267Dim intType As ITypeSymbol = comp.GetSpecialType(SpecialType.System_Int32)
7268Dim stringType As ITypeSymbol = comp.GetSpecialType(SpecialType.System_String)
7290Dim intType As ITypeSymbol = comp.GetSpecialType(SpecialType.System_Int32)
7291Dim stringType As ITypeSymbol = comp.GetSpecialType(SpecialType.System_String)
7308Dim intType As ITypeSymbol = comp.GetSpecialType(SpecialType.System_Int32)
7309Dim stringType As ITypeSymbol = comp.GetSpecialType(SpecialType.System_String)
7326Dim intType As ITypeSymbol = comp.GetSpecialType(SpecialType.System_Int32)
7342Dim intType As ITypeSymbol = comp.GetSpecialType(SpecialType.System_Int32)
7343Dim stringType As ITypeSymbol = comp.GetSpecialType(SpecialType.System_String)
7363Dim intType As ITypeSymbol = comp.GetSpecialType(SpecialType.System_Int32)
7364Dim stringType As ITypeSymbol = comp.GetSpecialType(SpecialType.System_String)
7384Dim intType As ITypeSymbol = comp.GetSpecialType(SpecialType.System_Int32)
7385Dim stringType As ITypeSymbol = comp.GetSpecialType(SpecialType.System_String)
7405Dim intType As ITypeSymbol = comp.GetSpecialType(SpecialType.System_Int32)
7406Dim stringType As ITypeSymbol = comp.GetSpecialType(SpecialType.System_String)
7432Dim intType As ITypeSymbol = comp.GetSpecialType(SpecialType.System_Int32)
7449Dim intType As ITypeSymbol = comp.GetSpecialType(SpecialType.System_Int32)
7481Dim stringType As ITypeSymbol = comp.GetSpecialType(SpecialType.System_String)
7510Dim tuple3 = DirectCast(comp.CreateTupleTypeSymbol(ImmutableArray.Create(Of ITypeSymbol)(intType, intType, intType, intType, intType, intType, intType, stringType, stringType),
7727Private Shared Function TypeEquals(a As ITypeSymbol, b As ITypeSymbol, compareKind As TypeCompareKind) As Boolean
Microsoft.CodeAnalysis.VisualBasic.Features (69)
Microsoft.CodeAnalysis.VisualBasic.Features.UnitTests (2)
Microsoft.CodeAnalysis.VisualBasic.Semantic.UnitTests (27)
Compilation\CompilationAPITests.vb (25)
1552ImmutableArray.Create(DirectCast(Nothing, ITypeSymbol)),
1563ImmutableArray.Create(DirectCast(compilation.GetSpecialType(SpecialType.System_Int32), ITypeSymbol),
1564DirectCast(compilation.GetSpecialType(SpecialType.System_Int32), ITypeSymbol)),
1576ImmutableArray.Create(DirectCast(Compilation.GetSpecialType(SpecialType.System_Int32), ITypeSymbol),
1577DirectCast(Compilation.GetSpecialType(SpecialType.System_Int32), ITypeSymbol)),
1587ImmutableArray.Create(DirectCast(compilation.GetSpecialType(SpecialType.System_Int32), ITypeSymbol),
1588DirectCast(compilation.GetSpecialType(SpecialType.System_Int32), ITypeSymbol)),
1608ImmutableArray.Create(DirectCast(compilation.GetSpecialType(SpecialType.System_Int32), ITypeSymbol),
1609DirectCast(compilation.GetSpecialType(SpecialType.System_Int32), ITypeSymbol)),
1626ImmutableArray.Create(DirectCast(Nothing, ITypeSymbol)),
1635ImmutableArray.Create(Of ITypeSymbol)(compilation.GetSpecialType(SpecialType.System_Int32)),
1649ImmutableArray.Create(Of ITypeSymbol)(compilation.GetSpecialType(SpecialType.System_Int32)),
1664ImmutableArray.Create(Of ITypeSymbol)(compilation.GetSpecialType(SpecialType.System_Int32), compilation.GetSpecialType(SpecialType.System_Boolean)),
1678Dim memberTypes = ImmutableArray.Create(Of ITypeSymbol)(comp.GetSpecialType(SpecialType.System_Object), comp.GetSpecialType(SpecialType.System_String))
1707Dim type = comp.CreateAnonymousTypeSymbol(ImmutableArray(Of ITypeSymbol).Empty, ImmutableArray(Of String).Empty, memberNullableAnnotations:=ImmutableArray(Of CodeAnalysis.NullableAnnotation).Empty)
1716Dim memberTypes = ImmutableArray.Create(Of ITypeSymbol)(comp.GetSpecialType(SpecialType.System_Object), comp.GetSpecialType(SpecialType.System_String))
1730Private Shared Function GetAnonymousTypeNullableAnnotations(type As ITypeSymbol) As ImmutableArray(Of CodeAnalysis.NullableAnnotation)
1943Dim typeArguments = ImmutableArray.Create(Of ITypeSymbol)(comp.GetSpecialType(SpecialType.System_Object), comp.GetSpecialType(SpecialType.System_String))
1945Assert.Throws(Of ArgumentException)(Function() genericType.Construct(New ImmutableArray(Of ITypeSymbol), New ImmutableArray(Of CodeAnalysis.NullableAnnotation)))
1953Assert.Throws(Of ArgumentException)(Function() genericType.Construct(ImmutableArray.Create(Of ITypeSymbol)(Nothing, Nothing), Nothing))
1961typeArguments = ImmutableArray.Create(Of ITypeSymbol)(comp.GetSpecialType(SpecialType.System_Object), comp.GetSpecialType(SpecialType.System_String))
1975Dim typeArguments = ImmutableArray.Create(Of ITypeSymbol)(comp.GetSpecialType(SpecialType.System_Object), comp.GetSpecialType(SpecialType.System_String))
1977Assert.Throws(Of ArgumentException)(Function() genericMethod.Construct(New ImmutableArray(Of ITypeSymbol), New ImmutableArray(Of CodeAnalysis.NullableAnnotation)))
1985Assert.Throws(Of ArgumentException)(Function() genericMethod.Construct(ImmutableArray.Create(Of ITypeSymbol)(Nothing, Nothing), Nothing))
1993typeArguments = ImmutableArray.Create(Of ITypeSymbol)(comp.GetSpecialType(SpecialType.System_Object), comp.GetSpecialType(SpecialType.System_String))
Microsoft.CodeAnalysis.VisualBasic.Symbol.UnitTests (10)
Microsoft.CodeAnalysis.VisualBasic.Test.Utilities (2)
Microsoft.CodeAnalysis.VisualBasic.Workspaces (83)
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
Microsoft.CodeAnalysis.VisualBasic.Workspaces.UnitTests (2)
Microsoft.CodeAnalysis.Workspaces (477)
Editing\SyntaxGenerator.cs (20)
337private protected abstract SyntaxNode GenerateExpression(ITypeSymbol? type, object? value, bool canUseFieldReference);
1606/// <see langword="true"/> if the language requires a <see cref="TypeExpression(ITypeSymbol)"/>
1608/// <see cref="LocalDeclarationStatement(ITypeSymbol, string, SyntaxNode, bool)"/>.
1631public SyntaxNode LocalDeclarationStatement(ITypeSymbol type, string name, SyntaxNode? initializer = null, bool isConst = false)
1744public SyntaxNode CatchClause(ITypeSymbol type, string identifier, IEnumerable<SyntaxNode> statements)
1785public SyntaxNode DefaultExpression(ITypeSymbol type)
1854public SyntaxNode GenericName(string identifier, IEnumerable<ITypeSymbol> typeArguments)
1866public SyntaxNode GenericName(string identifier, params ITypeSymbol[] typeArguments)
1867=> GenericName(identifier, (IEnumerable<ITypeSymbol>)typeArguments);
1935public SyntaxNode TypeExpression(ITypeSymbol typeSymbol)
1943public SyntaxNode TypeExpression(ITypeSymbol typeSymbol, bool addImport)
1995public SyntaxNode TupleTypeExpression(IEnumerable<ITypeSymbol> elementTypes, IEnumerable<string>? elementNames = null)
2024public SyntaxNode TupleElementExpression(ITypeSymbol type, string? name = null)
2207public SyntaxNode ObjectCreationExpression(ITypeSymbol type, IEnumerable<SyntaxNode> arguments)
2219public SyntaxNode ObjectCreationExpression(ITypeSymbol type, params SyntaxNode[] arguments)
2274public SyntaxNode IsTypeExpression(SyntaxNode expression, ITypeSymbol type)
2285public SyntaxNode TryCastExpression(SyntaxNode expression, ITypeSymbol type)
2297public SyntaxNode CastExpression(ITypeSymbol type, SyntaxNode expression)
2309public SyntaxNode ConvertExpression(ITypeSymbol type, SyntaxNode expression)
2388public 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)
407if (container is not ITypeSymbol containerType)
436static bool MatchesConstraints(ITypeSymbol originalContainerType, ImmutableArray<ITypeSymbol> constraintTypes)
443foreach (var constraintType in constraintTypes)
452static bool MatchesConstraint(ITypeSymbol originalContainerType, ITypeSymbol originalConstraintType)
470foreach (var constraintType in typeParameterContainer.ConstraintTypes)
495foreach (var constrainedType in typeParameterContainer.ConstraintTypes)
520static bool MatchesAnyBaseTypes(ITypeSymbol source, ITypeSymbol matched)
522for (var current = source; current != null; current = current.BaseType)
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\Compiler\Extensions\Symbols\ITypeSymbolExtensions.cs (100)
26public static bool IsIntegralType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
29public static bool IsSignedIntegralType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
32public static bool CanAddNullCheck([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
43public static ImmutableArray<INamedTypeSymbol> GetAllInterfacesIncludingThis(this ITypeSymbol type)
51public static bool IsAbstractClass([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
54public static bool IsSystemVoid([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
57public static bool IsNullable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
60public static bool IsNonNullableValueType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
64[NotNullWhen(true)] this ITypeSymbol? symbol,
65[NotNullWhen(true)] out ITypeSymbol? underlyingType)
77public static bool IsModuleType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
80public static bool IsInterfaceType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
83public static bool IsDelegateType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
86public static bool IsFunctionPointerType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
89public static bool IsStructType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
96this ITypeSymbol type,
110public static IEnumerable<ITypeSymbol> GetBaseTypesAndThis(this ITypeSymbol? type)
112var current = type;
120public static IEnumerable<INamedTypeSymbol> GetBaseTypes(this ITypeSymbol? type)
130public static IEnumerable<ITypeSymbol> GetContainingTypesAndThis(this ITypeSymbol? type)
132var current = type;
140public static IEnumerable<INamedTypeSymbol> GetContainingTypes(this ITypeSymbol type)
153this ITypeSymbol type, ITypeSymbol baseType, bool includeInterfaces)
166this ITypeSymbol type, ITypeSymbol baseType)
174this ITypeSymbol type, ITypeSymbol baseType)
176var originalBaseType = baseType.OriginalDefinition;
184IEnumerable<ITypeSymbol> baseTypes = (baseType.TypeKind == TypeKind.Interface) ? type.AllInterfaces : type.GetBaseTypes();
191this ITypeSymbol type, ITypeSymbol baseType)
193var originalBaseType = baseType.OriginalDefinition;
213this ITypeSymbol type, ITypeSymbol interfaceType)
215var originalInterfaceType = interfaceType.OriginalDefinition;
220this ITypeSymbol type, ITypeSymbol interfaceType)
225public static bool IsAttribute(this ITypeSymbol symbol)
243public static bool IsFormattableStringOrIFormattable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
252this ITypeSymbol typeSymbol, bool allowDelegateAndEnumConstraints = false)
280public static bool IsNumericType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
306public static Accessibility DetermineMinimalAccessibility(this ITypeSymbol typeSymbol)
309public static bool ContainsAnonymousType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
325foreach (var typeArg in type.GetAllTypeArguments())
334public static string CreateParameterName(this ITypeSymbol type, bool capitalize = false)
355private static string GetParameterName(ITypeSymbol? type)
368public static bool IsSpecialType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
399public static bool CanSupportCollectionInitializer(this ITypeSymbol typeSymbol, ISymbol within)
410public static INamedTypeSymbol? GetDelegateType(this ITypeSymbol? typeSymbol, Compilation compilation)
417var typeArgument = ((INamedTypeSymbol)typeSymbol).TypeArguments[0];
430public static IEnumerable<T> GetAccessibleMembersInBaseTypes<T>(this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol
439public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, ISymbol within) where T : class, ISymbol
449public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, string memberName, ISymbol within) where T : class, ISymbol
459public static bool? AreMoreSpecificThan(this IList<ITypeSymbol> t1, IList<ITypeSymbol> t2)
494public static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, ISymbol within) where T : class, ISymbol
504private static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, string memberName, ISymbol within) where T : class, ISymbol
514private static bool? IsMoreSpecificThan(this ITypeSymbol t1, ITypeSymbol t2)
592public static bool IsOrDerivesFromExceptionType([NotNullWhen(returnValue: true)] this ITypeSymbol? type, Compilation compilation)
599foreach (var baseType in type.GetBaseTypesAndThis())
610foreach (var constraint in ((ITypeParameterSymbol)type).ConstraintTypes)
625public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type)
628public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type, [NotNullWhen(true)] out INamedTypeSymbol? enumType)
640public static bool? IsMutableValueType(this ITypeSymbol type)
642if (type.IsNullable(out var underlyingType))
719public static bool IsDisposable([NotNullWhen(returnValue: true)] this ITypeSymbol? type, [NotNullWhen(returnValue: true)] ITypeSymbol? iDisposableType)
724public static ITypeSymbol WithNullableAnnotationFrom(this ITypeSymbol type, ITypeSymbol symbolForNullableAnnotation)
728public static ITypeSymbol? RemoveNullableIfPresent(this ITypeSymbol? symbol)
730if (symbol.IsNullable(out var underlyingType))
738public static bool IsSpanOrReadOnlySpan([NotNullWhen(true)] this ITypeSymbol? type)
741public static bool IsSpan([NotNullWhen(true)] this ITypeSymbol? type)
757public static bool IsInlineArray([NotNullWhen(true)] this ITypeSymbol? type)
762public static ITypeSymbol? RemoveUnavailableTypeParameters(
763this ITypeSymbol? type,
771private static ITypeSymbol? RemoveUnavailableTypeParameters(
772this ITypeSymbol? type,
780public static ITypeSymbol? RemoveAnonymousTypes(
781this ITypeSymbol? type,
788public static ITypeSymbol? RemoveUnnamedErrorTypes(
789this ITypeSymbol? type,
796this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
802this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
808this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result, bool onlyMethodTypeParameters)
817public static IList<ITypeParameterSymbol> GetReferencedTypeParameters(this ITypeSymbol? type)
825public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
826this ITypeSymbol? type,
829where TType1 : ITypeSymbol
830where TType2 : ITypeSymbol
836public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
837this ITypeSymbol? type,
840where TType1 : ITypeSymbol
841where TType2 : ITypeSymbol
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationSymbolFactory.cs (18)
30DeclarationModifiers modifiers, ITypeSymbol type,
47ITypeSymbol type,
79ITypeSymbol type, RefKind refKind, ImmutableArray<IPropertySymbol> explicitInterfaceImplementations, string name,
106ITypeSymbol type, string name,
152ITypeSymbol? returnType,
174ITypeSymbol? returnType,
195ITypeSymbol returnType,
220ITypeSymbol toType,
248ITypeSymbol toType,
264public static IParameterSymbol CreateParameterSymbol(ITypeSymbol type, string name)
267public static IParameterSymbol CreateParameterSymbol(RefKind refKind, ITypeSymbol type, string name)
277ImmutableArray<AttributeData> attributes, RefKind refKind, bool isParams, ITypeSymbol type, string name, bool isOptional = false, bool hasDefaultValue = false, object? defaultValue = null)
290ITypeSymbol? type = null,
331ImmutableArray<ITypeSymbol> constraintTypes,
347public static IPointerTypeSymbol CreatePointerTypeSymbol(ITypeSymbol pointedAtType)
353public static IArrayTypeSymbol CreateArrayTypeSymbol(ITypeSymbol elementType, int rank = 1, NullableAnnotation nullableAnnotation = NullableAnnotation.None)
463ITypeSymbol returnType,
520ITypeSymbol? 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)
15ITypeSymbol toType,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationOperatorSymbol.cs (1)
15ITypeSymbol returnType,
Microsoft.CodeAnalysis.Workspaces.UnitTests (6)
Microsoft.Extensions.Logging.Generators (4)
Microsoft.Extensions.Options.SourceGeneration (43)
Parser.cs (35)
29private readonly Dictionary<ITypeSymbol, ValidatorType> _synthesizedValidators = new(SymbolEqualityComparer.Default);
30private readonly HashSet<ITypeSymbol> _visitedModelTypes = new(SymbolEqualityComparer.Default);
59var validatorType = sm.GetDeclaredSymbol(syntax) as ITypeSymbol;
80foreach (var modelType in modelTypes)
167private static string GetTypeKeyword(ITypeSymbol type)
210private static bool HasOpenGenerics(ITypeSymbol type, out string genericType)
216foreach (var ta in mt.TypeArguments)
240private ITypeSymbol? GetEnumeratedType(ITypeSymbol type)
266private List<ValidatedMember> GetMembersToValidate(ITypeSymbol modelType, bool speculate, Location lowerLocationInCompilation, ITypeSymbol validatorType)
316private ValidatedMember? GetMemberInfo(ISymbol member, bool speculate, Location location, ITypeSymbol modelType, ITypeSymbol validatorType)
318ITypeSymbol memberType;
410var enumeratedType = GetEnumeratedType(memberType);
565var enumeratedType = GetEnumeratedType(memberType);
598private bool LengthBasedAttributeIsTrackedForSubstitution(ITypeSymbol memberType, Location location, ITypeSymbol attributeType, ref string attributeFullQualifiedName)
619private void TrackCompareAttributeForSubstitution(AttributeData attribute, ITypeSymbol modelType, ref string attributeFullQualifiedName)
630private void TrackRangeAttributeForSubstitution(AttributeData attribute, ITypeSymbol memberType, ref string attributeFullQualifiedName)
633ITypeSymbol? argumentType = null;
636ITypeSymbol typeSymbol = memberType;
684private string? AddSynthesizedValidator(ITypeSymbol modelType, ISymbol member, Location location, ITypeSymbol validatorType)
686var mt = modelType.WithNullableAnnotation(NullableAnnotation.None);
728private bool ConvertTo(ITypeSymbol source, ITypeSymbol dest)
734private bool ModelSelfValidates(ITypeSymbol modelType)
747private List<ITypeSymbol> GetModelTypes(ITypeSymbol validatorType)
749var result = new List<ITypeSymbol>();
761private bool CanValidate(ITypeSymbol validatorType, ISymbol modelType)
767var t = implementingInterface.TypeArguments.First();
804private string GetArgumentExpression(ITypeSymbol type, object? value)
Microsoft.Extensions.Validation.ValidationsGenerator (44)
src\Shared\RoslynUtils\ParsabilityHelper.cs (12)
20private static readonly BoundedCacheWithFactory<ITypeSymbol, (BindabilityMethod?, IMethodSymbol?)> BindabilityCache = new();
21private static readonly BoundedCacheWithFactory<ITypeSymbol, (Parsability, ParsabilityMethod?)> ParsabilityCache = new();
23private static bool IsTypeAlwaysParsable(ITypeSymbol typeSymbol, WellKnownTypes wellKnownTypes, [NotNullWhen(true)] out ParsabilityMethod? parsabilityMethod)
50internal static Parsability GetParsability(ITypeSymbol typeSymbol, WellKnownTypes wellKnownTypes)
55internal static Parsability GetParsability(ITypeSymbol typeSymbol, WellKnownTypes wellKnownTypes, [NotNullWhen(false)] out ParsabilityMethod? parsabilityMethod)
115internal static bool IsParsableViaIParsable(ITypeSymbol typeSymbol, WellKnownTypes wellKnownTypes)
124private static bool IsBindableViaIBindableFromHttpContext(ITypeSymbol typeSymbol, WellKnownTypes wellKnownTypes)
134private static bool IsBindAsync(IMethodSymbol methodSymbol, ITypeSymbol typeSymbol, WellKnownTypes wellKnownTypes)
145private static bool IsBindAsyncWithParameter(IMethodSymbol methodSymbol, ITypeSymbol typeSymbol, WellKnownTypes wellKnownTypes)
156private static bool IsReturningValueTaskOfTOrNullableT(INamedTypeSymbol returnType, ITypeSymbol containingType, WellKnownTypes wellKnownTypes)
162internal static Bindability GetBindability(ITypeSymbol typeSymbol, WellKnownTypes wellKnownTypes, out BindabilityMethod? bindabilityMethod, out IMethodSymbol? bindMethodSymbol)
180foreach (var candidate in searchCandidates)
Microsoft.Gen.ComplianceReports (6)
Microsoft.Gen.Logging (44)
Microsoft.Gen.Logging.Unit.Tests (5)
Microsoft.Gen.MetadataExtractor (21)
Microsoft.Gen.Metrics (15)
Microsoft.Gen.MetricsReports (15)
Microsoft.Interop.ComInterfaceGenerator (18)
Analyzers\RuntimeComApiUsageWithSourceGeneratedComAnalyzer.cs (9)
34List<Func<ITypeSymbol, bool>> sourceGeneratedComRecognizers = new();
53var methodsOfInterest = new Dictionary<ISymbol, ImmutableArray<Func<IInvocationOperation, (ITypeSymbol, Location)?>>>(SymbolEqualityComparer.Default);
108if (methodsOfInterest.TryGetValue(operation.TargetMethod.OriginalDefinition, out ImmutableArray<Func<IInvocationOperation, (ITypeSymbol, Location)?>> discoverers))
110foreach (Func<IInvocationOperation, (ITypeSymbol, Location)?> discoverer in discoverers)
113if (typeInfo is (ITypeSymbol targetType, Location diagnosticLocation))
200static Func<IInvocationOperation, (ITypeSymbol Type, Location location)?> CreateArgumentTypeLookup(int ordinal) => invocation => invocation.GetArgumentByOrdinal(ordinal).Value switch
206static Func<IInvocationOperation, (ITypeSymbol Type, Location location)?> CreateTypeArgumentTypeLookup(int ordinal) => invocation =>
208var type = invocation.TargetMethod.TypeArguments[ordinal];
235static Func<IInvocationOperation, (ITypeSymbol Type, Location location)?> CreateTypeOfArgumentTypeLookup(int ordinal) => invocation => invocation.GetArgumentByOrdinal(ordinal).Value switch
Microsoft.Interop.JavaScript.JSImportGenerator (10)
Microsoft.Interop.LibraryImportGenerator (44)
Analyzers\CustomMarshallerAttributeAnalyzer.cs (19)
659ITypeSymbol managedTypeInAttribute = managedTypeOfOp.TypeOperand;
665(entryType, managedType) => managedTypeReporter.CreateAndReportDiagnostic(ManagedTypeMustBeClosedOrMatchArityRule, managedType, entryType), out ITypeSymbol managedType))
679ITypeSymbol? marshallerTypeInAttribute = marshallerTypeOfOp.TypeOperand;
684out ITypeSymbol marshallerType))
708private void AnalyzeMarshallerType(DiagnosticReporter diagnosticReporter, ITypeSymbol managedType, MarshalMode mode, INamedTypeSymbol marshallerType, bool isLinearCollectionMarshaller)
724private void AnalyzeStatelessMarshallerType(DiagnosticReporter diagnosticReporter, ITypeSymbol managedType, MarshalMode mode, INamedTypeSymbol marshallerType, bool isLinearCollectionMarshaller)
881ITypeSymbol? unmanagedType = null;
947if (TryGetElementTypeFromSpanType(methods.ManagedValuesSource.ReturnType, out ITypeSymbol sourceElementType)
948&& TryGetElementTypeFromSpanType(methods.ManagedValuesDestination.ReturnType, out ITypeSymbol destinationElementType)
956ITypeSymbol expectedUnmanagedCollectionElementType = typeArguments[typeArguments.Length - 1];
963private void VerifyUnmanagedCollectionElementType(DiagnosticReporter diagnosticReporter, IMethodSymbol? unmanagedValuesCollectionMethod, ITypeSymbol expectedElementType, INamedTypeSymbol expectedSpanType)
966&& TryGetElementTypeFromSpanType(unmanagedValuesCollectionMethod.ReturnType, out ITypeSymbol sourceElementType)
996private bool TryGetElementTypeFromSpanType(ITypeSymbol spanTypeMaybe, [NotNullWhen(true)] out ITypeSymbol? elementType)
1008private void AnalyzeStatefulMarshallerType(DiagnosticReporter diagnosticReporter, ITypeSymbol managedType, MarshalMode mode, INamedTypeSymbol marshallerType, bool isLinearCollectionMarshaller)
1198ITypeSymbol? unmanagedType = null;
1235if (TryGetElementTypeFromSpanType(methods.ManagedValuesSource.ReturnType, out ITypeSymbol sourceElementType)
1236&& TryGetElementTypeFromSpanType(methods.ManagedValuesDestination.ReturnType, out ITypeSymbol destinationElementType)
1244ITypeSymbol expectedUnmanagedCollectionElementType = typeArguments[typeArguments.Length - 1];
Analyzers\CustomMarshallerAttributeFixer.cs (15)
32Dictionary<(INamedTypeSymbol marshallerType, ITypeSymbol managedType, bool isLinearCollectionMarshaller), HashSet<string>> uniqueMarshallersToFix = new();
40ITypeSymbol? managedType = GetManagedTypeInAttributeSyntax(diagnostic.Location, entryPointTypeSymbol);
161var managedTypeSymbolInAttribute = GetManagedTypeInAttributeSyntax(node.GetLocation(), entryPointTypeSymbol);
167ManualTypeMarshallingHelper.TryResolveManagedType(entryPointTypeSymbol, ManualTypeMarshallingHelper.ReplaceGenericPlaceholderInType(managedTypeSymbolInAttribute, entryPointTypeSymbol, model.Compilation), isLinearCollectionMarshaller, IgnoreArityMismatch, out ITypeSymbol managedType);
181private static ITypeSymbol GetManagedTypeInAttributeSyntax(Location locationInAttribute, INamedTypeSymbol attributedTypeSymbol)
182=> (ITypeSymbol)attributedTypeSymbol.GetAttributes().First(attr =>
190ITypeSymbol managedType,
204private static void AddMissingMembersToStatelessMarshaller(DocumentEditor editor, SyntaxNode declaringSyntax, INamedTypeSymbol marshallerType, ITypeSymbol managedType, HashSet<string> missingMemberNames, bool isLinearCollectionMarshaller)
215Lazy<ITypeSymbol> managedElementTypeSymbol = new(CreateManagedElementTypeSymbol, isThreadSafe: false);
352ITypeSymbol? unmanagedType = null;
385ITypeSymbol CreateManagedElementTypeSymbol()
400private static void AddMissingMembersToStatefulMarshaller(DocumentEditor editor, SyntaxNode declaringSyntax, INamedTypeSymbol marshallerType, ITypeSymbol managedType, HashSet<string> missingMemberNames, bool isLinearCollectionMarshaller)
411Lazy<ITypeSymbol> managedElementTypeSymbol = new(CreateManagedElementTypeSymbol, isThreadSafe: false);
527ITypeSymbol? unmanagedType = null;
552ITypeSymbol CreateManagedElementTypeSymbol()
Microsoft.Interop.LibraryImportGenerator.Downlevel (2)
Microsoft.Interop.SourceGeneration (177)
ManualTypeMarshallingHelper.cs (41)
89public static bool HasEntryPointMarshallerAttribute(ITypeSymbol entryPointType)
96ITypeSymbol managedType,
105ITypeSymbol managedType,
115ITypeSymbol managedType,
117Func<ITypeSymbol, MarshallingInfo> getMarshallingInfo,
125ITypeSymbol managedType,
127Func<ITypeSymbol, MarshallingInfo> getMarshallingInfo,
136ITypeSymbol managedType,
147ITypeSymbol managedType,
150Func<ITypeSymbol, MarshallingInfo> getMarshallingInfoForElement,
182ITypeSymbol? managedTypeOnAttr = attr.ConstructorArguments[0].Value as ITypeSymbol;
191if (!TryResolveManagedType(entryPointType, ReplaceGenericPlaceholderInType(managedTypeOnAttr, entryPointType, compilation), isLinearCollectionMarshalling, onArityMismatch, out ITypeSymbol managedTypeInst))
206ITypeSymbol? marshallerTypeOnAttr = attr.ConstructorArguments[2].Value as ITypeSymbol;
210ITypeSymbol marshallerType = marshallerTypeOnAttr;
241public static bool TryResolveEntryPointType(INamedTypeSymbol managedType, ITypeSymbol typeInAttribute, bool isLinearCollectionMarshalling, Action<INamedTypeSymbol, INamedTypeSymbol> onArityMismatch, [NotNullWhen(true)] out ITypeSymbol? entryPoint)
283public static bool TryResolveManagedType(INamedTypeSymbol entryPointType, ITypeSymbol typeInAttribute, bool isLinearCollectionMarshalling, Action<INamedTypeSymbol, INamedTypeSymbol> onArityMismatch, [NotNullWhen(true)] out ITypeSymbol? managed)
326public static bool TryResolveMarshallerType(INamedTypeSymbol entryPointType, ITypeSymbol typeInAttribute, Action<INamedTypeSymbol, INamedTypeSymbol> onArityMismatch, [NotNullWhen(true)] out ITypeSymbol? marshallerType)
356public static ITypeSymbol ReplaceGenericPlaceholderInType(ITypeSymbol managedType, INamedTypeSymbol entryType, Compilation compilation)
362Stack<ITypeSymbol> typeStack = new();
363ITypeSymbol innerType = managedType;
383ITypeSymbol resultType = entryType.TypeArguments[0];
387ITypeSymbol wrapperType = typeStack.Pop();
405ITypeSymbol marshallerType,
407ITypeSymbol managedType,
410Func<ITypeSymbol, MarshallingInfo> getMarshallingInfo)
453private static CustomTypeMarshallerData? GetStatelessMarshallerDataForType(ITypeSymbol marshallerType, MarshalMode mode, ITypeSymbol managedType, bool isLinearCollectionMarshaller, Compilation compilation, Func<ITypeSymbol, MarshallingInfo>? getMarshallingInfo)
457ITypeSymbol? collectionElementType = null;
458ITypeSymbol? nativeType = null;
548ITypeSymbol marshallerType,
550ITypeSymbol managedType,
553Func<ITypeSymbol, MarshallingInfo>? getMarshallingInfo)
557ITypeSymbol? nativeType = null;
558ITypeSymbol? collectionElementType = null;
MarshallerShape.cs (66)
111public static (MarshallerShape, MarshallerMethods) GetShapeForType(ITypeSymbol marshallerType, ITypeSymbol managedType, bool isLinearCollectionMarshaller, Compilation compilation)
204private static IMethodSymbol? GetStatelessFree(ITypeSymbol type)
212private static IMethodSymbol? GetStatelessGetPinnableReference(ITypeSymbol type, ITypeSymbol managedType)
224internal static bool IsSpanOfUnmanagedType(ITypeSymbol typeToCheck, ITypeSymbol spanOfT, ITypeSymbol containingType)
231ITypeSymbol typeArgument = namedType.TypeArguments[0];
257internal static IMethodSymbol? ConvertToUnmanaged(ITypeSymbol type, ITypeSymbol managedType)
267ITypeSymbol type,
268ITypeSymbol managedType,
269ITypeSymbol spanOfT)
288internal static IMethodSymbol? ConvertToManaged(ITypeSymbol type, ITypeSymbol managedType)
297internal static IMethodSymbol? ConvertToManagedFinally(ITypeSymbol type, ITypeSymbol managedType)
309internal static IMethodSymbol? AllocateContainerForUnmanagedElements(ITypeSymbol type, ITypeSymbol managedType)
320internal static IMethodSymbol? AllocateContainerForUnmanagedElementsWithCallerAllocatedBuffer(ITypeSymbol type, ITypeSymbol managedType, ITypeSymbol spanOfT)
341internal static IMethodSymbol? GetManagedValuesSource(ITypeSymbol type, ITypeSymbol managedType, ITypeSymbol readOnlySpanOfT)
351internal static IMethodSymbol? GetUnmanagedValuesDestination(ITypeSymbol type, ITypeSymbol spanOfT)
361internal static IMethodSymbol? AllocateContainerForManagedElements(ITypeSymbol type, ITypeSymbol managedType)
371internal static IMethodSymbol? AllocateContainerForManagedElementsFinally(ITypeSymbol type, ITypeSymbol managedType)
381internal static IMethodSymbol? GetManagedValuesDestination(ITypeSymbol type, ITypeSymbol managedType, ITypeSymbol spanOfT)
391internal static IMethodSymbol? GetUnmanagedValuesSource(ITypeSymbol type, ITypeSymbol readOnlySpanOfT)
446public static (MarshallerShape shape, MarshallerMethods methods) GetShapeForType(ITypeSymbol marshallerType, ITypeSymbol managedType, bool isLinearCollectionMarshaller, Compilation compilation)
451ITypeSymbol? unmanagedType = null;
561private static IMethodSymbol? GetFromManagedMethod(ITypeSymbol type, ITypeSymbol managedType)
570ITypeSymbol type,
571ITypeSymbol managedType,
572ITypeSymbol spanOfT)
590private static IMethodSymbol? GetToManagedMethod(ITypeSymbol type, ITypeSymbol managedType)
598private static IMethodSymbol? GetToManagedFinallyMethod(ITypeSymbol type, ITypeSymbol managedType)
606private static IMethodSymbol? GetToUnmanagedMethod(ITypeSymbol type)
613public static ImmutableArray<IMethodSymbol> GetFromUnmanagedMethodCandidates(ITypeSymbol type)
621private static IMethodSymbol? GetFromUnmanagedMethod(ITypeSymbol type, ITypeSymbol? unmanagedType)
652private static IMethodSymbol? GetStatefulFreeMethod(ITypeSymbol type)
659private static IMethodSymbol? GetOnInvokedMethod(ITypeSymbol type)
666private static IMethodSymbol? GetStatelessGetPinnableReference(ITypeSymbol type, ITypeSymbol managedType)
675private static IMethodSymbol? GetStatefulGetPinnableReference(ITypeSymbol type)
685internal static IMethodSymbol? GetManagedValuesSource(ITypeSymbol type, ITypeSymbol readOnlySpanOfT)
694internal static IMethodSymbol? GetUnmanagedValuesDestination(ITypeSymbol type, ITypeSymbol spanOfT)
703internal static IMethodSymbol? GetManagedValuesDestination(ITypeSymbol type, ITypeSymbol spanOfT)
713internal static IMethodSymbol? GetUnmanagedValuesSource(ITypeSymbol type, ITypeSymbol readOnlySpanOfT)
MarshallingInfoParser.cs (8)
27public delegate MarshallingInfo GetMarshallingInfoCallback(ITypeSymbol type, UseSiteAttributeProvider useSiteAttributes, int indirectionDepth);
72MarshallingInfo? ParseAttribute(AttributeData attributeData, ITypeSymbol type, int indirectionDepth, UseSiteAttributeProvider useSiteAttributes, GetMarshallingInfoCallback marshallingInfoCallback);
85bool CanProvideMarshallingInfoForType(ITypeSymbol type);
94MarshallingInfo GetMarshallingInfo(ITypeSymbol type, int indirectionDepth, UseSiteAttributeProvider useSiteAttributes, GetMarshallingInfoCallback marshallingInfoCallback);
213ITypeSymbol managedType,
228ITypeSymbol type,
255private MarshallingInfo? GetMarshallingInfoForAttribute(AttributeData attribute, ITypeSymbol type, int indirectionDepth, UseSiteAttributeProvider useSiteAttributes, GetMarshallingInfoCallback marshallingInfoCallback)
269private MarshallingInfo? GetMarshallingInfoForType(ITypeSymbol type, int indirectionDepth, UseSiteAttributeProvider useSiteAttributes, GetMarshallingInfoCallback marshallingInfoCallback)
TypeSymbolExtensions.cs (26)
29public static bool IsConsideredBlittable(this ITypeSymbol type)
34return IsBlittableWorker(type, ImmutableHashSet.Create<ITypeSymbol>(SymbolEqualityComparer.Default), compilation: null!, &IsConsideredBlittableWorker);
37static bool IsConsideredBlittableWorker(ITypeSymbol t, ImmutableHashSet<ITypeSymbol> seenTypes, Compilation compilation)
55public static bool IsStrictlyBlittableInContext(this ITypeSymbol type, Compilation compilation)
59return IsBlittableWorker(type, ImmutableHashSet.Create<ITypeSymbol>(SymbolEqualityComparer.Default), compilation, &IsStrictlyBlittableWorker);
62static unsafe bool IsStrictlyBlittableWorker(ITypeSymbol t, ImmutableHashSet<ITypeSymbol> seenTypes, Compilation compilation)
100private static unsafe bool IsBlittableWorker(this ITypeSymbol type, ImmutableHashSet<ITypeSymbol> seenTypes, Compilation compilation, delegate*<ITypeSymbol, ImmutableHashSet<ITypeSymbol>, Compilation, bool> isBlittable)
135private static bool IsAutoLayout(this ITypeSymbol type)
147private static unsafe bool HasOnlyBlittableFields(this ITypeSymbol type, ImmutableHashSet<ITypeSymbol> seenTypes, Compilation compilation, delegate*<ITypeSymbol, ImmutableHashSet<ITypeSymbol>, Compilation, bool> isBlittable)
170public static TypeSyntax AsTypeSyntax(this ITypeSymbol type)
206public static bool IsConstructedFromEqualTypes(this ITypeSymbol type, ITypeSymbol other)
275var arguments = new ITypeSymbol[numArgumentsToInsert];
291currentType.TypeParameters.CastArray<ITypeSymbol>().CopyTo(currentType.TypeParameters.Length - numArgumentsToPropogate, arguments, numArgumentsToCopy, numArgumentsToPropogate);
305public static (ImmutableArray<ITypeSymbol> TypeArguments, ImmutableArray<NullableAnnotation> TypeArgumentNullableAnnotations) GetAllTypeArgumentsIncludingInContainingTypes(this INamedTypeSymbol genericType)
309Stack<(ImmutableArray<ITypeSymbol>, ImmutableArray<NullableAnnotation>)> genericTypesToSubstitute = new();
316ImmutableArray<ITypeSymbol>.Builder typeArguments = ImmutableArray.CreateBuilder<ITypeSymbol>();
Microsoft.Maui.Controls.BindingSourceGen (24)
Microsoft.ML.InternalCodeAnalyzer (1)
Microsoft.VisualStudio.LanguageServices (11)
Microsoft.VisualStudio.LanguageServices.CSharp (20)
CodeModel\CSharpCodeModelService.cs (16)
676var typeSymbol = GetTypeSymbolFromFullName(typeName, compilation);
693public override EnvDTE.vsCMTypeRef GetTypeKindForCodeTypeRef(ITypeSymbol typeSymbol)
766public override string GetAsFullNameForCodeTypeRef(ITypeSymbol typeSymbol)
769public override string GetAsStringForCodeTypeRef(ITypeSymbol typeSymbol)
2715public override SyntaxNode SetType(SyntaxNode node, ITypeSymbol? typeSymbol)
3013protected override ITypeSymbol? GetTypeSymbolFromPartialName(string partialName, SemanticModel semanticModel, int position)
3020public override ITypeSymbol? GetTypeSymbolFromFullName(string fullName, Compilation compilation)
3022ITypeSymbol? typeSymbol = compilation.GetTypeByMetadataName(fullName);
3063public override SyntaxNode CreateReturnDefaultValueStatement(ITypeSymbol type)
3689private static TypeDeclarationSyntax InsertIntoBaseList(TypeDeclarationSyntax typeDeclaration, ITypeSymbol typeSymbol, SemanticModel semanticModel, int insertionIndex)
3707public override bool IsValidBaseType(SyntaxNode node, ITypeSymbol typeSymbol)
3721public override SyntaxNode AddBase(SyntaxNode node, ITypeSymbol typeSymbol, SemanticModel semanticModel, int? position)
3754public override SyntaxNode RemoveBase(SyntaxNode node, ITypeSymbol typeSymbol, SemanticModel semanticModel)
3804public override bool IsValidInterfaceType(SyntaxNode node, ITypeSymbol typeSymbol)
3814public override SyntaxNode AddImplementedInterface(SyntaxNode node, ITypeSymbol typeSymbol, SemanticModel semanticModel, int? position)
3849public override SyntaxNode RemoveImplementedInterface(SyntaxNode node, ITypeSymbol typeSymbol, SemanticModel semanticModel)
Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests (4)
Microsoft.VisualStudio.LanguageServices.VisualBasic (32)
CodeModel\VisualBasicCodeModelService.vb (24)
750Public Overrides Function GetTypeKindForCodeTypeRef(typeSymbol As ITypeSymbol) As EnvDTE.vsCMTypeRef
819Public Overrides Function GetAsFullNameForCodeTypeRef(typeSymbol As ITypeSymbol) As String
823Public Overrides Function GetAsStringForCodeTypeRef(typeSymbol As ITypeSymbol) As String
2973Private Shared Function SetDelegateType(delegateStatement As DelegateStatementSyntax, typeSymbol As ITypeSymbol) As DelegateStatementSyntax
3023Private Shared Function SetEventType(eventStatement As EventStatementSyntax, typeSymbol As ITypeSymbol) As EventStatementSyntax
3056Private Shared Function SetEventType(eventBlock As EventBlockSyntax, typeSymbol As ITypeSymbol) As EventBlockSyntax
3137Private Shared Function SetMethodType(declareStatement As DeclareStatementSyntax, typeSymbol As ITypeSymbol) As DeclareStatementSyntax
3193Private Shared Function SetMethodType(methodStatement As MethodStatementSyntax, typeSymbol As ITypeSymbol) As MethodStatementSyntax
3247Private Shared Function SetMethodType(methodBlock As MethodBlockSyntax, typeSymbol As ITypeSymbol) As MethodBlockSyntax
3276Private Shared Function SetParameterType(parameter As ParameterSyntax, typeSymbol As ITypeSymbol) As ParameterSyntax
3305Private Shared Function SetPropertyType(propertyStatement As PropertyStatementSyntax, typeSymbol As ITypeSymbol) As PropertyStatementSyntax
3334Private Shared Function SetPropertyType(propertyBlock As PropertyBlockSyntax, typeSymbol As ITypeSymbol) As PropertyBlockSyntax
3388Private Shared Function SetVariableType(variableDeclarator As VariableDeclaratorSyntax, typeSymbol As ITypeSymbol) As VariableDeclaratorSyntax
3417Public Overrides Function SetType(node As SyntaxNode, typeSymbol As ITypeSymbol) As SyntaxNode
3627Public Overrides Function GetTypeSymbolFromFullName(fullName As String, compilation As Compilation) As ITypeSymbol
3628Dim typeSymbol As ITypeSymbol = compilation.GetTypeByMetadataName(fullName)
3671Protected Overrides Function GetTypeSymbolFromPartialName(partialName As String, semanticModel As SemanticModel, position As Integer) As ITypeSymbol
3677Public Overrides Function CreateReturnDefaultValueStatement(type As ITypeSymbol) As SyntaxNode
4245Public Overrides Function IsValidBaseType(node As SyntaxNode, typeSymbol As ITypeSymbol) As Boolean
4255Public Overrides Function AddBase(node As SyntaxNode, typeSymbol As ITypeSymbol, semanticModel As SemanticModel, position As Integer?) As SyntaxNode
4281Public Overrides Function RemoveBase(node As SyntaxNode, typeSymbol As ITypeSymbol, semanticModel As SemanticModel) As SyntaxNode
4313Public Overrides Function IsValidInterfaceType(node As SyntaxNode, typeSymbol As ITypeSymbol) As Boolean
4321Public Overrides Function AddImplementedInterface(node As SyntaxNode, typeSymbol As ITypeSymbol, semanticModel As SemanticModel, position As Integer?) As SyntaxNode
4353Public Overrides Function RemoveImplementedInterface(node As SyntaxNode, typeSymbol As ITypeSymbol, semanticModel As SemanticModel) As SyntaxNode
Mvc.Api.Analyzers.Test (4)
Roslyn.Diagnostics.Analyzers (455)
DefaultableTypeShouldHaveDefaultableFieldsAnalyzer.cs (6)
50var knownNonDefaultableTypes = new ConcurrentDictionary<ITypeSymbol, bool>();
56private static void AnalyzeField(SymbolAnalysisContext context, INamedTypeSymbol nonDefaultableAttribute, ConcurrentDictionary<ITypeSymbol, bool> knownNonDefaultableTypes)
61private static void AnalyzeNamedType(SymbolAnalysisContext context, INamedTypeSymbol nonDefaultableAttribute, ConcurrentDictionary<ITypeSymbol, bool> knownNonDefaultableTypes)
76private static void AnalyzeField(SymbolAnalysisContext originalContext, IFieldSymbol field, INamedTypeSymbol nonDefaultableAttribute, ConcurrentDictionary<ITypeSymbol, bool> knownNonDefaultableTypes)
110private static bool IsDefaultable(ITypeSymbol type, INamedTypeSymbol nonDefaultableAttribute, ConcurrentDictionary<ITypeSymbol, bool> knownNonDefaultableTypes)
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\Compiler\Extensions\Symbols\ITypeSymbolExtensions.cs (100)
26public static bool IsIntegralType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
29public static bool IsSignedIntegralType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
32public static bool CanAddNullCheck([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
43public static ImmutableArray<INamedTypeSymbol> GetAllInterfacesIncludingThis(this ITypeSymbol type)
51public static bool IsAbstractClass([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
54public static bool IsSystemVoid([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
57public static bool IsNullable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
60public static bool IsNonNullableValueType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
64[NotNullWhen(true)] this ITypeSymbol? symbol,
65[NotNullWhen(true)] out ITypeSymbol? underlyingType)
77public static bool IsModuleType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
80public static bool IsInterfaceType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
83public static bool IsDelegateType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
86public static bool IsFunctionPointerType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
89public static bool IsStructType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
96this ITypeSymbol type,
110public static IEnumerable<ITypeSymbol> GetBaseTypesAndThis(this ITypeSymbol? type)
112var current = type;
120public static IEnumerable<INamedTypeSymbol> GetBaseTypes(this ITypeSymbol? type)
130public static IEnumerable<ITypeSymbol> GetContainingTypesAndThis(this ITypeSymbol? type)
132var current = type;
140public static IEnumerable<INamedTypeSymbol> GetContainingTypes(this ITypeSymbol type)
153this ITypeSymbol type, ITypeSymbol baseType, bool includeInterfaces)
166this ITypeSymbol type, ITypeSymbol baseType)
174this ITypeSymbol type, ITypeSymbol baseType)
176var originalBaseType = baseType.OriginalDefinition;
184IEnumerable<ITypeSymbol> baseTypes = (baseType.TypeKind == TypeKind.Interface) ? type.AllInterfaces : type.GetBaseTypes();
191this ITypeSymbol type, ITypeSymbol baseType)
193var originalBaseType = baseType.OriginalDefinition;
213this ITypeSymbol type, ITypeSymbol interfaceType)
215var originalInterfaceType = interfaceType.OriginalDefinition;
220this ITypeSymbol type, ITypeSymbol interfaceType)
225public static bool IsAttribute(this ITypeSymbol symbol)
243public static bool IsFormattableStringOrIFormattable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
252this ITypeSymbol typeSymbol, bool allowDelegateAndEnumConstraints = false)
280public static bool IsNumericType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
306public static Accessibility DetermineMinimalAccessibility(this ITypeSymbol typeSymbol)
309public static bool ContainsAnonymousType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
325foreach (var typeArg in type.GetAllTypeArguments())
334public static string CreateParameterName(this ITypeSymbol type, bool capitalize = false)
355private static string GetParameterName(ITypeSymbol? type)
368public static bool IsSpecialType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
399public static bool CanSupportCollectionInitializer(this ITypeSymbol typeSymbol, ISymbol within)
410public static INamedTypeSymbol? GetDelegateType(this ITypeSymbol? typeSymbol, Compilation compilation)
417var typeArgument = ((INamedTypeSymbol)typeSymbol).TypeArguments[0];
430public static IEnumerable<T> GetAccessibleMembersInBaseTypes<T>(this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol
439public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, ISymbol within) where T : class, ISymbol
449public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, string memberName, ISymbol within) where T : class, ISymbol
459public static bool? AreMoreSpecificThan(this IList<ITypeSymbol> t1, IList<ITypeSymbol> t2)
494public static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, ISymbol within) where T : class, ISymbol
504private static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, string memberName, ISymbol within) where T : class, ISymbol
514private static bool? IsMoreSpecificThan(this ITypeSymbol t1, ITypeSymbol t2)
592public static bool IsOrDerivesFromExceptionType([NotNullWhen(returnValue: true)] this ITypeSymbol? type, Compilation compilation)
599foreach (var baseType in type.GetBaseTypesAndThis())
610foreach (var constraint in ((ITypeParameterSymbol)type).ConstraintTypes)
625public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type)
628public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type, [NotNullWhen(true)] out INamedTypeSymbol? enumType)
640public static bool? IsMutableValueType(this ITypeSymbol type)
642if (type.IsNullable(out var underlyingType))
719public static bool IsDisposable([NotNullWhen(returnValue: true)] this ITypeSymbol? type, [NotNullWhen(returnValue: true)] ITypeSymbol? iDisposableType)
724public static ITypeSymbol WithNullableAnnotationFrom(this ITypeSymbol type, ITypeSymbol symbolForNullableAnnotation)
728public static ITypeSymbol? RemoveNullableIfPresent(this ITypeSymbol? symbol)
730if (symbol.IsNullable(out var underlyingType))
738public static bool IsSpanOrReadOnlySpan([NotNullWhen(true)] this ITypeSymbol? type)
741public static bool IsSpan([NotNullWhen(true)] this ITypeSymbol? type)
757public static bool IsInlineArray([NotNullWhen(true)] this ITypeSymbol? type)
762public static ITypeSymbol? RemoveUnavailableTypeParameters(
763this ITypeSymbol? type,
771private static ITypeSymbol? RemoveUnavailableTypeParameters(
772this ITypeSymbol? type,
780public static ITypeSymbol? RemoveAnonymousTypes(
781this ITypeSymbol? type,
788public static ITypeSymbol? RemoveUnnamedErrorTypes(
789this ITypeSymbol? type,
796this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
802this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
808this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result, bool onlyMethodTypeParameters)
817public static IList<ITypeParameterSymbol> GetReferencedTypeParameters(this ITypeSymbol? type)
825public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
826this ITypeSymbol? type,
829where TType1 : ITypeSymbol
830where TType2 : ITypeSymbol
836public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
837this ITypeSymbol? type,
840where TType1 : ITypeSymbol
841where TType2 : ITypeSymbol
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationSymbolFactory.cs (18)
30DeclarationModifiers modifiers, ITypeSymbol type,
47ITypeSymbol type,
79ITypeSymbol type, RefKind refKind, ImmutableArray<IPropertySymbol> explicitInterfaceImplementations, string name,
106ITypeSymbol type, string name,
152ITypeSymbol? returnType,
174ITypeSymbol? returnType,
195ITypeSymbol returnType,
220ITypeSymbol toType,
248ITypeSymbol toType,
264public static IParameterSymbol CreateParameterSymbol(ITypeSymbol type, string name)
267public static IParameterSymbol CreateParameterSymbol(RefKind refKind, ITypeSymbol type, string name)
277ImmutableArray<AttributeData> attributes, RefKind refKind, bool isParams, ITypeSymbol type, string name, bool isOptional = false, bool hasDefaultValue = false, object? defaultValue = null)
290ITypeSymbol? type = null,
331ImmutableArray<ITypeSymbol> constraintTypes,
347public static IPointerTypeSymbol CreatePointerTypeSymbol(ITypeSymbol pointedAtType)
353public static IArrayTypeSymbol CreateArrayTypeSymbol(ITypeSymbol elementType, int rank = 1, NullableAnnotation nullableAnnotation = NullableAnnotation.None)
463ITypeSymbol returnType,
520ITypeSymbol? 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)
15ITypeSymbol toType,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationOperatorSymbol.cs (1)
15ITypeSymbol returnType,
Roslyn.Diagnostics.CSharp.Analyzers (168)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\ExpressionSyntaxExtensions.cs (24)
906public static ITypeSymbol? GetTargetType(
936bool HasType(ExpressionSyntax expression, [NotNullWhen(true)] out ITypeSymbol? type)
942ITypeSymbol? GetTargetTypeForArgument(ArgumentSyntax argument)
946var tupleType = tupleExpression.GetTargetType(semanticModel, cancellationToken);
961ITypeSymbol? GetTargetTypeForAttributeArgument(AttributeArgumentSyntax argument)
964ITypeSymbol? GetTargetTypeForArrowExpression(ArrowExpressionClauseSyntax arrowExpression)
971ITypeSymbol? GetTargetTypeForReturnStatement(ReturnStatementSyntax returnStatement)
985ITypeSymbol? GetTargetTypeForEqualsValueClause(EqualsValueClauseSyntax equalsValue)
995ITypeSymbol? GetTargetTypedForCastExpression(CastExpressionSyntax castExpression)
998ITypeSymbol? GetTargetTypeForConditionalExpression(ConditionalExpressionSyntax conditionalExpression, ExpressionSyntax expression)
1001return HasType(conditionalExpression.WhenFalse, out var falseType) ? falseType : conditionalExpression.GetTargetType(semanticModel, cancellationToken);
1003return HasType(conditionalExpression.WhenTrue, out var trueType) ? trueType : conditionalExpression.GetTargetType(semanticModel, cancellationToken);
1008ITypeSymbol? GetTargetTypeForLambdaExpression(LambdaExpressionSyntax lambda, ExpressionSyntax expression)
1012ITypeSymbol? GetTargetTypeForSwitchExpressionArm(SwitchExpressionArmSyntax switchExpressionArm)
1019if (arm != switchExpressionArm && HasType(arm.Expression, out var armType))
1027ITypeSymbol? GetTargetTypeForCollectionElement(CollectionElementSyntax collectionElement)
1035var collectionTargetType = collectionExpression.GetTargetType(semanticModel, cancellationToken);
1055ITypeSymbol? GetTargetTypeForInitializerExpression(InitializerExpressionSyntax initializerExpression, ExpressionSyntax expression)
1059return HasType(arrayCreation.Type, out var elementType) ? elementType : null;
1066if (sibling != expression && HasType(sibling, out var siblingType))
1084ITypeSymbol? GetTargetTypeForAssignmentExpression(AssignmentExpressionSyntax assignmentExpression, ExpressionSyntax expression)
1086return expression == assignmentExpression.Right && HasType(assignmentExpression.Left, out var leftType) ? leftType : null;
1089ITypeSymbol? GetTargetTypeForBinaryExpression(BinaryExpressionSyntax binaryExpression, ExpressionSyntax expression)
1091return 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;
943private static bool IsNullOrErrorType([NotNullWhen(false)] ITypeSymbol? type)
1066var castSideType = semanticModel.GetTypeInfo(castSide, cancellationToken).Type;
1067var castedExpressionType = semanticModel.GetTypeInfo(castExpression.Expression, cancellationToken).Type;
1071var otherSideType = semanticModel.GetTypeInfo(otherSide, cancellationToken).Type;
1089var castType = semanticModel.GetTypeInfo(castNode, cancellationToken).Type;
1090var castedExpressionType = semanticModel.GetTypeInfo(castedExpressionNode, cancellationToken).Type;
1147private static bool IsFloatingPointType(ITypeSymbol? type)
1317var rewrittenType = rewrittenSemanticModel.GetTypeInfo(rewrittenExpression, cancellationToken).Type;
1432private static bool IsIntrinsicOrEnum(ITypeSymbol rewrittenType)
1440ITypeSymbol rewrittenType,
1530private static (ITypeSymbol? rewrittenConvertedType, Conversion rewrittenConversion) GetRewrittenInfo(
1533Conversion originalConversion, ITypeSymbol originalConvertedType,
1544var convertedType = originalConversion.IsIdentity ? originalConvertedType : originalSemanticModel.Compilation.ObjectType;
1548var 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);
Roslyn.Diagnostics.VisualBasic.Analyzers (48)
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\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
System.Private.CoreLib.Generators (1)
System.Text.Json.SourceGeneration (64)
JsonSourceGenerator.Parser.cs (38)
44private readonly HashSet<ITypeSymbol> _builtInSupportTypes;
47private readonly Dictionary<ITypeSymbol, TypeGenerationSpec> _generatedTypes = new(SymbolEqualityComparer.Default);
207private TypeRef EnqueueType(ITypeSymbol type, JsonSourceGenerationMode? generationMode)
314var converterType = (ITypeSymbol?)element.Value;
461var typeSymbol = (ITypeSymbol?)attributeData.ConstructorArguments[0].Value;
509ITypeSymbol type = typeToGenerate.Type;
555else if (type.IsNullableValueType(out ITypeSymbol? underlyingType))
576out ITypeSymbol? valueType,
577out ITypeSymbol? keyType,
733var derivedType = (ITypeSymbol)attributeData.ConstructorArguments[0].Value!;
747ITypeSymbol type,
748[NotNullWhen(true)] out ITypeSymbol? valueType,
749out ITypeSymbol? keyType,
816ImmutableArray<ITypeSymbol> genericArgs = ((INamedTypeSymbol)type).TypeArguments;
910private TypeRef? GetDictionaryTypeRef(ITypeSymbol keyType, ITypeSymbol valueType)
989ITypeSymbol memberType,
1100private bool IsValidDataExtensionPropertyType(ITypeSymbol type)
1122ITypeSymbol memberType,
1447ITypeSymbol type = typeToGenerate.Type;
1583Debug.Assert(attributeData.ConstructorArguments.Length == 1 && attributeData.ConstructorArguments[0].Value is null or ITypeSymbol);
1584var converterType = (ITypeSymbol?)attributeData.ConstructorArguments[0].Value;
1588private TypeRef? GetConverterTypeFromAttribute(INamedTypeSymbol contextType, ITypeSymbol? converterType, ISymbol declaringSymbol, AttributeData attributeData)
1662private JsonPrimitiveTypeKind? GetPrimitiveTypeKind(ITypeSymbol type)
1695private static string GetTypeInfoPropertyName(ITypeSymbol type)
1715if (namedType.GetAllTypeArgumentsInScope() is List<ITypeSymbol> typeArgsInScope)
1717foreach (ITypeSymbol genericArg in typeArgsInScope)
1727ITypeSymbol type,
1795private bool IsUnsupportedType(ITypeSymbol type)
1806private bool IsBuiltInSupportType(ITypeSymbol type)
1819private static HashSet<ITypeSymbol> CreateBuiltInSupportTypeSet(KnownTypeSymbols knownSymbols)
1822HashSet<ITypeSymbol> builtInSupportTypes = new(SymbolEqualityComparer.Default);
1848void AddTypeIfNotNull(ITypeSymbol? type)
1859public required ITypeSymbol Type { get; init; }
System.Text.RegularExpressions.Generator (1)
System.Windows.Forms.PrivateSourceGenerators (5)
Test.Utilities (301)
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\Compiler\Extensions\Symbols\ITypeSymbolExtensions.cs (100)
26public static bool IsIntegralType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
29public static bool IsSignedIntegralType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
32public static bool CanAddNullCheck([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
43public static ImmutableArray<INamedTypeSymbol> GetAllInterfacesIncludingThis(this ITypeSymbol type)
51public static bool IsAbstractClass([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
54public static bool IsSystemVoid([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
57public static bool IsNullable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
60public static bool IsNonNullableValueType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
64[NotNullWhen(true)] this ITypeSymbol? symbol,
65[NotNullWhen(true)] out ITypeSymbol? underlyingType)
77public static bool IsModuleType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
80public static bool IsInterfaceType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
83public static bool IsDelegateType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
86public static bool IsFunctionPointerType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
89public static bool IsStructType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
96this ITypeSymbol type,
110public static IEnumerable<ITypeSymbol> GetBaseTypesAndThis(this ITypeSymbol? type)
112var current = type;
120public static IEnumerable<INamedTypeSymbol> GetBaseTypes(this ITypeSymbol? type)
130public static IEnumerable<ITypeSymbol> GetContainingTypesAndThis(this ITypeSymbol? type)
132var current = type;
140public static IEnumerable<INamedTypeSymbol> GetContainingTypes(this ITypeSymbol type)
153this ITypeSymbol type, ITypeSymbol baseType, bool includeInterfaces)
166this ITypeSymbol type, ITypeSymbol baseType)
174this ITypeSymbol type, ITypeSymbol baseType)
176var originalBaseType = baseType.OriginalDefinition;
184IEnumerable<ITypeSymbol> baseTypes = (baseType.TypeKind == TypeKind.Interface) ? type.AllInterfaces : type.GetBaseTypes();
191this ITypeSymbol type, ITypeSymbol baseType)
193var originalBaseType = baseType.OriginalDefinition;
213this ITypeSymbol type, ITypeSymbol interfaceType)
215var originalInterfaceType = interfaceType.OriginalDefinition;
220this ITypeSymbol type, ITypeSymbol interfaceType)
225public static bool IsAttribute(this ITypeSymbol symbol)
243public static bool IsFormattableStringOrIFormattable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
252this ITypeSymbol typeSymbol, bool allowDelegateAndEnumConstraints = false)
280public static bool IsNumericType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
306public static Accessibility DetermineMinimalAccessibility(this ITypeSymbol typeSymbol)
309public static bool ContainsAnonymousType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
325foreach (var typeArg in type.GetAllTypeArguments())
334public static string CreateParameterName(this ITypeSymbol type, bool capitalize = false)
355private static string GetParameterName(ITypeSymbol? type)
368public static bool IsSpecialType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
399public static bool CanSupportCollectionInitializer(this ITypeSymbol typeSymbol, ISymbol within)
410public static INamedTypeSymbol? GetDelegateType(this ITypeSymbol? typeSymbol, Compilation compilation)
417var typeArgument = ((INamedTypeSymbol)typeSymbol).TypeArguments[0];
430public static IEnumerable<T> GetAccessibleMembersInBaseTypes<T>(this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol
439public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, ISymbol within) where T : class, ISymbol
449public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, string memberName, ISymbol within) where T : class, ISymbol
459public static bool? AreMoreSpecificThan(this IList<ITypeSymbol> t1, IList<ITypeSymbol> t2)
494public static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, ISymbol within) where T : class, ISymbol
504private static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, string memberName, ISymbol within) where T : class, ISymbol
514private static bool? IsMoreSpecificThan(this ITypeSymbol t1, ITypeSymbol t2)
592public static bool IsOrDerivesFromExceptionType([NotNullWhen(returnValue: true)] this ITypeSymbol? type, Compilation compilation)
599foreach (var baseType in type.GetBaseTypesAndThis())
610foreach (var constraint in ((ITypeParameterSymbol)type).ConstraintTypes)
625public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type)
628public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type, [NotNullWhen(true)] out INamedTypeSymbol? enumType)
640public static bool? IsMutableValueType(this ITypeSymbol type)
642if (type.IsNullable(out var underlyingType))
719public static bool IsDisposable([NotNullWhen(returnValue: true)] this ITypeSymbol? type, [NotNullWhen(returnValue: true)] ITypeSymbol? iDisposableType)
724public static ITypeSymbol WithNullableAnnotationFrom(this ITypeSymbol type, ITypeSymbol symbolForNullableAnnotation)
728public static ITypeSymbol? RemoveNullableIfPresent(this ITypeSymbol? symbol)
730if (symbol.IsNullable(out var underlyingType))
738public static bool IsSpanOrReadOnlySpan([NotNullWhen(true)] this ITypeSymbol? type)
741public static bool IsSpan([NotNullWhen(true)] this ITypeSymbol? type)
757public static bool IsInlineArray([NotNullWhen(true)] this ITypeSymbol? type)
762public static ITypeSymbol? RemoveUnavailableTypeParameters(
763this ITypeSymbol? type,
771private static ITypeSymbol? RemoveUnavailableTypeParameters(
772this ITypeSymbol? type,
780public static ITypeSymbol? RemoveAnonymousTypes(
781this ITypeSymbol? type,
788public static ITypeSymbol? RemoveUnnamedErrorTypes(
789this ITypeSymbol? type,
796this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
802this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
808this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result, bool onlyMethodTypeParameters)
817public static IList<ITypeParameterSymbol> GetReferencedTypeParameters(this ITypeSymbol? type)
825public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
826this ITypeSymbol? type,
829where TType1 : ITypeSymbol
830where TType2 : ITypeSymbol
836public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
837this ITypeSymbol? type,
840where TType1 : ITypeSymbol
841where TType2 : ITypeSymbol
Text.Analyzers (431)
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\Compiler\Extensions\Symbols\ITypeSymbolExtensions.cs (100)
26public static bool IsIntegralType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
29public static bool IsSignedIntegralType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
32public static bool CanAddNullCheck([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
43public static ImmutableArray<INamedTypeSymbol> GetAllInterfacesIncludingThis(this ITypeSymbol type)
51public static bool IsAbstractClass([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
54public static bool IsSystemVoid([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
57public static bool IsNullable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
60public static bool IsNonNullableValueType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
64[NotNullWhen(true)] this ITypeSymbol? symbol,
65[NotNullWhen(true)] out ITypeSymbol? underlyingType)
77public static bool IsModuleType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
80public static bool IsInterfaceType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
83public static bool IsDelegateType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
86public static bool IsFunctionPointerType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
89public static bool IsStructType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
96this ITypeSymbol type,
110public static IEnumerable<ITypeSymbol> GetBaseTypesAndThis(this ITypeSymbol? type)
112var current = type;
120public static IEnumerable<INamedTypeSymbol> GetBaseTypes(this ITypeSymbol? type)
130public static IEnumerable<ITypeSymbol> GetContainingTypesAndThis(this ITypeSymbol? type)
132var current = type;
140public static IEnumerable<INamedTypeSymbol> GetContainingTypes(this ITypeSymbol type)
153this ITypeSymbol type, ITypeSymbol baseType, bool includeInterfaces)
166this ITypeSymbol type, ITypeSymbol baseType)
174this ITypeSymbol type, ITypeSymbol baseType)
176var originalBaseType = baseType.OriginalDefinition;
184IEnumerable<ITypeSymbol> baseTypes = (baseType.TypeKind == TypeKind.Interface) ? type.AllInterfaces : type.GetBaseTypes();
191this ITypeSymbol type, ITypeSymbol baseType)
193var originalBaseType = baseType.OriginalDefinition;
213this ITypeSymbol type, ITypeSymbol interfaceType)
215var originalInterfaceType = interfaceType.OriginalDefinition;
220this ITypeSymbol type, ITypeSymbol interfaceType)
225public static bool IsAttribute(this ITypeSymbol symbol)
243public static bool IsFormattableStringOrIFormattable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
252this ITypeSymbol typeSymbol, bool allowDelegateAndEnumConstraints = false)
280public static bool IsNumericType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
306public static Accessibility DetermineMinimalAccessibility(this ITypeSymbol typeSymbol)
309public static bool ContainsAnonymousType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
325foreach (var typeArg in type.GetAllTypeArguments())
334public static string CreateParameterName(this ITypeSymbol type, bool capitalize = false)
355private static string GetParameterName(ITypeSymbol? type)
368public static bool IsSpecialType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
399public static bool CanSupportCollectionInitializer(this ITypeSymbol typeSymbol, ISymbol within)
410public static INamedTypeSymbol? GetDelegateType(this ITypeSymbol? typeSymbol, Compilation compilation)
417var typeArgument = ((INamedTypeSymbol)typeSymbol).TypeArguments[0];
430public static IEnumerable<T> GetAccessibleMembersInBaseTypes<T>(this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol
439public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, ISymbol within) where T : class, ISymbol
449public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, string memberName, ISymbol within) where T : class, ISymbol
459public static bool? AreMoreSpecificThan(this IList<ITypeSymbol> t1, IList<ITypeSymbol> t2)
494public static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, ISymbol within) where T : class, ISymbol
504private static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, string memberName, ISymbol within) where T : class, ISymbol
514private static bool? IsMoreSpecificThan(this ITypeSymbol t1, ITypeSymbol t2)
592public static bool IsOrDerivesFromExceptionType([NotNullWhen(returnValue: true)] this ITypeSymbol? type, Compilation compilation)
599foreach (var baseType in type.GetBaseTypesAndThis())
610foreach (var constraint in ((ITypeParameterSymbol)type).ConstraintTypes)
625public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type)
628public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type, [NotNullWhen(true)] out INamedTypeSymbol? enumType)
640public static bool? IsMutableValueType(this ITypeSymbol type)
642if (type.IsNullable(out var underlyingType))
719public static bool IsDisposable([NotNullWhen(returnValue: true)] this ITypeSymbol? type, [NotNullWhen(returnValue: true)] ITypeSymbol? iDisposableType)
724public static ITypeSymbol WithNullableAnnotationFrom(this ITypeSymbol type, ITypeSymbol symbolForNullableAnnotation)
728public static ITypeSymbol? RemoveNullableIfPresent(this ITypeSymbol? symbol)
730if (symbol.IsNullable(out var underlyingType))
738public static bool IsSpanOrReadOnlySpan([NotNullWhen(true)] this ITypeSymbol? type)
741public static bool IsSpan([NotNullWhen(true)] this ITypeSymbol? type)
757public static bool IsInlineArray([NotNullWhen(true)] this ITypeSymbol? type)
762public static ITypeSymbol? RemoveUnavailableTypeParameters(
763this ITypeSymbol? type,
771private static ITypeSymbol? RemoveUnavailableTypeParameters(
772this ITypeSymbol? type,
780public static ITypeSymbol? RemoveAnonymousTypes(
781this ITypeSymbol? type,
788public static ITypeSymbol? RemoveUnnamedErrorTypes(
789this ITypeSymbol? type,
796this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
802this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
808this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result, bool onlyMethodTypeParameters)
817public static IList<ITypeParameterSymbol> GetReferencedTypeParameters(this ITypeSymbol? type)
825public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
826this ITypeSymbol? type,
829where TType1 : ITypeSymbol
830where TType2 : ITypeSymbol
836public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
837this ITypeSymbol? type,
840where TType1 : ITypeSymbol
841where TType2 : ITypeSymbol
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationSymbolFactory.cs (18)
30DeclarationModifiers modifiers, ITypeSymbol type,
47ITypeSymbol type,
79ITypeSymbol type, RefKind refKind, ImmutableArray<IPropertySymbol> explicitInterfaceImplementations, string name,
106ITypeSymbol type, string name,
152ITypeSymbol? returnType,
174ITypeSymbol? returnType,
195ITypeSymbol returnType,
220ITypeSymbol toType,
248ITypeSymbol toType,
264public static IParameterSymbol CreateParameterSymbol(ITypeSymbol type, string name)
267public static IParameterSymbol CreateParameterSymbol(RefKind refKind, ITypeSymbol type, string name)
277ImmutableArray<AttributeData> attributes, RefKind refKind, bool isParams, ITypeSymbol type, string name, bool isOptional = false, bool hasDefaultValue = false, object? defaultValue = null)
290ITypeSymbol? type = null,
331ImmutableArray<ITypeSymbol> constraintTypes,
347public static IPointerTypeSymbol CreatePointerTypeSymbol(ITypeSymbol pointedAtType)
353public static IArrayTypeSymbol CreateArrayTypeSymbol(ITypeSymbol elementType, int rank = 1, NullableAnnotation nullableAnnotation = NullableAnnotation.None)
463ITypeSymbol returnType,
520ITypeSymbol? 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)
15ITypeSymbol toType,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\Symbols\CodeGenerationOperatorSymbol.cs (1)
15ITypeSymbol returnType,