src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\NamingStyles\Serialization\SymbolSpecification.cs (20)
62new SymbolKindOrTypeKind(TypeKind.Class),
63new SymbolKindOrTypeKind(TypeKind.Struct),
64new SymbolKindOrTypeKind(TypeKind.Interface),
65new SymbolKindOrTypeKind(TypeKind.Delegate),
66new SymbolKindOrTypeKind(TypeKind.Enum),
67new SymbolKindOrTypeKind(TypeKind.Module),
68new SymbolKindOrTypeKind(TypeKind.Pointer),
75new SymbolKindOrTypeKind(TypeKind.TypeParameter),
293foreach (var typeKindElement in symbolKindListElement.Elements(nameof(TypeKind)))
344public SymbolKindOrTypeKind(TypeKind typeKind)
355public TypeKind? TypeKind => (_category == SymbolCategory.Type) ? (TypeKind)_kind : null;
362SymbolCategory.Type => symbol is ITypeSymbol type && type.TypeKind == (TypeKind)_kind,
371SymbolCategory.Type => new XElement(nameof(TypeKind), GetTypeKindString((TypeKind)_kind)),
376private static string GetTypeKindString(TypeKind typeKind)
383CodeAnalysis.TypeKind.Structure => nameof(CodeAnalysis.TypeKind.Struct),
433=> new((TypeKind)Enum.Parse(typeof(TypeKind), typeKindElement.Value));
441public static implicit operator SymbolKindOrTypeKind(TypeKind symbolKind)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\NamingStyles\Serialization\SymbolSpecification.cs (20)
62new SymbolKindOrTypeKind(TypeKind.Class),
63new SymbolKindOrTypeKind(TypeKind.Struct),
64new SymbolKindOrTypeKind(TypeKind.Interface),
65new SymbolKindOrTypeKind(TypeKind.Delegate),
66new SymbolKindOrTypeKind(TypeKind.Enum),
67new SymbolKindOrTypeKind(TypeKind.Module),
68new SymbolKindOrTypeKind(TypeKind.Pointer),
75new SymbolKindOrTypeKind(TypeKind.TypeParameter),
293foreach (var typeKindElement in symbolKindListElement.Elements(nameof(TypeKind)))
344public SymbolKindOrTypeKind(TypeKind typeKind)
355public TypeKind? TypeKind => (_category == SymbolCategory.Type) ? (TypeKind)_kind : null;
362SymbolCategory.Type => symbol is ITypeSymbol type && type.TypeKind == (TypeKind)_kind,
371SymbolCategory.Type => new XElement(nameof(TypeKind), GetTypeKindString((TypeKind)_kind)),
376private static string GetTypeKindString(TypeKind typeKind)
383CodeAnalysis.TypeKind.Structure => nameof(CodeAnalysis.TypeKind.Struct),
433=> new((TypeKind)Enum.Parse(typeof(TypeKind), typeKindElement.Value));
441public static implicit operator SymbolKindOrTypeKind(TypeKind symbolKind)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\NamingStyles\Serialization\SymbolSpecification.cs (20)
62new SymbolKindOrTypeKind(TypeKind.Class),
63new SymbolKindOrTypeKind(TypeKind.Struct),
64new SymbolKindOrTypeKind(TypeKind.Interface),
65new SymbolKindOrTypeKind(TypeKind.Delegate),
66new SymbolKindOrTypeKind(TypeKind.Enum),
67new SymbolKindOrTypeKind(TypeKind.Module),
68new SymbolKindOrTypeKind(TypeKind.Pointer),
75new SymbolKindOrTypeKind(TypeKind.TypeParameter),
293foreach (var typeKindElement in symbolKindListElement.Elements(nameof(TypeKind)))
344public SymbolKindOrTypeKind(TypeKind typeKind)
355public TypeKind? TypeKind => (_category == SymbolCategory.Type) ? (TypeKind)_kind : null;
362SymbolCategory.Type => symbol is ITypeSymbol type && type.TypeKind == (TypeKind)_kind,
371SymbolCategory.Type => new XElement(nameof(TypeKind), GetTypeKindString((TypeKind)_kind)),
376private static string GetTypeKindString(TypeKind typeKind)
383CodeAnalysis.TypeKind.Structure => nameof(CodeAnalysis.TypeKind.Struct),
433=> new((TypeKind)Enum.Parse(typeof(TypeKind), typeKindElement.Value));
441public static implicit operator SymbolKindOrTypeKind(TypeKind symbolKind)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\NamingStyles\Serialization\SymbolSpecification.cs (20)
62new SymbolKindOrTypeKind(TypeKind.Class),
63new SymbolKindOrTypeKind(TypeKind.Struct),
64new SymbolKindOrTypeKind(TypeKind.Interface),
65new SymbolKindOrTypeKind(TypeKind.Delegate),
66new SymbolKindOrTypeKind(TypeKind.Enum),
67new SymbolKindOrTypeKind(TypeKind.Module),
68new SymbolKindOrTypeKind(TypeKind.Pointer),
75new SymbolKindOrTypeKind(TypeKind.TypeParameter),
293foreach (var typeKindElement in symbolKindListElement.Elements(nameof(TypeKind)))
344public SymbolKindOrTypeKind(TypeKind typeKind)
355public TypeKind? TypeKind => (_category == SymbolCategory.Type) ? (TypeKind)_kind : null;
362SymbolCategory.Type => symbol is ITypeSymbol type && type.TypeKind == (TypeKind)_kind,
371SymbolCategory.Type => new XElement(nameof(TypeKind), GetTypeKindString((TypeKind)_kind)),
376private static string GetTypeKindString(TypeKind typeKind)
383CodeAnalysis.TypeKind.Structure => nameof(CodeAnalysis.TypeKind.Struct),
433=> new((TypeKind)Enum.Parse(typeof(TypeKind), typeKindElement.Value));
441public static implicit operator SymbolKindOrTypeKind(TypeKind symbolKind)
src\roslyn\src\Analyzers\Core\CodeFixes\GenerateParameterizedMember\AbstractGenerateConversionService.cs (2)
24protected abstract bool TryInitializeImplicitConversionState(SemanticDocument document, SyntaxNode expression, ISet<TypeKind> classInterfaceModuleStructTypes, CancellationToken cancellationToken, out SyntaxToken identifierToken, [NotNullWhen(true)] out IMethodSymbol? methodSymbol, [NotNullWhen(true)] out INamedTypeSymbol? typeToGenerateIn);
25protected abstract bool TryInitializeExplicitConversionState(SemanticDocument document, SyntaxNode expression, ISet<TypeKind> classInterfaceModuleStructTypes, CancellationToken cancellationToken, out SyntaxToken identifierToken, [NotNullWhen(true)] out IMethodSymbol? methodSymbol, [NotNullWhen(true)] out INamedTypeSymbol? typeToGenerateIn);
Binder\Binder_Conversions.cs (26)
858case TypeKind.Enum:
859case TypeKind.Struct:
860case TypeKind.Class when !type.IsAnonymousType: // We don't want to enable object creation with unspeakable types
862case TypeKind.TypeParameter:
864case TypeKind.Delegate:
866case TypeKind.Interface:
868case TypeKind.Array:
869case TypeKind.Class:
870case TypeKind.Dynamic:
872goto case TypeKind.Error;
873case TypeKind.Pointer:
874case TypeKind.FunctionPointer:
876goto case TypeKind.Error;
877case TypeKind.Error:
3519Debug.Assert(delegateType is NamedTypeSymbol { TypeKind: TypeKind.Delegate, DelegateInvokeMethod: { HasUseSiteError: false } }
3520|| delegateType.TypeKind == TypeKind.FunctionPointer,
3636static bool hasConversion(TypeKind targetKind, Conversions conversions, TypeSymbol source, TypeSymbol destination,
3657return targetKind == TypeKind.FunctionPointer
3662static ErrorCode getMethodMismatchErrorCode(TypeKind type)
3665TypeKind.Delegate => ErrorCode.ERR_MethDelegateMismatch,
3666TypeKind.FunctionPointer => ErrorCode.ERR_MethFuncPtrMismatch,
3670static ErrorCode getRefMismatchErrorCode(TypeKind type)
3673TypeKind.Delegate => ErrorCode.ERR_DelegateRefMismatch,
3674TypeKind.FunctionPointer => ErrorCode.ERR_FuncPtrRefMismatch,
3710Debug.Assert(Conversions.IsAssignableFromMulticastDelegate(delegateOrFuncPtrType, ref discardedUseSiteInfo) || delegateOrFuncPtrType.TypeKind == TypeKind.Delegate || delegateOrFuncPtrType.TypeKind == TypeKind.FunctionPointer);
Symbols\TypeSymbolExtensions.cs (71)
72if (type.TypeKind != TypeKind.TypeParameter)
118if (type.TypeKind == TypeKind.TypeParameter)
240return type.TypeKind == TypeKind.Enum;
335case TypeKind.Pointer:
336case TypeKind.Dynamic:
337case TypeKind.FunctionPointer:
346return type is { IsValueType: true, TypeKind: not TypeKind.TypeParameter };
358return type.TypeKind == TypeKind.Class;
364return type.TypeKind == TypeKind.Struct;
380return type.TypeKind == TypeKind.Dynamic;
386return type.TypeKind == TypeKind.TypeParameter;
392return type.TypeKind == TypeKind.Array;
398return type.TypeKind == TypeKind.Array && ((ArrayTypeSymbol)type).IsSZArray;
441return type.TypeKind == TypeKind.FunctionPointer;
448case TypeKind.Pointer:
449case TypeKind.FunctionPointer:
461case TypeKind.Class:
462case TypeKind.Struct:
465case TypeKind.TypeParameter:
611return type.TypeKind == TypeKind.Delegate;
747case TypeKind.Class:
748case TypeKind.Struct:
749case TypeKind.Interface:
750case TypeKind.Enum:
751case TypeKind.Delegate:
752case TypeKind.Submission:
822case TypeKind.Class:
823case TypeKind.Struct:
824case TypeKind.Interface:
825case TypeKind.Enum:
826case TypeKind.Delegate:
841case TypeKind.Submission:
880case TypeKind.Dynamic:
881case TypeKind.TypeParameter:
882case TypeKind.Submission:
883case TypeKind.Enum:
893goto case TypeKind.Delegate;
895case TypeKind.Error:
896case TypeKind.Class:
897case TypeKind.Struct:
898case TypeKind.Interface:
899case TypeKind.Delegate:
900case TypeKind.Extension:
968case TypeKind.Array:
972case TypeKind.Pointer:
976case TypeKind.FunctionPointer:
1211if (ReferenceEquals(parent2.OriginalDefinition, parent1OriginalDefinition) || parent1OriginalDefinition.TypeKind == TypeKind.Submission && parent2.TypeKind == TypeKind.Submission)
1251(type, parameter, unused) => type.TypeKind == TypeKind.TypeParameter && (parameter is null || TypeSymbol.Equals(type, parameter, TypeCompareKind.ConsiderEverything2));
1262(type, typeParameterContainer, unused) => type.TypeKind == TypeKind.TypeParameter && (object)type.ContainingSymbol == (object)typeParameterContainer;
1271(type, parameters, unused) => type.TypeKind == TypeKind.TypeParameter && parameters.Contains((TypeParameterSymbol)type);
1318(type, _, _) => type.TypeKind == TypeKind.TypeParameter && type.ContainingSymbol is MethodSymbol;
1329private static readonly Func<TypeSymbol, object?, bool, bool> s_containsDynamicPredicate = (type, unused1, unused2) => type.TypeKind == TypeKind.Dynamic;
1367type.VisitType((TypeSymbol t, object? _, bool _) => t.TypeKind is TypeKind.Pointer or TypeKind.FunctionPointer, null) is object;
1395internal static TypeKind GetNonErrorTypeKindGuess(this TypeSymbol type)
1594case TypeKind.Struct:
1597case TypeKind.Array:
1598case TypeKind.Class:
1599case TypeKind.Delegate:
1600case TypeKind.Dynamic:
1601case TypeKind.Error:
1602case TypeKind.Interface:
1603case TypeKind.Pointer:
1604case TypeKind.FunctionPointer:
1607case TypeKind.Enum:
1610case TypeKind.TypeParameter:
1613case TypeKind.Submission:
1754return type.IsReferenceType && type.TypeKind != TypeKind.TypeParameter;
1762return type.IsValueType && type.TypeKind != TypeKind.TypeParameter;
2087if (taskType.TypeKind == TypeKind.Error)
Completion\Providers\ImportCompletionProvider\ExtensionMemberImportCompletionHelper.SymbolComputer_Constraints.cs (5)
31=> CheckConstraints(receiverTypeSymbol, typeParameter, TypeKind.Interface, static type => type.GetAllInterfacesIncludingThis());
34=> CheckConstraints(receiverTypeSymbol, typeParameter, TypeKind.Class, static type => type.GetBaseTypesAndThis());
38TypeKind typeKind,
68TypeKind constraintTypeKind,
105ITypeSymbol type, TypeKind typeKind, Func<ITypeSymbol, IEnumerable<ITypeSymbol>> getInheritanceTypes)
src\roslyn\src\Analyzers\Core\CodeFixes\GenerateParameterizedMember\AbstractGenerateConversionService.cs (2)
24protected abstract bool TryInitializeImplicitConversionState(SemanticDocument document, SyntaxNode expression, ISet<TypeKind> classInterfaceModuleStructTypes, CancellationToken cancellationToken, out SyntaxToken identifierToken, [NotNullWhen(true)] out IMethodSymbol? methodSymbol, [NotNullWhen(true)] out INamedTypeSymbol? typeToGenerateIn);
25protected abstract bool TryInitializeExplicitConversionState(SemanticDocument document, SyntaxNode expression, ISet<TypeKind> classInterfaceModuleStructTypes, CancellationToken cancellationToken, out SyntaxToken identifierToken, [NotNullWhen(true)] out IMethodSymbol? methodSymbol, [NotNullWhen(true)] out INamedTypeSymbol? typeToGenerateIn);
Microsoft.NetCore.Analyzers\Runtime\DoNotCallEnumerableCastOrOfTypeWithIncompatibleTypesAnalyzer.cs (44)
194if (castFrom.TypeKind == TypeKind.Error
195|| castTo.TypeKind == TypeKind.Error)
246if (t.TypeKind == TypeKind.Class)
257case (TypeKind.Dynamic, _):
258case (_, TypeKind.Dynamic):
261case (TypeKind.TypeParameter, _):
274if (castTo.TypeKind == TypeKind.TypeParameter)
280case (_, TypeKind.TypeParameter):
283case (TypeKind.Class, TypeKind.Class):
287case (TypeKind.Interface, TypeKind.Class):
289case (TypeKind.Class, TypeKind.Interface):
292case (TypeKind.Interface, TypeKind.Struct):
294case (TypeKind.Struct, TypeKind.Interface):
297case (TypeKind.Class, TypeKind.Enum):
300case (TypeKind.Enum, TypeKind.Class):
304case (TypeKind.Struct, TypeKind.Enum)
307case (TypeKind.Enum, TypeKind.Struct)
311case (TypeKind.Enum, TypeKind.Enum)
321case (TypeKind.Array, TypeKind.Array)
327case (TypeKind.Array, TypeKind.Class):
329case (TypeKind.Class, TypeKind.Array):
332case (TypeKind.Class, TypeKind.Struct):
334case (TypeKind.Struct, TypeKind.Class):
337case (_, TypeKind.Enum):
338case (TypeKind.Enum, _):
339case (_, TypeKind.Struct):
340case (TypeKind.Struct, _):
343case (TypeKind.Interface, TypeKind.Interface):
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\NamingStyles\Serialization\SymbolSpecification.cs (20)
62new SymbolKindOrTypeKind(TypeKind.Class),
63new SymbolKindOrTypeKind(TypeKind.Struct),
64new SymbolKindOrTypeKind(TypeKind.Interface),
65new SymbolKindOrTypeKind(TypeKind.Delegate),
66new SymbolKindOrTypeKind(TypeKind.Enum),
67new SymbolKindOrTypeKind(TypeKind.Module),
68new SymbolKindOrTypeKind(TypeKind.Pointer),
75new SymbolKindOrTypeKind(TypeKind.TypeParameter),
293foreach (var typeKindElement in symbolKindListElement.Elements(nameof(TypeKind)))
344public SymbolKindOrTypeKind(TypeKind typeKind)
355public TypeKind? TypeKind => (_category == SymbolCategory.Type) ? (TypeKind)_kind : null;
362SymbolCategory.Type => symbol is ITypeSymbol type && type.TypeKind == (TypeKind)_kind,
371SymbolCategory.Type => new XElement(nameof(TypeKind), GetTypeKindString((TypeKind)_kind)),
376private static string GetTypeKindString(TypeKind typeKind)
383CodeAnalysis.TypeKind.Structure => nameof(CodeAnalysis.TypeKind.Struct),
433=> new((TypeKind)Enum.Parse(typeof(TypeKind), typeKindElement.Value));
441public static implicit operator SymbolKindOrTypeKind(TypeKind symbolKind)
Classification\ClassificationExtensions.cs (11)
12TypeKind.Class => type.IsRecord ? ClassificationTypeNames.RecordClassName : ClassificationTypeNames.ClassName,
13TypeKind.Module => ClassificationTypeNames.ModuleName,
14TypeKind.Struct => type.IsRecord ? ClassificationTypeNames.RecordStructName : ClassificationTypeNames.StructName,
15TypeKind.Interface => ClassificationTypeNames.InterfaceName,
16TypeKind.Enum => ClassificationTypeNames.EnumName,
17TypeKind.Delegate => ClassificationTypeNames.DelegateName,
18TypeKind.TypeParameter => ClassificationTypeNames.TypeParameterName,
19TypeKind.Dynamic => ClassificationTypeNames.Keyword,
20TypeKind.Array => ClassificationTypeNames.ArrayName,
21TypeKind.Pointer => ClassificationTypeNames.PointerName,
22TypeKind.FunctionPointer => ClassificationTypeNames.FunctionPointerName,
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\NamingStyles\Serialization\SymbolSpecification.cs (20)
62new SymbolKindOrTypeKind(TypeKind.Class),
63new SymbolKindOrTypeKind(TypeKind.Struct),
64new SymbolKindOrTypeKind(TypeKind.Interface),
65new SymbolKindOrTypeKind(TypeKind.Delegate),
66new SymbolKindOrTypeKind(TypeKind.Enum),
67new SymbolKindOrTypeKind(TypeKind.Module),
68new SymbolKindOrTypeKind(TypeKind.Pointer),
75new SymbolKindOrTypeKind(TypeKind.TypeParameter),
293foreach (var typeKindElement in symbolKindListElement.Elements(nameof(TypeKind)))
344public SymbolKindOrTypeKind(TypeKind typeKind)
355public TypeKind? TypeKind => (_category == SymbolCategory.Type) ? (TypeKind)_kind : null;
362SymbolCategory.Type => symbol is ITypeSymbol type && type.TypeKind == (TypeKind)_kind,
371SymbolCategory.Type => new XElement(nameof(TypeKind), GetTypeKindString((TypeKind)_kind)),
376private static string GetTypeKindString(TypeKind typeKind)
383CodeAnalysis.TypeKind.Structure => nameof(CodeAnalysis.TypeKind.Struct),
433=> new((TypeKind)Enum.Parse(typeof(TypeKind), typeKindElement.Value));
441public static implicit operator SymbolKindOrTypeKind(TypeKind symbolKind)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\NamingStyles\Serialization\SymbolSpecification.cs (20)
62new SymbolKindOrTypeKind(TypeKind.Class),
63new SymbolKindOrTypeKind(TypeKind.Struct),
64new SymbolKindOrTypeKind(TypeKind.Interface),
65new SymbolKindOrTypeKind(TypeKind.Delegate),
66new SymbolKindOrTypeKind(TypeKind.Enum),
67new SymbolKindOrTypeKind(TypeKind.Module),
68new SymbolKindOrTypeKind(TypeKind.Pointer),
75new SymbolKindOrTypeKind(TypeKind.TypeParameter),
293foreach (var typeKindElement in symbolKindListElement.Elements(nameof(TypeKind)))
344public SymbolKindOrTypeKind(TypeKind typeKind)
355public TypeKind? TypeKind => (_category == SymbolCategory.Type) ? (TypeKind)_kind : null;
362SymbolCategory.Type => symbol is ITypeSymbol type && type.TypeKind == (TypeKind)_kind,
371SymbolCategory.Type => new XElement(nameof(TypeKind), GetTypeKindString((TypeKind)_kind)),
376private static string GetTypeKindString(TypeKind typeKind)
383CodeAnalysis.TypeKind.Structure => nameof(CodeAnalysis.TypeKind.Struct),
433=> new((TypeKind)Enum.Parse(typeof(TypeKind), typeKindElement.Value));
441public static implicit operator SymbolKindOrTypeKind(TypeKind symbolKind)