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)
9966 references to ITypeSymbol
Aspire.Hosting.Analyzers (20)
AspireExportAnalyzer.cs (15)
150var targetType = method.Parameters[0].Type;
253ITypeSymbol type,
273ITypeSymbol type,
314ITypeSymbol type,
377private static bool IsSimpleType(ITypeSymbol type, WellKnownTypes wellKnownTypes)
408private static bool IsWellKnownScalarType(ITypeSymbol type, WellKnownTypes wellKnownTypes)
429private static bool TryMatchType(ITypeSymbol type, WellKnownTypes wellKnownTypes, WellKnownTypeData.WellKnownType wellKnownType)
443private static bool TryMatchGenericType(ITypeSymbol type, WellKnownTypes wellKnownTypes, WellKnownTypeData.WellKnownType wellKnownType)
463ITypeSymbol type,
510private static bool HasAspireExportAttribute(ITypeSymbol type, INamedTypeSymbol aspireExportAttribute)
524private static bool HasAspireDtoAttribute(ITypeSymbol type)
539private static bool IsResourceType(ITypeSymbol type, WellKnownTypes wellKnownTypes)
553private static bool IsResourceBuilderType(ITypeSymbol type, WellKnownTypes wellKnownTypes)
594var type = parameter.Type;
611private static bool IsDelegateType(ITypeSymbol type)
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 (441)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (25)
102protected abstract TConversion ClassifyConversion(SemanticModel model, TExpressionSyntax expression, ITypeSymbol targetType);
103protected abstract TConversion ClassifyConversion(SemanticModel model, ITypeSymbol originalType, ITypeSymbol targetType);
105protected abstract bool ConversionsAreCompatible(TExpressionSyntax originalExpression, ITypeSymbol originalTargetType, TExpressionSyntax newExpression, ITypeSymbol newTargetType);
106protected abstract bool IsReferenceConversion(Compilation model, ITypeSymbol sourceType, ITypeSymbol targetType);
112SemanticModel model, TForEachStatementSyntax forEach, out IMethodSymbol getEnumeratorMethod, out ITypeSymbol elementType, out ImmutableArray<ILocalSymbol> localVariables);
305private bool ImplicitConversionsAreCompatible(TExpressionSyntax originalExpression, ITypeSymbol originalTargetType, TExpressionSyntax newExpression, ITypeSymbol newTargetType)
740var previousOriginalType = this.OriginalSemanticModel.GetTypeInfo(previousOriginalNode).Type;
741var previousReplacedType = this.SpeculativeSemanticModel.GetTypeInfo(previousReplacedNode).Type;
778GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
779GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
824var expressionType = this.SpeculativeSemanticModel.GetTypeInfo(newForEachStatementExpression, CancellationToken).ConvertedType;
847var originalThrowExpressionType = this.OriginalSemanticModel.GetTypeInfo(originalThrowExpression).Type;
849var newThrowExpressionType = this.SpeculativeSemanticModel.GetTypeInfo(newThrowExpression).Type;
959var originalTargetType = this.OriginalSemanticModel.GetTypeInfo(originalLeft).Type;
962var newTargetType = this.SpeculativeSemanticModel.GetTypeInfo(newLeft).Type;
995var newReceiverType = newReceiver != null
1034var receiverType = semanticModel.GetTypeInfo(receiver).Type;
1186ITypeSymbol originalTargetType,
1188ITypeSymbol newTargetType,
1203var originalConvertedTypeSymbol = this.OriginalSemanticModel.GetTypeInfo(originalExpression).ConvertedType;
1209var newConvertedTypeSymbol = this.SpeculativeSemanticModel.GetTypeInfo(newExpression).ConvertedType;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Symbols\ITypeSymbolExtensions.cs (101)
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)
244public static bool IsFormattableStringOrIFormattable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
253this ITypeSymbol typeSymbol, bool allowDelegateAndEnumConstraints = false)
281public static bool IsNumericType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
307public static Accessibility DetermineMinimalAccessibility(this ITypeSymbol typeSymbol)
310public static bool ContainsAnonymousType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
326foreach (var typeArg in type.GetAllTypeArguments())
335public static string CreateParameterName(this ITypeSymbol type, bool capitalize = false)
362private static string GetParameterName(ITypeSymbol? type)
375public static bool IsSpecialType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
406public static bool CanSupportCollectionInitializer(this ITypeSymbol typeSymbol, ISymbol within)
417public static INamedTypeSymbol? GetDelegateType(this ITypeSymbol? typeSymbol, Compilation compilation)
424var typeArgument = ((INamedTypeSymbol)typeSymbol).TypeArguments[0];
437public static IEnumerable<T> GetAccessibleMembersInBaseTypes<T>(this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol
446public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, ISymbol within) where T : class, ISymbol
456public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, string memberName, ISymbol within) where T : class, ISymbol
466public static bool? AreMoreSpecificThan(this IList<ITypeSymbol> t1, IList<ITypeSymbol> t2)
501public static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, ISymbol within) where T : class, ISymbol
511private static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, string memberName, ISymbol within) where T : class, ISymbol
521private static bool? IsMoreSpecificThan(this ITypeSymbol t1, ITypeSymbol t2)
599public static bool IsOrDerivesFromExceptionType([NotNullWhen(returnValue: true)] this ITypeSymbol? type, Compilation compilation)
606foreach (var baseType in type.GetBaseTypesAndThis())
617foreach (var constraint in ((ITypeParameterSymbol)type).ConstraintTypes)
632public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type)
635public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type, [NotNullWhen(true)] out INamedTypeSymbol? enumType)
647public static bool? IsMutableValueType(this ITypeSymbol type)
649if (type.IsNullable(out var underlyingType))
728static bool IsWellKnownImmutableValueType(ITypeSymbol type)
761public static bool IsDisposable([NotNullWhen(returnValue: true)] this ITypeSymbol? type, [NotNullWhen(returnValue: true)] ITypeSymbol? iDisposableType)
766public static ITypeSymbol WithNullableAnnotationFrom(this ITypeSymbol type, ITypeSymbol symbolForNullableAnnotation)
770public static ITypeSymbol? RemoveNullableIfPresent(this ITypeSymbol? symbol)
772if (symbol.IsNullable(out var underlyingType))
780public static bool IsSpanOrReadOnlySpan([NotNullWhen(true)] this ITypeSymbol? type)
783public static bool IsSpan([NotNullWhen(true)] this ITypeSymbol? type)
799public static bool IsInlineArray([NotNullWhen(true)] this ITypeSymbol? type)
804public static ITypeSymbol? RemoveUnavailableTypeParameters(
805this ITypeSymbol? type,
813private static ITypeSymbol? RemoveUnavailableTypeParameters(
814this ITypeSymbol? type,
822public static ITypeSymbol? RemoveAnonymousTypes(
823this ITypeSymbol? type,
830public static ITypeSymbol? RemoveUnnamedErrorTypes(
831this ITypeSymbol? type,
838this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
844this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
850this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result, bool onlyMethodTypeParameters)
859public static IList<ITypeParameterSymbol> GetReferencedTypeParameters(this ITypeSymbol? type)
867public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
868this ITypeSymbol? type,
871where TType1 : ITypeSymbol
872where TType2 : ITypeSymbol
878public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
879this ITypeSymbol? type,
882where TType1 : ITypeSymbol
883where 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 (83)
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 (7)
34internal void GetReflectionAccessDiagnostics(Location location, ITypeSymbol typeSymbol, DynamicallyAccessedMemberTypes requiredMemberTypes, bool declaredOnly = false)
65internal void GetReflectionAccessDiagnosticsForEventsOnTypeHierarchy(Location location, ITypeSymbol typeSymbol, string name, BindingFlags? bindingFlags)
71internal void GetReflectionAccessDiagnosticsForFieldsOnTypeHierarchy(Location location, ITypeSymbol typeSymbol, string name, BindingFlags? bindingFlags)
77internal void GetReflectionAccessDiagnosticsForPropertiesOnTypeHierarchy(Location location, ITypeSymbol typeSymbol, string name, BindingFlags? bindingFlags)
83internal void GetReflectionAccessDiagnosticsForConstructorsOnType(Location location, ITypeSymbol typeSymbol, BindingFlags? bindingFlags, int? parameterCount)
89internal void GetReflectionAccessDiagnosticsForPublicParameterlessConstructor(Location location, ITypeSymbol typeSymbol)
223internal bool TryResolveTypeNameAndMark(string typeName, in DiagnosticContext diagnosticContext, bool needsAssemblyName, [NotNullWhen(true)] out ITypeSymbol? type)
Metrics (315)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (25)
102protected abstract TConversion ClassifyConversion(SemanticModel model, TExpressionSyntax expression, ITypeSymbol targetType);
103protected abstract TConversion ClassifyConversion(SemanticModel model, ITypeSymbol originalType, ITypeSymbol targetType);
105protected abstract bool ConversionsAreCompatible(TExpressionSyntax originalExpression, ITypeSymbol originalTargetType, TExpressionSyntax newExpression, ITypeSymbol newTargetType);
106protected abstract bool IsReferenceConversion(Compilation model, ITypeSymbol sourceType, ITypeSymbol targetType);
112SemanticModel model, TForEachStatementSyntax forEach, out IMethodSymbol getEnumeratorMethod, out ITypeSymbol elementType, out ImmutableArray<ILocalSymbol> localVariables);
305private bool ImplicitConversionsAreCompatible(TExpressionSyntax originalExpression, ITypeSymbol originalTargetType, TExpressionSyntax newExpression, ITypeSymbol newTargetType)
740var previousOriginalType = this.OriginalSemanticModel.GetTypeInfo(previousOriginalNode).Type;
741var previousReplacedType = this.SpeculativeSemanticModel.GetTypeInfo(previousReplacedNode).Type;
778GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
779GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
824var expressionType = this.SpeculativeSemanticModel.GetTypeInfo(newForEachStatementExpression, CancellationToken).ConvertedType;
847var originalThrowExpressionType = this.OriginalSemanticModel.GetTypeInfo(originalThrowExpression).Type;
849var newThrowExpressionType = this.SpeculativeSemanticModel.GetTypeInfo(newThrowExpression).Type;
959var originalTargetType = this.OriginalSemanticModel.GetTypeInfo(originalLeft).Type;
962var newTargetType = this.SpeculativeSemanticModel.GetTypeInfo(newLeft).Type;
995var newReceiverType = newReceiver != null
1034var receiverType = semanticModel.GetTypeInfo(receiver).Type;
1186ITypeSymbol originalTargetType,
1188ITypeSymbol newTargetType,
1203var originalConvertedTypeSymbol = this.OriginalSemanticModel.GetTypeInfo(originalExpression).ConvertedType;
1209var newConvertedTypeSymbol = this.SpeculativeSemanticModel.GetTypeInfo(newExpression).ConvertedType;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Symbols\ITypeSymbolExtensions.cs (101)
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)
244public static bool IsFormattableStringOrIFormattable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
253this ITypeSymbol typeSymbol, bool allowDelegateAndEnumConstraints = false)
281public static bool IsNumericType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
307public static Accessibility DetermineMinimalAccessibility(this ITypeSymbol typeSymbol)
310public static bool ContainsAnonymousType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
326foreach (var typeArg in type.GetAllTypeArguments())
335public static string CreateParameterName(this ITypeSymbol type, bool capitalize = false)
362private static string GetParameterName(ITypeSymbol? type)
375public static bool IsSpecialType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
406public static bool CanSupportCollectionInitializer(this ITypeSymbol typeSymbol, ISymbol within)
417public static INamedTypeSymbol? GetDelegateType(this ITypeSymbol? typeSymbol, Compilation compilation)
424var typeArgument = ((INamedTypeSymbol)typeSymbol).TypeArguments[0];
437public static IEnumerable<T> GetAccessibleMembersInBaseTypes<T>(this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol
446public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, ISymbol within) where T : class, ISymbol
456public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, string memberName, ISymbol within) where T : class, ISymbol
466public static bool? AreMoreSpecificThan(this IList<ITypeSymbol> t1, IList<ITypeSymbol> t2)
501public static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, ISymbol within) where T : class, ISymbol
511private static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, string memberName, ISymbol within) where T : class, ISymbol
521private static bool? IsMoreSpecificThan(this ITypeSymbol t1, ITypeSymbol t2)
599public static bool IsOrDerivesFromExceptionType([NotNullWhen(returnValue: true)] this ITypeSymbol? type, Compilation compilation)
606foreach (var baseType in type.GetBaseTypesAndThis())
617foreach (var constraint in ((ITypeParameterSymbol)type).ConstraintTypes)
632public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type)
635public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type, [NotNullWhen(true)] out INamedTypeSymbol? enumType)
647public static bool? IsMutableValueType(this ITypeSymbol type)
649if (type.IsNullable(out var underlyingType))
728static bool IsWellKnownImmutableValueType(ITypeSymbol type)
761public static bool IsDisposable([NotNullWhen(returnValue: true)] this ITypeSymbol? type, [NotNullWhen(returnValue: true)] ITypeSymbol? iDisposableType)
766public static ITypeSymbol WithNullableAnnotationFrom(this ITypeSymbol type, ITypeSymbol symbolForNullableAnnotation)
770public static ITypeSymbol? RemoveNullableIfPresent(this ITypeSymbol? symbol)
772if (symbol.IsNullable(out var underlyingType))
780public static bool IsSpanOrReadOnlySpan([NotNullWhen(true)] this ITypeSymbol? type)
783public static bool IsSpan([NotNullWhen(true)] this ITypeSymbol? type)
799public static bool IsInlineArray([NotNullWhen(true)] this ITypeSymbol? type)
804public static ITypeSymbol? RemoveUnavailableTypeParameters(
805this ITypeSymbol? type,
813private static ITypeSymbol? RemoveUnavailableTypeParameters(
814this ITypeSymbol? type,
822public static ITypeSymbol? RemoveAnonymousTypes(
823this ITypeSymbol? type,
830public static ITypeSymbol? RemoveUnnamedErrorTypes(
831this ITypeSymbol? type,
838this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
844this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
850this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result, bool onlyMethodTypeParameters)
859public static IList<ITypeParameterSymbol> GetReferencedTypeParameters(this ITypeSymbol? type)
867public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
868this ITypeSymbol? type,
871where TType1 : ITypeSymbol
872where TType2 : ITypeSymbol
878public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
879this ITypeSymbol? type,
882where TType1 : ITypeSymbol
883where TType2 : ITypeSymbol
Metrics.Legacy (315)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (25)
102protected abstract TConversion ClassifyConversion(SemanticModel model, TExpressionSyntax expression, ITypeSymbol targetType);
103protected abstract TConversion ClassifyConversion(SemanticModel model, ITypeSymbol originalType, ITypeSymbol targetType);
105protected abstract bool ConversionsAreCompatible(TExpressionSyntax originalExpression, ITypeSymbol originalTargetType, TExpressionSyntax newExpression, ITypeSymbol newTargetType);
106protected abstract bool IsReferenceConversion(Compilation model, ITypeSymbol sourceType, ITypeSymbol targetType);
112SemanticModel model, TForEachStatementSyntax forEach, out IMethodSymbol getEnumeratorMethod, out ITypeSymbol elementType, out ImmutableArray<ILocalSymbol> localVariables);
305private bool ImplicitConversionsAreCompatible(TExpressionSyntax originalExpression, ITypeSymbol originalTargetType, TExpressionSyntax newExpression, ITypeSymbol newTargetType)
740var previousOriginalType = this.OriginalSemanticModel.GetTypeInfo(previousOriginalNode).Type;
741var previousReplacedType = this.SpeculativeSemanticModel.GetTypeInfo(previousReplacedNode).Type;
778GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
779GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
824var expressionType = this.SpeculativeSemanticModel.GetTypeInfo(newForEachStatementExpression, CancellationToken).ConvertedType;
847var originalThrowExpressionType = this.OriginalSemanticModel.GetTypeInfo(originalThrowExpression).Type;
849var newThrowExpressionType = this.SpeculativeSemanticModel.GetTypeInfo(newThrowExpression).Type;
959var originalTargetType = this.OriginalSemanticModel.GetTypeInfo(originalLeft).Type;
962var newTargetType = this.SpeculativeSemanticModel.GetTypeInfo(newLeft).Type;
995var newReceiverType = newReceiver != null
1034var receiverType = semanticModel.GetTypeInfo(receiver).Type;
1186ITypeSymbol originalTargetType,
1188ITypeSymbol newTargetType,
1203var originalConvertedTypeSymbol = this.OriginalSemanticModel.GetTypeInfo(originalExpression).ConvertedType;
1209var newConvertedTypeSymbol = this.SpeculativeSemanticModel.GetTypeInfo(newExpression).ConvertedType;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Symbols\ITypeSymbolExtensions.cs (101)
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)
244public static bool IsFormattableStringOrIFormattable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
253this ITypeSymbol typeSymbol, bool allowDelegateAndEnumConstraints = false)
281public static bool IsNumericType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
307public static Accessibility DetermineMinimalAccessibility(this ITypeSymbol typeSymbol)
310public static bool ContainsAnonymousType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
326foreach (var typeArg in type.GetAllTypeArguments())
335public static string CreateParameterName(this ITypeSymbol type, bool capitalize = false)
362private static string GetParameterName(ITypeSymbol? type)
375public static bool IsSpecialType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
406public static bool CanSupportCollectionInitializer(this ITypeSymbol typeSymbol, ISymbol within)
417public static INamedTypeSymbol? GetDelegateType(this ITypeSymbol? typeSymbol, Compilation compilation)
424var typeArgument = ((INamedTypeSymbol)typeSymbol).TypeArguments[0];
437public static IEnumerable<T> GetAccessibleMembersInBaseTypes<T>(this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol
446public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, ISymbol within) where T : class, ISymbol
456public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, string memberName, ISymbol within) where T : class, ISymbol
466public static bool? AreMoreSpecificThan(this IList<ITypeSymbol> t1, IList<ITypeSymbol> t2)
501public static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, ISymbol within) where T : class, ISymbol
511private static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, string memberName, ISymbol within) where T : class, ISymbol
521private static bool? IsMoreSpecificThan(this ITypeSymbol t1, ITypeSymbol t2)
599public static bool IsOrDerivesFromExceptionType([NotNullWhen(returnValue: true)] this ITypeSymbol? type, Compilation compilation)
606foreach (var baseType in type.GetBaseTypesAndThis())
617foreach (var constraint in ((ITypeParameterSymbol)type).ConstraintTypes)
632public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type)
635public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type, [NotNullWhen(true)] out INamedTypeSymbol? enumType)
647public static bool? IsMutableValueType(this ITypeSymbol type)
649if (type.IsNullable(out var underlyingType))
728static bool IsWellKnownImmutableValueType(ITypeSymbol type)
761public static bool IsDisposable([NotNullWhen(returnValue: true)] this ITypeSymbol? type, [NotNullWhen(returnValue: true)] ITypeSymbol? iDisposableType)
766public static ITypeSymbol WithNullableAnnotationFrom(this ITypeSymbol type, ITypeSymbol symbolForNullableAnnotation)
770public static ITypeSymbol? RemoveNullableIfPresent(this ITypeSymbol? symbol)
772if (symbol.IsNullable(out var underlyingType))
780public static bool IsSpanOrReadOnlySpan([NotNullWhen(true)] this ITypeSymbol? type)
783public static bool IsSpan([NotNullWhen(true)] this ITypeSymbol? type)
799public static bool IsInlineArray([NotNullWhen(true)] this ITypeSymbol? type)
804public static ITypeSymbol? RemoveUnavailableTypeParameters(
805this ITypeSymbol? type,
813private static ITypeSymbol? RemoveUnavailableTypeParameters(
814this ITypeSymbol? type,
822public static ITypeSymbol? RemoveAnonymousTypes(
823this ITypeSymbol? type,
830public static ITypeSymbol? RemoveUnnamedErrorTypes(
831this ITypeSymbol? type,
838this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
844this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
850this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result, bool onlyMethodTypeParameters)
859public static IList<ITypeParameterSymbol> GetReferencedTypeParameters(this ITypeSymbol? type)
867public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
868this ITypeSymbol? type,
871where TType1 : ITypeSymbol
872where TType2 : ITypeSymbol
878public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
879this ITypeSymbol? type,
882where TType1 : ITypeSymbol
883where TType2 : ITypeSymbol
Microsoft.Analyzers.Extra (24)
Microsoft.Analyzers.Local (3)
Microsoft.AspNetCore.App.Analyzers (66)
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)
src\Shared\RoslynUtils\SymbolExtensions.cs (21)
19public static ITypeSymbol UnwrapTypeSymbol(this ITypeSymbol typeSymbol, bool unwrapArray = false, bool unwrapNullable = false)
42public static IEnumerable<ITypeSymbol> GetThisAndBaseTypes(this ITypeSymbol? type)
44var current = type;
70public static bool HasAttribute(this ITypeSymbol typeSymbol, INamedTypeSymbol attributeSymbol)
72var current = typeSymbol;
174public static bool Implements(this ITypeSymbol type, ITypeSymbol interfaceType)
186public static bool InheritsFrom(this ITypeSymbol type, ITypeSymbol baseType)
188foreach (var t in type.GetThisAndBaseTypes())
204public static ITypeSymbol GetParameterType(this ISymbol symbol)
244private static string InnerGetDefaultValueString(object? defaultValue, ITypeSymbol parameterType)
247if (IsEnumType(parameterType, out var enumType))
253if (IsNullableEnumType(parameterType, out var underlyingEnumType))
308private static bool IsEnumType(ITypeSymbol typeSymbol, out ITypeSymbol enumType)
314private static bool IsNullableEnumType(ITypeSymbol typeSymbol, [NotNullWhen(true)] out ITypeSymbol? underlyingEnumType)
320var underlyingType = namedType.TypeArguments.FirstOrDefault();
Microsoft.AspNetCore.App.CodeFixes (4)
Microsoft.AspNetCore.Components.Analyzers (4)
Microsoft.AspNetCore.Http.RequestDelegateGenerator (70)
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)
src\Shared\RoslynUtils\SymbolExtensions.cs (21)
19public static ITypeSymbol UnwrapTypeSymbol(this ITypeSymbol typeSymbol, bool unwrapArray = false, bool unwrapNullable = false)
42public static IEnumerable<ITypeSymbol> GetThisAndBaseTypes(this ITypeSymbol? type)
44var current = type;
70public static bool HasAttribute(this ITypeSymbol typeSymbol, INamedTypeSymbol attributeSymbol)
72var current = typeSymbol;
174public static bool Implements(this ITypeSymbol type, ITypeSymbol interfaceType)
186public static bool InheritsFrom(this ITypeSymbol type, ITypeSymbol baseType)
188foreach (var t in type.GetThisAndBaseTypes())
204public static ITypeSymbol GetParameterType(this ISymbol symbol)
244private static string InnerGetDefaultValueString(object? defaultValue, ITypeSymbol parameterType)
247if (IsEnumType(parameterType, out var enumType))
253if (IsNullableEnumType(parameterType, out var underlyingEnumType))
308private static bool IsEnumType(ITypeSymbol typeSymbol, out ITypeSymbol enumType)
314private static bool IsNullableEnumType(ITypeSymbol typeSymbol, [NotNullWhen(true)] out ITypeSymbol? underlyingEnumType)
320var underlyingType = namedType.TypeArguments.FirstOrDefault();
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 (449)
Compilation\Compilation.cs (39)
1016internal abstract bool IsAttributeType(ITypeSymbol type);
1029public ITypeSymbol DynamicType { get { return CommonDynamicType; } }
1030protected abstract ITypeSymbol CommonDynamicType { get; }
1035internal ITypeSymbol? ScriptGlobalsType => CommonScriptGlobalsType;
1036protected abstract ITypeSymbol? CommonScriptGlobalsType { get; }
1094public IArrayTypeSymbol CreateArrayTypeSymbol(ITypeSymbol elementType, int rank = 1, NullableAnnotation elementNullableAnnotation = NullableAnnotation.None)
1104public IArrayTypeSymbol CreateArrayTypeSymbol(ITypeSymbol elementType, int rank)
1109protected abstract IArrayTypeSymbol CommonCreateArrayTypeSymbol(ITypeSymbol elementType, int rank, NullableAnnotation elementNullableAnnotation);
1116public IPointerTypeSymbol CreatePointerTypeSymbol(ITypeSymbol pointedAtType)
1121protected abstract IPointerTypeSymbol CommonCreatePointerTypeSymbol(ITypeSymbol elementType);
1137ITypeSymbol returnType,
1139ImmutableArray<ITypeSymbol> parameterTypes,
1148ITypeSymbol returnType,
1150ImmutableArray<ITypeSymbol> parameterTypes,
1306ImmutableArray<ITypeSymbol> elementTypes,
1347ImmutableArray<ITypeSymbol> elementTypes,
1411ImmutableArray<ITypeSymbol> elementTypes,
1463ImmutableArray<ITypeSymbol> memberTypes,
1532ImmutableArray<ITypeSymbol> memberTypes,
1541ImmutableArray<ITypeSymbol> memberTypes,
1557public IMethodSymbol CreateBuiltinOperator(string name, ITypeSymbol returnType, ITypeSymbol leftType, ITypeSymbol rightType)
1573protected abstract IMethodSymbol CommonCreateBuiltinOperator(string name, ITypeSymbol returnType, ITypeSymbol leftType, ITypeSymbol rightType);
1584public IMethodSymbol CreateBuiltinOperator(string name, ITypeSymbol returnType, ITypeSymbol operandType)
1597protected abstract IMethodSymbol CommonCreateBuiltinOperator(string name, ITypeSymbol returnType, ITypeSymbol operandType);
1607public abstract CommonConversion ClassifyCommonConversion(ITypeSymbol source, ITypeSymbol destination);
1615public bool HasImplicitConversion(ITypeSymbol? fromType, ITypeSymbol? toType)
1638ITypeSymbol? throughType = null)
1767ITypeSymbol? throughType);
1769internal abstract IConvertibleConversion ClassifyConvertibleConversion(IOperation source, ITypeSymbol destination, out ConstantValue? constantValue);
3774internal string GetMessage(ITypeSymbol source, ITypeSymbol destination)
DocumentationCommentId.cs (14)
887private static ITypeSymbol? ParseTypeSymbol(string id, ref int index, Compilation compilation, ISymbol? typeParameterContext)
899return (ITypeSymbol)results[0];
941results.AddRange(contexts.OfType<ITypeSymbol>());
967var typeSymbol = (ITypeSymbol)results[i];
1045List<ITypeSymbol>? typeArguments = null;
1051typeArguments = new List<ITypeSymbol>();
1144private static bool ParseTypeArguments(string id, ref int index, Compilation compilation, ISymbol? typeParameterContext, List<ITypeSymbol> typeArguments)
1150var type = ParseTypeSymbol(id, ref index, compilation, typeParameterContext);
1320ITypeSymbol? returnType = ParseTypeSymbol(id, ref index, compilation, methodSymbol);
1464var parameterType = parameterInfo.Type;
1500internal readonly ITypeSymbol Type;
1503public ParameterInfo(ITypeSymbol type, bool isRefOrOut)
1557var type = ParseTypeSymbol(id, ref index, compilation, typeParameterContext);
Generated\Operations.Generated.cs (275)
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; }
4009ITypeSymbol? ElementType { get; }
4090public override ITypeSymbol? Type => null;
4145public override ITypeSymbol? Type => null;
4215public override ITypeSymbol? Type => null;
4321public override ITypeSymbol? Type => null;
4413public override ITypeSymbol? Type => null;
4525public override ITypeSymbol? Type => null;
4549public override ITypeSymbol? Type => null;
4602public override ITypeSymbol? Type => null;
4622public override ITypeSymbol? Type => null;
4636public override ITypeSymbol? Type => null;
4688public override ITypeSymbol? Type => null;
4752public override ITypeSymbol? Type => null;
4831public override ITypeSymbol? Type => null;
4899public override ITypeSymbol? Type => null;
4950public override ITypeSymbol? Type => null;
5014public override ITypeSymbol? Type => null;
5028public override ITypeSymbol? Type => null;
5042public override ITypeSymbol? Type => null;
5108public override ITypeSymbol? Type => null;
5116internal LiteralOperation(SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit)
5126public override ITypeSymbol? Type { get; }
5134internal ConversionOperation(IOperation operand, IConvertibleConversion conversion, bool isTryCast, bool isChecked, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit)
5186public override ITypeSymbol? Type { get; }
5194internal InvocationOperation(IMethodSymbol targetMethod, ITypeSymbol? constrainedToType, IOperation? instance, bool isVirtual, ImmutableArray<IArgumentOperation> arguments, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
5205public ITypeSymbol? ConstrainedToType { get; }
5259public override ITypeSymbol? Type { get; }
5267internal ArrayElementReferenceOperation(IOperation arrayReference, ImmutableArray<IOperation> indices, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
5326public override ITypeSymbol? Type { get; }
5334internal LocalReferenceOperation(ILocalSymbol local, bool isDeclaration, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit)
5348public override ITypeSymbol? Type { get; }
5356internal ParameterReferenceOperation(IParameterSymbol parameter, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
5367public override ITypeSymbol? Type { get; }
5381public abstract ITypeSymbol? ConstrainedToType { get; }
5385internal FieldReferenceOperation(IFieldSymbol field, bool isDeclaration, IOperation? instance, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit)
5432public override ITypeSymbol? Type { get; }
5440internal MethodReferenceOperation(IMethodSymbol method, ITypeSymbol? constrainedToType, bool isVirtual, IOperation? instance, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
5449public override ITypeSymbol? ConstrainedToType { get; }
5488public override ITypeSymbol? Type { get; }
5496internal PropertyReferenceOperation(IPropertySymbol property, ITypeSymbol? constrainedToType, ImmutableArray<IArgumentOperation> arguments, IOperation? instance, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
5505public override ITypeSymbol? ConstrainedToType { get; }
5557public override ITypeSymbol? Type { get; }
5565internal EventReferenceOperation(IEventSymbol @event, ITypeSymbol? constrainedToType, IOperation? instance, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
5573public override ITypeSymbol? ConstrainedToType { get; }
5611public override ITypeSymbol? Type { get; }
5619internal UnaryOperation(UnaryOperatorKind operatorKind, IOperation operand, bool isLifted, bool isChecked, IMethodSymbol? operatorMethod, ITypeSymbol? constrainedToType, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit)
5636public ITypeSymbol? ConstrainedToType { get; }
5674public override ITypeSymbol? Type { get; }
5682internal 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)
5704public ITypeSymbol? ConstrainedToType { get; }
5752public override ITypeSymbol? Type { get; }
5760internal ConditionalOperation(IOperation condition, IOperation whenTrue, IOperation? whenFalse, bool isRef, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit)
5829public override ITypeSymbol? Type { get; }
5837internal CoalesceOperation(IOperation value, IOperation whenNull, IConvertibleConversion valueConversion, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit)
5896public override ITypeSymbol? Type { get; }
5949public override ITypeSymbol? Type => null;
5957internal ObjectCreationOperation(IMethodSymbol? constructor, IObjectOrCollectionInitializerOperation? initializer, ImmutableArray<IArgumentOperation> arguments, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit)
6019public override ITypeSymbol? Type { get; }
6027internal TypeParameterObjectCreationOperation(IObjectOrCollectionInitializerOperation? initializer, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
6071public override ITypeSymbol? Type { get; }
6079internal ArrayCreationOperation(ImmutableArray<IOperation> dimensionSizes, IArrayInitializerOperation? initializer, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
6138public override ITypeSymbol? Type { get; }
6146internal InstanceReferenceOperation(InstanceReferenceKind referenceKind, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
6157public override ITypeSymbol? Type { get; }
6165internal IsTypeOperation(IOperation valueOperand, ITypeSymbol typeOperand, bool isNegated, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
6174public ITypeSymbol TypeOperand { get; }
6213public override ITypeSymbol? Type { get; }
6221internal AwaitOperation(IOperation operation, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
6265public override ITypeSymbol? Type { get; }
6284internal SimpleAssignmentOperation(bool isRef, IOperation target, IOperation value, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit)
6338public override ITypeSymbol? Type { get; }
6346internal 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)
6366public ITypeSymbol? ConstrainedToType { get; }
6413public override ITypeSymbol? Type { get; }
6421internal ParenthesizedOperation(IOperation operand, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit)
6466public override ITypeSymbol? Type { get; }
6474internal EventAssignmentOperation(IOperation eventReference, IOperation handlerValue, bool adds, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
6531public override ITypeSymbol? Type { get; }
6539internal ConditionalAccessOperation(IOperation operation, IOperation whenNotNull, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
6594public override ITypeSymbol? Type { get; }
6602internal ConditionalAccessInstanceOperation(SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
6611public override ITypeSymbol? Type { get; }
6619internal InterpolatedStringOperation(ImmutableArray<IInterpolatedStringContentOperation> parts, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit)
6668public override ITypeSymbol? Type { get; }
6676internal AnonymousObjectCreationOperation(ImmutableArray<IOperation> initializers, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
6724public override ITypeSymbol? Type { get; }
6732internal ObjectOrCollectionInitializerOperation(ImmutableArray<IOperation> initializers, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
6780public override ITypeSymbol? Type { get; }
6788internal MemberInitializerOperation(IOperation initializedMember, IObjectOrCollectionInitializerOperation initializer, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
6843public override ITypeSymbol? Type { get; }
6851internal NameOfOperation(IOperation argument, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit)
6896public override ITypeSymbol? Type { get; }
6904internal TupleOperation(ImmutableArray<IOperation> elements, ITypeSymbol? naturalType, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
6912public ITypeSymbol? NaturalType { get; }
6954public override ITypeSymbol? Type { get; }
6962internal DynamicMemberReferenceOperation(IOperation? instance, string memberName, ImmutableArray<ITypeSymbol> typeArguments, ITypeSymbol? containingType, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
6973public ImmutableArray<ITypeSymbol> TypeArguments { get; }
6974public ITypeSymbol? ContainingType { get; }
7012public override ITypeSymbol? Type { get; }
7020internal TranslatedQueryOperation(IOperation operation, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
7064public override ITypeSymbol? Type { get; }
7072internal DelegateCreationOperation(IOperation target, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
7116public override ITypeSymbol? Type { get; }
7124internal DefaultValueOperation(SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit)
7134public override ITypeSymbol? Type { get; }
7142internal TypeOfOperation(ITypeSymbol typeOperand, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
7148public ITypeSymbol TypeOperand { get; }
7153public override ITypeSymbol? Type { get; }
7161internal SizeOfOperation(ITypeSymbol typeOperand, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit)
7168public ITypeSymbol TypeOperand { get; }
7173public override ITypeSymbol? Type { get; }
7181internal AddressOfOperation(IOperation reference, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
7225public override ITypeSymbol? Type { get; }
7233internal IsPatternOperation(IOperation value, IPatternOperation pattern, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
7288public override ITypeSymbol? Type { get; }
7296internal IncrementOrDecrementOperation(bool isPostfix, bool isLifted, bool isChecked, IOperation target, IMethodSymbol? operatorMethod, ITypeSymbol? constrainedToType, OperationKind kind, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
7313public ITypeSymbol? ConstrainedToType { get; }
7351public override ITypeSymbol? Type { get; }
7359internal ThrowOperation(IOperation? exception, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
7403public override ITypeSymbol? Type { get; }
7411internal DeconstructionAssignmentOperation(IOperation target, IOperation value, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
7462public override ITypeSymbol? Type { get; }
7470internal DeclarationExpressionOperation(IOperation expression, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
7514public override ITypeSymbol? Type { get; }
7522internal OmittedArgumentOperation(SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
7531public override ITypeSymbol? Type { get; }
7593public override ITypeSymbol? Type => null;
7640public override ITypeSymbol? Type => null;
7691public override ITypeSymbol? Type => null;
7742public override ITypeSymbol? Type => null;
7797public override ITypeSymbol? Type => null;
7865public override ITypeSymbol? Type => null;
7946public override ITypeSymbol? Type => null;
8007public override ITypeSymbol? Type => null;
8015internal CatchClauseOperation(IOperation? exceptionDeclarationOrExpression, ITypeSymbol exceptionType, ImmutableArray<ILocalSymbol> locals, IOperation? filter, IBlockOperation handler, SemanticModel? semanticModel, SyntaxNode syntax, bool isImplicit)
8025public ITypeSymbol ExceptionType { get; }
8084public override ITypeSymbol? Type => null;
8158public override ITypeSymbol? Type => null;
8182public override ITypeSymbol? Type => null;
8245public override ITypeSymbol? Type => null;
8307public override ITypeSymbol? Type => null;
8360public override ITypeSymbol? Type => null;
8411public override ITypeSymbol? Type => null;
8467public override ITypeSymbol? Type => null;
8540public override ITypeSymbol? Type => null;
8548protected BasePatternOperation(ITypeSymbol inputType, ITypeSymbol narrowedType, SemanticModel? semanticModel, SyntaxNode syntax, bool isImplicit)
8554public ITypeSymbol InputType { get; }
8555public ITypeSymbol NarrowedType { get; }
8559internal ConstantPatternOperation(IOperation value, ITypeSymbol inputType, ITypeSymbol narrowedType, SemanticModel? semanticModel, SyntaxNode syntax, bool isImplicit)
8602public override ITypeSymbol? Type => null;
8610internal DeclarationPatternOperation(ITypeSymbol? matchedType, bool matchesNull, ISymbol? declaredSymbol, ITypeSymbol inputType, ITypeSymbol narrowedType, SemanticModel? semanticModel, SyntaxNode syntax, bool isImplicit)
8617public ITypeSymbol? MatchedType { get; }
8624public override ITypeSymbol? Type => null;
8632internal TupleBinaryOperation(BinaryOperatorKind operatorKind, IOperation leftOperand, IOperation rightOperand, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
8689public override ITypeSymbol? Type { get; }
8756public override ITypeSymbol? Type => null;
8827public override ITypeSymbol? Type => null;
8835internal DiscardOperation(IDiscardSymbol discardSymbol, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
8846public override ITypeSymbol? Type { get; }
8899public override ITypeSymbol? Type => null;
8907internal FlowCaptureReferenceOperation(CaptureId id, bool isInitialization, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit)
8921public override ITypeSymbol? Type { get; }
8929internal IsNullOperation(IOperation operand, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, ConstantValue? constantValue, bool isImplicit)
8974public override ITypeSymbol? Type { get; }
8982internal CaughtExceptionOperation(SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
8991public override ITypeSymbol? Type { get; }
8999internal StaticLocalInitializationSemaphoreOperation(ILocalSymbol local, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
9010public override ITypeSymbol? Type { get; }
9018internal CoalesceAssignmentOperation(IOperation target, IOperation value, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
9069public override ITypeSymbol? Type { get; }
9077internal RangeOperation(IOperation? leftOperand, IOperation? rightOperand, bool isLifted, IMethodSymbol? method, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
9136public override ITypeSymbol? Type { get; }
9193public override ITypeSymbol? Type => null;
9259public override ITypeSymbol? Type => null;
9267internal RecursivePatternOperation(ITypeSymbol matchedType, ISymbol? deconstructSymbol, ImmutableArray<IPatternOperation> deconstructionSubpatterns, ImmutableArray<IPropertySubpatternOperation> propertySubpatterns, ISymbol? declaredSymbol, ITypeSymbol inputType, ITypeSymbol narrowedType, SemanticModel? semanticModel, SyntaxNode syntax, bool isImplicit)
9276public ITypeSymbol MatchedType { get; }
9335public override ITypeSymbol? Type => null;
9343internal DiscardPatternOperation(ITypeSymbol inputType, ITypeSymbol narrowedType, SemanticModel? semanticModel, SyntaxNode syntax, bool isImplicit)
9349public override ITypeSymbol? Type => null;
9357internal SwitchExpressionOperation(IOperation value, ImmutableArray<ISwitchExpressionArmOperation> arms, bool isExhaustive, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
9418public override ITypeSymbol? Type { get; }
9493public override ITypeSymbol? Type => null;
9555public override ITypeSymbol? Type => null;
9563internal AggregateQueryOperation(IOperation group, IOperation aggregation, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
9618public override ITypeSymbol? Type { get; }
9682public override ITypeSymbol? Type => null;
9690internal NoPiaObjectCreationOperation(IObjectOrCollectionInitializerOperation? initializer, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
9734public override ITypeSymbol? Type { get; }
9742internal PlaceholderOperation(PlaceholderKind placeholderKind, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
9753public override ITypeSymbol? Type { get; }
9815public override ITypeSymbol? Type => null;
9870public override ITypeSymbol? Type => null;
9878internal NegatedPatternOperation(IPatternOperation pattern, ITypeSymbol inputType, ITypeSymbol narrowedType, SemanticModel? semanticModel, SyntaxNode syntax, bool isImplicit)
9921public override ITypeSymbol? Type => null;
9929internal BinaryPatternOperation(BinaryOperatorKind operatorKind, IPatternOperation leftPattern, IPatternOperation rightPattern, ITypeSymbol inputType, ITypeSymbol narrowedType, SemanticModel? semanticModel, SyntaxNode syntax, bool isImplicit)
9985public override ITypeSymbol? Type => null;
9993internal TypePatternOperation(ITypeSymbol matchedType, ITypeSymbol inputType, ITypeSymbol narrowedType, SemanticModel? semanticModel, SyntaxNode syntax, bool isImplicit)
9998public ITypeSymbol MatchedType { get; }
10003public override ITypeSymbol? Type => null;
10011internal RelationalPatternOperation(BinaryOperatorKind operatorKind, IOperation value, ITypeSymbol inputType, ITypeSymbol narrowedType, SemanticModel? semanticModel, SyntaxNode syntax, bool isImplicit)
10056public override ITypeSymbol? Type => null;
10064internal WithOperation(IOperation operand, IMethodSymbol? cloneMethod, IObjectOrCollectionInitializerOperation initializer, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
10121public override ITypeSymbol? Type { get; }
10129internal InterpolatedStringHandlerCreationOperation(IOperation handlerCreation, bool handlerCreationHasSuccessParameter, bool handlerAppendCallsReturnBool, IOperation content, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
10188public override ITypeSymbol? Type { get; }
10250public override ITypeSymbol? Type => null;
10302public override ITypeSymbol? Type => null;
10322public override ITypeSymbol? Type => null;
10330internal FunctionPointerInvocationOperation(IOperation target, ImmutableArray<IArgumentOperation> arguments, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
10389public override ITypeSymbol? Type { get; }
10397internal ListPatternOperation(ISymbol? lengthSymbol, ISymbol? indexerSymbol, ImmutableArray<IPatternOperation> patterns, ISymbol? declaredSymbol, ITypeSymbol inputType, ITypeSymbol narrowedType, SemanticModel? semanticModel, SyntaxNode syntax, bool isImplicit)
10450public override ITypeSymbol? Type => null;
10458internal SlicePatternOperation(ISymbol? sliceSymbol, IPatternOperation? pattern, ITypeSymbol inputType, ITypeSymbol narrowedType, SemanticModel? semanticModel, SyntaxNode syntax, bool isImplicit)
10503public override ITypeSymbol? Type => null;
10511internal ImplicitIndexerReferenceOperation(IOperation instance, IOperation argument, ISymbol lengthSymbol, ISymbol indexerSymbol, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
10570public override ITypeSymbol? Type { get; }
10578internal Utf8StringOperation(string value, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
10589public override ITypeSymbol? Type { get; }
10640public override ITypeSymbol? Type => null;
10648internal InlineArrayAccessOperation(IOperation instance, IOperation argument, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
10703public override ITypeSymbol? Type { get; }
10711internal CollectionExpressionOperation(IMethodSymbol? constructMethod, ImmutableArray<IOperation> constructArguments, ImmutableArray<IOperation> elements, SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
10776public override ITypeSymbol? Type { get; }
10784internal SpreadOperation(IOperation operand, ITypeSymbol? elementType, IConvertibleConversion elementConversion, SemanticModel? semanticModel, SyntaxNode syntax, bool isImplicit)
10792public ITypeSymbol? ElementType { get; }
10832public override ITypeSymbol? Type => null;
10840internal CollectionExpressionElementsPlaceholderOperation(SemanticModel? semanticModel, SyntaxNode syntax, ITypeSymbol? type, bool isImplicit)
10849public override ITypeSymbol? Type { get; }
Operations\ControlFlowGraphBuilder.cs (21)
2458private IOperation CreateConversion(IOperation operand, ITypeSymbol type)
2990ITypeSymbol? valueTypeOpt = operationValue.Type;
3290private static IOperation MakeInvalidOperation(ITypeSymbol? type, IOperation child)
3297private static IOperation MakeInvalidOperation(SyntaxNode syntax, ITypeSymbol? type, IOperation child1, IOperation child2)
3302private static IOperation MakeInvalidOperation(SyntaxNode syntax, ITypeSymbol? type, ImmutableArray<IOperation> children)
3314private static IsNullOperation MakeIsNullOperation(IOperation operand, ITypeSymbol booleanType)
3332ITypeSymbol? valueType = value.Type;
3533ITypeSymbol? testExpressionType = testExpression.Type;
3787private void AddExceptionStore(ITypeSymbol exceptionType, IOperation? exceptionDeclarationOrExpression)
3963ITypeSymbol iDisposable = isAsynchronous
4114private void AddDisposingFinally(IOperation resource, bool requiresRuntimeConversion, ITypeSymbol iDisposable, IMethodSymbol? disposeMethod, ImmutableArray<IArgumentOperation> disposeArguments, bool isAsynchronous)
4206bool isNotNullableValueType([NotNullWhen(true)] ITypeSymbol? type)
4212private IOperation ConvertToIDisposable(IOperation operand, ITypeSymbol iDisposable, bool isTryCast = false)
4275ITypeSymbol objectType = _compilation.GetSpecialType(SpecialType.System_Object);
4539var iDisposable = isAsynchronous
4561IOperation applyConversion(IConvertibleConversion? conversionOpt, IOperation operand, ITypeSymbol? targetType)
4744ITypeSymbol booleanType = _compilation.GetSpecialType(SpecialType.System_Boolean);
4757ITypeSymbol? stepEnumUnderlyingTypeOrSelf = ITypeSymbolHelpers.GetEnumUnderlyingTypeOrSelf(operation.StepValue.Type);
4928ITypeSymbol? stepValueEnumUnderlyingTypeOrSelf = ITypeSymbolHelpers.GetEnumUnderlyingTypeOrSelf(stepValue.Type);
5664private IOperation MakeNullable(IOperation operand, ITypeSymbol type)
5834ITypeSymbol 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 (461)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (25)
102protected abstract TConversion ClassifyConversion(SemanticModel model, TExpressionSyntax expression, ITypeSymbol targetType);
103protected abstract TConversion ClassifyConversion(SemanticModel model, ITypeSymbol originalType, ITypeSymbol targetType);
105protected abstract bool ConversionsAreCompatible(TExpressionSyntax originalExpression, ITypeSymbol originalTargetType, TExpressionSyntax newExpression, ITypeSymbol newTargetType);
106protected abstract bool IsReferenceConversion(Compilation model, ITypeSymbol sourceType, ITypeSymbol targetType);
112SemanticModel model, TForEachStatementSyntax forEach, out IMethodSymbol getEnumeratorMethod, out ITypeSymbol elementType, out ImmutableArray<ILocalSymbol> localVariables);
305private bool ImplicitConversionsAreCompatible(TExpressionSyntax originalExpression, ITypeSymbol originalTargetType, TExpressionSyntax newExpression, ITypeSymbol newTargetType)
740var previousOriginalType = this.OriginalSemanticModel.GetTypeInfo(previousOriginalNode).Type;
741var previousReplacedType = this.SpeculativeSemanticModel.GetTypeInfo(previousReplacedNode).Type;
778GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
779GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
824var expressionType = this.SpeculativeSemanticModel.GetTypeInfo(newForEachStatementExpression, CancellationToken).ConvertedType;
847var originalThrowExpressionType = this.OriginalSemanticModel.GetTypeInfo(originalThrowExpression).Type;
849var newThrowExpressionType = this.SpeculativeSemanticModel.GetTypeInfo(newThrowExpression).Type;
959var originalTargetType = this.OriginalSemanticModel.GetTypeInfo(originalLeft).Type;
962var newTargetType = this.SpeculativeSemanticModel.GetTypeInfo(newLeft).Type;
995var newReceiverType = newReceiver != null
1034var receiverType = semanticModel.GetTypeInfo(receiver).Type;
1186ITypeSymbol originalTargetType,
1188ITypeSymbol newTargetType,
1203var originalConvertedTypeSymbol = this.OriginalSemanticModel.GetTypeInfo(originalExpression).ConvertedType;
1209var newConvertedTypeSymbol = this.SpeculativeSemanticModel.GetTypeInfo(newExpression).ConvertedType;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Symbols\ITypeSymbolExtensions.cs (101)
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)
244public static bool IsFormattableStringOrIFormattable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
253this ITypeSymbol typeSymbol, bool allowDelegateAndEnumConstraints = false)
281public static bool IsNumericType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
307public static Accessibility DetermineMinimalAccessibility(this ITypeSymbol typeSymbol)
310public static bool ContainsAnonymousType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
326foreach (var typeArg in type.GetAllTypeArguments())
335public static string CreateParameterName(this ITypeSymbol type, bool capitalize = false)
362private static string GetParameterName(ITypeSymbol? type)
375public static bool IsSpecialType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
406public static bool CanSupportCollectionInitializer(this ITypeSymbol typeSymbol, ISymbol within)
417public static INamedTypeSymbol? GetDelegateType(this ITypeSymbol? typeSymbol, Compilation compilation)
424var typeArgument = ((INamedTypeSymbol)typeSymbol).TypeArguments[0];
437public static IEnumerable<T> GetAccessibleMembersInBaseTypes<T>(this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol
446public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, ISymbol within) where T : class, ISymbol
456public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, string memberName, ISymbol within) where T : class, ISymbol
466public static bool? AreMoreSpecificThan(this IList<ITypeSymbol> t1, IList<ITypeSymbol> t2)
501public static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, ISymbol within) where T : class, ISymbol
511private static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, string memberName, ISymbol within) where T : class, ISymbol
521private static bool? IsMoreSpecificThan(this ITypeSymbol t1, ITypeSymbol t2)
599public static bool IsOrDerivesFromExceptionType([NotNullWhen(returnValue: true)] this ITypeSymbol? type, Compilation compilation)
606foreach (var baseType in type.GetBaseTypesAndThis())
617foreach (var constraint in ((ITypeParameterSymbol)type).ConstraintTypes)
632public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type)
635public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type, [NotNullWhen(true)] out INamedTypeSymbol? enumType)
647public static bool? IsMutableValueType(this ITypeSymbol type)
649if (type.IsNullable(out var underlyingType))
728static bool IsWellKnownImmutableValueType(ITypeSymbol type)
761public static bool IsDisposable([NotNullWhen(returnValue: true)] this ITypeSymbol? type, [NotNullWhen(returnValue: true)] ITypeSymbol? iDisposableType)
766public static ITypeSymbol WithNullableAnnotationFrom(this ITypeSymbol type, ITypeSymbol symbolForNullableAnnotation)
770public static ITypeSymbol? RemoveNullableIfPresent(this ITypeSymbol? symbol)
772if (symbol.IsNullable(out var underlyingType))
780public static bool IsSpanOrReadOnlySpan([NotNullWhen(true)] this ITypeSymbol? type)
783public static bool IsSpan([NotNullWhen(true)] this ITypeSymbol? type)
799public static bool IsInlineArray([NotNullWhen(true)] this ITypeSymbol? type)
804public static ITypeSymbol? RemoveUnavailableTypeParameters(
805this ITypeSymbol? type,
813private static ITypeSymbol? RemoveUnavailableTypeParameters(
814this ITypeSymbol? type,
822public static ITypeSymbol? RemoveAnonymousTypes(
823this ITypeSymbol? type,
830public static ITypeSymbol? RemoveUnnamedErrorTypes(
831this ITypeSymbol? type,
838this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
844this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
850this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result, bool onlyMethodTypeParameters)
859public static IList<ITypeParameterSymbol> GetReferencedTypeParameters(this ITypeSymbol? type)
867public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
868this ITypeSymbol? type,
871where TType1 : ITypeSymbol
872where TType2 : ITypeSymbol
878public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
879this ITypeSymbol? type,
882where TType1 : ITypeSymbol
883where 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 (414)
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)
102protected abstract TConversion ClassifyConversion(SemanticModel model, TExpressionSyntax expression, ITypeSymbol targetType);
103protected abstract TConversion ClassifyConversion(SemanticModel model, ITypeSymbol originalType, ITypeSymbol targetType);
105protected abstract bool ConversionsAreCompatible(TExpressionSyntax originalExpression, ITypeSymbol originalTargetType, TExpressionSyntax newExpression, ITypeSymbol newTargetType);
106protected abstract bool IsReferenceConversion(Compilation model, ITypeSymbol sourceType, ITypeSymbol targetType);
112SemanticModel model, TForEachStatementSyntax forEach, out IMethodSymbol getEnumeratorMethod, out ITypeSymbol elementType, out ImmutableArray<ILocalSymbol> localVariables);
305private bool ImplicitConversionsAreCompatible(TExpressionSyntax originalExpression, ITypeSymbol originalTargetType, TExpressionSyntax newExpression, ITypeSymbol newTargetType)
740var previousOriginalType = this.OriginalSemanticModel.GetTypeInfo(previousOriginalNode).Type;
741var previousReplacedType = this.SpeculativeSemanticModel.GetTypeInfo(previousReplacedNode).Type;
778GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
779GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
824var expressionType = this.SpeculativeSemanticModel.GetTypeInfo(newForEachStatementExpression, CancellationToken).ConvertedType;
847var originalThrowExpressionType = this.OriginalSemanticModel.GetTypeInfo(originalThrowExpression).Type;
849var newThrowExpressionType = this.SpeculativeSemanticModel.GetTypeInfo(newThrowExpression).Type;
959var originalTargetType = this.OriginalSemanticModel.GetTypeInfo(originalLeft).Type;
962var newTargetType = this.SpeculativeSemanticModel.GetTypeInfo(newLeft).Type;
995var newReceiverType = newReceiver != null
1034var receiverType = semanticModel.GetTypeInfo(receiver).Type;
1186ITypeSymbol originalTargetType,
1188ITypeSymbol newTargetType,
1203var originalConvertedTypeSymbol = this.OriginalSemanticModel.GetTypeInfo(originalExpression).ConvertedType;
1209var newConvertedTypeSymbol = this.SpeculativeSemanticModel.GetTypeInfo(newExpression).ConvertedType;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Symbols\ITypeSymbolExtensions.cs (101)
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)
244public static bool IsFormattableStringOrIFormattable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
253this ITypeSymbol typeSymbol, bool allowDelegateAndEnumConstraints = false)
281public static bool IsNumericType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
307public static Accessibility DetermineMinimalAccessibility(this ITypeSymbol typeSymbol)
310public static bool ContainsAnonymousType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
326foreach (var typeArg in type.GetAllTypeArguments())
335public static string CreateParameterName(this ITypeSymbol type, bool capitalize = false)
362private static string GetParameterName(ITypeSymbol? type)
375public static bool IsSpecialType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
406public static bool CanSupportCollectionInitializer(this ITypeSymbol typeSymbol, ISymbol within)
417public static INamedTypeSymbol? GetDelegateType(this ITypeSymbol? typeSymbol, Compilation compilation)
424var typeArgument = ((INamedTypeSymbol)typeSymbol).TypeArguments[0];
437public static IEnumerable<T> GetAccessibleMembersInBaseTypes<T>(this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol
446public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, ISymbol within) where T : class, ISymbol
456public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, string memberName, ISymbol within) where T : class, ISymbol
466public static bool? AreMoreSpecificThan(this IList<ITypeSymbol> t1, IList<ITypeSymbol> t2)
501public static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, ISymbol within) where T : class, ISymbol
511private static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, string memberName, ISymbol within) where T : class, ISymbol
521private static bool? IsMoreSpecificThan(this ITypeSymbol t1, ITypeSymbol t2)
599public static bool IsOrDerivesFromExceptionType([NotNullWhen(returnValue: true)] this ITypeSymbol? type, Compilation compilation)
606foreach (var baseType in type.GetBaseTypesAndThis())
617foreach (var constraint in ((ITypeParameterSymbol)type).ConstraintTypes)
632public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type)
635public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type, [NotNullWhen(true)] out INamedTypeSymbol? enumType)
647public static bool? IsMutableValueType(this ITypeSymbol type)
649if (type.IsNullable(out var underlyingType))
728static bool IsWellKnownImmutableValueType(ITypeSymbol type)
761public static bool IsDisposable([NotNullWhen(returnValue: true)] this ITypeSymbol? type, [NotNullWhen(returnValue: true)] ITypeSymbol? iDisposableType)
766public static ITypeSymbol WithNullableAnnotationFrom(this ITypeSymbol type, ITypeSymbol symbolForNullableAnnotation)
770public static ITypeSymbol? RemoveNullableIfPresent(this ITypeSymbol? symbol)
772if (symbol.IsNullable(out var underlyingType))
780public static bool IsSpanOrReadOnlySpan([NotNullWhen(true)] this ITypeSymbol? type)
783public static bool IsSpan([NotNullWhen(true)] this ITypeSymbol? type)
799public static bool IsInlineArray([NotNullWhen(true)] this ITypeSymbol? type)
804public static ITypeSymbol? RemoveUnavailableTypeParameters(
805this ITypeSymbol? type,
813private static ITypeSymbol? RemoveUnavailableTypeParameters(
814this ITypeSymbol? type,
822public static ITypeSymbol? RemoveAnonymousTypes(
823this ITypeSymbol? type,
830public static ITypeSymbol? RemoveUnnamedErrorTypes(
831this ITypeSymbol? type,
838this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
844this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
850this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result, bool onlyMethodTypeParameters)
859public static IList<ITypeParameterSymbol> GetReferencedTypeParameters(this ITypeSymbol? type)
867public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
868this ITypeSymbol? type,
871where TType1 : ITypeSymbol
872where TType2 : ITypeSymbol
878public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
879this ITypeSymbol? type,
882where TType1 : ITypeSymbol
883where TType2 : ITypeSymbol
Microsoft.CodeAnalysis.BannedApiAnalyzers (450)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (25)
102protected abstract TConversion ClassifyConversion(SemanticModel model, TExpressionSyntax expression, ITypeSymbol targetType);
103protected abstract TConversion ClassifyConversion(SemanticModel model, ITypeSymbol originalType, ITypeSymbol targetType);
105protected abstract bool ConversionsAreCompatible(TExpressionSyntax originalExpression, ITypeSymbol originalTargetType, TExpressionSyntax newExpression, ITypeSymbol newTargetType);
106protected abstract bool IsReferenceConversion(Compilation model, ITypeSymbol sourceType, ITypeSymbol targetType);
112SemanticModel model, TForEachStatementSyntax forEach, out IMethodSymbol getEnumeratorMethod, out ITypeSymbol elementType, out ImmutableArray<ILocalSymbol> localVariables);
305private bool ImplicitConversionsAreCompatible(TExpressionSyntax originalExpression, ITypeSymbol originalTargetType, TExpressionSyntax newExpression, ITypeSymbol newTargetType)
740var previousOriginalType = this.OriginalSemanticModel.GetTypeInfo(previousOriginalNode).Type;
741var previousReplacedType = this.SpeculativeSemanticModel.GetTypeInfo(previousReplacedNode).Type;
778GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
779GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
824var expressionType = this.SpeculativeSemanticModel.GetTypeInfo(newForEachStatementExpression, CancellationToken).ConvertedType;
847var originalThrowExpressionType = this.OriginalSemanticModel.GetTypeInfo(originalThrowExpression).Type;
849var newThrowExpressionType = this.SpeculativeSemanticModel.GetTypeInfo(newThrowExpression).Type;
959var originalTargetType = this.OriginalSemanticModel.GetTypeInfo(originalLeft).Type;
962var newTargetType = this.SpeculativeSemanticModel.GetTypeInfo(newLeft).Type;
995var newReceiverType = newReceiver != null
1034var receiverType = semanticModel.GetTypeInfo(receiver).Type;
1186ITypeSymbol originalTargetType,
1188ITypeSymbol newTargetType,
1203var originalConvertedTypeSymbol = this.OriginalSemanticModel.GetTypeInfo(originalExpression).ConvertedType;
1209var newConvertedTypeSymbol = this.SpeculativeSemanticModel.GetTypeInfo(newExpression).ConvertedType;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Symbols\ITypeSymbolExtensions.cs (101)
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)
244public static bool IsFormattableStringOrIFormattable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
253this ITypeSymbol typeSymbol, bool allowDelegateAndEnumConstraints = false)
281public static bool IsNumericType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
307public static Accessibility DetermineMinimalAccessibility(this ITypeSymbol typeSymbol)
310public static bool ContainsAnonymousType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
326foreach (var typeArg in type.GetAllTypeArguments())
335public static string CreateParameterName(this ITypeSymbol type, bool capitalize = false)
362private static string GetParameterName(ITypeSymbol? type)
375public static bool IsSpecialType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
406public static bool CanSupportCollectionInitializer(this ITypeSymbol typeSymbol, ISymbol within)
417public static INamedTypeSymbol? GetDelegateType(this ITypeSymbol? typeSymbol, Compilation compilation)
424var typeArgument = ((INamedTypeSymbol)typeSymbol).TypeArguments[0];
437public static IEnumerable<T> GetAccessibleMembersInBaseTypes<T>(this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol
446public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, ISymbol within) where T : class, ISymbol
456public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, string memberName, ISymbol within) where T : class, ISymbol
466public static bool? AreMoreSpecificThan(this IList<ITypeSymbol> t1, IList<ITypeSymbol> t2)
501public static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, ISymbol within) where T : class, ISymbol
511private static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, string memberName, ISymbol within) where T : class, ISymbol
521private static bool? IsMoreSpecificThan(this ITypeSymbol t1, ITypeSymbol t2)
599public static bool IsOrDerivesFromExceptionType([NotNullWhen(returnValue: true)] this ITypeSymbol? type, Compilation compilation)
606foreach (var baseType in type.GetBaseTypesAndThis())
617foreach (var constraint in ((ITypeParameterSymbol)type).ConstraintTypes)
632public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type)
635public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type, [NotNullWhen(true)] out INamedTypeSymbol? enumType)
647public static bool? IsMutableValueType(this ITypeSymbol type)
649if (type.IsNullable(out var underlyingType))
728static bool IsWellKnownImmutableValueType(ITypeSymbol type)
761public static bool IsDisposable([NotNullWhen(returnValue: true)] this ITypeSymbol? type, [NotNullWhen(returnValue: true)] ITypeSymbol? iDisposableType)
766public static ITypeSymbol WithNullableAnnotationFrom(this ITypeSymbol type, ITypeSymbol symbolForNullableAnnotation)
770public static ITypeSymbol? RemoveNullableIfPresent(this ITypeSymbol? symbol)
772if (symbol.IsNullable(out var underlyingType))
780public static bool IsSpanOrReadOnlySpan([NotNullWhen(true)] this ITypeSymbol? type)
783public static bool IsSpan([NotNullWhen(true)] this ITypeSymbol? type)
799public static bool IsInlineArray([NotNullWhen(true)] this ITypeSymbol? type)
804public static ITypeSymbol? RemoveUnavailableTypeParameters(
805this ITypeSymbol? type,
813private static ITypeSymbol? RemoveUnavailableTypeParameters(
814this ITypeSymbol? type,
822public static ITypeSymbol? RemoveAnonymousTypes(
823this ITypeSymbol? type,
830public static ITypeSymbol? RemoveUnnamedErrorTypes(
831this ITypeSymbol? type,
838this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
844this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
850this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result, bool onlyMethodTypeParameters)
859public static IList<ITypeParameterSymbol> GetReferencedTypeParameters(this ITypeSymbol? type)
867public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
868this ITypeSymbol? type,
871where TType1 : ITypeSymbol
872where TType2 : ITypeSymbol
878public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
879this ITypeSymbol? type,
882where TType1 : ITypeSymbol
883where 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 (332)
src\Analyzers\Core\Analyzers\RemoveUnusedParametersAndValues\AbstractRemoveUnusedParametersAndValuesDiagnosticAnalyzer.SymbolStartAnalyzer.cs (1)
292ITypeSymbol containingType,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (25)
102protected abstract TConversion ClassifyConversion(SemanticModel model, TExpressionSyntax expression, ITypeSymbol targetType);
103protected abstract TConversion ClassifyConversion(SemanticModel model, ITypeSymbol originalType, ITypeSymbol targetType);
105protected abstract bool ConversionsAreCompatible(TExpressionSyntax originalExpression, ITypeSymbol originalTargetType, TExpressionSyntax newExpression, ITypeSymbol newTargetType);
106protected abstract bool IsReferenceConversion(Compilation model, ITypeSymbol sourceType, ITypeSymbol targetType);
112SemanticModel model, TForEachStatementSyntax forEach, out IMethodSymbol getEnumeratorMethod, out ITypeSymbol elementType, out ImmutableArray<ILocalSymbol> localVariables);
305private bool ImplicitConversionsAreCompatible(TExpressionSyntax originalExpression, ITypeSymbol originalTargetType, TExpressionSyntax newExpression, ITypeSymbol newTargetType)
740var previousOriginalType = this.OriginalSemanticModel.GetTypeInfo(previousOriginalNode).Type;
741var previousReplacedType = this.SpeculativeSemanticModel.GetTypeInfo(previousReplacedNode).Type;
778GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
779GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
824var expressionType = this.SpeculativeSemanticModel.GetTypeInfo(newForEachStatementExpression, CancellationToken).ConvertedType;
847var originalThrowExpressionType = this.OriginalSemanticModel.GetTypeInfo(originalThrowExpression).Type;
849var newThrowExpressionType = this.SpeculativeSemanticModel.GetTypeInfo(newThrowExpression).Type;
959var originalTargetType = this.OriginalSemanticModel.GetTypeInfo(originalLeft).Type;
962var newTargetType = this.SpeculativeSemanticModel.GetTypeInfo(newLeft).Type;
995var newReceiverType = newReceiver != null
1034var receiverType = semanticModel.GetTypeInfo(receiver).Type;
1186ITypeSymbol originalTargetType,
1188ITypeSymbol newTargetType,
1203var originalConvertedTypeSymbol = this.OriginalSemanticModel.GetTypeInfo(originalExpression).ConvertedType;
1209var newConvertedTypeSymbol = this.SpeculativeSemanticModel.GetTypeInfo(newExpression).ConvertedType;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Symbols\ITypeSymbolExtensions.cs (101)
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)
244public static bool IsFormattableStringOrIFormattable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
253this ITypeSymbol typeSymbol, bool allowDelegateAndEnumConstraints = false)
281public static bool IsNumericType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
307public static Accessibility DetermineMinimalAccessibility(this ITypeSymbol typeSymbol)
310public static bool ContainsAnonymousType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
326foreach (var typeArg in type.GetAllTypeArguments())
335public static string CreateParameterName(this ITypeSymbol type, bool capitalize = false)
362private static string GetParameterName(ITypeSymbol? type)
375public static bool IsSpecialType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
406public static bool CanSupportCollectionInitializer(this ITypeSymbol typeSymbol, ISymbol within)
417public static INamedTypeSymbol? GetDelegateType(this ITypeSymbol? typeSymbol, Compilation compilation)
424var typeArgument = ((INamedTypeSymbol)typeSymbol).TypeArguments[0];
437public static IEnumerable<T> GetAccessibleMembersInBaseTypes<T>(this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol
446public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, ISymbol within) where T : class, ISymbol
456public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, string memberName, ISymbol within) where T : class, ISymbol
466public static bool? AreMoreSpecificThan(this IList<ITypeSymbol> t1, IList<ITypeSymbol> t2)
501public static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, ISymbol within) where T : class, ISymbol
511private static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, string memberName, ISymbol within) where T : class, ISymbol
521private static bool? IsMoreSpecificThan(this ITypeSymbol t1, ITypeSymbol t2)
599public static bool IsOrDerivesFromExceptionType([NotNullWhen(returnValue: true)] this ITypeSymbol? type, Compilation compilation)
606foreach (var baseType in type.GetBaseTypesAndThis())
617foreach (var constraint in ((ITypeParameterSymbol)type).ConstraintTypes)
632public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type)
635public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type, [NotNullWhen(true)] out INamedTypeSymbol? enumType)
647public static bool? IsMutableValueType(this ITypeSymbol type)
649if (type.IsNullable(out var underlyingType))
728static bool IsWellKnownImmutableValueType(ITypeSymbol type)
761public static bool IsDisposable([NotNullWhen(returnValue: true)] this ITypeSymbol? type, [NotNullWhen(returnValue: true)] ITypeSymbol? iDisposableType)
766public static ITypeSymbol WithNullableAnnotationFrom(this ITypeSymbol type, ITypeSymbol symbolForNullableAnnotation)
770public static ITypeSymbol? RemoveNullableIfPresent(this ITypeSymbol? symbol)
772if (symbol.IsNullable(out var underlyingType))
780public static bool IsSpanOrReadOnlySpan([NotNullWhen(true)] this ITypeSymbol? type)
783public static bool IsSpan([NotNullWhen(true)] this ITypeSymbol? type)
799public static bool IsInlineArray([NotNullWhen(true)] this ITypeSymbol? type)
804public static ITypeSymbol? RemoveUnavailableTypeParameters(
805this ITypeSymbol? type,
813private static ITypeSymbol? RemoveUnavailableTypeParameters(
814this ITypeSymbol? type,
822public static ITypeSymbol? RemoveAnonymousTypes(
823this ITypeSymbol? type,
830public static ITypeSymbol? RemoveUnnamedErrorTypes(
831this ITypeSymbol? type,
838this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
844this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
850this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result, bool onlyMethodTypeParameters)
859public static IList<ITypeParameterSymbol> GetReferencedTypeParameters(this ITypeSymbol? type)
867public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
868this ITypeSymbol? type,
871where TType1 : ITypeSymbol
872where TType2 : ITypeSymbol
878public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
879this ITypeSymbol? type,
882where TType1 : ITypeSymbol
883where TType2 : ITypeSymbol
Microsoft.CodeAnalysis.CodeStyle.Fixes (257)
src\Analyzers\Core\CodeFixes\AddExplicitCast\AbstractAddExplicitCastCodeFixProvider.cs (11)
29protected abstract TExpressionSyntax Cast(TExpressionSyntax expression, ITypeSymbol type);
47protected ImmutableArray<(TExpressionSyntax node, ITypeSymbol type)> GetPotentialTargetTypes(
51using var _ = ArrayBuilder<(TExpressionSyntax node, ITypeSymbol type)>.GetInstance(out var candidates);
62ArrayBuilder<(TExpressionSyntax node, ITypeSymbol type)> candidates,
118ITypeSymbol conversionType,
141var castType = semanticModel.GetTypeInfo(castTypeNode, cancellationToken).Type;
159protected virtual (SyntaxNode finalTarget, SyntaxNode finalReplacement) Cast(SemanticModel semanticModel, TExpressionSyntax targetNode, ITypeSymbol conversionType)
162private static string GetSubItemName(SemanticModel semanticModel, int position, ITypeSymbol conversionType)
169private static ImmutableArray<(TExpressionSyntax, ITypeSymbol)> FilterValidPotentialConversionTypes(
172ArrayBuilder<(TExpressionSyntax node, ITypeSymbol type)> candidates)
177using 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 (257)
Compilation\CSharpCompilation.cs (22)
1860protected override ITypeSymbol? CommonScriptGlobalsType
2388public Conversion ClassifyConversion(ITypeSymbol source, ITypeSymbol destination)
2422public override CommonConversion ClassifyCommonConversion(ITypeSymbol source, ITypeSymbol destination)
2428internal override IConvertibleConversion ClassifyConvertibleConversion(IOperation source, ITypeSymbol? destination, out ConstantValue? constantValue)
2437ITypeSymbol? sourceType = source.Type;
2496ITypeSymbol? throughType)
2512ITypeSymbol? throughType = null)
4161protected override IArrayTypeSymbol CommonCreateArrayTypeSymbol(ITypeSymbol elementType, int rank, CodeAnalysis.NullableAnnotation elementNullableAnnotation)
4166protected override IPointerTypeSymbol CommonCreatePointerTypeSymbol(ITypeSymbol elementType)
4172ITypeSymbol returnType,
4174ImmutableArray<ITypeSymbol> parameterTypes,
4269ImmutableArray<ITypeSymbol> elementTypes,
4277ITypeSymbol typeSymbol = elementTypes[i];
4324ImmutableArray<ITypeSymbol> memberTypes,
4358ITypeSymbol returnType,
4359ITypeSymbol leftType,
4360ITypeSymbol rightType)
4584ITypeSymbol returnType,
4585ITypeSymbol operandType)
4658protected override ITypeSymbol CommonDynamicType
Compilation\CSharpSemanticModel.cs (5)
579private static SymbolInfo GetSymbolInfoFromSymbolOrNone(ITypeSymbol type)
593private (ITypeSymbol Type, CodeAnalysis.NullableAnnotation Annotation) TypeFromVariable(SingleVariableDesignationSyntax variableDesignation, CancellationToken cancellationToken)
979var (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)
667return SymbolDisplay.ToDisplayString((ITypeSymbol)ISymbol, topLevelNullability, format);
672return SymbolDisplay.ToDisplayParts((ITypeSymbol)ISymbol, topLevelNullability, format);
681return SymbolDisplay.ToMinimalDisplayString((ITypeSymbol)ISymbol, topLevelNullability, semanticModel, position, format);
690return SymbolDisplay.ToMinimalDisplayParts((ITypeSymbol)ISymbol, topLevelNullability, semanticModel, position, format);
2512internal ITypeSymbol GetITypeSymbol(CodeAnalysis.NullableAnnotation nullableAnnotation)
2516return (ITypeSymbol)this.ISymbol;
2524protected abstract ITypeSymbol CreateITypeSymbol(CodeAnalysis.NullableAnnotation nullableAnnotation);
2536ITypeSymbol ITypeSymbolInternal.GetITypeSymbol()
Microsoft.CodeAnalysis.CSharp.Analyzers (4)
Microsoft.CodeAnalysis.CSharp.CodeStyle (137)
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 (34)
129var castedType = semanticModel.GetTypeInfo(castExpression.Type, cancellationToken).Type;
164var castedType = semanticModel.GetTypeInfo(castExpression.Type, cancellationToken).Type;
168var parentCastType = semanticModel.GetTypeInfo(parentCast.Type, cancellationToken).Type;
315var originalConvertedType = originalSemanticModel.GetTypeInfo(castNode.WalkUpParentheses(), cancellationToken).ConvertedType;
507var castedExpressionType = originalSemanticModel.GetTypeInfo(castedExpressionNode, cancellationToken).Type;
508var isType = originalSemanticModel.GetTypeInfo(isExpression.Right, cancellationToken).Type;
544var targetType = castNode.GetTargetType(originalSemanticModel, cancellationToken);
619ITypeSymbol originalConvertedType,
623var castedType = originalSemanticModel.GetTypeInfo(castNode, cancellationToken).Type;
698var castType = semanticModel.GetTypeInfo(castNode, cancellationToken).Type;
818var originalConvertedType = originalConversionOperation.Type;
819var rewrittenBitwiseNotConversionType = rewrittenBitwiseNotConversionOperation.Type;
832private static bool IsSignedIntegralOrIntPtrType(ITypeSymbol? type)
954var castType = originalSemanticModel.GetTypeInfo(castExpression, cancellationToken).Type;
988var otherSideType = originalSemanticModel.GetTypeInfo(otherSide, cancellationToken).Type;
989var thisSideRewrittenType = rewrittenSemanticModel.GetTypeInfo(rewrittenExpression, cancellationToken).Type;
1001var rewrittenConditionalConvertedType = rewrittenSemanticModel.GetTypeInfo(rewrittenConditionalOrSwitchExpression, cancellationToken).ConvertedType;
1036private static bool IsNullOrErrorType([NotNullWhen(false)] ITypeSymbol? type)
1159var castSideType = semanticModel.GetTypeInfo(castSide, cancellationToken).Type;
1160var castedExpressionType = semanticModel.GetTypeInfo(castExpression.Expression, cancellationToken).Type;
1162if (castSideType.IsNullable(out var underlyingType) && Equals(underlyingType, castedExpressionType))
1164var otherSideType = semanticModel.GetTypeInfo(otherSide, cancellationToken).Type;
1182var castType = semanticModel.GetTypeInfo(castNode, cancellationToken).Type;
1183var castedExpressionType = semanticModel.GetTypeInfo(castedExpressionNode, cancellationToken).Type;
1240private static bool IsFloatingPointType(ITypeSymbol? type)
1409var rewrittenType = rewrittenSemanticModel.GetTypeInfo(rewrittenExpression, cancellationToken).Type;
1524private static bool IsIntrinsicOrEnum(ITypeSymbol rewrittenType)
1532ITypeSymbol rewrittenType,
1571var originalMemberType = originalMemberSymbol.GetMemberType();
1572var rewrittenMemberType = rewrittenMemberSymbol.GetMemberType();
1622private static (ITypeSymbol? rewrittenConvertedType, Conversion rewrittenConversion) GetRewrittenInfo(
1625Conversion originalConversion, ITypeSymbol originalConvertedType,
1636var convertedType = originalConversion.IsIdentity ? originalConvertedType : originalSemanticModel.Compilation.ObjectType;
1640var rewrittenConvertedType = rewrittenSemanticModel.GetTypeInfo(rewrittenExpression, cancellationToken).ConvertedType;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\SpeculationAnalyzer.cs (18)
267var originalParamType = this.OriginalSemanticModel.GetDeclaredSymbol(originalParam).Type;
268var replacedParamType = this.SpeculativeSemanticModel.GetDeclaredSymbol(replacedParam).Type;
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 (167)
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 (11)
101var tupleTypeSymbol = GetConvertedType(semanticModel, typeSyntax.Parent, cancellationToken);
113var typeSymbol = GetConvertedType(semanticModel, typeSyntax, cancellationToken);
148var typeSymbol = GetConvertedType(semanticModel, typeSyntax, cancellationToken);
160private static ITypeSymbol AdjustNullabilityOfTypeSymbol(
163ITypeSymbol typeSymbol,
184ITypeSymbol typeSymbol,
196var type = elements[i].Type;
203var symbolType = localSymbol.GetSymbolType() ?? type;
234private static TypeSyntax GenerateTypeDeclaration(TypeSyntax typeSyntax, ITypeSymbol newTypeSymbol)
246private static ITypeSymbol GetConvertedType(SemanticModel semanticModel, SyntaxNode typeSyntax, CancellationToken cancellationToken)
248var typeSymbol = semanticModel.GetTypeInfo(typeSyntax, cancellationToken).ConvertedType;
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\ExpressionGenerator.cs (10)
34return typedConstant.Value is ITypeSymbol typeSymbol
54ITypeSymbol? type,
63if (type.IsNullable(out var underlyingType))
75internal static ExpressionSyntax GenerateNonEnumValueExpression(ITypeSymbol? type, object? value, bool canUseFieldReference)
126private static string DetermineSuffix(ITypeSymbol? type, object value)
180private static ExpressionSyntax GenerateDoubleLiteralExpression(ITypeSymbol? type, double value, bool canUseFieldReference)
209private static ExpressionSyntax GenerateSingleLiteralExpression(ITypeSymbol? type, float value, bool canUseFieldReference)
239ITypeSymbol? type, T value, IEnumerable<KeyValuePair<T, string>> constants,
250ITypeSymbol? type, T value, IEnumerable<KeyValuePair<T, string>> constants,
286private static ExpressionSyntax? GenerateFieldReference<T>(ITypeSymbol? type, T value, IEnumerable<KeyValuePair<T, string>> constants)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpTypeInferenceService.TypeInferrer.cs (38)
35protected override bool IsUnusableType(ITypeSymbol otherSideType)
620private static IMethodSymbol Instantiate(IMethodSymbol method, IList<ITypeSymbol> invocationTypes)
644IDictionary<ITypeParameterSymbol, ITypeSymbol> bestMap = null;
645foreach (var type in invocationTypes)
666private static Dictionary<ITypeParameterSymbol, ITypeSymbol> DetermineTypeParameterMapping(ITypeSymbol inferredType, ITypeSymbol returnType)
668var result = new Dictionary<ITypeParameterSymbol, ITypeSymbol>();
673private static void DetermineTypeParameterMapping(ITypeSymbol inferredType, ITypeSymbol returnType, Dictionary<ITypeParameterSymbol, ITypeSymbol> result)
1126return leftTypes.Select(x => x.InferredType.IsNullable(out var underlying)
1138static ITypeSymbol MakeNullable(ITypeSymbol symbol, Compilation compilation)
1245var collectionType = SemanticModel.GetTypeInfo(collectionExpression, CancellationToken).ConvertedType;
1249SemanticModel.Compilation, collectionType, out var elementType))
1526var type = this.SemanticModel.GetTypeInfo(recursivePattern).ConvertedType;
1645var elementTypesBuilder = ArrayBuilder<ITypeSymbol>.GetInstance(subPatternCount);
1670private static ImmutableArray<NullableAnnotation> GetNullableAnnotations(ImmutableArray<ITypeSymbol> elementTypes)
1841var typeArg = delegateType?.TypeArguments.Length > 0
1859private ITypeSymbol InferTypeForFirstParameterOfLambda(
1874private ITypeSymbol InferTypeForFirstParameterOfParenthesizedLambda(
1883private ITypeSymbol InferTypeForFirstParameterOfSimpleLambda(
1890private ITypeSymbol InferTypeForFirstParameterOfLambda(
1897private ITypeSymbol InferTypeForFirstParameterOfLambda(
1915var type = InferTypeForFirstParameterOfLambda(parameterName, child.AsNode());
2068var memberType = memberSymbol.GetMemberType();
2080private ITypeSymbol UnwrapTaskLike(ITypeSymbol type, bool isAsync)
2121var type = symbol.GetMemberType();
2260var type = symbol.GetSymbolType();
2349var tupleType = GetTupleType(tupleExpression);
2358private ITypeSymbol GetTupleType(
2372out ImmutableArray<ITypeSymbol> elementTypes,
2378using var _1 = ArrayBuilder<ITypeSymbol>.GetInstance(out var elementTypesBuilder);
2416ArrayBuilder<ITypeSymbol> elementTypesBuilder,
2438ArrayBuilder<ITypeSymbol> elementTypesBuilder,
2441var tupleType = GetTupleType(tuple);
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (11)
Microsoft.CodeAnalysis.CSharp.Emit.UnitTests (74)
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 (2)
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (32)
Microsoft.CodeAnalysis.CSharp.EndToEnd.UnitTests (1)
Microsoft.CodeAnalysis.CSharp.Features (253)
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 (11)
101var tupleTypeSymbol = GetConvertedType(semanticModel, typeSyntax.Parent, cancellationToken);
113var typeSymbol = GetConvertedType(semanticModel, typeSyntax, cancellationToken);
148var typeSymbol = GetConvertedType(semanticModel, typeSyntax, cancellationToken);
160private static ITypeSymbol AdjustNullabilityOfTypeSymbol(
163ITypeSymbol typeSymbol,
184ITypeSymbol typeSymbol,
196var type = elements[i].Type;
203var symbolType = localSymbol.GetSymbolType() ?? type;
234private static TypeSyntax GenerateTypeDeclaration(TypeSyntax typeSyntax, ITypeSymbol newTypeSymbol)
246private static ITypeSymbol GetConvertedType(SemanticModel semanticModel, SyntaxNode typeSyntax, CancellationToken cancellationToken)
248var typeSymbol = semanticModel.GetTypeInfo(typeSyntax, cancellationToken).ConvertedType;
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (72)
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (214)
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)
1526Assert.Throws<ArgumentNullException>("returnType", () => comp.CreateFunctionPointerTypeSymbol(returnType: null!, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty));
1528Assert.Throws<ArgumentNullException>("parameterTypes[0]", () => comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray.Create((ITypeSymbol?)null)!, parameterRefKinds: ImmutableArray.Create(RefKind.None)));
1529Assert.Throws<ArgumentNullException>("parameterRefKinds", () => comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: default));
1530Assert.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!)));
1531Assert.Throws<ArgumentException>(() => comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray.Create(RefKind.None)));
1532Assert.Throws<ArgumentException>(() => comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.Out, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty));
1533Assert.Throws<ArgumentOutOfRangeException>(() => comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty, callingConvention: (SignatureCallingConvention)10));
1534Assert.Throws<ArgumentException>(() => comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty, callingConvention: SignatureCallingConvention.Default, callingConventionTypes: ImmutableArray.Create(cdeclType)!));
1535Assert.Throws<ArgumentException>(() => comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty, callingConvention: SignatureCallingConvention.StdCall, callingConventionTypes: ImmutableArray.Create(cdeclType)!));
1536Assert.Throws<ArgumentException>(() => comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty, callingConvention: SignatureCallingConvention.FastCall, callingConventionTypes: ImmutableArray.Create(cdeclType)!));
1537Assert.Throws<ArgumentException>(() => comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty, callingConvention: SignatureCallingConvention.CDecl, callingConventionTypes: ImmutableArray.Create(cdeclType)!));
1538Assert.Throws<ArgumentException>(() => comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty, callingConvention: SignatureCallingConvention.ThisCall, callingConventionTypes: ImmutableArray.Create(cdeclType)!));
1539Assert.Throws<ArgumentException>(() => comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty, callingConvention: SignatureCallingConvention.Unmanaged, callingConventionTypes: ImmutableArray.Create(@string)!));
1547var ptr = comp.CreateFunctionPointerTypeSymbol(returnType: @string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty, callingConvention: SignatureCallingConvention.VarArgs);
1579ImmutableArray.Create((ITypeSymbol)@string),
1596ImmutableArray.Create((ITypeSymbol)@string),
1614ImmutableArray.Create((ITypeSymbol)@string),
1632var ptr = comp.CreateFunctionPointerTypeSymbol(@string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty, convention);
1634ptr = comp.CreateFunctionPointerTypeSymbol(@string, returnRefKind: RefKind.RefReadOnly, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty, convention);
1647var ptr = comp.CreateFunctionPointerTypeSymbol(@string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty, SignatureCallingConvention.Unmanaged, ImmutableArray.Create(cdeclType, stdcallType)!);
1649ptr = comp.CreateFunctionPointerTypeSymbol(@string, returnRefKind: RefKind.RefReadOnly, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty, SignatureCallingConvention.Unmanaged, ImmutableArray.Create(cdeclType, stdcallType)!);
1652ptr = comp.CreateFunctionPointerTypeSymbol(@string, returnRefKind: RefKind.None, parameterTypes: ImmutableArray<ITypeSymbol>.Empty, parameterRefKinds: ImmutableArray<RefKind>.Empty, SignatureCallingConvention.Unmanaged, ImmutableArray.Create(cdeclType)!);
1962parameterTypes: 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 (231)
Recommendations\CSharpRecommendationServiceRunner.cs (14)
51public override bool TryGetExplicitTypeOfLambdaParameter(SyntaxNode lambdaSyntax, int ordinalInLambda, [NotNullWhen(true)] out ITypeSymbol? explicitLambdaParameterType)
547if (name.ShouldNameExpressionBeTreatedAsExpressionInsteadOfType(_context.SemanticModel, out var nameBinding, out var container))
605var container = _context.SemanticModel.GetTypeInfo(identifier, _cancellationToken).Type;
655var container = _context.SemanticModel.GetTypeInfo(expression, _cancellationToken).Type;
665var container = _context.SemanticModel.GetTypeInfo(expression, _cancellationToken).Type;
680var container = _context.SemanticModel.GetTypeInfo(expression, _cancellationToken).Type;
696ITypeSymbol? containerType,
761private RecommendedSymbols GetSymbolsOffOfBoundExpressionWorker(SymbolInfo leftHandBinding, ExpressionSyntax originalExpression, ExpressionSyntax expression, ITypeSymbol? containerType, bool unwrapNullable, bool isForDereference)
869ITypeSymbol? containerType,
877if (symbol.IsStatic || symbol is ITypeSymbol)
906var container = GetContainerForUnnamedSymbols(semanticModel, originalExpression);
925private ITypeSymbol? GetContainerForUnnamedSymbols(SemanticModel semanticModel, ExpressionSyntax originalExpression)
927return originalExpression.ShouldNameExpressionBeTreatedAsExpressionInsteadOfType(_context.SemanticModel, out _, out var container)
932private 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 (34)
129var castedType = semanticModel.GetTypeInfo(castExpression.Type, cancellationToken).Type;
164var castedType = semanticModel.GetTypeInfo(castExpression.Type, cancellationToken).Type;
168var parentCastType = semanticModel.GetTypeInfo(parentCast.Type, cancellationToken).Type;
315var originalConvertedType = originalSemanticModel.GetTypeInfo(castNode.WalkUpParentheses(), cancellationToken).ConvertedType;
507var castedExpressionType = originalSemanticModel.GetTypeInfo(castedExpressionNode, cancellationToken).Type;
508var isType = originalSemanticModel.GetTypeInfo(isExpression.Right, cancellationToken).Type;
544var targetType = castNode.GetTargetType(originalSemanticModel, cancellationToken);
619ITypeSymbol originalConvertedType,
623var castedType = originalSemanticModel.GetTypeInfo(castNode, cancellationToken).Type;
698var castType = semanticModel.GetTypeInfo(castNode, cancellationToken).Type;
818var originalConvertedType = originalConversionOperation.Type;
819var rewrittenBitwiseNotConversionType = rewrittenBitwiseNotConversionOperation.Type;
832private static bool IsSignedIntegralOrIntPtrType(ITypeSymbol? type)
954var castType = originalSemanticModel.GetTypeInfo(castExpression, cancellationToken).Type;
988var otherSideType = originalSemanticModel.GetTypeInfo(otherSide, cancellationToken).Type;
989var thisSideRewrittenType = rewrittenSemanticModel.GetTypeInfo(rewrittenExpression, cancellationToken).Type;
1001var rewrittenConditionalConvertedType = rewrittenSemanticModel.GetTypeInfo(rewrittenConditionalOrSwitchExpression, cancellationToken).ConvertedType;
1036private static bool IsNullOrErrorType([NotNullWhen(false)] ITypeSymbol? type)
1159var castSideType = semanticModel.GetTypeInfo(castSide, cancellationToken).Type;
1160var castedExpressionType = semanticModel.GetTypeInfo(castExpression.Expression, cancellationToken).Type;
1162if (castSideType.IsNullable(out var underlyingType) && Equals(underlyingType, castedExpressionType))
1164var otherSideType = semanticModel.GetTypeInfo(otherSide, cancellationToken).Type;
1182var castType = semanticModel.GetTypeInfo(castNode, cancellationToken).Type;
1183var castedExpressionType = semanticModel.GetTypeInfo(castedExpressionNode, cancellationToken).Type;
1240private static bool IsFloatingPointType(ITypeSymbol? type)
1409var rewrittenType = rewrittenSemanticModel.GetTypeInfo(rewrittenExpression, cancellationToken).Type;
1524private static bool IsIntrinsicOrEnum(ITypeSymbol rewrittenType)
1532ITypeSymbol rewrittenType,
1571var originalMemberType = originalMemberSymbol.GetMemberType();
1572var rewrittenMemberType = rewrittenMemberSymbol.GetMemberType();
1622private static (ITypeSymbol? rewrittenConvertedType, Conversion rewrittenConversion) GetRewrittenInfo(
1625Conversion originalConversion, ITypeSymbol originalConvertedType,
1636var convertedType = originalConversion.IsIdentity ? originalConvertedType : originalSemanticModel.Compilation.ObjectType;
1640var rewrittenConvertedType = rewrittenSemanticModel.GetTypeInfo(rewrittenExpression, cancellationToken).ConvertedType;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\SpeculationAnalyzer.cs (18)
267var originalParamType = this.OriginalSemanticModel.GetDeclaredSymbol(originalParam).Type;
268var replacedParamType = this.SpeculativeSemanticModel.GetDeclaredSymbol(replacedParam).Type;
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 (10)
34return typedConstant.Value is ITypeSymbol typeSymbol
54ITypeSymbol? type,
63if (type.IsNullable(out var underlyingType))
75internal static ExpressionSyntax GenerateNonEnumValueExpression(ITypeSymbol? type, object? value, bool canUseFieldReference)
126private static string DetermineSuffix(ITypeSymbol? type, object value)
180private static ExpressionSyntax GenerateDoubleLiteralExpression(ITypeSymbol? type, double value, bool canUseFieldReference)
209private static ExpressionSyntax GenerateSingleLiteralExpression(ITypeSymbol? type, float value, bool canUseFieldReference)
239ITypeSymbol? type, T value, IEnumerable<KeyValuePair<T, string>> constants,
250ITypeSymbol? type, T value, IEnumerable<KeyValuePair<T, string>> constants,
286private static ExpressionSyntax? GenerateFieldReference<T>(ITypeSymbol? type, T value, IEnumerable<KeyValuePair<T, string>> constants)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpTypeInferenceService.TypeInferrer.cs (38)
35protected override bool IsUnusableType(ITypeSymbol otherSideType)
620private static IMethodSymbol Instantiate(IMethodSymbol method, IList<ITypeSymbol> invocationTypes)
644IDictionary<ITypeParameterSymbol, ITypeSymbol> bestMap = null;
645foreach (var type in invocationTypes)
666private static Dictionary<ITypeParameterSymbol, ITypeSymbol> DetermineTypeParameterMapping(ITypeSymbol inferredType, ITypeSymbol returnType)
668var result = new Dictionary<ITypeParameterSymbol, ITypeSymbol>();
673private static void DetermineTypeParameterMapping(ITypeSymbol inferredType, ITypeSymbol returnType, Dictionary<ITypeParameterSymbol, ITypeSymbol> result)
1126return leftTypes.Select(x => x.InferredType.IsNullable(out var underlying)
1138static ITypeSymbol MakeNullable(ITypeSymbol symbol, Compilation compilation)
1245var collectionType = SemanticModel.GetTypeInfo(collectionExpression, CancellationToken).ConvertedType;
1249SemanticModel.Compilation, collectionType, out var elementType))
1526var type = this.SemanticModel.GetTypeInfo(recursivePattern).ConvertedType;
1645var elementTypesBuilder = ArrayBuilder<ITypeSymbol>.GetInstance(subPatternCount);
1670private static ImmutableArray<NullableAnnotation> GetNullableAnnotations(ImmutableArray<ITypeSymbol> elementTypes)
1841var typeArg = delegateType?.TypeArguments.Length > 0
1859private ITypeSymbol InferTypeForFirstParameterOfLambda(
1874private ITypeSymbol InferTypeForFirstParameterOfParenthesizedLambda(
1883private ITypeSymbol InferTypeForFirstParameterOfSimpleLambda(
1890private ITypeSymbol InferTypeForFirstParameterOfLambda(
1897private ITypeSymbol InferTypeForFirstParameterOfLambda(
1915var type = InferTypeForFirstParameterOfLambda(parameterName, child.AsNode());
2068var memberType = memberSymbol.GetMemberType();
2080private ITypeSymbol UnwrapTaskLike(ITypeSymbol type, bool isAsync)
2121var type = symbol.GetMemberType();
2260var type = symbol.GetSymbolType();
2349var tupleType = GetTupleType(tupleExpression);
2358private ITypeSymbol GetTupleType(
2372out ImmutableArray<ITypeSymbol> elementTypes,
2378using var _1 = ArrayBuilder<ITypeSymbol>.GetInstance(out var elementTypesBuilder);
2416ArrayBuilder<ITypeSymbol> elementTypesBuilder,
2438ArrayBuilder<ITypeSymbol> elementTypesBuilder,
2441var 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 (211)
Symbols\ITypeSymbolExtensions.cs (101)
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)
244public static bool IsFormattableStringOrIFormattable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
253this ITypeSymbol typeSymbol, bool allowDelegateAndEnumConstraints = false)
281public static bool IsNumericType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
307public static Accessibility DetermineMinimalAccessibility(this ITypeSymbol typeSymbol)
310public static bool ContainsAnonymousType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
326foreach (var typeArg in type.GetAllTypeArguments())
335public static string CreateParameterName(this ITypeSymbol type, bool capitalize = false)
362private static string GetParameterName(ITypeSymbol? type)
375public static bool IsSpecialType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
406public static bool CanSupportCollectionInitializer(this ITypeSymbol typeSymbol, ISymbol within)
417public static INamedTypeSymbol? GetDelegateType(this ITypeSymbol? typeSymbol, Compilation compilation)
424var typeArgument = ((INamedTypeSymbol)typeSymbol).TypeArguments[0];
437public static IEnumerable<T> GetAccessibleMembersInBaseTypes<T>(this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol
446public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, ISymbol within) where T : class, ISymbol
456public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, string memberName, ISymbol within) where T : class, ISymbol
466public static bool? AreMoreSpecificThan(this IList<ITypeSymbol> t1, IList<ITypeSymbol> t2)
501public static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, ISymbol within) where T : class, ISymbol
511private static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, string memberName, ISymbol within) where T : class, ISymbol
521private static bool? IsMoreSpecificThan(this ITypeSymbol t1, ITypeSymbol t2)
599public static bool IsOrDerivesFromExceptionType([NotNullWhen(returnValue: true)] this ITypeSymbol? type, Compilation compilation)
606foreach (var baseType in type.GetBaseTypesAndThis())
617foreach (var constraint in ((ITypeParameterSymbol)type).ConstraintTypes)
632public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type)
635public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type, [NotNullWhen(true)] out INamedTypeSymbol? enumType)
647public static bool? IsMutableValueType(this ITypeSymbol type)
649if (type.IsNullable(out var underlyingType))
728static bool IsWellKnownImmutableValueType(ITypeSymbol type)
761public static bool IsDisposable([NotNullWhen(returnValue: true)] this ITypeSymbol? type, [NotNullWhen(returnValue: true)] ITypeSymbol? iDisposableType)
766public static ITypeSymbol WithNullableAnnotationFrom(this ITypeSymbol type, ITypeSymbol symbolForNullableAnnotation)
770public static ITypeSymbol? RemoveNullableIfPresent(this ITypeSymbol? symbol)
772if (symbol.IsNullable(out var underlyingType))
780public static bool IsSpanOrReadOnlySpan([NotNullWhen(true)] this ITypeSymbol? type)
783public static bool IsSpan([NotNullWhen(true)] this ITypeSymbol? type)
799public static bool IsInlineArray([NotNullWhen(true)] this ITypeSymbol? type)
804public static ITypeSymbol? RemoveUnavailableTypeParameters(
805this ITypeSymbol? type,
813private static ITypeSymbol? RemoveUnavailableTypeParameters(
814this ITypeSymbol? type,
822public static ITypeSymbol? RemoveAnonymousTypes(
823this ITypeSymbol? type,
830public static ITypeSymbol? RemoveUnnamedErrorTypes(
831this ITypeSymbol? type,
838this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
844this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
850this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result, bool onlyMethodTypeParameters)
859public static IList<ITypeParameterSymbol> GetReferencedTypeParameters(this ITypeSymbol? type)
867public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
868this ITypeSymbol? type,
871where TType1 : ITypeSymbol
872where TType2 : ITypeSymbol
878public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
879this ITypeSymbol? type,
882where TType1 : ITypeSymbol
883where TType2 : ITypeSymbol
Microsoft.CodeAnalysis.Features (493)
AddImport\SymbolReferenceFinder.cs (14)
205var typeSymbols = OfType<ITypeSymbol>(symbols);
232ITypeSymbol symbol,
311var propertyOrFieldType = symbol.GetSymbolType();
390(ITypeSymbol? receiverType, bool isStatic) GetReceiverType()
404return (semanticInfo.Type, isStatic: symbol is ITypeSymbol);
429var objectCreationType = _semanticModel.GetTypeInfo(objectCreationExpression, cancellationToken).Type;
449var type = _owner.GetQueryClauseInfo(_semanticModel, _node, cancellationToken);
473var type = GetAwaitInfo(_semanticModel, _syntaxFacts, _node);
495var type = GetCollectionExpressionType(_semanticModel, _syntaxFacts, _node);
517var type = GetCollectionExpressionType(_semanticModel, _syntaxFacts, _node);
539var type = _owner.GetDeconstructInfo(_semanticModel, _node, cancellationToken);
555SearchScope searchScope, string name, ITypeSymbol? type, Func<IMethodSymbol, bool>? predicate, CancellationToken cancellationToken)
575IMethodSymbol? method, ITypeSymbol? receiver, Func<IMethodSymbol, bool>? predicate)
607ISymbol? member, ITypeSymbol? receiver)
Completion\Providers\ImportCompletionProvider\AbstractTypeImportCompletionProvider.cs (1)
76Target: ITypeSymbol
Completion\Providers\ImportCompletionProvider\ExtensionMemberImportCompletionHelper.cs (9)
56ITypeSymbol receiverTypeSymbol,
59ImmutableArray<ITypeSymbol> targetTypesSymbols,
97ITypeSymbol receiverTypeSymbol,
100ImmutableArray<ITypeSymbol> targetTypes,
129Compilation compilation, ImmutableArray<ISymbol> extensionMemberSymbols, ImmutableArray<ITypeSymbol> targetTypeSymbols, CancellationToken cancellationToken)
131Dictionary<ITypeSymbol, bool> typeConvertibilityCache = [];
200Compilation compilation, ISymbol extensionSymbol, ImmutableArray<ITypeSymbol> targetTypeSymbols,
201Dictionary<ITypeSymbol, bool> typeConvertibilityCache)
203var returnType = extensionSymbol.GetMemberType();
Completion\Providers\ImportCompletionProvider\ExtensionMemberImportCompletionHelper.SymbolComputer.cs (16)
36private readonly ITypeSymbol _receiverTypeSymbol;
43private readonly ConcurrentDictionary<ITypeSymbol, bool> _checkedReceiverTypes = [];
48ITypeSymbol receiverTypeSymbol,
259MultiDictionary<ITypeSymbol, ISymbol> matchingMemberSymbols,
268var declaredReceiverTypeInOriginatingCompilation = SymbolFinder.FindSimilarSymbols(declaredReceiverType, _originatingSemanticModel.Compilation, cancellationToken).FirstOrDefault();
330MultiDictionary<ITypeSymbol, ISymbol> matchingMemberSymbols,
366private static ISymbol? TryReduceExtensionMember(ISymbol memberSymbol, ITypeSymbol receiverTypeSymbol)
397private MultiDictionary<ITypeSymbol, ISymbol> GetPotentialMatchingSymbolsFromAssembly(
403var builder = new MultiDictionary<ITypeSymbol, ISymbol>();
457if (MatchExtensionMember(memberSymbol, receiverTypeName, internalsVisible, out var receiverType))
490[NotNullWhen(true)] out ITypeSymbol? receiverType)
580private static ImmutableArray<string> GetReceiverTypeNames(ITypeSymbol receiverTypeSymbol)
586static void AddNamesForTypeWorker(ITypeSymbol receiverTypeSymbol, PooledHashSet<string> builder)
590foreach (var constraintType in typeParameter.ConstraintTypes)
624private static string GetReceiverTypeName(ITypeSymbol typeSymbol)
632var elementType = arrayType.ElementType;
Completion\Providers\ImportCompletionProvider\ExtensionMemberImportCompletionHelper.SymbolComputer_Constraints.cs (18)
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)
46foreach (var constraintType in currentTypeParameter.ConstraintTypes)
58foreach (var baseType in GetAllTypes(constraintType, typeKind, getInheritanceTypes))
66ITypeSymbol receiverTypeSymbol,
69Func<ITypeSymbol, IEnumerable<ITypeSymbol>> getInheritanceTypes)
76foreach (var constraintType in currentTypeParameter.ConstraintTypes)
88var originalConstraintType = constraintType.OriginalDefinition;
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))
234INamedTypeSymbol containingType, ITypeSymbol type, string memberName) where TSymbol : class, ISymbol
241INamedTypeSymbol containingType, ITypeSymbol type, string memberName) where TSymbol : class, ISymbol
247INamedTypeSymbol containingType, ITypeSymbol collectionType,
249[NotNullWhen(true)] out ITypeSymbol? iterationType)
284INamedTypeSymbol ienumeratorType, [NotNullWhen(true)] out ITypeSymbol? iterationType)
286var getEnumeratorReturnType = getEnumeratorMethod.ReturnType;
317ITypeSymbol collectionType,
318ITypeSymbol iterationType,
347var indexerType = GetIndexerType(containingType, collectionType, semanticModel.Compilation.GetSpecialType(SpecialType.System_Collections_Generic_IEnumerable_T));
501private static ITypeSymbol? GetIndexerType(
503ITypeSymbol collectionType,
ConvertIfToSwitch\AbstractConvertIfToSwitchCodeRefactoringProvider.Analyzer.cs (6)
52public abstract bool CanImplicitlyConvert(SemanticModel semanticModel, SyntaxNode syntax, ITypeSymbol targetType);
65private ITypeSymbol? _switchTargetType = null;
259var (e, v) when IsConstant(v) && CheckTargetExpression(e, out var switchTargetType) && CheckConstantType(v, switchTargetType) => ConstantResult.Right,
260var (v, e) when IsConstant(v) && CheckTargetExpression(e, out var switchTargetType) && CheckConstantType(v, switchTargetType) => ConstantResult.Left,
451private bool CheckTargetExpression(IOperation operation, [NotNullWhen(true)] out ITypeSymbol? switchTargetType)
474private bool CheckConstantType(IOperation operation, ITypeSymbol switchTargetType)
EditAndContinue\AbstractEditAndContinueAnalyzer.cs (13)
1962protected void AddRudeTypeUpdateAroundActiveStatement(RudeEditDiagnosticsBuilder diagnostics, SyntaxNode newNode, ITypeSymbol oldType, ITypeSymbol newType)
2145var oldType = oldModel.GetTypeInfo(oldTypedNodes[t], cancellationToken).Type;
2146var newType = newModel.GetTypeInfo(newTypedNodes[t], cancellationToken).Type;
2582protected static bool TypesEquivalent(ITypeSymbol? oldType, ITypeSymbol? newType, bool exact)
2583=> (exact ? s_exactSymbolEqualityComparer : (IEqualityComparer<ITypeSymbol?>)s_runtimeSymbolEqualityComparer.SignatureTypeEquivalenceComparer).Equals(oldType, newType);
2585protected static bool TypesEquivalent<T>(ImmutableArray<T> oldTypes, ImmutableArray<T> newTypes, bool exact) where T : ITypeSymbol
6643var oldType = GetType(oldSymbol);
6644var newType = GetType(newSymbol);
6731private static ITypeSymbol GetType(ISymbol localOrParameter)
6976TypedConstantKind.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)
29protected abstract TExpressionSyntax Cast(TExpressionSyntax expression, ITypeSymbol type);
47protected ImmutableArray<(TExpressionSyntax node, ITypeSymbol type)> GetPotentialTargetTypes(
51using var _ = ArrayBuilder<(TExpressionSyntax node, ITypeSymbol type)>.GetInstance(out var candidates);
62ArrayBuilder<(TExpressionSyntax node, ITypeSymbol type)> candidates,
118ITypeSymbol conversionType,
141var castType = semanticModel.GetTypeInfo(castTypeNode, cancellationToken).Type;
159protected virtual (SyntaxNode finalTarget, SyntaxNode finalReplacement) Cast(SemanticModel semanticModel, TExpressionSyntax targetNode, ITypeSymbol conversionType)
162private static string GetSubItemName(SemanticModel semanticModel, int position, ITypeSymbol conversionType)
169private static ImmutableArray<(TExpressionSyntax, ITypeSymbol)> FilterValidPotentialConversionTypes(
172ArrayBuilder<(TExpressionSyntax node, ITypeSymbol type)> candidates)
177using 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.Features.UnitTests (1)
Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers (444)
Microsoft.CodeAnalysis.PublicApiAnalyzers (321)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (25)
102protected abstract TConversion ClassifyConversion(SemanticModel model, TExpressionSyntax expression, ITypeSymbol targetType);
103protected abstract TConversion ClassifyConversion(SemanticModel model, ITypeSymbol originalType, ITypeSymbol targetType);
105protected abstract bool ConversionsAreCompatible(TExpressionSyntax originalExpression, ITypeSymbol originalTargetType, TExpressionSyntax newExpression, ITypeSymbol newTargetType);
106protected abstract bool IsReferenceConversion(Compilation model, ITypeSymbol sourceType, ITypeSymbol targetType);
112SemanticModel model, TForEachStatementSyntax forEach, out IMethodSymbol getEnumeratorMethod, out ITypeSymbol elementType, out ImmutableArray<ILocalSymbol> localVariables);
305private bool ImplicitConversionsAreCompatible(TExpressionSyntax originalExpression, ITypeSymbol originalTargetType, TExpressionSyntax newExpression, ITypeSymbol newTargetType)
740var previousOriginalType = this.OriginalSemanticModel.GetTypeInfo(previousOriginalNode).Type;
741var previousReplacedType = this.SpeculativeSemanticModel.GetTypeInfo(previousReplacedNode).Type;
778GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
779GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
824var expressionType = this.SpeculativeSemanticModel.GetTypeInfo(newForEachStatementExpression, CancellationToken).ConvertedType;
847var originalThrowExpressionType = this.OriginalSemanticModel.GetTypeInfo(originalThrowExpression).Type;
849var newThrowExpressionType = this.SpeculativeSemanticModel.GetTypeInfo(newThrowExpression).Type;
959var originalTargetType = this.OriginalSemanticModel.GetTypeInfo(originalLeft).Type;
962var newTargetType = this.SpeculativeSemanticModel.GetTypeInfo(newLeft).Type;
995var newReceiverType = newReceiver != null
1034var receiverType = semanticModel.GetTypeInfo(receiver).Type;
1186ITypeSymbol originalTargetType,
1188ITypeSymbol newTargetType,
1203var originalConvertedTypeSymbol = this.OriginalSemanticModel.GetTypeInfo(originalExpression).ConvertedType;
1209var newConvertedTypeSymbol = this.SpeculativeSemanticModel.GetTypeInfo(newExpression).ConvertedType;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Symbols\ITypeSymbolExtensions.cs (101)
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)
244public static bool IsFormattableStringOrIFormattable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
253this ITypeSymbol typeSymbol, bool allowDelegateAndEnumConstraints = false)
281public static bool IsNumericType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
307public static Accessibility DetermineMinimalAccessibility(this ITypeSymbol typeSymbol)
310public static bool ContainsAnonymousType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
326foreach (var typeArg in type.GetAllTypeArguments())
335public static string CreateParameterName(this ITypeSymbol type, bool capitalize = false)
362private static string GetParameterName(ITypeSymbol? type)
375public static bool IsSpecialType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
406public static bool CanSupportCollectionInitializer(this ITypeSymbol typeSymbol, ISymbol within)
417public static INamedTypeSymbol? GetDelegateType(this ITypeSymbol? typeSymbol, Compilation compilation)
424var typeArgument = ((INamedTypeSymbol)typeSymbol).TypeArguments[0];
437public static IEnumerable<T> GetAccessibleMembersInBaseTypes<T>(this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol
446public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, ISymbol within) where T : class, ISymbol
456public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, string memberName, ISymbol within) where T : class, ISymbol
466public static bool? AreMoreSpecificThan(this IList<ITypeSymbol> t1, IList<ITypeSymbol> t2)
501public static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, ISymbol within) where T : class, ISymbol
511private static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, string memberName, ISymbol within) where T : class, ISymbol
521private static bool? IsMoreSpecificThan(this ITypeSymbol t1, ITypeSymbol t2)
599public static bool IsOrDerivesFromExceptionType([NotNullWhen(returnValue: true)] this ITypeSymbol? type, Compilation compilation)
606foreach (var baseType in type.GetBaseTypesAndThis())
617foreach (var constraint in ((ITypeParameterSymbol)type).ConstraintTypes)
632public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type)
635public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type, [NotNullWhen(true)] out INamedTypeSymbol? enumType)
647public static bool? IsMutableValueType(this ITypeSymbol type)
649if (type.IsNullable(out var underlyingType))
728static bool IsWellKnownImmutableValueType(ITypeSymbol type)
761public static bool IsDisposable([NotNullWhen(returnValue: true)] this ITypeSymbol? type, [NotNullWhen(returnValue: true)] ITypeSymbol? iDisposableType)
766public static ITypeSymbol WithNullableAnnotationFrom(this ITypeSymbol type, ITypeSymbol symbolForNullableAnnotation)
770public static ITypeSymbol? RemoveNullableIfPresent(this ITypeSymbol? symbol)
772if (symbol.IsNullable(out var underlyingType))
780public static bool IsSpanOrReadOnlySpan([NotNullWhen(true)] this ITypeSymbol? type)
783public static bool IsSpan([NotNullWhen(true)] this ITypeSymbol? type)
799public static bool IsInlineArray([NotNullWhen(true)] this ITypeSymbol? type)
804public static ITypeSymbol? RemoveUnavailableTypeParameters(
805this ITypeSymbol? type,
813private static ITypeSymbol? RemoveUnavailableTypeParameters(
814this ITypeSymbol? type,
822public static ITypeSymbol? RemoveAnonymousTypes(
823this ITypeSymbol? type,
830public static ITypeSymbol? RemoveUnnamedErrorTypes(
831this ITypeSymbol? type,
838this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
844this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
850this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result, bool onlyMethodTypeParameters)
859public static IList<ITypeParameterSymbol> GetReferencedTypeParameters(this ITypeSymbol? type)
867public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
868this ITypeSymbol? type,
871where TType1 : ITypeSymbol
872where TType2 : ITypeSymbol
878public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
879this ITypeSymbol? type,
882where TType1 : ITypeSymbol
883where TType2 : ITypeSymbol
Microsoft.CodeAnalysis.Remote.ServiceHub (2)
Microsoft.CodeAnalysis.ResxSourceGenerator (315)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (25)
102protected abstract TConversion ClassifyConversion(SemanticModel model, TExpressionSyntax expression, ITypeSymbol targetType);
103protected abstract TConversion ClassifyConversion(SemanticModel model, ITypeSymbol originalType, ITypeSymbol targetType);
105protected abstract bool ConversionsAreCompatible(TExpressionSyntax originalExpression, ITypeSymbol originalTargetType, TExpressionSyntax newExpression, ITypeSymbol newTargetType);
106protected abstract bool IsReferenceConversion(Compilation model, ITypeSymbol sourceType, ITypeSymbol targetType);
112SemanticModel model, TForEachStatementSyntax forEach, out IMethodSymbol getEnumeratorMethod, out ITypeSymbol elementType, out ImmutableArray<ILocalSymbol> localVariables);
305private bool ImplicitConversionsAreCompatible(TExpressionSyntax originalExpression, ITypeSymbol originalTargetType, TExpressionSyntax newExpression, ITypeSymbol newTargetType)
740var previousOriginalType = this.OriginalSemanticModel.GetTypeInfo(previousOriginalNode).Type;
741var previousReplacedType = this.SpeculativeSemanticModel.GetTypeInfo(previousReplacedNode).Type;
778GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
779GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
824var expressionType = this.SpeculativeSemanticModel.GetTypeInfo(newForEachStatementExpression, CancellationToken).ConvertedType;
847var originalThrowExpressionType = this.OriginalSemanticModel.GetTypeInfo(originalThrowExpression).Type;
849var newThrowExpressionType = this.SpeculativeSemanticModel.GetTypeInfo(newThrowExpression).Type;
959var originalTargetType = this.OriginalSemanticModel.GetTypeInfo(originalLeft).Type;
962var newTargetType = this.SpeculativeSemanticModel.GetTypeInfo(newLeft).Type;
995var newReceiverType = newReceiver != null
1034var receiverType = semanticModel.GetTypeInfo(receiver).Type;
1186ITypeSymbol originalTargetType,
1188ITypeSymbol newTargetType,
1203var originalConvertedTypeSymbol = this.OriginalSemanticModel.GetTypeInfo(originalExpression).ConvertedType;
1209var newConvertedTypeSymbol = this.SpeculativeSemanticModel.GetTypeInfo(newExpression).ConvertedType;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Symbols\ITypeSymbolExtensions.cs (101)
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)
244public static bool IsFormattableStringOrIFormattable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
253this ITypeSymbol typeSymbol, bool allowDelegateAndEnumConstraints = false)
281public static bool IsNumericType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
307public static Accessibility DetermineMinimalAccessibility(this ITypeSymbol typeSymbol)
310public static bool ContainsAnonymousType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
326foreach (var typeArg in type.GetAllTypeArguments())
335public static string CreateParameterName(this ITypeSymbol type, bool capitalize = false)
362private static string GetParameterName(ITypeSymbol? type)
375public static bool IsSpecialType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
406public static bool CanSupportCollectionInitializer(this ITypeSymbol typeSymbol, ISymbol within)
417public static INamedTypeSymbol? GetDelegateType(this ITypeSymbol? typeSymbol, Compilation compilation)
424var typeArgument = ((INamedTypeSymbol)typeSymbol).TypeArguments[0];
437public static IEnumerable<T> GetAccessibleMembersInBaseTypes<T>(this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol
446public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, ISymbol within) where T : class, ISymbol
456public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, string memberName, ISymbol within) where T : class, ISymbol
466public static bool? AreMoreSpecificThan(this IList<ITypeSymbol> t1, IList<ITypeSymbol> t2)
501public static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, ISymbol within) where T : class, ISymbol
511private static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, string memberName, ISymbol within) where T : class, ISymbol
521private static bool? IsMoreSpecificThan(this ITypeSymbol t1, ITypeSymbol t2)
599public static bool IsOrDerivesFromExceptionType([NotNullWhen(returnValue: true)] this ITypeSymbol? type, Compilation compilation)
606foreach (var baseType in type.GetBaseTypesAndThis())
617foreach (var constraint in ((ITypeParameterSymbol)type).ConstraintTypes)
632public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type)
635public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type, [NotNullWhen(true)] out INamedTypeSymbol? enumType)
647public static bool? IsMutableValueType(this ITypeSymbol type)
649if (type.IsNullable(out var underlyingType))
728static bool IsWellKnownImmutableValueType(ITypeSymbol type)
761public static bool IsDisposable([NotNullWhen(returnValue: true)] this ITypeSymbol? type, [NotNullWhen(returnValue: true)] ITypeSymbol? iDisposableType)
766public static ITypeSymbol WithNullableAnnotationFrom(this ITypeSymbol type, ITypeSymbol symbolForNullableAnnotation)
770public static ITypeSymbol? RemoveNullableIfPresent(this ITypeSymbol? symbol)
772if (symbol.IsNullable(out var underlyingType))
780public static bool IsSpanOrReadOnlySpan([NotNullWhen(true)] this ITypeSymbol? type)
783public static bool IsSpan([NotNullWhen(true)] this ITypeSymbol? type)
799public static bool IsInlineArray([NotNullWhen(true)] this ITypeSymbol? type)
804public static ITypeSymbol? RemoveUnavailableTypeParameters(
805this ITypeSymbol? type,
813private static ITypeSymbol? RemoveUnavailableTypeParameters(
814this ITypeSymbol? type,
822public static ITypeSymbol? RemoveAnonymousTypes(
823this ITypeSymbol? type,
830public static ITypeSymbol? RemoveUnnamedErrorTypes(
831this ITypeSymbol? type,
838this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
844this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
850this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result, bool onlyMethodTypeParameters)
859public static IList<ITypeParameterSymbol> GetReferencedTypeParameters(this ITypeSymbol? type)
867public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
868this ITypeSymbol? type,
871where TType1 : ITypeSymbol
872where TType2 : ITypeSymbol
878public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
879this ITypeSymbol? type,
882where TType1 : ITypeSymbol
883where 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 (155)
Compilation\VisualBasicCompilation.vb (21)
867Protected Overrides ReadOnly Property CommonScriptGlobalsType As ITypeSymbol
1877Public Shadows Function ClassifyConversion(source As ITypeSymbol, destination As ITypeSymbol) As Conversion
1896Public Overrides Function ClassifyCommonConversion(source As ITypeSymbol, destination As ITypeSymbol) As CommonConversion
1900Friend Overrides Function ClassifyConvertibleConversion(source As IOperation, destination As ITypeSymbol, ByRef constantValue As ConstantValue) As IConvertibleConversion
1907Dim sourceType As ITypeSymbol = source.Type
2020Private Protected Overrides Function IsSymbolAccessibleWithinCore(symbol As ISymbol, within As ISymbol, throughType As ITypeSymbol) As Boolean
2030Friend Shadows Function IsSymbolAccessibleWithin(symbol As ISymbol, within As ISymbol, Optional throughType As ITypeSymbol = Nothing) As Boolean
2875Protected Overrides Function CommonCreateArrayTypeSymbol(elementType As ITypeSymbol, rank As Integer, elementNullableAnnotation As NullableAnnotation) As IArrayTypeSymbol
2879Protected Overrides Function CommonCreateTupleTypeSymbol(elementTypes As ImmutableArray(Of ITypeSymbol),
2920Protected Overrides Function CommonCreatePointerTypeSymbol(elementType As ITypeSymbol) As IPointerTypeSymbol
2925returnType As ITypeSymbol,
2927parameterTypes As ImmutableArray(Of ITypeSymbol),
2939memberTypes As ImmutableArray(Of ITypeSymbol),
2969returnType As ITypeSymbol,
2970leftType As ITypeSymbol,
2971rightType As ITypeSymbol) As IMethodSymbol
3053returnType As ITypeSymbol,
3054operandType As ITypeSymbol) As IMethodSymbol
3103Protected 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
787Private ReadOnly Property ITypeSymbol_IsExtension As Boolean Implements ITypeSymbol.IsExtension
794Private ReadOnly Property ITypeSymbol_ExtensionParameter As IParameterSymbol Implements ITypeSymbol.ExtensionParameter
Microsoft.CodeAnalysis.Workspaces (488)
Editing\SyntaxGenerator.cs (20)
338private protected abstract SyntaxNode GenerateExpression(ITypeSymbol? type, object? value, bool canUseFieldReference);
1659/// <see langword="true"/> if the language requires a <see cref="TypeExpression(ITypeSymbol)"/>
1661/// <see cref="LocalDeclarationStatement(ITypeSymbol, string, SyntaxNode, bool)"/>.
1684public SyntaxNode LocalDeclarationStatement(ITypeSymbol type, string name, SyntaxNode? initializer = null, bool isConst = false)
1797public SyntaxNode CatchClause(ITypeSymbol type, string identifier, IEnumerable<SyntaxNode> statements)
1838public SyntaxNode DefaultExpression(ITypeSymbol type)
1907public SyntaxNode GenericName(string identifier, IEnumerable<ITypeSymbol> typeArguments)
1919public SyntaxNode GenericName(string identifier, params ITypeSymbol[] typeArguments)
1920=> GenericName(identifier, (IEnumerable<ITypeSymbol>)typeArguments);
1988public SyntaxNode TypeExpression(ITypeSymbol typeSymbol)
1996public SyntaxNode TypeExpression(ITypeSymbol typeSymbol, bool addImport)
2048public SyntaxNode TupleTypeExpression(IEnumerable<ITypeSymbol> elementTypes, IEnumerable<string>? elementNames = null)
2077public SyntaxNode TupleElementExpression(ITypeSymbol type, string? name = null)
2260public SyntaxNode ObjectCreationExpression(ITypeSymbol type, IEnumerable<SyntaxNode> arguments)
2272public SyntaxNode ObjectCreationExpression(ITypeSymbol type, params SyntaxNode[] arguments)
2327public SyntaxNode IsTypeExpression(SyntaxNode expression, ITypeSymbol type)
2338public SyntaxNode TryCastExpression(SyntaxNode expression, ITypeSymbol type)
2350public SyntaxNode CastExpression(ITypeSymbol type, SyntaxNode expression)
2362public SyntaxNode ConvertExpression(ITypeSymbol type, SyntaxNode expression)
2441public 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)
102protected abstract TConversion ClassifyConversion(SemanticModel model, TExpressionSyntax expression, ITypeSymbol targetType);
103protected abstract TConversion ClassifyConversion(SemanticModel model, ITypeSymbol originalType, ITypeSymbol targetType);
105protected abstract bool ConversionsAreCompatible(TExpressionSyntax originalExpression, ITypeSymbol originalTargetType, TExpressionSyntax newExpression, ITypeSymbol newTargetType);
106protected abstract bool IsReferenceConversion(Compilation model, ITypeSymbol sourceType, ITypeSymbol targetType);
112SemanticModel model, TForEachStatementSyntax forEach, out IMethodSymbol getEnumeratorMethod, out ITypeSymbol elementType, out ImmutableArray<ILocalSymbol> localVariables);
305private bool ImplicitConversionsAreCompatible(TExpressionSyntax originalExpression, ITypeSymbol originalTargetType, TExpressionSyntax newExpression, ITypeSymbol newTargetType)
740var previousOriginalType = this.OriginalSemanticModel.GetTypeInfo(previousOriginalNode).Type;
741var previousReplacedType = this.SpeculativeSemanticModel.GetTypeInfo(previousReplacedNode).Type;
778GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
779GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
824var expressionType = this.SpeculativeSemanticModel.GetTypeInfo(newForEachStatementExpression, CancellationToken).ConvertedType;
847var originalThrowExpressionType = this.OriginalSemanticModel.GetTypeInfo(originalThrowExpression).Type;
849var newThrowExpressionType = this.SpeculativeSemanticModel.GetTypeInfo(newThrowExpression).Type;
959var originalTargetType = this.OriginalSemanticModel.GetTypeInfo(originalLeft).Type;
962var newTargetType = this.SpeculativeSemanticModel.GetTypeInfo(newLeft).Type;
995var newReceiverType = newReceiver != null
1034var receiverType = semanticModel.GetTypeInfo(receiver).Type;
1186ITypeSymbol originalTargetType,
1188ITypeSymbol newTargetType,
1203var originalConvertedTypeSymbol = this.OriginalSemanticModel.GetTypeInfo(originalExpression).ConvertedType;
1209var newConvertedTypeSymbol = this.SpeculativeSemanticModel.GetTypeInfo(newExpression).ConvertedType;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Symbols\ITypeSymbolExtensions.cs (101)
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)
244public static bool IsFormattableStringOrIFormattable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
253this ITypeSymbol typeSymbol, bool allowDelegateAndEnumConstraints = false)
281public static bool IsNumericType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
307public static Accessibility DetermineMinimalAccessibility(this ITypeSymbol typeSymbol)
310public static bool ContainsAnonymousType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
326foreach (var typeArg in type.GetAllTypeArguments())
335public static string CreateParameterName(this ITypeSymbol type, bool capitalize = false)
362private static string GetParameterName(ITypeSymbol? type)
375public static bool IsSpecialType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
406public static bool CanSupportCollectionInitializer(this ITypeSymbol typeSymbol, ISymbol within)
417public static INamedTypeSymbol? GetDelegateType(this ITypeSymbol? typeSymbol, Compilation compilation)
424var typeArgument = ((INamedTypeSymbol)typeSymbol).TypeArguments[0];
437public static IEnumerable<T> GetAccessibleMembersInBaseTypes<T>(this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol
446public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, ISymbol within) where T : class, ISymbol
456public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, string memberName, ISymbol within) where T : class, ISymbol
466public static bool? AreMoreSpecificThan(this IList<ITypeSymbol> t1, IList<ITypeSymbol> t2)
501public static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, ISymbol within) where T : class, ISymbol
511private static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, string memberName, ISymbol within) where T : class, ISymbol
521private static bool? IsMoreSpecificThan(this ITypeSymbol t1, ITypeSymbol t2)
599public static bool IsOrDerivesFromExceptionType([NotNullWhen(returnValue: true)] this ITypeSymbol? type, Compilation compilation)
606foreach (var baseType in type.GetBaseTypesAndThis())
617foreach (var constraint in ((ITypeParameterSymbol)type).ConstraintTypes)
632public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type)
635public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type, [NotNullWhen(true)] out INamedTypeSymbol? enumType)
647public static bool? IsMutableValueType(this ITypeSymbol type)
649if (type.IsNullable(out var underlyingType))
728static bool IsWellKnownImmutableValueType(ITypeSymbol type)
761public static bool IsDisposable([NotNullWhen(returnValue: true)] this ITypeSymbol? type, [NotNullWhen(returnValue: true)] ITypeSymbol? iDisposableType)
766public static ITypeSymbol WithNullableAnnotationFrom(this ITypeSymbol type, ITypeSymbol symbolForNullableAnnotation)
770public static ITypeSymbol? RemoveNullableIfPresent(this ITypeSymbol? symbol)
772if (symbol.IsNullable(out var underlyingType))
780public static bool IsSpanOrReadOnlySpan([NotNullWhen(true)] this ITypeSymbol? type)
783public static bool IsSpan([NotNullWhen(true)] this ITypeSymbol? type)
799public static bool IsInlineArray([NotNullWhen(true)] this ITypeSymbol? type)
804public static ITypeSymbol? RemoveUnavailableTypeParameters(
805this ITypeSymbol? type,
813private static ITypeSymbol? RemoveUnavailableTypeParameters(
814this ITypeSymbol? type,
822public static ITypeSymbol? RemoveAnonymousTypes(
823this ITypeSymbol? type,
830public static ITypeSymbol? RemoveUnnamedErrorTypes(
831this ITypeSymbol? type,
838this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
844this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
850this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result, bool onlyMethodTypeParameters)
859public static IList<ITypeParameterSymbol> GetReferencedTypeParameters(this ITypeSymbol? type)
867public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
868this ITypeSymbol? type,
871where TType1 : ITypeSymbol
872where TType2 : ITypeSymbol
878public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
879this ITypeSymbol? type,
882where TType1 : ITypeSymbol
883where 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 (5)
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 (58)
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)
src\Shared\RoslynUtils\SymbolExtensions.cs (21)
19public static ITypeSymbol UnwrapTypeSymbol(this ITypeSymbol typeSymbol, bool unwrapArray = false, bool unwrapNullable = false)
42public static IEnumerable<ITypeSymbol> GetThisAndBaseTypes(this ITypeSymbol? type)
44var current = type;
70public static bool HasAttribute(this ITypeSymbol typeSymbol, INamedTypeSymbol attributeSymbol)
72var current = typeSymbol;
174public static bool Implements(this ITypeSymbol type, ITypeSymbol interfaceType)
186public static bool InheritsFrom(this ITypeSymbol type, ITypeSymbol baseType)
188foreach (var t in type.GetThisAndBaseTypes())
204public static ITypeSymbol GetParameterType(this ISymbol symbol)
244private static string InnerGetDefaultValueString(object? defaultValue, ITypeSymbol parameterType)
247if (IsEnumType(parameterType, out var enumType))
253if (IsNullableEnumType(parameterType, out var underlyingEnumType))
308private static bool IsEnumType(ITypeSymbol typeSymbol, out ITypeSymbol enumType)
314private static bool IsNullableEnumType(ITypeSymbol typeSymbol, [NotNullWhen(true)] out ITypeSymbol? underlyingEnumType)
320var underlyingType = namedType.TypeArguments.FirstOrDefault();
Microsoft.Gen.BuildMetadata (5)
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 (178)
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 (9)
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,
250private MarshallingInfo? GetMarshallingInfoForAttribute(AttributeData attribute, ITypeSymbol type, int indirectionDepth, UseSiteAttributeProvider useSiteAttributes, GetMarshallingInfoCallback marshallingInfoCallback)
255private MarshallingInfo? GetMarshallingInfoForAttributes(ReadOnlySpan<AttributeData> attrs, ITypeSymbol type, int indirectionDepth, UseSiteAttributeProvider useSiteAttributes, GetMarshallingInfoCallback marshallingInfoCallback)
270private 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 (12)
Microsoft.VisualStudio.LanguageServices.CSharp (25)
CodeModel\CSharpCodeModelService.cs (16)
677var typeSymbol = GetTypeSymbolFromFullName(typeName, compilation);
694public override EnvDTE.vsCMTypeRef GetTypeKindForCodeTypeRef(ITypeSymbol typeSymbol)
767public override string GetAsFullNameForCodeTypeRef(ITypeSymbol typeSymbol)
770public override string GetAsStringForCodeTypeRef(ITypeSymbol typeSymbol)
2716public override SyntaxNode SetType(SyntaxNode node, ITypeSymbol? typeSymbol)
3014protected override ITypeSymbol? GetTypeSymbolFromPartialName(string partialName, SemanticModel semanticModel, int position)
3021public override ITypeSymbol? GetTypeSymbolFromFullName(string fullName, Compilation compilation)
3023ITypeSymbol? typeSymbol = compilation.GetTypeByMetadataName(fullName);
3064public override SyntaxNode CreateReturnDefaultValueStatement(ITypeSymbol type)
3690private static TypeDeclarationSyntax InsertIntoBaseList(TypeDeclarationSyntax typeDeclaration, ITypeSymbol typeSymbol, SemanticModel semanticModel, int insertionIndex)
3708public override bool IsValidBaseType(SyntaxNode node, ITypeSymbol typeSymbol)
3722public override SyntaxNode AddBase(SyntaxNode node, ITypeSymbol typeSymbol, SemanticModel semanticModel, int? position)
3755public override SyntaxNode RemoveBase(SyntaxNode node, ITypeSymbol typeSymbol, SemanticModel semanticModel)
3805public override bool IsValidInterfaceType(SyntaxNode node, ITypeSymbol typeSymbol)
3815public override SyntaxNode AddImplementedInterface(SyntaxNode node, ITypeSymbol typeSymbol, SemanticModel semanticModel, int? position)
3850public override SyntaxNode RemoveImplementedInterface(SyntaxNode node, ITypeSymbol typeSymbol, SemanticModel semanticModel)
Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests (4)
Microsoft.VisualStudio.LanguageServices.Implementation (95)
CodeModel\AbstractCodeModelObject_CodeGen.cs (4)
83private protected SyntaxNode CreateEventDeclaration(SyntaxNode containerNode, string name, EnvDTE.vsCMAccess access, ITypeSymbol type, CodeGenerationOptions options, bool createPropertyStyleEvent)
129private protected SyntaxNode CreateFieldDeclaration(SyntaxNode containerNode, string name, EnvDTE.vsCMAccess access, ITypeSymbol type, CodeGenerationOptions options)
144private protected SyntaxNode CreateMethodDeclaration(SyntaxNode containerNode, string name, EnvDTE.vsCMAccess access, ITypeSymbol returnType, CodeGenerationOptions options)
178ITypeSymbol type,
CodeModel\AbstractCodeModelService.cs (19)
255public EnvDTE.CodeElement CreateCodeType(CodeModelState state, ProjectId projectId, ITypeSymbol typeSymbol)
309public abstract EnvDTE.vsCMTypeRef GetTypeKindForCodeTypeRef(ITypeSymbol typeSymbol);
310public abstract string GetAsFullNameForCodeTypeRef(ITypeSymbol typeSymbol);
311public abstract string GetAsStringForCodeTypeRef(ITypeSymbol typeSymbol);
542protected EnvDTE.vsCMElement GetElementKind(ITypeSymbol typeSymbol)
572CodeModelState state, Project project, ITypeSymbol typeSymbol, [NotNullWhen(true)] out EnvDTE.CodeElement? element)
731public abstract SyntaxNode SetType(SyntaxNode node, ITypeSymbol? typeSymbol);
802private ITypeSymbol GetSpecialType(EnvDTE.vsCMTypeRef type, Compilation compilation)
805protected abstract ITypeSymbol? GetTypeSymbolFromPartialName(string partialName, SemanticModel semanticModel, int position);
806public abstract ITypeSymbol? GetTypeSymbolFromFullName(string fullName, Compilation compilation);
808public ITypeSymbol GetTypeSymbol(object type, SemanticModel semanticModel, int position)
810ITypeSymbol? typeSymbol;
849public abstract SyntaxNode CreateReturnDefaultValueStatement(ITypeSymbol type);
1293public abstract bool IsValidBaseType(SyntaxNode node, ITypeSymbol typeSymbol);
1294public abstract SyntaxNode AddBase(SyntaxNode node, ITypeSymbol typeSymbol, SemanticModel semanticModel, int? position);
1295public abstract SyntaxNode RemoveBase(SyntaxNode node, ITypeSymbol typeSymbol, SemanticModel semanticModel);
1297public abstract bool IsValidInterfaceType(SyntaxNode node, ITypeSymbol typeSymbol);
1298public abstract SyntaxNode AddImplementedInterface(SyntaxNode node, ITypeSymbol typeSymbol, SemanticModel semanticModel, int? position);
1299public abstract SyntaxNode RemoveImplementedInterface(SyntaxNode node, ITypeSymbol typeSymbol, SemanticModel semanticModel);
CodeModel\FileCodeModel_CodeGen.cs (11)
166var typeSymbol = CodeModelService.GetTypeSymbol(type, this.GetSemanticModel(), containerNode.SpanStart);
263var type = (ITypeSymbol?)semanticModel.GetDeclaredSymbol(containerNode);
310var returnType = kind == EnvDTE.vsCMFunction.vsCMFunctionFunction
394var propertyType = CodeModelService.GetTypeSymbol(type, semanticModel, containerNodePosition);
444var fieldType = CodeModelService.GetTypeSymbol(type, semanticModel, containerNodePosition);
652var typeSymbol = codeTypeRef != null
697var typeSymbol = CodeModelService.GetTypeSymbol(@base, semanticModel, node.SpanStart);
720var typeSymbol = CodeModelService.GetTypeSymbol(element, semanticModel, node.SpanStart);
733var typeSymbol = CodeModelService.GetTypeSymbol(@base, semanticModel, node.SpanStart);
758var typeSymbol = CodeModelService.GetTypeSymbol(element, semanticModel, node.SpanStart);
CodeModel\ICodeModelService.cs (14)
88EnvDTE.CodeElement CreateCodeType(CodeModelState state, ProjectId projectId, ITypeSymbol typeSymbol);
95EnvDTE.vsCMTypeRef GetTypeKindForCodeTypeRef(ITypeSymbol typeSymbol);
96string GetAsFullNameForCodeTypeRef(ITypeSymbol typeSymbol);
97string GetAsStringForCodeTypeRef(ITypeSymbol typeSymbol);
262SyntaxNode SetType(SyntaxNode node, ITypeSymbol? typeSymbol);
286ITypeSymbol GetTypeSymbol(object type, SemanticModel semanticModel, int position);
288ITypeSymbol? GetTypeSymbolFromFullName(string fullName, Compilation compilation);
290SyntaxNode CreateReturnDefaultValueStatement(ITypeSymbol type);
368bool IsValidBaseType(SyntaxNode node, ITypeSymbol typeSymbol);
369SyntaxNode AddBase(SyntaxNode node, ITypeSymbol typeSymbol, SemanticModel semanticModel, int? position);
370SyntaxNode RemoveBase(SyntaxNode node, ITypeSymbol typeSymbol, SemanticModel semanticModel);
372bool IsValidInterfaceType(SyntaxNode node, ITypeSymbol typeSymbol);
373SyntaxNode AddImplementedInterface(SyntaxNode node, ITypeSymbol typeSymbol, SemanticModel semanticModel, int? position);
374SyntaxNode RemoveImplementedInterface(SyntaxNode node, ITypeSymbol typeSymbol, SemanticModel semanticModel);
Mvc.Api.Analyzers.Test (4)
Roslyn.Diagnostics.Analyzers (468)
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)
102protected abstract TConversion ClassifyConversion(SemanticModel model, TExpressionSyntax expression, ITypeSymbol targetType);
103protected abstract TConversion ClassifyConversion(SemanticModel model, ITypeSymbol originalType, ITypeSymbol targetType);
105protected abstract bool ConversionsAreCompatible(TExpressionSyntax originalExpression, ITypeSymbol originalTargetType, TExpressionSyntax newExpression, ITypeSymbol newTargetType);
106protected abstract bool IsReferenceConversion(Compilation model, ITypeSymbol sourceType, ITypeSymbol targetType);
112SemanticModel model, TForEachStatementSyntax forEach, out IMethodSymbol getEnumeratorMethod, out ITypeSymbol elementType, out ImmutableArray<ILocalSymbol> localVariables);
305private bool ImplicitConversionsAreCompatible(TExpressionSyntax originalExpression, ITypeSymbol originalTargetType, TExpressionSyntax newExpression, ITypeSymbol newTargetType)
740var previousOriginalType = this.OriginalSemanticModel.GetTypeInfo(previousOriginalNode).Type;
741var previousReplacedType = this.SpeculativeSemanticModel.GetTypeInfo(previousReplacedNode).Type;
778GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
779GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
824var expressionType = this.SpeculativeSemanticModel.GetTypeInfo(newForEachStatementExpression, CancellationToken).ConvertedType;
847var originalThrowExpressionType = this.OriginalSemanticModel.GetTypeInfo(originalThrowExpression).Type;
849var newThrowExpressionType = this.SpeculativeSemanticModel.GetTypeInfo(newThrowExpression).Type;
959var originalTargetType = this.OriginalSemanticModel.GetTypeInfo(originalLeft).Type;
962var newTargetType = this.SpeculativeSemanticModel.GetTypeInfo(newLeft).Type;
995var newReceiverType = newReceiver != null
1034var receiverType = semanticModel.GetTypeInfo(receiver).Type;
1186ITypeSymbol originalTargetType,
1188ITypeSymbol newTargetType,
1203var originalConvertedTypeSymbol = this.OriginalSemanticModel.GetTypeInfo(originalExpression).ConvertedType;
1209var newConvertedTypeSymbol = this.SpeculativeSemanticModel.GetTypeInfo(newExpression).ConvertedType;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Symbols\ITypeSymbolExtensions.cs (101)
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)
244public static bool IsFormattableStringOrIFormattable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
253this ITypeSymbol typeSymbol, bool allowDelegateAndEnumConstraints = false)
281public static bool IsNumericType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
307public static Accessibility DetermineMinimalAccessibility(this ITypeSymbol typeSymbol)
310public static bool ContainsAnonymousType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
326foreach (var typeArg in type.GetAllTypeArguments())
335public static string CreateParameterName(this ITypeSymbol type, bool capitalize = false)
362private static string GetParameterName(ITypeSymbol? type)
375public static bool IsSpecialType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
406public static bool CanSupportCollectionInitializer(this ITypeSymbol typeSymbol, ISymbol within)
417public static INamedTypeSymbol? GetDelegateType(this ITypeSymbol? typeSymbol, Compilation compilation)
424var typeArgument = ((INamedTypeSymbol)typeSymbol).TypeArguments[0];
437public static IEnumerable<T> GetAccessibleMembersInBaseTypes<T>(this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol
446public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, ISymbol within) where T : class, ISymbol
456public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, string memberName, ISymbol within) where T : class, ISymbol
466public static bool? AreMoreSpecificThan(this IList<ITypeSymbol> t1, IList<ITypeSymbol> t2)
501public static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, ISymbol within) where T : class, ISymbol
511private static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, string memberName, ISymbol within) where T : class, ISymbol
521private static bool? IsMoreSpecificThan(this ITypeSymbol t1, ITypeSymbol t2)
599public static bool IsOrDerivesFromExceptionType([NotNullWhen(returnValue: true)] this ITypeSymbol? type, Compilation compilation)
606foreach (var baseType in type.GetBaseTypesAndThis())
617foreach (var constraint in ((ITypeParameterSymbol)type).ConstraintTypes)
632public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type)
635public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type, [NotNullWhen(true)] out INamedTypeSymbol? enumType)
647public static bool? IsMutableValueType(this ITypeSymbol type)
649if (type.IsNullable(out var underlyingType))
728static bool IsWellKnownImmutableValueType(ITypeSymbol type)
761public static bool IsDisposable([NotNullWhen(returnValue: true)] this ITypeSymbol? type, [NotNullWhen(returnValue: true)] ITypeSymbol? iDisposableType)
766public static ITypeSymbol WithNullableAnnotationFrom(this ITypeSymbol type, ITypeSymbol symbolForNullableAnnotation)
770public static ITypeSymbol? RemoveNullableIfPresent(this ITypeSymbol? symbol)
772if (symbol.IsNullable(out var underlyingType))
780public static bool IsSpanOrReadOnlySpan([NotNullWhen(true)] this ITypeSymbol? type)
783public static bool IsSpan([NotNullWhen(true)] this ITypeSymbol? type)
799public static bool IsInlineArray([NotNullWhen(true)] this ITypeSymbol? type)
804public static ITypeSymbol? RemoveUnavailableTypeParameters(
805this ITypeSymbol? type,
813private static ITypeSymbol? RemoveUnavailableTypeParameters(
814this ITypeSymbol? type,
822public static ITypeSymbol? RemoveAnonymousTypes(
823this ITypeSymbol? type,
830public static ITypeSymbol? RemoveUnnamedErrorTypes(
831this ITypeSymbol? type,
838this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
844this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
850this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result, bool onlyMethodTypeParameters)
859public static IList<ITypeParameterSymbol> GetReferencedTypeParameters(this ITypeSymbol? type)
867public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
868this ITypeSymbol? type,
871where TType1 : ITypeSymbol
872where TType2 : ITypeSymbol
878public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
879this ITypeSymbol? type,
882where TType1 : ITypeSymbol
883where 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 (181)
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 (34)
129var castedType = semanticModel.GetTypeInfo(castExpression.Type, cancellationToken).Type;
164var castedType = semanticModel.GetTypeInfo(castExpression.Type, cancellationToken).Type;
168var parentCastType = semanticModel.GetTypeInfo(parentCast.Type, cancellationToken).Type;
315var originalConvertedType = originalSemanticModel.GetTypeInfo(castNode.WalkUpParentheses(), cancellationToken).ConvertedType;
507var castedExpressionType = originalSemanticModel.GetTypeInfo(castedExpressionNode, cancellationToken).Type;
508var isType = originalSemanticModel.GetTypeInfo(isExpression.Right, cancellationToken).Type;
544var targetType = castNode.GetTargetType(originalSemanticModel, cancellationToken);
619ITypeSymbol originalConvertedType,
623var castedType = originalSemanticModel.GetTypeInfo(castNode, cancellationToken).Type;
698var castType = semanticModel.GetTypeInfo(castNode, cancellationToken).Type;
818var originalConvertedType = originalConversionOperation.Type;
819var rewrittenBitwiseNotConversionType = rewrittenBitwiseNotConversionOperation.Type;
832private static bool IsSignedIntegralOrIntPtrType(ITypeSymbol? type)
954var castType = originalSemanticModel.GetTypeInfo(castExpression, cancellationToken).Type;
988var otherSideType = originalSemanticModel.GetTypeInfo(otherSide, cancellationToken).Type;
989var thisSideRewrittenType = rewrittenSemanticModel.GetTypeInfo(rewrittenExpression, cancellationToken).Type;
1001var rewrittenConditionalConvertedType = rewrittenSemanticModel.GetTypeInfo(rewrittenConditionalOrSwitchExpression, cancellationToken).ConvertedType;
1036private static bool IsNullOrErrorType([NotNullWhen(false)] ITypeSymbol? type)
1159var castSideType = semanticModel.GetTypeInfo(castSide, cancellationToken).Type;
1160var castedExpressionType = semanticModel.GetTypeInfo(castExpression.Expression, cancellationToken).Type;
1162if (castSideType.IsNullable(out var underlyingType) && Equals(underlyingType, castedExpressionType))
1164var otherSideType = semanticModel.GetTypeInfo(otherSide, cancellationToken).Type;
1182var castType = semanticModel.GetTypeInfo(castNode, cancellationToken).Type;
1183var castedExpressionType = semanticModel.GetTypeInfo(castedExpressionNode, cancellationToken).Type;
1240private static bool IsFloatingPointType(ITypeSymbol? type)
1409var rewrittenType = rewrittenSemanticModel.GetTypeInfo(rewrittenExpression, cancellationToken).Type;
1524private static bool IsIntrinsicOrEnum(ITypeSymbol rewrittenType)
1532ITypeSymbol rewrittenType,
1571var originalMemberType = originalMemberSymbol.GetMemberType();
1572var rewrittenMemberType = rewrittenMemberSymbol.GetMemberType();
1622private static (ITypeSymbol? rewrittenConvertedType, Conversion rewrittenConversion) GetRewrittenInfo(
1625Conversion originalConversion, ITypeSymbol originalConvertedType,
1636var convertedType = originalConversion.IsIdentity ? originalConvertedType : originalSemanticModel.Compilation.ObjectType;
1640var rewrittenConvertedType = rewrittenSemanticModel.GetTypeInfo(rewrittenExpression, cancellationToken).ConvertedType;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\SpeculationAnalyzer.cs (18)
267var originalParamType = this.OriginalSemanticModel.GetDeclaredSymbol(originalParam).Type;
268var replacedParamType = this.SpeculativeSemanticModel.GetDeclaredSymbol(replacedParam).Type;
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 (10)
34return typedConstant.Value is ITypeSymbol typeSymbol
54ITypeSymbol? type,
63if (type.IsNullable(out var underlyingType))
75internal static ExpressionSyntax GenerateNonEnumValueExpression(ITypeSymbol? type, object? value, bool canUseFieldReference)
126private static string DetermineSuffix(ITypeSymbol? type, object value)
180private static ExpressionSyntax GenerateDoubleLiteralExpression(ITypeSymbol? type, double value, bool canUseFieldReference)
209private static ExpressionSyntax GenerateSingleLiteralExpression(ITypeSymbol? type, float value, bool canUseFieldReference)
239ITypeSymbol? type, T value, IEnumerable<KeyValuePair<T, string>> constants,
250ITypeSymbol? type, T value, IEnumerable<KeyValuePair<T, string>> constants,
286private static ExpressionSyntax? GenerateFieldReference<T>(ITypeSymbol? type, T value, IEnumerable<KeyValuePair<T, string>> constants)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\LanguageServices\CSharpTypeInferenceService.TypeInferrer.cs (38)
35protected override bool IsUnusableType(ITypeSymbol otherSideType)
620private static IMethodSymbol Instantiate(IMethodSymbol method, IList<ITypeSymbol> invocationTypes)
644IDictionary<ITypeParameterSymbol, ITypeSymbol> bestMap = null;
645foreach (var type in invocationTypes)
666private static Dictionary<ITypeParameterSymbol, ITypeSymbol> DetermineTypeParameterMapping(ITypeSymbol inferredType, ITypeSymbol returnType)
668var result = new Dictionary<ITypeParameterSymbol, ITypeSymbol>();
673private static void DetermineTypeParameterMapping(ITypeSymbol inferredType, ITypeSymbol returnType, Dictionary<ITypeParameterSymbol, ITypeSymbol> result)
1126return leftTypes.Select(x => x.InferredType.IsNullable(out var underlying)
1138static ITypeSymbol MakeNullable(ITypeSymbol symbol, Compilation compilation)
1245var collectionType = SemanticModel.GetTypeInfo(collectionExpression, CancellationToken).ConvertedType;
1249SemanticModel.Compilation, collectionType, out var elementType))
1526var type = this.SemanticModel.GetTypeInfo(recursivePattern).ConvertedType;
1645var elementTypesBuilder = ArrayBuilder<ITypeSymbol>.GetInstance(subPatternCount);
1670private static ImmutableArray<NullableAnnotation> GetNullableAnnotations(ImmutableArray<ITypeSymbol> elementTypes)
1841var typeArg = delegateType?.TypeArguments.Length > 0
1859private ITypeSymbol InferTypeForFirstParameterOfLambda(
1874private ITypeSymbol InferTypeForFirstParameterOfParenthesizedLambda(
1883private ITypeSymbol InferTypeForFirstParameterOfSimpleLambda(
1890private ITypeSymbol InferTypeForFirstParameterOfLambda(
1897private ITypeSymbol InferTypeForFirstParameterOfLambda(
1915var type = InferTypeForFirstParameterOfLambda(parameterName, child.AsNode());
2068var memberType = memberSymbol.GetMemberType();
2080private ITypeSymbol UnwrapTaskLike(ITypeSymbol type, bool isAsync)
2121var type = symbol.GetMemberType();
2260var type = symbol.GetSymbolType();
2349var tupleType = GetTupleType(tupleExpression);
2358private ITypeSymbol GetTupleType(
2372out ImmutableArray<ITypeSymbol> elementTypes,
2378using var _1 = ArrayBuilder<ITypeSymbol>.GetInstance(out var elementTypesBuilder);
2416ArrayBuilder<ITypeSymbol> elementTypesBuilder,
2438ArrayBuilder<ITypeSymbol> elementTypesBuilder,
2441var tupleType = GetTupleType(tuple);
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);
216private TypeRef EnqueueType(ITypeSymbol type, JsonSourceGenerationMode? generationMode)
371var converterType = (ITypeSymbol?)element.Value;
518var typeSymbol = (ITypeSymbol?)attributeData.ConstructorArguments[0].Value;
566ITypeSymbol type = typeToGenerate.Type;
612else if (type.IsNullableValueType(out ITypeSymbol? underlyingType))
633out ITypeSymbol? valueType,
634out ITypeSymbol? keyType,
790var derivedType = (ITypeSymbol)attributeData.ConstructorArguments[0].Value!;
804ITypeSymbol type,
805[NotNullWhen(true)] out ITypeSymbol? valueType,
806out ITypeSymbol? keyType,
873ImmutableArray<ITypeSymbol> genericArgs = ((INamedTypeSymbol)type).TypeArguments;
972private TypeRef? GetDictionaryTypeRef(ITypeSymbol keyType, ITypeSymbol valueType)
1051ITypeSymbol memberType,
1162private bool IsValidDataExtensionPropertyType(ITypeSymbol type)
1209ITypeSymbol memberType,
1534ITypeSymbol type = typeToGenerate.Type;
1670Debug.Assert(attributeData.ConstructorArguments.Length == 1 && attributeData.ConstructorArguments[0].Value is null or ITypeSymbol);
1671var converterType = (ITypeSymbol?)attributeData.ConstructorArguments[0].Value;
1675private TypeRef? GetConverterTypeFromAttribute(INamedTypeSymbol contextType, ITypeSymbol? converterType, ISymbol declaringSymbol, AttributeData attributeData)
1749private JsonPrimitiveTypeKind? GetPrimitiveTypeKind(ITypeSymbol type)
1782private static string GetTypeInfoPropertyName(ITypeSymbol type)
1802if (namedType.GetAllTypeArgumentsInScope() is List<ITypeSymbol> typeArgsInScope)
1804foreach (ITypeSymbol genericArg in typeArgsInScope)
1814ITypeSymbol type,
1882private bool IsUnsupportedType(ITypeSymbol type)
1893private bool IsBuiltInSupportType(ITypeSymbol type)
1906private static HashSet<ITypeSymbol> CreateBuiltInSupportTypeSet(KnownTypeSymbols knownSymbols)
1909HashSet<ITypeSymbol> builtInSupportTypes = new(SymbolEqualityComparer.Default);
1935void AddTypeIfNotNull(ITypeSymbol? type)
1946public required ITypeSymbol Type { get; init; }
System.Windows.Forms.PrivateSourceGenerators (5)
Test.Utilities (312)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (25)
102protected abstract TConversion ClassifyConversion(SemanticModel model, TExpressionSyntax expression, ITypeSymbol targetType);
103protected abstract TConversion ClassifyConversion(SemanticModel model, ITypeSymbol originalType, ITypeSymbol targetType);
105protected abstract bool ConversionsAreCompatible(TExpressionSyntax originalExpression, ITypeSymbol originalTargetType, TExpressionSyntax newExpression, ITypeSymbol newTargetType);
106protected abstract bool IsReferenceConversion(Compilation model, ITypeSymbol sourceType, ITypeSymbol targetType);
112SemanticModel model, TForEachStatementSyntax forEach, out IMethodSymbol getEnumeratorMethod, out ITypeSymbol elementType, out ImmutableArray<ILocalSymbol> localVariables);
305private bool ImplicitConversionsAreCompatible(TExpressionSyntax originalExpression, ITypeSymbol originalTargetType, TExpressionSyntax newExpression, ITypeSymbol newTargetType)
740var previousOriginalType = this.OriginalSemanticModel.GetTypeInfo(previousOriginalNode).Type;
741var previousReplacedType = this.SpeculativeSemanticModel.GetTypeInfo(previousReplacedNode).Type;
778GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
779GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
824var expressionType = this.SpeculativeSemanticModel.GetTypeInfo(newForEachStatementExpression, CancellationToken).ConvertedType;
847var originalThrowExpressionType = this.OriginalSemanticModel.GetTypeInfo(originalThrowExpression).Type;
849var newThrowExpressionType = this.SpeculativeSemanticModel.GetTypeInfo(newThrowExpression).Type;
959var originalTargetType = this.OriginalSemanticModel.GetTypeInfo(originalLeft).Type;
962var newTargetType = this.SpeculativeSemanticModel.GetTypeInfo(newLeft).Type;
995var newReceiverType = newReceiver != null
1034var receiverType = semanticModel.GetTypeInfo(receiver).Type;
1186ITypeSymbol originalTargetType,
1188ITypeSymbol newTargetType,
1203var originalConvertedTypeSymbol = this.OriginalSemanticModel.GetTypeInfo(originalExpression).ConvertedType;
1209var newConvertedTypeSymbol = this.SpeculativeSemanticModel.GetTypeInfo(newExpression).ConvertedType;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Symbols\ITypeSymbolExtensions.cs (101)
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)
244public static bool IsFormattableStringOrIFormattable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
253this ITypeSymbol typeSymbol, bool allowDelegateAndEnumConstraints = false)
281public static bool IsNumericType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
307public static Accessibility DetermineMinimalAccessibility(this ITypeSymbol typeSymbol)
310public static bool ContainsAnonymousType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
326foreach (var typeArg in type.GetAllTypeArguments())
335public static string CreateParameterName(this ITypeSymbol type, bool capitalize = false)
362private static string GetParameterName(ITypeSymbol? type)
375public static bool IsSpecialType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
406public static bool CanSupportCollectionInitializer(this ITypeSymbol typeSymbol, ISymbol within)
417public static INamedTypeSymbol? GetDelegateType(this ITypeSymbol? typeSymbol, Compilation compilation)
424var typeArgument = ((INamedTypeSymbol)typeSymbol).TypeArguments[0];
437public static IEnumerable<T> GetAccessibleMembersInBaseTypes<T>(this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol
446public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, ISymbol within) where T : class, ISymbol
456public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, string memberName, ISymbol within) where T : class, ISymbol
466public static bool? AreMoreSpecificThan(this IList<ITypeSymbol> t1, IList<ITypeSymbol> t2)
501public static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, ISymbol within) where T : class, ISymbol
511private static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, string memberName, ISymbol within) where T : class, ISymbol
521private static bool? IsMoreSpecificThan(this ITypeSymbol t1, ITypeSymbol t2)
599public static bool IsOrDerivesFromExceptionType([NotNullWhen(returnValue: true)] this ITypeSymbol? type, Compilation compilation)
606foreach (var baseType in type.GetBaseTypesAndThis())
617foreach (var constraint in ((ITypeParameterSymbol)type).ConstraintTypes)
632public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type)
635public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type, [NotNullWhen(true)] out INamedTypeSymbol? enumType)
647public static bool? IsMutableValueType(this ITypeSymbol type)
649if (type.IsNullable(out var underlyingType))
728static bool IsWellKnownImmutableValueType(ITypeSymbol type)
761public static bool IsDisposable([NotNullWhen(returnValue: true)] this ITypeSymbol? type, [NotNullWhen(returnValue: true)] ITypeSymbol? iDisposableType)
766public static ITypeSymbol WithNullableAnnotationFrom(this ITypeSymbol type, ITypeSymbol symbolForNullableAnnotation)
770public static ITypeSymbol? RemoveNullableIfPresent(this ITypeSymbol? symbol)
772if (symbol.IsNullable(out var underlyingType))
780public static bool IsSpanOrReadOnlySpan([NotNullWhen(true)] this ITypeSymbol? type)
783public static bool IsSpan([NotNullWhen(true)] this ITypeSymbol? type)
799public static bool IsInlineArray([NotNullWhen(true)] this ITypeSymbol? type)
804public static ITypeSymbol? RemoveUnavailableTypeParameters(
805this ITypeSymbol? type,
813private static ITypeSymbol? RemoveUnavailableTypeParameters(
814this ITypeSymbol? type,
822public static ITypeSymbol? RemoveAnonymousTypes(
823this ITypeSymbol? type,
830public static ITypeSymbol? RemoveUnnamedErrorTypes(
831this ITypeSymbol? type,
838this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
844this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
850this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result, bool onlyMethodTypeParameters)
859public static IList<ITypeParameterSymbol> GetReferencedTypeParameters(this ITypeSymbol? type)
867public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
868this ITypeSymbol? type,
871where TType1 : ITypeSymbol
872where TType2 : ITypeSymbol
878public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
879this ITypeSymbol? type,
882where TType1 : ITypeSymbol
883where TType2 : ITypeSymbol
Text.Analyzers (444)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\AbstractSpeculationAnalyzer.cs (25)
102protected abstract TConversion ClassifyConversion(SemanticModel model, TExpressionSyntax expression, ITypeSymbol targetType);
103protected abstract TConversion ClassifyConversion(SemanticModel model, ITypeSymbol originalType, ITypeSymbol targetType);
105protected abstract bool ConversionsAreCompatible(TExpressionSyntax originalExpression, ITypeSymbol originalTargetType, TExpressionSyntax newExpression, ITypeSymbol newTargetType);
106protected abstract bool IsReferenceConversion(Compilation model, ITypeSymbol sourceType, ITypeSymbol targetType);
112SemanticModel model, TForEachStatementSyntax forEach, out IMethodSymbol getEnumeratorMethod, out ITypeSymbol elementType, out ImmutableArray<ILocalSymbol> localVariables);
305private bool ImplicitConversionsAreCompatible(TExpressionSyntax originalExpression, ITypeSymbol originalTargetType, TExpressionSyntax newExpression, ITypeSymbol newTargetType)
740var previousOriginalType = this.OriginalSemanticModel.GetTypeInfo(previousOriginalNode).Type;
741var previousReplacedType = this.SpeculativeSemanticModel.GetTypeInfo(previousReplacedNode).Type;
778GetForEachSymbols(this.OriginalSemanticModel, forEachStatement, out var originalGetEnumerator, out var originalElementType, out var originalLocalVariables);
779GetForEachSymbols(this.SpeculativeSemanticModel, newForEachStatement, out var newGetEnumerator, out var newElementType, out var newLocalVariables);
824var expressionType = this.SpeculativeSemanticModel.GetTypeInfo(newForEachStatementExpression, CancellationToken).ConvertedType;
847var originalThrowExpressionType = this.OriginalSemanticModel.GetTypeInfo(originalThrowExpression).Type;
849var newThrowExpressionType = this.SpeculativeSemanticModel.GetTypeInfo(newThrowExpression).Type;
959var originalTargetType = this.OriginalSemanticModel.GetTypeInfo(originalLeft).Type;
962var newTargetType = this.SpeculativeSemanticModel.GetTypeInfo(newLeft).Type;
995var newReceiverType = newReceiver != null
1034var receiverType = semanticModel.GetTypeInfo(receiver).Type;
1186ITypeSymbol originalTargetType,
1188ITypeSymbol newTargetType,
1203var originalConvertedTypeSymbol = this.OriginalSemanticModel.GetTypeInfo(originalExpression).ConvertedType;
1209var newConvertedTypeSymbol = this.SpeculativeSemanticModel.GetTypeInfo(newExpression).ConvertedType;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Symbols\ITypeSymbolExtensions.cs (101)
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)
244public static bool IsFormattableStringOrIFormattable([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
253this ITypeSymbol typeSymbol, bool allowDelegateAndEnumConstraints = false)
281public static bool IsNumericType([NotNullWhen(returnValue: true)] this ITypeSymbol? type)
307public static Accessibility DetermineMinimalAccessibility(this ITypeSymbol typeSymbol)
310public static bool ContainsAnonymousType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
326foreach (var typeArg in type.GetAllTypeArguments())
335public static string CreateParameterName(this ITypeSymbol type, bool capitalize = false)
362private static string GetParameterName(ITypeSymbol? type)
375public static bool IsSpecialType([NotNullWhen(returnValue: true)] this ITypeSymbol? symbol)
406public static bool CanSupportCollectionInitializer(this ITypeSymbol typeSymbol, ISymbol within)
417public static INamedTypeSymbol? GetDelegateType(this ITypeSymbol? typeSymbol, Compilation compilation)
424var typeArgument = ((INamedTypeSymbol)typeSymbol).TypeArguments[0];
437public static IEnumerable<T> GetAccessibleMembersInBaseTypes<T>(this ITypeSymbol containingType, ISymbol within) where T : class, ISymbol
446public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, ISymbol within) where T : class, ISymbol
456public static ImmutableArray<T> GetAccessibleMembersInThisAndBaseTypes<T>(this ITypeSymbol? containingType, string memberName, ISymbol within) where T : class, ISymbol
466public static bool? AreMoreSpecificThan(this IList<ITypeSymbol> t1, IList<ITypeSymbol> t2)
501public static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, ISymbol within) where T : class, ISymbol
511private static IEnumerable<T> SelectAccessibleMembers<T>(this IEnumerable<ITypeSymbol>? types, string memberName, ISymbol within) where T : class, ISymbol
521private static bool? IsMoreSpecificThan(this ITypeSymbol t1, ITypeSymbol t2)
599public static bool IsOrDerivesFromExceptionType([NotNullWhen(returnValue: true)] this ITypeSymbol? type, Compilation compilation)
606foreach (var baseType in type.GetBaseTypesAndThis())
617foreach (var constraint in ((ITypeParameterSymbol)type).ConstraintTypes)
632public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type)
635public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type, [NotNullWhen(true)] out INamedTypeSymbol? enumType)
647public static bool? IsMutableValueType(this ITypeSymbol type)
649if (type.IsNullable(out var underlyingType))
728static bool IsWellKnownImmutableValueType(ITypeSymbol type)
761public static bool IsDisposable([NotNullWhen(returnValue: true)] this ITypeSymbol? type, [NotNullWhen(returnValue: true)] ITypeSymbol? iDisposableType)
766public static ITypeSymbol WithNullableAnnotationFrom(this ITypeSymbol type, ITypeSymbol symbolForNullableAnnotation)
770public static ITypeSymbol? RemoveNullableIfPresent(this ITypeSymbol? symbol)
772if (symbol.IsNullable(out var underlyingType))
780public static bool IsSpanOrReadOnlySpan([NotNullWhen(true)] this ITypeSymbol? type)
783public static bool IsSpan([NotNullWhen(true)] this ITypeSymbol? type)
799public static bool IsInlineArray([NotNullWhen(true)] this ITypeSymbol? type)
804public static ITypeSymbol? RemoveUnavailableTypeParameters(
805this ITypeSymbol? type,
813private static ITypeSymbol? RemoveUnavailableTypeParameters(
814this ITypeSymbol? type,
822public static ITypeSymbol? RemoveAnonymousTypes(
823this ITypeSymbol? type,
830public static ITypeSymbol? RemoveUnnamedErrorTypes(
831this ITypeSymbol? type,
838this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
844this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result)
850this ITypeSymbol? type, ArrayBuilder<ITypeParameterSymbol> result, bool onlyMethodTypeParameters)
859public static IList<ITypeParameterSymbol> GetReferencedTypeParameters(this ITypeSymbol? type)
867public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
868this ITypeSymbol? type,
871where TType1 : ITypeSymbol
872where TType2 : ITypeSymbol
878public static ITypeSymbol? SubstituteTypes<TType1, TType2>(
879this ITypeSymbol? type,
882where TType1 : ITypeSymbol
883where 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,