src\Analyzers\Core\Analyzers\MakeFieldReadonly\AbstractMakeFieldReadonlyDiagnosticAnalyzer.cs (14)
50var threadStaticAttribute = context.Compilation.ThreadStaticAttributeType();
51var dataContractAttribute = context.Compilation.DataContractAttribute();
52var dataMemberAttribute = context.Compilation.DataMemberAttribute();
66if (!ShouldAnalyze(context, (INamedTypeSymbol)context.Symbol))
118var members = ((INamedTypeSymbol)symbolEndContext.Symbol).GetMembers();
140bool ShouldAnalyze(SymbolStartAnalysisContext context, INamedTypeSymbol namedType)
161static bool IsCandidateField(IFieldSymbol symbol, INamedTypeSymbol? threadStaticAttribute, INamedTypeSymbol? dataContractAttribute, INamedTypeSymbol? dataMemberAttribute)
177static bool IsDataContractSerializable(IFieldSymbol symbol, INamedTypeSymbol? dataContractAttribute, INamedTypeSymbol? dataMemberAttribute)
216INamedTypeSymbol? threadStaticAttribute,
217INamedTypeSymbol? dataContractAttribute,
218INamedTypeSymbol? dataMemberAttribute,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\INamedTypeSymbolExtensions.cs (73)
20public static IEnumerable<INamedTypeSymbol> GetBaseTypesAndThis(this INamedTypeSymbol? namedType)
22var current = namedType;
30public static ImmutableArray<ITypeParameterSymbol> GetAllTypeParameters(this INamedTypeSymbol? symbol)
36public static IEnumerable<ITypeSymbol> GetAllTypeArguments(this INamedTypeSymbol? symbol)
42private static Stack<INamedTypeSymbol> GetContainmentStack(INamedTypeSymbol? symbol)
44var stack = new Stack<INamedTypeSymbol>();
45for (var current = symbol; current != null; current = current.ContainingType)
53public static bool IsContainedWithin([NotNullWhen(returnValue: true)] this INamedTypeSymbol? symbol, INamedTypeSymbol outer)
56for (var current = symbol; current != null; current = current.ContainingType)
67public static ISymbol? FindImplementationForAbstractMember(this INamedTypeSymbol? type, ISymbol symbol)
78private static bool ImplementationExists(INamedTypeSymbol classOrStructType, ISymbol member)
82this INamedTypeSymbol classOrStructType,
84Func<INamedTypeSymbol, ISymbol, bool> isValidImplementation,
114private static bool IsInterfacePropertyImplemented(INamedTypeSymbol classOrStructType, IPropertySymbol propertySymbol)
122static bool IsAccessorImplemented(IMethodSymbol? accessor, INamedTypeSymbol classOrStructType)
128private static bool IsAbstractPropertyImplemented(INamedTypeSymbol classOrStructType, IPropertySymbol propertySymbol)
151this INamedTypeSymbol classOrStructType,
153Func<INamedTypeSymbol, ISymbol, bool> isValid,
176public static ImmutableArray<(INamedTypeSymbol type, ImmutableArray<ISymbol> members)> GetAllUnimplementedMembers(
177this INamedTypeSymbol classOrStructType,
178IEnumerable<INamedTypeSymbol> interfaces,
194static ImmutableArray<ISymbol> GetImplicitlyImplementableMembers(INamedTypeSymbol type, ISymbol within)
244public static ImmutableArray<(INamedTypeSymbol type, ImmutableArray<ISymbol> members)> GetAllUnimplementedMembersInThis(
245this INamedTypeSymbol classOrStructType,
246IEnumerable<INamedTypeSymbol> interfacesOrAbstractClasses,
262public static ImmutableArray<(INamedTypeSymbol type, ImmutableArray<ISymbol> members)> GetAllUnimplementedMembersInThis(
263this INamedTypeSymbol classOrStructType,
264IEnumerable<INamedTypeSymbol> interfacesOrAbstractClasses,
265Func<INamedTypeSymbol, ISymbol, ImmutableArray<ISymbol>> interfaceMemberGetter,
281public static ImmutableArray<(INamedTypeSymbol type, ImmutableArray<ISymbol> members)> GetAllUnimplementedExplicitMembers(
282this INamedTypeSymbol classOrStructType,
283IEnumerable<INamedTypeSymbol> interfaces,
295private static ImmutableArray<ISymbol> GetExplicitlyImplementableMembers(INamedTypeSymbol type, ISymbol within)
322private static ImmutableArray<(INamedTypeSymbol type, ImmutableArray<ISymbol> members)> GetAllUnimplementedMembers(
323this INamedTypeSymbol classOrStructType,
324IEnumerable<INamedTypeSymbol> interfacesOrAbstractClasses,
325Func<INamedTypeSymbol, ISymbol, Func<INamedTypeSymbol, ISymbol, bool>, CancellationToken, bool> isImplemented,
326Func<INamedTypeSymbol, ISymbol, bool> isValidImplementation,
327Func<INamedTypeSymbol, ISymbol, ImmutableArray<ISymbol>> interfaceMemberGetter,
356private static ImmutableArray<INamedTypeSymbol> GetTypesToImplement(
357INamedTypeSymbol classOrStructType,
358IEnumerable<INamedTypeSymbol> interfacesOrAbstractClasses,
367private static ImmutableArray<INamedTypeSymbol> GetAbstractClassesToImplement(
368IEnumerable<INamedTypeSymbol> abstractClasses)
375private static ImmutableArray<INamedTypeSymbol> GetInterfacesToImplement(
376INamedTypeSymbol classOrStructType,
377IEnumerable<INamedTypeSymbol> interfaces,
384var interfacesToImplement = new List<INamedTypeSymbol>(
389var baseType = classOrStructType.BaseType;
400this INamedTypeSymbol classOrStructType,
401INamedTypeSymbol interfaceType,
402Func<INamedTypeSymbol, ISymbol, Func<INamedTypeSymbol, ISymbol, bool>, CancellationToken, bool> isImplemented,
403Func<INamedTypeSymbol, ISymbol, bool> isValidImplementation,
404Func<INamedTypeSymbol, ISymbol, ImmutableArray<ISymbol>> interfaceMemberGetter,
446this INamedTypeSymbol attributeSymbol,
452var systemAttributeType = compilation.AttributeType();
454foreach (var type in attributeSymbol.GetBaseTypesAndThis())
514private static ImmutableArray<ISymbol> GetMembers(INamedTypeSymbol type, ISymbol within)
528this INamedTypeSymbol containingType, CancellationToken cancellationToken)
545foreach (var type in baseTypes)
566Dictionary<ISymbol, int> result, INamedTypeSymbol containingType, CancellationToken cancellationToken)
587Dictionary<ISymbol, int> result, INamedTypeSymbol containingType, CancellationToken cancellationToken)
609Dictionary<ISymbol, int> result, INamedTypeSymbol containingType,
610INamedTypeSymbol type, ref int index, CancellationToken cancellationToken)
623private static bool IsOverridable(ISymbol member, INamedTypeSymbol containingType)
665public static INamedTypeSymbol TryConstruct(this INamedTypeSymbol type, ITypeSymbol[] typeArguments)
668public static bool IsCollectionBuilderAttribute([NotNullWhen(true)] this INamedTypeSymbol? type)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\SymbolEquivalenceComparer.EquivalenceVisitor.cs (65)
21public bool AreEquivalent(ISymbol? x, ISymbol? y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
50return AreArrayAndReadOnlySpanEquivalent((IArrayTypeSymbol)x, (INamedTypeSymbol)y, equivalentTypesWithDifferingAssemblies);
54return AreArrayAndReadOnlySpanEquivalent((IArrayTypeSymbol)y, (INamedTypeSymbol)x, equivalentTypesWithDifferingAssemblies);
64private bool AreArrayAndReadOnlySpanEquivalent(IArrayTypeSymbol array, INamedTypeSymbol readOnlySpanType, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
72internal bool AreEquivalent(CustomModifier x, CustomModifier y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
75internal bool AreEquivalent(ImmutableArray<CustomModifier> x, ImmutableArray<CustomModifier> y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
111private bool AreEquivalentWorker(ISymbol x, ISymbol y, SymbolKind k, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
125SymbolKind.NamedType => NamedTypesAreEquivalent((INamedTypeSymbol)x, (INamedTypeSymbol)y, equivalentTypesWithDifferingAssemblies),
126SymbolKind.ErrorType => NamedTypesAreEquivalent((INamedTypeSymbol)x, (INamedTypeSymbol)y, equivalentTypesWithDifferingAssemblies),
139private bool ArrayTypesAreEquivalent(IArrayTypeSymbol x, IArrayTypeSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
151private bool FieldsAreEquivalent(IFieldSymbol x, IFieldSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
169private bool MethodsAreEquivalent(IMethodSymbol x, IMethodSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies, bool considerReturnRefKinds = false)
280private bool NamedTypesAreEquivalent(INamedTypeSymbol x, INamedTypeSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
300private bool NamedTypesAreEquivalentError(INamedTypeSymbol x, INamedTypeSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
302foreach (var type1 in Unwrap(x))
305foreach (var type2 in Unwrap(y))
329private bool HandleNamedTypesWorker(INamedTypeSymbol x, INamedTypeSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
418private bool HandleTupleTypes(INamedTypeSymbol x, INamedTypeSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
463Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies,
486internal bool ReturnTypesAreEquivalent(IMethodSymbol x, IMethodSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies = null)
492private bool TypeArgumentsAreEquivalent(ImmutableArray<ITypeSymbol> xTypeArguments, ImmutableArray<ITypeSymbol> yTypeArguments, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
511private bool HandleAnonymousTypes(INamedTypeSymbol x, INamedTypeSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
547private bool NamespacesAreEquivalent(INamespaceSymbol x, INamespaceSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
564private bool ParametersAreEquivalent(IParameterSymbol x, IParameterSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
574private bool PointerTypesAreEquivalent(IPointerTypeSymbol x, IPointerTypeSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
581private bool FunctionPointerTypesAreEquivalent(IFunctionPointerTypeSymbol x, IFunctionPointerTypeSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
584private bool PropertiesAreEquivalent(IPropertySymbol x, IPropertySymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
608private bool EventsAreEquivalent(IEventSymbol x, IEventSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
615private bool TypeParametersAreEquivalent(ITypeParameterSymbol x, ITypeParameterSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
src\Analyzers\Core\CodeFixes\GenerateConstructor\AbstractGenerateConstructorService.cs (5)
28protected abstract bool ContainingTypesOrSelfHasUnsafeKeyword(INamedTypeSymbol containingType);
33protected abstract bool TryInitializeImplicitObjectCreation(SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken, out SyntaxToken token, out ImmutableArray<Argument> arguments, out INamedTypeSymbol typeToGenerateIn);
34protected abstract bool TryInitializeSimpleNameGenerationState(SemanticDocument document, SyntaxNode simpleName, CancellationToken cancellationToken, out SyntaxToken token, out ImmutableArray<Argument> arguments, out INamedTypeSymbol typeToGenerateIn);
35protected abstract bool TryInitializeConstructorInitializerGeneration(SemanticDocument document, SyntaxNode constructorInitializer, CancellationToken cancellationToken, out SyntaxToken token, out ImmutableArray<Argument> arguments, out INamedTypeSymbol typeToGenerateIn);
36protected abstract bool TryInitializeSimpleAttributeNameGenerationState(SemanticDocument document, SyntaxNode simpleName, CancellationToken cancellationToken, out SyntaxToken token, out ImmutableArray<Argument> arguments, out INamedTypeSymbol typeToGenerateIn);
src\Analyzers\Core\CodeFixes\GenerateMember\AbstractGenerateMemberService.cs (13)
33[NotNullWhen(true)] INamedTypeSymbol? typeToGenerateIn,
57INamedTypeSymbol containingType,
60[NotNullWhen(true)] out INamedTypeSymbol? typeToGenerateIn,
74INamedTypeSymbol containingType,
77out INamedTypeSymbol? typeToGenerateIn,
112underlyingType is INamedTypeSymbol underlyingNamedType)
130typeToGenerateIn = pointerType.PointedAtType as INamedTypeSymbol;
146typeToGenerateIn = attributeType.Type as INamedTypeSymbol;
154typeToGenerateIn = semanticModel.GetTypeInfo(initializedObject, cancellationToken).Type as INamedTypeSymbol;
166typeToGenerateIn = inferenceService.InferType(semanticModel, propertyPatternClause, objectAsDefault: true, cancellationToken) as INamedTypeSymbol;
181out INamedTypeSymbol? typeToGenerateIn,
191: typeInfo.Type as INamedTypeSymbol;
193isStatic = semanticInfo.Symbol is INamedTypeSymbol;
src\Analyzers\Core\CodeFixes\GenerateParameterizedMember\AbstractGenerateConversionService.cs (2)
26protected abstract bool TryInitializeImplicitConversionState(SemanticDocument document, SyntaxNode expression, ISet<TypeKind> classInterfaceModuleStructTypes, CancellationToken cancellationToken, out SyntaxToken identifierToken, out IMethodSymbol methodSymbol, out INamedTypeSymbol typeToGenerateIn);
27protected abstract bool TryInitializeExplicitConversionState(SemanticDocument document, SyntaxNode expression, ISet<TypeKind> classInterfaceModuleStructTypes, CancellationToken cancellationToken, out SyntaxToken identifierToken, out IMethodSymbol methodSymbol, out INamedTypeSymbol typeToGenerateIn);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService.cs (15)
60public TDeclarationNode AddNamedType<TDeclarationNode>(TDeclarationNode destination, INamedTypeSymbol namedType, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
89public SyntaxNode CreateNamedTypeDeclaration(INamedTypeSymbol namedType, CodeGenerationDestination destination, CodeGenerationContextInfo info, CancellationToken cancellationToken)
128protected abstract TDeclarationNode AddNamedType<TDeclarationNode>(TDeclarationNode destination, INamedTypeSymbol namedType, TCodeGenerationContextInfo info, IList<bool>? availableIndices, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
151public abstract SyntaxNode CreateNamedTypeDeclaration(INamedTypeSymbol namedType, CodeGenerationDestination destination, TCodeGenerationContextInfo info, CancellationToken cancellationToken);
350INamedTypeSymbol namedType => CreateNamedTypeDeclaration(namedType, codeGenerationDestination, info, cancellationToken),
368INamedTypeSymbol namedType => AddNamedType(currentDestination, namedType, info, availableIndices, cancellationToken),
393CodeGenerationSolutionContext context, INamedTypeSymbol destination, IEventSymbol @event, CancellationToken cancellationToken)
402public Task<Document> AddFieldAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IFieldSymbol field, CancellationToken cancellationToken)
411public Task<Document> AddPropertyAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IPropertySymbol property, CancellationToken cancellationToken)
420public Task<Document> AddNamedTypeAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, INamedTypeSymbol namedType, CancellationToken cancellationToken)
429public Task<Document> AddNamedTypeAsync(CodeGenerationSolutionContext context, INamespaceSymbol destination, INamedTypeSymbol namedType, CancellationToken cancellationToken)
447public Task<Document> AddMethodAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IMethodSymbol method, CancellationToken cancellationToken)
456public Task<Document> AddMembersAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IEnumerable<ISymbol> members, CancellationToken cancellationToken)
478return AddNamedTypeAsync(context, destination, (INamedTypeSymbol)namespaceOrType, cancellationToken);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractFlagsEnumGenerator.cs (10)
15protected abstract SyntaxNode CreateExplicitlyCastedLiteralValue(SyntaxGenerator generator, INamedTypeSymbol enumType, SpecialType underlyingSpecialType, object constantValue);
16protected abstract bool IsValidName(INamedTypeSymbol enumType, string name);
18public SyntaxNode CreateEnumConstantValue(SyntaxGenerator generator, INamedTypeSymbol enumType, object constantValue)
34private static bool IsFlagsEnum(INamedTypeSymbol typeSymbol)
46var type = ctor.ContainingType;
63private SyntaxNode CreateFlagsEnumConstantValue(SyntaxGenerator generator, INamedTypeSymbol enumType, object constantValue)
75INamedTypeSymbol enumType,
141SyntaxGenerator generator, IFieldSymbol field, INamedTypeSymbol enumType, SpecialType underlyingSpecialType)
171INamedTypeSymbol enumType,
188private SyntaxNode CreateNonFlagsEnumConstantValue(SyntaxGenerator generator, INamedTypeSymbol enumType, object constantValue)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationSymbolFactory.cs (14)
48INamedTypeSymbol? containingType,
152INamedTypeSymbol? containingType,
226INamedTypeSymbol? containingType = null,
254INamedTypeSymbol? containingType = null,
408INamedTypeSymbol attributeClass,
418public static INamedTypeSymbol CreateNamedTypeSymbol(
424INamedTypeSymbol? baseType = null,
425ImmutableArray<INamedTypeSymbol> interfaces = default,
437public static INamedTypeSymbol CreateNamedTypeSymbol(
443INamedTypeSymbol? baseType = null,
444ImmutableArray<INamedTypeSymbol> interfaces = default,
455members.WhereAsArray(m => m is not INamedTypeSymbol),
456members.OfType<INamedTypeSymbol>().Select(n => n.ToCodeGenerationSymbol()).ToImmutableArray(),
523INamedTypeSymbol? containingType = null,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerator.cs (8)
30public static Task<Document> AddEventDeclarationAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IEventSymbol @event, CancellationToken cancellationToken)
37public static Task<Document> AddFieldDeclarationAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IFieldSymbol field, CancellationToken cancellationToken)
44public static Task<Document> AddMethodDeclarationAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IMethodSymbol method, CancellationToken cancellationToken)
51public static Task<Document> AddPropertyDeclarationAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IPropertySymbol property, CancellationToken cancellationToken)
58public static Task<Document> AddNamedTypeDeclarationAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, INamedTypeSymbol namedType, CancellationToken cancellationToken)
65public static Task<Document> AddNamedTypeDeclarationAsync(CodeGenerationSolutionContext context, INamespaceSymbol destination, INamedTypeSymbol namedType, CancellationToken cancellationToken)
86public static Task<Document> AddMemberDeclarationsAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IEnumerable<ISymbol> members, CancellationToken cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\ICodeGenerationService.cs (10)
44SyntaxNode CreateNamedTypeDeclaration(INamedTypeSymbol namedType, CodeGenerationDestination destination, CodeGenerationContextInfo info, CancellationToken cancellationToken);
74TDeclarationNode AddNamedType<TDeclarationNode>(TDeclarationNode destination, INamedTypeSymbol namedType, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
134Task<Document> AddEventAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IEventSymbol @event, CancellationToken cancellationToken);
139Task<Document> AddFieldAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IFieldSymbol field, CancellationToken cancellationToken);
144Task<Document> AddMethodAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IMethodSymbol method, CancellationToken cancellationToken);
149Task<Document> AddPropertyAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IPropertySymbol property, CancellationToken cancellationToken);
154Task<Document> AddNamedTypeAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, INamedTypeSymbol namedType, CancellationToken cancellationToken);
159Task<Document> AddNamedTypeAsync(CodeGenerationSolutionContext context, INamespaceSymbol destination, INamedTypeSymbol namedType, CancellationToken cancellationToken);
174Task<Document> AddMembersAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IEnumerable<ISymbol> members, CancellationToken cancellationToken);
src\Analyzers\CSharp\Analyzers\UsePrimaryConstructor\CSharpUsePrimaryConstructorDiagnosticAnalyzer.cs (16)
79var namedTypeToAnalyzer = new ConcurrentDictionary<INamedTypeSymbol, Analyzer>();
85INamedTypeSymbol namedType,
142INamedTypeSymbol namedType,
145ConcurrentDictionary<INamedTypeSymbol, Analyzer> namedTypeToAnalyzer)
150private readonly INamedTypeSymbol _namedType = namedType;
154private readonly ConcurrentDictionary<INamedTypeSymbol, Analyzer> _namedTypeToAnalyzer = namedTypeToAnalyzer;
204ConcurrentDictionary<INamedTypeSymbol, Analyzer> namedTypeToAnalyzer)
209var startSymbol = (INamedTypeSymbol)context.Symbol;
215for (var containingType = startSymbol.ContainingType; containingType != null; containingType = containingType.ContainingType)
245INamedTypeSymbol namedType)
260Analyzer? TryCreateAnalyzer(INamedTypeSymbol namedType)
340INamedTypeSymbol namedType,
385INamedTypeSymbol namedType,
406INamedTypeSymbol namedType,
463INamedTypeSymbol namedType,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationService.cs (5)
63CodeGenerationSolutionContext context, INamedTypeSymbol destination, IEventSymbol @event, CancellationToken cancellationToken)
68var namedType = @event.Type as INamedTypeSymbol;
247protected override TDeclarationNode AddNamedType<TDeclarationNode>(TDeclarationNode destination, INamedTypeSymbol namedType, CSharpCodeGenerationContextInfo info, IList<bool>? availableIndices, CancellationToken cancellationToken)
705INamedTypeSymbol namedType, CodeGenerationDestination destination, CSharpCodeGenerationContextInfo info, CancellationToken cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\NamedTypeGenerator.cs (14)
28INamedTypeSymbol namedType,
42INamedTypeSymbol namedType,
57INamedTypeSymbol namedType,
69INamedTypeSymbol namedType,
152INamedTypeSymbol namedType,
182INamedTypeSymbol namedType,
226INamedTypeSymbol namedType,
244INamedTypeSymbol namedType,
261INamedTypeSymbol namedType, CSharpCodeGenerationContextInfo info)
267INamedTypeSymbol namedType,
311INamedTypeSymbol namedType, CSharpCodeGenerationContextInfo info)
316private static BaseListSyntax? GenerateBaseList(INamedTypeSymbol namedType)
322foreach (var type in namedType.Interfaces)
331private static SyntaxList<TypeParameterConstraintClauseSyntax> GenerateConstraintClauses(INamedTypeSymbol namedType)
SignatureHelp\TupleConstructionSignatureHelpProvider.cs (5)
125private IEnumerable<INamedTypeSymbol>? FindNearestTupleConstructionWithInferrableType(SyntaxNode root, SemanticModel semanticModel, int position, SignatureHelpTriggerInfo triggerInfo,
137var tupleTypes = inferredTypes.Where(t => t.IsTupleType).OfType<INamedTypeSymbol>().ToList();
151SyntaxNode targetExpression, SemanticModel semanticModel, IEnumerable<INamedTypeSymbol> tupleTypes, CancellationToken cancellationToken)
165private static SignatureHelpItem Convert(INamedTypeSymbol tupleType, ImmutableArray<TaggedText> prefixParts, ImmutableArray<TaggedText> suffixParts,
179private static IEnumerable<SignatureHelpParameter> ConvertTupleMembers(INamedTypeSymbol tupleType, SemanticModel semanticModel, int position)
src\Analyzers\CSharp\Analyzers\UsePrimaryConstructor\CSharpUsePrimaryConstructorDiagnosticAnalyzer.cs (16)
79var namedTypeToAnalyzer = new ConcurrentDictionary<INamedTypeSymbol, Analyzer>();
85INamedTypeSymbol namedType,
142INamedTypeSymbol namedType,
145ConcurrentDictionary<INamedTypeSymbol, Analyzer> namedTypeToAnalyzer)
150private readonly INamedTypeSymbol _namedType = namedType;
154private readonly ConcurrentDictionary<INamedTypeSymbol, Analyzer> _namedTypeToAnalyzer = namedTypeToAnalyzer;
204ConcurrentDictionary<INamedTypeSymbol, Analyzer> namedTypeToAnalyzer)
209var startSymbol = (INamedTypeSymbol)context.Symbol;
215for (var containingType = startSymbol.ContainingType; containingType != null; containingType = containingType.ContainingType)
245INamedTypeSymbol namedType)
260Analyzer? TryCreateAnalyzer(INamedTypeSymbol namedType)
340INamedTypeSymbol namedType,
385INamedTypeSymbol namedType,
406INamedTypeSymbol namedType,
463INamedTypeSymbol namedType,
Recommendations\CSharpRecommendationServiceRunner_Conversions.cs (6)
137if (container.RemoveNullableIfPresent() is INamedTypeSymbol namedType)
153ITypeSymbol container, INamedTypeSymbol containerWithoutNullable, ArrayBuilder<ISymbol> symbols)
201ITypeSymbol container, INamedTypeSymbol containerWithoutNullable, ArrayBuilder<ISymbol> symbols)
229ITypeSymbol container, INamedTypeSymbol containerWithoutNullable, ArrayBuilder<ISymbol> symbols, ImmutableArray<SpecialType> specialTypes)
258private static IMethodSymbol CreateConversion(INamedTypeSymbol containingType, ITypeSymbol fromType, ITypeSymbol toType, string? documentationCommentXml)
266ITypeSymbol container, INamedTypeSymbol containerWithoutNullable, ArrayBuilder<ISymbol> symbols)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationService.cs (5)
63CodeGenerationSolutionContext context, INamedTypeSymbol destination, IEventSymbol @event, CancellationToken cancellationToken)
68var namedType = @event.Type as INamedTypeSymbol;
247protected override TDeclarationNode AddNamedType<TDeclarationNode>(TDeclarationNode destination, INamedTypeSymbol namedType, CSharpCodeGenerationContextInfo info, IList<bool>? availableIndices, CancellationToken cancellationToken)
705INamedTypeSymbol namedType, CodeGenerationDestination destination, CSharpCodeGenerationContextInfo info, CancellationToken cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\NamedTypeGenerator.cs (14)
28INamedTypeSymbol namedType,
42INamedTypeSymbol namedType,
57INamedTypeSymbol namedType,
69INamedTypeSymbol namedType,
152INamedTypeSymbol namedType,
182INamedTypeSymbol namedType,
226INamedTypeSymbol namedType,
244INamedTypeSymbol namedType,
261INamedTypeSymbol namedType, CSharpCodeGenerationContextInfo info)
267INamedTypeSymbol namedType,
311INamedTypeSymbol namedType, CSharpCodeGenerationContextInfo info)
316private static BaseListSyntax? GenerateBaseList(INamedTypeSymbol namedType)
322foreach (var type in namedType.Interfaces)
331private static SyntaxList<TypeParameterConstraintClauseSyntax> GenerateConstraintClauses(INamedTypeSymbol namedType)
Completion\Providers\AbstractPartialTypeCompletionProvider.cs (9)
41if (semanticModel.GetDeclaredSymbol(node, cancellationToken) is INamedTypeSymbol declaredSymbol)
61private CompletionItem CreateCompletionItem(INamedTypeSymbol symbol, TSyntaxContext context)
75protected abstract ImmutableArray<KeyValuePair<string, string>> GetProperties(INamedTypeSymbol symbol, TSyntaxContext context);
79protected abstract (string displayText, string suffix, string insertionText) GetDisplayAndSuffixAndInsertionText(INamedTypeSymbol symbol, TSyntaxContext context);
81protected virtual IEnumerable<INamedTypeSymbol>? LookupCandidateSymbols(TSyntaxContext context, INamedTypeSymbol declaredSymbol, CancellationToken cancellationToken)
94.OfType<INamedTypeSymbol>()
100private static bool InSameProject(INamedTypeSymbol symbol, Compilation compilation)
103private static bool NotNewDeclaredMember(INamedTypeSymbol symbol, TSyntaxContext context)
ConvertAnonymousType\AbstractConvertAnonymousTypeToClassCodeRefactoringProvider.cs (8)
104var namedTypeSymbol = await GenerateFinalNamedTypeAsync(
178Document document, SyntaxEditor editor, INamedTypeSymbol classSymbol,
180INamedTypeSymbol anonymousType, CancellationToken cancellationToken)
214SyntaxEditor editor, INamedTypeSymbol classSymbol,
242private static async Task<INamedTypeSymbol> GenerateFinalNamedTypeAsync(
283var namedTypeWithoutMembers = CreateNamedType(typeName, isRecord: false, capturedTypeParameters, members: default);
312private static INamedTypeSymbol CreateNamedType(
321Document document, INamedTypeSymbol anonymousType)
ConvertForToForEach\AbstractConvertForToForEachCodeRefactoringProvider.cs (10)
232INamedTypeSymbol containingType, ITypeSymbol type, string memberName) where TSymbol : class, ISymbol
239INamedTypeSymbol containingType, ITypeSymbol type, string memberName) where TSymbol : class, ISymbol
245INamedTypeSymbol containingType, ITypeSymbol collectionType,
246INamedTypeSymbol ienumerableType, INamedTypeSymbol ienumeratorType,
281INamedTypeSymbol containingType, IMethodSymbol getEnumeratorMethod,
282INamedTypeSymbol ienumeratorType, [NotNullWhen(true)] out ITypeSymbol? iterationType)
314INamedTypeSymbol containingType,
500INamedTypeSymbol containingType,
502INamedTypeSymbol ienumerableType)
ConvertTupleToStruct\AbstractConvertTupleToStructCodeRefactoringProvider.cs (25)
183private static async Task<(SyntaxNode, INamedTypeSymbol)> TryGetTupleInfoAsync(
207var tupleType = semanticModel.GetTypeInfo(expressionOrType, cancellationToken).Type as INamedTypeSymbol;
327SyntaxNode tupleExprOrTypeNode, INamedTypeSymbol tupleType,
420INamedTypeSymbol tupleType, Scope scope, CancellationToken cancellationToken)
436Project startingProject, INamedTypeSymbol tupleType, CancellationToken cancellationToken)
478Project project, INamedTypeSymbol tupleType, CancellationToken cancellationToken)
526var typeSymbol = (INamedTypeSymbol)semanticModel.GetRequiredDeclaredSymbol(containingType, cancellationToken);
553Document document, SyntaxNode tupleExprOrTypeNode, INamedTypeSymbol namedTypeSymbol,
615SyntaxNode startingNode, INamedTypeSymbol tupleType, TNameSyntax fullyQualifiedStructName,
635SyntaxNode startingNode, INamedTypeSymbol tupleType, TNameSyntax qualifiedTypeName,
649if (semanticModel.GetTypeInfo(childCreation, cancellationToken).Type is not INamedTypeSymbol childType)
666private static bool AreEquivalent(StringComparer comparer, INamedTypeSymbol tupleType, INamedTypeSymbol childType)
749INamedTypeSymbol tupleType, TNameSyntax qualifiedTypeName,
762if (semanticModel.GetTypeInfo(childTupleType, cancellationToken).Type is not INamedTypeSymbol childType)
798private static async Task<INamedTypeSymbol> GenerateFinalNamedTypeAsync(
800INamedTypeSymbol tupleType, NamingRule parameterNamingRule, CancellationToken cancellationToken)
812var namedTypeWithoutMembers = CreateNamedType(
848var namedTypeSymbol = CreateNamedType(
855INamedTypeSymbol tupleType, IMethodSymbol constructor)
881INamedTypeSymbol tupleType, INamedTypeSymbol structType)
908private static INamedTypeSymbol CreateNamedType(
ExtractInterface\AbstractExtractInterfaceService.cs (11)
41INamedTypeSymbol extractedInterfaceSymbol,
42INamedTypeSymbol typeToExtractFrom,
47internal abstract string GetContainingNamespaceDisplay(INamedTypeSymbol typeSymbol, CompilationOptions compilationOptions);
102var typeToExtractFrom = type as INamedTypeSymbol;
141var extractedInterfaceSymbol = CodeGenerationSymbolFactory.CreateNamedTypeSymbol(
175Solution solution, string containingNamespaceDisplay, INamedTypeSymbol extractedInterfaceSymbol,
217Solution solution, ExtractInterfaceTypeAnalysisResult refactoringResult, INamedTypeSymbol extractedInterfaceSymbol,
257INamedTypeSymbol type,
317INamedTypeSymbol typeToExtractFrom,
318INamedTypeSymbol extractedInterfaceSymbol,
GenerateComparisonOperators\GenerateComparisonOperatorsCodeRefactoringProvider.cs (14)
66var containingType = semanticModel.GetDeclaredSymbol(typeDeclaration, cancellationToken) as INamedTypeSymbol;
70using var _1 = ArrayBuilder<INamedTypeSymbol>.GetInstance(out var missingComparableTypes);
72foreach (var iface in containingType.Interfaces)
122private static IMethodSymbol? TryGetCompareMethodImpl(INamedTypeSymbol containingType, ITypeSymbol comparableType)
136INamedTypeSymbol comparableType,
141var containingType = (INamedTypeSymbol)semanticModel.GetRequiredDeclaredSymbol(typeDeclaration, cancellationToken);
160INamedTypeSymbol comparableType,
177INamedTypeSymbol containingType,
178INamedTypeSymbol comparableType,
183var boolType = compilation.GetSpecialType(SpecialType.System_Boolean);
229private static bool HasAllComparisonOperators(INamedTypeSymbol containingType, ITypeSymbol comparedType)
240private static bool HasComparisonOperator(INamedTypeSymbol containingType, ITypeSymbol comparedType, CodeGenerationOperatorKind kind)
GenerateEqualsAndGetHashCodeFromMembers\AbstractGenerateEqualsAndGetHashCodeService.cs (9)
39Document document, INamedTypeSymbol namedType, ImmutableArray<ISymbol> members,
51Document document, INamedTypeSymbol namedType,
52ImmutableArray<ISymbol> members, INamedTypeSymbol constructedEquatableType, CancellationToken cancellationToken)
62Document document, INamedTypeSymbol containingType, CancellationToken cancellationToken)
118Document document, INamedTypeSymbol namedType,
129INamedTypeSymbol namedType, ImmutableArray<ISymbol> members)
149INamedTypeSymbol namedType, ImmutableArray<ISymbol> members)
152var hashCodeType = compilation.GetTypeByMetadataName("System.HashCode");
183var valueTupleType = compilation.GetTypeByMetadataName(typeof(ValueTuple).FullName!);
GenerateEqualsAndGetHashCodeFromMembers\GenerateEqualsAndGetHashCodeFromMembersCodeRefactoringProvider.cs (12)
87var containingType = semanticModel.GetDeclaredSymbol(typeDeclaration) as INamedTypeSymbol;
121private static bool HasOperators(INamedTypeSymbol containingType)
125private static bool HasOperator(INamedTypeSymbol containingType, string operatorName)
134SemanticModel semanticModel, INamedTypeSymbol containingType,
135[NotNullWhen(true)] out INamedTypeSymbol? constructedType)
141var equatableTypeOpt = semanticModel.Compilation.GetTypeByMetadataName(typeof(IEquatable<>).FullName!);
156private static void GetExistingMemberInfo(INamedTypeSymbol containingType, out bool hasEquals, out bool hasGetHashCode)
199Document document, SyntaxNode typeDeclaration, INamedTypeSymbol containingType, ImmutableArray<ISymbol> selectedMembers,
239Document document, SyntaxNode typeDeclaration, INamedTypeSymbol containingType, ImmutableArray<ISymbol> members,
256Document document, SyntaxNode typeDeclaration, INamedTypeSymbol containingType, ImmutableArray<ISymbol> members,
293Document document, SyntaxNode typeDeclaration, INamedTypeSymbol containingType, ImmutableArray<ISymbol> members,
GenerateEqualsAndGetHashCodeFromMembers\IGenerateEqualsAndGetHashCodeService.cs (5)
29Task<IMethodSymbol> GenerateEqualsMethodAsync(Document document, INamedTypeSymbol namedType, ImmutableArray<ISymbol> members, string? localNameOpt, CancellationToken cancellationToken);
35Task<IMethodSymbol> GenerateEqualsMethodThroughIEquatableEqualsAsync(Document document, INamedTypeSymbol namedType, CancellationToken cancellationToken);
41Task<IMethodSymbol> GenerateIEquatableEqualsMethodAsync(Document document, INamedTypeSymbol namedType, ImmutableArray<ISymbol> members, INamedTypeSymbol constructedEquatableType, CancellationToken cancellationToken);
50Task<IMethodSymbol> GenerateGetHashCodeMethodAsync(Document document, INamedTypeSymbol namedType, ImmutableArray<ISymbol> members, CancellationToken cancellationToken);
LanguageServices\AnonymousTypeDisplayService\AbstractStructuralTypeDisplayService.cs (17)
23protected abstract ImmutableArray<SymbolDisplayPart> GetNormalAnonymousTypeParts(INamedTypeSymbol anonymousType, SemanticModel semanticModel, int position);
25public ImmutableArray<SymbolDisplayPart> GetAnonymousTypeParts(INamedTypeSymbol anonymousType, SemanticModel semanticModel, int position)
31INamedTypeSymbol anonymousType,
63ImmutableArray<INamedTypeSymbol> directStructuralTypeReferences,
70SpecializedCollections.EmptyDictionary<INamedTypeSymbol, string>(),
92var structuralType = transitiveStructuralTypeReferences[i];
120private static Dictionary<INamedTypeSymbol, string> GenerateStructuralTypeNames(
121IList<INamedTypeSymbol> anonymousTypes)
124var anonymousTypeToName = new Dictionary<INamedTypeSymbol, string>();
125foreach (var type in anonymousTypes)
145private static ImmutableArray<INamedTypeSymbol> OrderStructuralTypes(
146ImmutableArray<INamedTypeSymbol> structuralTypes,
185private static ImmutableArray<INamedTypeSymbol> GetTransitiveStructuralTypeReferences(
186ImmutableArray<INamedTypeSymbol> structuralTypes)
188var transitiveReferences = new Dictionary<INamedTypeSymbol, (int order, int count)>();
191foreach (var type in structuralTypes)
198using var _ = ArrayBuilder<INamedTypeSymbol>.GetInstance(out var result);
Shared\Utilities\ExtractTypeHelpers.cs (7)
29public static async Task<(Document containingDocument, SyntaxAnnotation typeAnnotation)> AddTypeToExistingFileAsync(Document document, INamedTypeSymbol newType, AnnotatedSymbolMapping symbolMapping, CancellationToken cancellationToken)
56INamedTypeSymbol newSymbol,
115public static string GetTypeParameterSuffix(Document document, SyntaxFormattingOptions formattingOptions, INamedTypeSymbol type, IEnumerable<ISymbol> extractableMembers, CancellationToken cancellationToken)
130public static ImmutableArray<ITypeParameterSymbol> GetRequiredTypeParametersForMembers(INamedTypeSymbol type, IEnumerable<ISymbol> includedMembers)
163private static ImmutableArray<ITypeParameterSymbol> GetPotentialTypeParameters(INamedTypeSymbol type)
167var typesToVisit = new Stack<INamedTypeSymbol>();
169var currentType = type;
src\Analyzers\Core\Analyzers\MakeFieldReadonly\AbstractMakeFieldReadonlyDiagnosticAnalyzer.cs (11)
66if (!ShouldAnalyze(context, (INamedTypeSymbol)context.Symbol))
118var members = ((INamedTypeSymbol)symbolEndContext.Symbol).GetMembers();
140bool ShouldAnalyze(SymbolStartAnalysisContext context, INamedTypeSymbol namedType)
161static bool IsCandidateField(IFieldSymbol symbol, INamedTypeSymbol? threadStaticAttribute, INamedTypeSymbol? dataContractAttribute, INamedTypeSymbol? dataMemberAttribute)
177static bool IsDataContractSerializable(IFieldSymbol symbol, INamedTypeSymbol? dataContractAttribute, INamedTypeSymbol? dataMemberAttribute)
216INamedTypeSymbol? threadStaticAttribute,
217INamedTypeSymbol? dataContractAttribute,
218INamedTypeSymbol? dataMemberAttribute,
src\Analyzers\Core\CodeFixes\GenerateConstructor\AbstractGenerateConstructorService.cs (5)
28protected abstract bool ContainingTypesOrSelfHasUnsafeKeyword(INamedTypeSymbol containingType);
33protected abstract bool TryInitializeImplicitObjectCreation(SemanticDocument document, SyntaxNode node, CancellationToken cancellationToken, out SyntaxToken token, out ImmutableArray<Argument> arguments, out INamedTypeSymbol typeToGenerateIn);
34protected abstract bool TryInitializeSimpleNameGenerationState(SemanticDocument document, SyntaxNode simpleName, CancellationToken cancellationToken, out SyntaxToken token, out ImmutableArray<Argument> arguments, out INamedTypeSymbol typeToGenerateIn);
35protected abstract bool TryInitializeConstructorInitializerGeneration(SemanticDocument document, SyntaxNode constructorInitializer, CancellationToken cancellationToken, out SyntaxToken token, out ImmutableArray<Argument> arguments, out INamedTypeSymbol typeToGenerateIn);
36protected abstract bool TryInitializeSimpleAttributeNameGenerationState(SemanticDocument document, SyntaxNode simpleName, CancellationToken cancellationToken, out SyntaxToken token, out ImmutableArray<Argument> arguments, out INamedTypeSymbol typeToGenerateIn);
src\Analyzers\Core\CodeFixes\GenerateMember\AbstractGenerateMemberService.cs (13)
33[NotNullWhen(true)] INamedTypeSymbol? typeToGenerateIn,
57INamedTypeSymbol containingType,
60[NotNullWhen(true)] out INamedTypeSymbol? typeToGenerateIn,
74INamedTypeSymbol containingType,
77out INamedTypeSymbol? typeToGenerateIn,
112underlyingType is INamedTypeSymbol underlyingNamedType)
130typeToGenerateIn = pointerType.PointedAtType as INamedTypeSymbol;
146typeToGenerateIn = attributeType.Type as INamedTypeSymbol;
154typeToGenerateIn = semanticModel.GetTypeInfo(initializedObject, cancellationToken).Type as INamedTypeSymbol;
166typeToGenerateIn = inferenceService.InferType(semanticModel, propertyPatternClause, objectAsDefault: true, cancellationToken) as INamedTypeSymbol;
181out INamedTypeSymbol? typeToGenerateIn,
191: typeInfo.Type as INamedTypeSymbol;
193isStatic = semanticInfo.Symbol is INamedTypeSymbol;
src\Analyzers\Core\CodeFixes\GenerateParameterizedMember\AbstractGenerateConversionService.cs (2)
26protected abstract bool TryInitializeImplicitConversionState(SemanticDocument document, SyntaxNode expression, ISet<TypeKind> classInterfaceModuleStructTypes, CancellationToken cancellationToken, out SyntaxToken identifierToken, out IMethodSymbol methodSymbol, out INamedTypeSymbol typeToGenerateIn);
27protected abstract bool TryInitializeExplicitConversionState(SemanticDocument document, SyntaxNode expression, ISet<TypeKind> classInterfaceModuleStructTypes, CancellationToken cancellationToken, out SyntaxToken identifierToken, out IMethodSymbol methodSymbol, out INamedTypeSymbol typeToGenerateIn);
CodeFixes\GenerateEvent\GenerateEventCodeFixProvider.vb (16)
97Dim targetType As INamedTypeSymbol = Nothing
110targetType = TryCast(sourceDefinition, INamedTypeSymbol)
124targetType As INamedTypeSymbol,
172Dim typeSymbol = TryCast(semanticModel.GetTypeInfo(handlerExpression, cancellationToken).Type, INamedTypeSymbol)
187Private Shared Function ResolveTargetType(ByRef targetType As INamedTypeSymbol, semanticModel As SemanticModel) As Boolean
194targetType = DirectCast(targetType.GetSymbolKey().Resolve(semanticModel.Compilation).Symbol, INamedTypeSymbol)
203Private Shared Function TryGetNameAndTargetType(eventExpression As ExpressionSyntax, containingSymbol As INamedTypeSymbol, semanticModel As SemanticModel, ByRef targetType As INamedTypeSymbol, ByRef actualEventName As String, cancellationToken As CancellationToken) As Boolean
205Dim eventType As INamedTypeSymbol = Nothing
213eventType = TryCast(semanticModel.GetTypeInfo(qualifier, cancellationToken).Type, INamedTypeSymbol)
259Dim targetType = TryCast(Await SymbolFinder.FindSourceDefinitionAsync(semanticModel.GetSymbolInfo(node.Left, cancellationToken).Symbol, document.Project.Solution, cancellationToken).ConfigureAwait(False), INamedTypeSymbol)
278Dim eventType = TryCast(boundEvent.Type, INamedTypeSymbol)
327Dim targetType As INamedTypeSymbol = Nothing
350targetType = TryCast(Await SymbolFinder.FindSourceDefinitionAsync(withEventsProperty.Type, document.Project.Solution, cancellationToken).ConfigureAwait(False), INamedTypeSymbol)
354targetType = TryCast(Await SymbolFinder.FindSourceDefinitionAsync(targetType, document.Project.Solution, cancellationToken).ConfigureAwait(False), INamedTypeSymbol)
363targetType = DirectCast(targetType.GetSymbolKey(cancellationToken).Resolve(semanticModel.Compilation, cancellationToken:=cancellationToken).Symbol, INamedTypeSymbol)
GenerateType\VisualBasicGenerateTypeService.vb (4)
333generateTypeServiceStateOptions.DelegateCreationMethodSymbol = DirectCast(type, INamedTypeSymbol).DelegateInvokeMethod
395cancellationToken As CancellationToken) As INamedTypeSymbol
400Return If(typeBlock Is Nothing, Nothing, TryCast(semanticModel.GetDeclaredSymbol(typeBlock.BlockStatement, cancellationToken), INamedTypeSymbol))
426Public Overrides Async Function GetOrGenerateEnclosingNamespaceSymbolAsync(namedTypeSymbol As INamedTypeSymbol, containers() As String, selectedDocument As Document, selectedDocumentRoot As SyntaxNode, cancellationToken As CancellationToken) As Task(Of (INamespaceSymbol, INamespaceOrTypeSymbol, Location))
NavigationBar\VisualBasicNavigationBarItemService.vb (9)
61Private Shared Function GetTypesAndDeclarationsInFile(semanticModel As SemanticModel, cancellationToken As CancellationToken) As IEnumerable(Of Tuple(Of INamedTypeSymbol, SyntaxNode))
63Dim typesAndDeclarations As New Dictionary(Of INamedTypeSymbol, SyntaxNode)
70Return SpecializedCollections.EmptyEnumerable(Of Tuple(Of INamedTypeSymbol, SyntaxNode))()
74Dim type = TryCast(semanticModel.GetDeclaredSymbol(node, cancellationToken), INamedTypeSymbol)
103type As INamedTypeSymbol,
157type As INamedTypeSymbol,
202type As INamedTypeSymbol,
311containingType As INamedTypeSymbol,
360DirectCast(e.Type, INamedTypeSymbol).DelegateInvokeMethod IsNot Nothing Then
src\Analyzers\VisualBasic\CodeFixes\GenerateParameterizedMember\VisualBasicGenerateConversionService.vb (11)
55Protected Overrides Function TryInitializeExplicitConversionState(document As SemanticDocument, expression As SyntaxNode, classInterfaceModuleStructTypes As ISet(Of TypeKind), cancellationToken As CancellationToken, ByRef identifierToken As SyntaxToken, ByRef methodSymbol As IMethodSymbol, ByRef typeToGenerateIn As INamedTypeSymbol) As Boolean
69Protected Overrides Function TryInitializeImplicitConversionState(document As SemanticDocument, expression As SyntaxNode, classInterfaceModuleStructTypes As ISet(Of TypeKind), cancellationToken As CancellationToken, ByRef identifierToken As SyntaxToken, ByRef methodSymbol As IMethodSymbol, ByRef typeToGenerateIn As INamedTypeSymbol) As Boolean
83Private Shared Function TryGetConversionMethodAndTypeToGenerateIn(document As SemanticDocument, expression As SyntaxNode, classInterfaceModuleStructTypes As ISet(Of TypeKind), cancellationToken As CancellationToken, ByRef methodSymbol As IMethodSymbol, ByRef typeToGenerateIn As INamedTypeSymbol) As Boolean
113Private Shared Function TryGetExplicitConversionMethodAndTypeToGenerateIn(document As SemanticDocument, castExpression As CastExpressionSyntax, classInterfaceModuleStructTypes As ISet(Of TypeKind), cancellationToken As CancellationToken, ByRef methodSymbol As IMethodSymbol, ByRef typeToGenerateIn As INamedTypeSymbol) As Boolean
115typeToGenerateIn = TryCast(document.SemanticModel.GetTypeInfo(castExpression.Type, cancellationToken).Type, INamedTypeSymbol)
116Dim parameterSymbol = TryCast(document.SemanticModel.GetTypeInfo(castExpression.Expression, cancellationToken).Type, INamedTypeSymbol)
129Private Shared Function TryGetImplicitConversionMethodAndTypeToGenerateIn(document As SemanticDocument, expression As SyntaxNode, classInterfaceModuleStructTypes As ISet(Of TypeKind), cancellationToken As CancellationToken, ByRef methodSymbol As IMethodSymbol, ByRef typeToGenerateIn As INamedTypeSymbol) As Boolean
131typeToGenerateIn = TryCast(document.SemanticModel.GetTypeInfo(expression, cancellationToken).ConvertedType, INamedTypeSymbol)
132Dim parameterSymbol = TryCast(document.SemanticModel.GetTypeInfo(expression, cancellationToken).Type, INamedTypeSymbol)
145Private Shared Function GenerateMethodSymbol(typeToGenerateIn As INamedTypeSymbol, parameterSymbol As INamedTypeSymbol) As IMethodSymbol
FindSymbols\FindReferences\DependentTypeFinder.cs (30)
20using SymbolSet = HashSet<INamedTypeSymbol>;
45private static readonly Func<INamedTypeSymbol, bool> s_isInterface = static t => t is { TypeKind: TypeKind.Interface };
46private static readonly Func<INamedTypeSymbol, bool> s_isNonSealedClass = static t => t is { TypeKind: TypeKind.Class, IsSealed: false };
47private static readonly Func<INamedTypeSymbol, bool> s_isInterfaceOrNonSealedClass = static t => s_isInterface(t) || s_isNonSealedClass(t);
49private static readonly ObjectPool<PooledHashSet<INamedTypeSymbol>> s_symbolSetPool = PooledHashSet<INamedTypeSymbol>.CreatePool(SymbolEquivalenceComparer.Instance);
52/// Walks down a <paramref name="type"/>'s inheritance tree looking for more <see cref="INamedTypeSymbol"/>'s
60private static async Task<ImmutableArray<INamedTypeSymbol>> DescendInheritanceTreeAsync(
61INamedTypeSymbol type,
64Func<INamedTypeSymbol, SymbolSet, bool> typeMatches,
65Func<INamedTypeSymbol, bool> shouldContinueSearching,
209foreach (var type in typesToSearchFor)
254Func<INamedTypeSymbol, bool>? predicate)
266if (info.TryResolve(semanticModel, cancellationToken) is INamedTypeSymbol namedType &&
282if (info.TryResolve(semanticModel, cancellationToken) is INamedTypeSymbol namedType &&
351foreach (var metadataType in metadataTypes)
360foreach (var derivedType in symbolTreeInfo.GetDerivedMetadataTypes(baseTypeName, compilation, cancellationToken))
377foreach (var type in foundTypes)
384foreach (var type in foundTypes)
388private static void AddRange(SymbolSet foundTypes, SymbolSet currentTypes, Func<INamedTypeSymbol, bool> shouldContinueSearching)
391foreach (var type in foundTypes)
399INamedTypeSymbol type,
514private static bool TypeHasBaseTypeInSet(INamedTypeSymbol type, SymbolSet set)
516var baseType = type.BaseType?.OriginalDefinition;
520private static bool TypeHasInterfaceInSet(INamedTypeSymbol type, SymbolSet set)
522foreach (var interfaceType in type.Interfaces)
541Func<INamedTypeSymbol, bool> shouldContinueSearching)
548foreach (var derivedType in tempBuffer)
562public static PooledDisposer<PooledHashSet<INamedTypeSymbol>> GetSymbolSet(out SymbolSet instance)
567return new PooledDisposer<PooledHashSet<INamedTypeSymbol>>(pooledInstance);
FindSymbols\FindReferences\Finders\NamedTypeSymbolReferenceFinder.cs (12)
17internal sealed class NamedTypeSymbolReferenceFinder : AbstractReferenceFinder<INamedTypeSymbol>
19protected override bool CanFind(INamedTypeSymbol symbol)
22protected override Task<ImmutableArray<string>> DetermineGlobalAliasesAsync(INamedTypeSymbol symbol, Project project, CancellationToken cancellationToken)
28INamedTypeSymbol symbol,
53INamedTypeSymbol symbol,
108INamedTypeSymbol namedType,
140INamedTypeSymbol namedType,
157INamedTypeSymbol namedType, FindReferencesDocumentState state, Action<FinderLocation, TData> processResult, TData processResultData, string alias, CancellationToken cancellationToken)
175INamedTypeSymbol symbol,
190INamedTypeSymbol namedType,
207INamedTypeSymbol symbol,
227INamedTypeSymbol namedType,
FindSymbols\SymbolFinder_Hierarchy.cs (24)
46var containingType = symbol.ContainingType;
50foreach (var type in derivedTypes)
131var containingType = symbol.ContainingType.OriginalDefinition;
200public static Task<IEnumerable<INamedTypeSymbol>> FindDerivedClassesAsync(
201INamedTypeSymbol type, Solution solution, IImmutableSet<Project>? projects, CancellationToken cancellationToken)
218public static async Task<IEnumerable<INamedTypeSymbol>> FindDerivedClassesAsync(
219INamedTypeSymbol type, Solution solution, bool transitive = true, IImmutableSet<Project>? projects = null, CancellationToken cancellationToken = default)
231/// <inheritdoc cref="FindDerivedClassesArrayAsync(INamedTypeSymbol, Solution, bool, IImmutableSet{Project}, CancellationToken)"/>
233internal static async Task<ImmutableArray<INamedTypeSymbol>> FindDerivedClassesArrayAsync(
234INamedTypeSymbol type, Solution solution, bool transitive, IImmutableSet<Project>? projects = null, CancellationToken cancellationToken = default)
254public static async Task<IEnumerable<INamedTypeSymbol>> FindDerivedInterfacesAsync(
255INamedTypeSymbol type, Solution solution, bool transitive = true, IImmutableSet<Project>? projects = null, CancellationToken cancellationToken = default)
267/// <inheritdoc cref="FindDerivedInterfacesAsync(INamedTypeSymbol, Solution, bool, IImmutableSet{Project}, CancellationToken)"/>
269internal static async Task<ImmutableArray<INamedTypeSymbol>> FindDerivedInterfacesArrayAsync(
270INamedTypeSymbol type, Solution solution, bool transitive, IImmutableSet<Project>? projects = null, CancellationToken cancellationToken = default)
290public static async Task<IEnumerable<INamedTypeSymbol>> FindImplementationsAsync(
291INamedTypeSymbol type, Solution solution, bool transitive = true, IImmutableSet<Project>? projects = null, CancellationToken cancellationToken = default)
303/// <inheritdoc cref="FindImplementationsAsync(INamedTypeSymbol, Solution, bool, IImmutableSet{Project}, CancellationToken)"/>
305internal static async Task<ImmutableArray<INamedTypeSymbol>> FindImplementationsArrayAsync(
306INamedTypeSymbol type, Solution solution, bool transitive, IImmutableSet<Project>? projects = null, CancellationToken cancellationToken = default)
317/// cref="INamedTypeSymbol"/> this will be both immediate and transitive implementations.
330if (symbol is INamedTypeSymbol namedTypeSymbol)
349var containingType = symbol.ContainingType.OriginalDefinition;
359foreach (var t in allTypes)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\INamedTypeSymbolExtensions.cs (73)
20public static IEnumerable<INamedTypeSymbol> GetBaseTypesAndThis(this INamedTypeSymbol? namedType)
22var current = namedType;
30public static ImmutableArray<ITypeParameterSymbol> GetAllTypeParameters(this INamedTypeSymbol? symbol)
36public static IEnumerable<ITypeSymbol> GetAllTypeArguments(this INamedTypeSymbol? symbol)
42private static Stack<INamedTypeSymbol> GetContainmentStack(INamedTypeSymbol? symbol)
44var stack = new Stack<INamedTypeSymbol>();
45for (var current = symbol; current != null; current = current.ContainingType)
53public static bool IsContainedWithin([NotNullWhen(returnValue: true)] this INamedTypeSymbol? symbol, INamedTypeSymbol outer)
56for (var current = symbol; current != null; current = current.ContainingType)
67public static ISymbol? FindImplementationForAbstractMember(this INamedTypeSymbol? type, ISymbol symbol)
78private static bool ImplementationExists(INamedTypeSymbol classOrStructType, ISymbol member)
82this INamedTypeSymbol classOrStructType,
84Func<INamedTypeSymbol, ISymbol, bool> isValidImplementation,
114private static bool IsInterfacePropertyImplemented(INamedTypeSymbol classOrStructType, IPropertySymbol propertySymbol)
122static bool IsAccessorImplemented(IMethodSymbol? accessor, INamedTypeSymbol classOrStructType)
128private static bool IsAbstractPropertyImplemented(INamedTypeSymbol classOrStructType, IPropertySymbol propertySymbol)
151this INamedTypeSymbol classOrStructType,
153Func<INamedTypeSymbol, ISymbol, bool> isValid,
176public static ImmutableArray<(INamedTypeSymbol type, ImmutableArray<ISymbol> members)> GetAllUnimplementedMembers(
177this INamedTypeSymbol classOrStructType,
178IEnumerable<INamedTypeSymbol> interfaces,
194static ImmutableArray<ISymbol> GetImplicitlyImplementableMembers(INamedTypeSymbol type, ISymbol within)
244public static ImmutableArray<(INamedTypeSymbol type, ImmutableArray<ISymbol> members)> GetAllUnimplementedMembersInThis(
245this INamedTypeSymbol classOrStructType,
246IEnumerable<INamedTypeSymbol> interfacesOrAbstractClasses,
262public static ImmutableArray<(INamedTypeSymbol type, ImmutableArray<ISymbol> members)> GetAllUnimplementedMembersInThis(
263this INamedTypeSymbol classOrStructType,
264IEnumerable<INamedTypeSymbol> interfacesOrAbstractClasses,
265Func<INamedTypeSymbol, ISymbol, ImmutableArray<ISymbol>> interfaceMemberGetter,
281public static ImmutableArray<(INamedTypeSymbol type, ImmutableArray<ISymbol> members)> GetAllUnimplementedExplicitMembers(
282this INamedTypeSymbol classOrStructType,
283IEnumerable<INamedTypeSymbol> interfaces,
295private static ImmutableArray<ISymbol> GetExplicitlyImplementableMembers(INamedTypeSymbol type, ISymbol within)
322private static ImmutableArray<(INamedTypeSymbol type, ImmutableArray<ISymbol> members)> GetAllUnimplementedMembers(
323this INamedTypeSymbol classOrStructType,
324IEnumerable<INamedTypeSymbol> interfacesOrAbstractClasses,
325Func<INamedTypeSymbol, ISymbol, Func<INamedTypeSymbol, ISymbol, bool>, CancellationToken, bool> isImplemented,
326Func<INamedTypeSymbol, ISymbol, bool> isValidImplementation,
327Func<INamedTypeSymbol, ISymbol, ImmutableArray<ISymbol>> interfaceMemberGetter,
356private static ImmutableArray<INamedTypeSymbol> GetTypesToImplement(
357INamedTypeSymbol classOrStructType,
358IEnumerable<INamedTypeSymbol> interfacesOrAbstractClasses,
367private static ImmutableArray<INamedTypeSymbol> GetAbstractClassesToImplement(
368IEnumerable<INamedTypeSymbol> abstractClasses)
375private static ImmutableArray<INamedTypeSymbol> GetInterfacesToImplement(
376INamedTypeSymbol classOrStructType,
377IEnumerable<INamedTypeSymbol> interfaces,
384var interfacesToImplement = new List<INamedTypeSymbol>(
389var baseType = classOrStructType.BaseType;
400this INamedTypeSymbol classOrStructType,
401INamedTypeSymbol interfaceType,
402Func<INamedTypeSymbol, ISymbol, Func<INamedTypeSymbol, ISymbol, bool>, CancellationToken, bool> isImplemented,
403Func<INamedTypeSymbol, ISymbol, bool> isValidImplementation,
404Func<INamedTypeSymbol, ISymbol, ImmutableArray<ISymbol>> interfaceMemberGetter,
446this INamedTypeSymbol attributeSymbol,
452var systemAttributeType = compilation.AttributeType();
454foreach (var type in attributeSymbol.GetBaseTypesAndThis())
514private static ImmutableArray<ISymbol> GetMembers(INamedTypeSymbol type, ISymbol within)
528this INamedTypeSymbol containingType, CancellationToken cancellationToken)
545foreach (var type in baseTypes)
566Dictionary<ISymbol, int> result, INamedTypeSymbol containingType, CancellationToken cancellationToken)
587Dictionary<ISymbol, int> result, INamedTypeSymbol containingType, CancellationToken cancellationToken)
609Dictionary<ISymbol, int> result, INamedTypeSymbol containingType,
610INamedTypeSymbol type, ref int index, CancellationToken cancellationToken)
623private static bool IsOverridable(ISymbol member, INamedTypeSymbol containingType)
665public static INamedTypeSymbol TryConstruct(this INamedTypeSymbol type, ITypeSymbol[] typeArguments)
668public static bool IsCollectionBuilderAttribute([NotNullWhen(true)] this INamedTypeSymbol? type)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\SymbolEquivalenceComparer.EquivalenceVisitor.cs (65)
21public bool AreEquivalent(ISymbol? x, ISymbol? y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
50return AreArrayAndReadOnlySpanEquivalent((IArrayTypeSymbol)x, (INamedTypeSymbol)y, equivalentTypesWithDifferingAssemblies);
54return AreArrayAndReadOnlySpanEquivalent((IArrayTypeSymbol)y, (INamedTypeSymbol)x, equivalentTypesWithDifferingAssemblies);
64private bool AreArrayAndReadOnlySpanEquivalent(IArrayTypeSymbol array, INamedTypeSymbol readOnlySpanType, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
72internal bool AreEquivalent(CustomModifier x, CustomModifier y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
75internal bool AreEquivalent(ImmutableArray<CustomModifier> x, ImmutableArray<CustomModifier> y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
111private bool AreEquivalentWorker(ISymbol x, ISymbol y, SymbolKind k, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
125SymbolKind.NamedType => NamedTypesAreEquivalent((INamedTypeSymbol)x, (INamedTypeSymbol)y, equivalentTypesWithDifferingAssemblies),
126SymbolKind.ErrorType => NamedTypesAreEquivalent((INamedTypeSymbol)x, (INamedTypeSymbol)y, equivalentTypesWithDifferingAssemblies),
139private bool ArrayTypesAreEquivalent(IArrayTypeSymbol x, IArrayTypeSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
151private bool FieldsAreEquivalent(IFieldSymbol x, IFieldSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
169private bool MethodsAreEquivalent(IMethodSymbol x, IMethodSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies, bool considerReturnRefKinds = false)
280private bool NamedTypesAreEquivalent(INamedTypeSymbol x, INamedTypeSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
300private bool NamedTypesAreEquivalentError(INamedTypeSymbol x, INamedTypeSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
302foreach (var type1 in Unwrap(x))
305foreach (var type2 in Unwrap(y))
329private bool HandleNamedTypesWorker(INamedTypeSymbol x, INamedTypeSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
418private bool HandleTupleTypes(INamedTypeSymbol x, INamedTypeSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
463Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies,
486internal bool ReturnTypesAreEquivalent(IMethodSymbol x, IMethodSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies = null)
492private bool TypeArgumentsAreEquivalent(ImmutableArray<ITypeSymbol> xTypeArguments, ImmutableArray<ITypeSymbol> yTypeArguments, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
511private bool HandleAnonymousTypes(INamedTypeSymbol x, INamedTypeSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
547private bool NamespacesAreEquivalent(INamespaceSymbol x, INamespaceSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
564private bool ParametersAreEquivalent(IParameterSymbol x, IParameterSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
574private bool PointerTypesAreEquivalent(IPointerTypeSymbol x, IPointerTypeSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
581private bool FunctionPointerTypesAreEquivalent(IFunctionPointerTypeSymbol x, IFunctionPointerTypeSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
584private bool PropertiesAreEquivalent(IPropertySymbol x, IPropertySymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
608private bool EventsAreEquivalent(IEventSymbol x, IEventSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
615private bool TypeParametersAreEquivalent(ITypeParameterSymbol x, ITypeParameterSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol>? equivalentTypesWithDifferingAssemblies)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractCodeGenerationService.cs (15)
60public TDeclarationNode AddNamedType<TDeclarationNode>(TDeclarationNode destination, INamedTypeSymbol namedType, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode
89public SyntaxNode CreateNamedTypeDeclaration(INamedTypeSymbol namedType, CodeGenerationDestination destination, CodeGenerationContextInfo info, CancellationToken cancellationToken)
128protected abstract TDeclarationNode AddNamedType<TDeclarationNode>(TDeclarationNode destination, INamedTypeSymbol namedType, TCodeGenerationContextInfo info, IList<bool>? availableIndices, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
151public abstract SyntaxNode CreateNamedTypeDeclaration(INamedTypeSymbol namedType, CodeGenerationDestination destination, TCodeGenerationContextInfo info, CancellationToken cancellationToken);
350INamedTypeSymbol namedType => CreateNamedTypeDeclaration(namedType, codeGenerationDestination, info, cancellationToken),
368INamedTypeSymbol namedType => AddNamedType(currentDestination, namedType, info, availableIndices, cancellationToken),
393CodeGenerationSolutionContext context, INamedTypeSymbol destination, IEventSymbol @event, CancellationToken cancellationToken)
402public Task<Document> AddFieldAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IFieldSymbol field, CancellationToken cancellationToken)
411public Task<Document> AddPropertyAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IPropertySymbol property, CancellationToken cancellationToken)
420public Task<Document> AddNamedTypeAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, INamedTypeSymbol namedType, CancellationToken cancellationToken)
429public Task<Document> AddNamedTypeAsync(CodeGenerationSolutionContext context, INamespaceSymbol destination, INamedTypeSymbol namedType, CancellationToken cancellationToken)
447public Task<Document> AddMethodAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IMethodSymbol method, CancellationToken cancellationToken)
456public Task<Document> AddMembersAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IEnumerable<ISymbol> members, CancellationToken cancellationToken)
478return AddNamedTypeAsync(context, destination, (INamedTypeSymbol)namespaceOrType, cancellationToken);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\AbstractFlagsEnumGenerator.cs (10)
15protected abstract SyntaxNode CreateExplicitlyCastedLiteralValue(SyntaxGenerator generator, INamedTypeSymbol enumType, SpecialType underlyingSpecialType, object constantValue);
16protected abstract bool IsValidName(INamedTypeSymbol enumType, string name);
18public SyntaxNode CreateEnumConstantValue(SyntaxGenerator generator, INamedTypeSymbol enumType, object constantValue)
34private static bool IsFlagsEnum(INamedTypeSymbol typeSymbol)
46var type = ctor.ContainingType;
63private SyntaxNode CreateFlagsEnumConstantValue(SyntaxGenerator generator, INamedTypeSymbol enumType, object constantValue)
75INamedTypeSymbol enumType,
141SyntaxGenerator generator, IFieldSymbol field, INamedTypeSymbol enumType, SpecialType underlyingSpecialType)
171INamedTypeSymbol enumType,
188private SyntaxNode CreateNonFlagsEnumConstantValue(SyntaxGenerator generator, INamedTypeSymbol enumType, object constantValue)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerationSymbolFactory.cs (14)
48INamedTypeSymbol? containingType,
152INamedTypeSymbol? containingType,
226INamedTypeSymbol? containingType = null,
254INamedTypeSymbol? containingType = null,
408INamedTypeSymbol attributeClass,
418public static INamedTypeSymbol CreateNamedTypeSymbol(
424INamedTypeSymbol? baseType = null,
425ImmutableArray<INamedTypeSymbol> interfaces = default,
437public static INamedTypeSymbol CreateNamedTypeSymbol(
443INamedTypeSymbol? baseType = null,
444ImmutableArray<INamedTypeSymbol> interfaces = default,
455members.WhereAsArray(m => m is not INamedTypeSymbol),
456members.OfType<INamedTypeSymbol>().Select(n => n.ToCodeGenerationSymbol()).ToImmutableArray(),
523INamedTypeSymbol? containingType = null,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\CodeGenerator.cs (8)
30public static Task<Document> AddEventDeclarationAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IEventSymbol @event, CancellationToken cancellationToken)
37public static Task<Document> AddFieldDeclarationAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IFieldSymbol field, CancellationToken cancellationToken)
44public static Task<Document> AddMethodDeclarationAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IMethodSymbol method, CancellationToken cancellationToken)
51public static Task<Document> AddPropertyDeclarationAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IPropertySymbol property, CancellationToken cancellationToken)
58public static Task<Document> AddNamedTypeDeclarationAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, INamedTypeSymbol namedType, CancellationToken cancellationToken)
65public static Task<Document> AddNamedTypeDeclarationAsync(CodeGenerationSolutionContext context, INamespaceSymbol destination, INamedTypeSymbol namedType, CancellationToken cancellationToken)
86public static Task<Document> AddMemberDeclarationsAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IEnumerable<ISymbol> members, CancellationToken cancellationToken)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\CodeGeneration\ICodeGenerationService.cs (10)
44SyntaxNode CreateNamedTypeDeclaration(INamedTypeSymbol namedType, CodeGenerationDestination destination, CodeGenerationContextInfo info, CancellationToken cancellationToken);
74TDeclarationNode AddNamedType<TDeclarationNode>(TDeclarationNode destination, INamedTypeSymbol namedType, CodeGenerationContextInfo info, CancellationToken cancellationToken) where TDeclarationNode : SyntaxNode;
134Task<Document> AddEventAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IEventSymbol @event, CancellationToken cancellationToken);
139Task<Document> AddFieldAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IFieldSymbol field, CancellationToken cancellationToken);
144Task<Document> AddMethodAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IMethodSymbol method, CancellationToken cancellationToken);
149Task<Document> AddPropertyAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IPropertySymbol property, CancellationToken cancellationToken);
154Task<Document> AddNamedTypeAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, INamedTypeSymbol namedType, CancellationToken cancellationToken);
159Task<Document> AddNamedTypeAsync(CodeGenerationSolutionContext context, INamespaceSymbol destination, INamedTypeSymbol namedType, CancellationToken cancellationToken);
174Task<Document> AddMembersAsync(CodeGenerationSolutionContext context, INamedTypeSymbol destination, IEnumerable<ISymbol> members, CancellationToken cancellationToken);