1537 references to TypeDeclarationSyntax
Microsoft.CodeAnalysis.CSharp (76)
Binder\Binder_Statements.cs (6)
3623case TypeDeclarationSyntax typeDecl: 3677private BoundNode BindPrimaryConstructorBody(TypeDeclarationSyntax typeDecl, BindingDiagnosticBag diagnostics) 3817Debug.Assert(sourceConstructor?.SyntaxNode is TypeDeclarationSyntax 3876containerNode = containingType.DeclaringSyntaxReferences.Select(r => r.GetSyntax()).OfType<TypeDeclarationSyntax>().First(); 3880outerBinder = binderFactory.GetInTypeBodyBinder((TypeDeclarationSyntax)containerNode); 3896case TypeDeclarationSyntax typeDecl:
Binder\BinderFactory.BinderFactoryVisitor.cs (9)
163var parentType = methodDecl.Parent as TypeDeclarationSyntax; 725private Binder VisitTypeDeclarationCore(TypeDeclarationSyntax parent) 758internal Binder VisitTypeDeclarationCore(TypeDeclarationSyntax parent, NodeUsage extraInfo) 1247if (memberSyntax is TypeDeclarationSyntax { ParameterList: { ParameterCount: > 0 } } typeDeclaration) 1251SourceNamedTypeSymbol type = ((NamespaceOrTypeSymbol)outerBinder.ContainingMemberOrLambda).GetSourceTypeMember((TypeDeclarationSyntax)memberSyntax); 1321TypeDeclarationSyntax typeDeclSyntax = memberSyntax as TypeDeclarationSyntax; 1384if (baseTypeDeclaration is TypeDeclarationSyntax { SemicolonToken: { RawKind: (int)SyntaxKind.SemicolonToken }, OpenBraceToken: { RawKind: (int)SyntaxKind.None } } noBlockBodyTypeDeclarationWithSemicolon)
Binder\BinderFactory.cs (2)
157var typeDecl = constructor.GetSyntax(); 175internal Binder GetInTypeBodyBinder(TypeDeclarationSyntax typeDecl)
Binder\LocalBinderFactory.cs (1)
174private void VisitTypeDeclaration(TypeDeclarationSyntax node)
Compilation\CSharpSemanticModel.cs (2)
5176if (declaration is TypeDeclarationSyntax typeDeclaration) 5236protected static SynthesizedPrimaryConstructor TryGetSynthesizedPrimaryConstructor(TypeDeclarationSyntax node, NamedTypeSymbol type)
Compilation\MethodBodySemanticModel.cs (1)
260primaryCtor.GetSyntax() is TypeDeclarationSyntax typeDecl)
Compilation\SyntaxTreeSemanticModel.cs (11)
184case TypeDeclarationSyntax { ParameterList: { }, PrimaryConstructorBaseTypeIfClass: { } } typeDeclaration when TryGetSynthesizedPrimaryConstructor(typeDeclaration) is SynthesizedPrimaryConstructor: 805var typeDecl = (TypeDeclarationSyntax)memberDecl; 875var typeDecl = (TypeDeclarationSyntax)memberDecl; 1093SynthesizedPrimaryConstructor symbol = TryGetSynthesizedPrimaryConstructor((TypeDeclarationSyntax)node); 1254private SynthesizedPrimaryConstructor TryGetSynthesizedPrimaryConstructor(TypeDeclarationSyntax node) 2026if (memberDecl is TypeDeclarationSyntax typeDecl && typeDecl.ParameterList == paramList) 2432case TypeDeclarationSyntax typeDeclaration when TryGetSynthesizedPrimaryConstructor(typeDeclaration) is SynthesizedPrimaryConstructor ctor: 2498case PrimaryConstructorBaseTypeSyntax { Parent: BaseListSyntax { Parent: TypeDeclarationSyntax typeDeclaration } } baseType 2522case TypeDeclarationSyntax:
Declarations\DeclarationTreeBuilder.cs (2)
683private SingleTypeDeclaration VisitTypeDeclaration(TypeDeclarationSyntax node, DeclarationKind kind) 783private ImmutableArray<SingleTypeDeclaration> VisitTypeChildren(TypeDeclarationSyntax node)
Declarations\MergedTypeDeclaration.cs (1)
81attributesSyntaxList = ((TypeDeclarationSyntax)typeDecl).AttributeLists;
Lowering\Instrumentation\DebugInfoInjector.cs (1)
92case TypeDeclarationSyntax typeDecl:
Parser\LanguageParser.cs (1)
5142return ((CSharp.Syntax.TypeDeclarationSyntax)decl).Modifiers;
src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpDeclarationComputer.cs (4)
108var typeDeclaration = (TypeDeclarationSyntax)node; 126var t = (TypeDeclarationSyntax)node;
Symbols\NamespaceOrTypeSymbol.cs (1)
187internal SourceNamedTypeSymbol? GetSourceTypeMember(TypeDeclarationSyntax syntax)
Symbols\Source\SourceMemberContainerSymbol.cs (9)
2770var syntax = syntaxRef.GetSyntax() as TypeDeclarationSyntax; 2894public TypeDeclarationSyntax? DeclarationWithParameters; 2955public readonly TypeDeclarationSyntax? DeclarationWithParameters; 2971TypeDeclarationSyntax? declarationWithParameters, 3561var typeDecl = (TypeDeclarationSyntax)syntax; 3571void noteTypeParameters(TypeDeclarationSyntax syntax, DeclaredMembersAndInitializersBuilder builder, BindingDiagnosticBag diagnostics) 4142Debug.Assert(builder.DeclarationWithParameters is TypeDeclarationSyntax { ParameterList: not null } type
Symbols\Source\SourceNamedTypeSymbol.cs (5)
42TypeDeclarationSyntax typeBlock = (TypeDeclarationSyntax)part.GetSyntax(); 164tpl = ((TypeDeclarationSyntax)typeDecl).TypeParameterList; 473var typeDeclaration = (TypeDeclarationSyntax)node;
Symbols\Source\SourceNamedTypeSymbol_Bases.cs (1)
633(TypeKind != TypeKind.Class || baseType.TypeKind == TypeKind.Interface || ((TypeDeclarationSyntax)decl.SyntaxReference.GetSyntax()).ParameterList is null))
Symbols\Source\SourceOrdinaryMethodSymbol.cs (2)
234var typeDecl = syntax.Parent as TypeDeclarationSyntax;
Symbols\Synthesized\Records\SynthesizedPrimaryConstructor.cs (5)
22TypeDeclarationSyntax syntax) : 36private static (DeclarationModifiers, Flags) MakeModifiersAndFlags(SourceMemberContainerTypeSymbol containingType, TypeDeclarationSyntax syntax) 57internal TypeDeclarationSyntax GetSyntax() 60return (TypeDeclarationSyntax)syntaxReferenceOpt.GetSyntax(); 105TypeDeclarationSyntax typeDecl = GetSyntax();
Syntax\LookupPosition.cs (1)
111internal static bool IsInTypeParameterList(int position, TypeDeclarationSyntax typeDecl)
Syntax\TypeDeclarationSyntax.cs (11)
21public new TypeDeclarationSyntax AddAttributeLists(params AttributeListSyntax[] items) 22=> (TypeDeclarationSyntax)AddAttributeListsCore(items); 24public new TypeDeclarationSyntax AddModifiers(params SyntaxToken[] items) 25=> (TypeDeclarationSyntax)AddModifiersCore(items); 27public new TypeDeclarationSyntax WithAttributeLists(SyntaxList<AttributeListSyntax> attributeLists) 28=> (TypeDeclarationSyntax)WithAttributeListsCore(attributeLists); 30public new TypeDeclarationSyntax WithModifiers(SyntaxTokenList modifiers) 31=> (TypeDeclarationSyntax)WithModifiersCore(modifiers); 85public static TypeDeclarationSyntax TypeDeclaration(SyntaxKind kind, SyntaxToken identifier) 102public static TypeDeclarationSyntax TypeDeclaration(SyntaxKind kind, string identifier) 107public static TypeDeclarationSyntax TypeDeclaration(
Microsoft.CodeAnalysis.CSharp.CodeStyle (28)
src\Analyzers\CSharp\Analyzers\AddAccessibilityModifiers\CSharpAddAccessibilityModifiersDiagnosticAnalyzer.cs (1)
47if (member is TypeDeclarationSyntax typeDeclaration)
src\Analyzers\CSharp\Analyzers\ConvertProgram\ConvertProgramAnalysis_TopLevelStatements.cs (2)
61methodDeclaration.Parent is not TypeDeclarationSyntax containingTypeDeclaration || 91private static bool TypeCanBeConverted(INamedTypeSymbol containingType, TypeDeclarationSyntax typeDeclaration)
src\Analyzers\CSharp\Analyzers\MakeStructReadOnly\CSharpMakeStructReadOnlyDiagnosticAnalyzer.cs (1)
92if (typeReference.GetSyntax(cancellationToken) is not TypeDeclarationSyntax typeDeclaration)
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryDiscardDesignation\CSharpRemoveUnnecessaryDiscardDesignationDiagnosticAnalyzer.cs (1)
67identifierName.GetAncestor<TypeDeclarationSyntax>() is { } containingTypeSyntax)
src\Analyzers\CSharp\Analyzers\RemoveUnusedMembers\CSharpRemoveUnusedMembersDiagnosticAnalyzer.cs (4)
21TypeDeclarationSyntax, 26protected override IEnumerable<TypeDeclarationSyntax> GetTypeDeclarations(INamedTypeSymbol namedType, CancellationToken cancellationToken) 30.OfType<TypeDeclarationSyntax>(); 33protected override SyntaxList<MemberDeclarationSyntax> GetMembers(TypeDeclarationSyntax typeDeclaration)
src\Analyzers\CSharp\Analyzers\UsePrimaryConstructor\CSharpUsePrimaryConstructorDiagnosticAnalyzer.cs (1)
315if (primaryConstructorDeclaration.Parent is not TypeDeclarationSyntax)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\MemberDeclarationSyntaxExtensions.cs (3)
40return ((TypeDeclarationSyntax)member).Identifier; 79return ((TypeDeclarationSyntax)member).Arity; 101return ((TypeDeclarationSyntax)member).TypeParameterList;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SemanticModelExtensions.cs (1)
328var typeDeclarations = type.GetAncestors<TypeDeclarationSyntax>();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (2)
153TypeDeclarationSyntax typeDeclaration => typeDeclaration.ParameterList, 773case TypeDeclarationSyntax type:
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTreeExtensions.cs (3)
41public static TypeDeclarationSyntax? GetContainingTypeDeclaration( 53public static IEnumerable<TypeDeclarationSyntax> GetContainingTypeDeclarations( 58return token.GetAncestors<TypeDeclarationSyntax>().Where(t =>
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\AnchorIndentationFormattingRule.cs (1)
60case TypeDeclarationSyntax typeNode:
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SelectedMembers\CSharpSelectedMembers.cs (2)
21TypeDeclarationSyntax, 42protected override SyntaxList<MemberDeclarationSyntax> GetMembers(TypeDeclarationSyntax containingType)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpHeaderFacts.cs (1)
31var lastToken = (node as TypeDeclarationSyntax)?.TypeParameterList?.GetLastToken() ?? node.Identifier;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (4)
752TypeDeclarationSyntax or 782var parent = node.GetAncestor<TypeDeclarationSyntax>() ?? node.Parent; 783while (parent is TypeDeclarationSyntax) 928=> ((TypeDeclarationSyntax)typeDeclaration).Members;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\FormattingRangeHelper.cs (1)
349previousToken.Parent is TypeDeclarationSyntax ||
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (87)
src\Analyzers\CSharp\CodeFixes\ConvertToRecord\ConvertToRecordEngine.cs (5)
34Document document, TypeDeclarationSyntax typeDeclaration, CancellationToken cancellationToken) 83TypeDeclarationSyntax typeDeclaration, 328CreateRecordDeclaration(type, (TypeDeclarationSyntax)declaration, modifiedClassTrivia, 377TypeDeclarationSyntax typeDeclaration, 575TypeDeclarationSyntax typeDeclaration,
src\Analyzers\CSharp\CodeFixes\ConvertToRecord\CSharpConvertToRecordCodeFixProvider.cs (1)
39var typeDeclaration = baseTypeSyntax?.GetAncestor<TypeDeclarationSyntax>();
src\Analyzers\CSharp\CodeFixes\GenerateDefaultConstructors\CSharpGenerateDefaultConstructorsService.cs (1)
46if (baseList.Parent is TypeDeclarationSyntax(SyntaxKind.ClassDeclaration or SyntaxKind.RecordDeclaration) parentTypeDecl &&
src\Analyzers\CSharp\CodeFixes\ImplementAbstractClass\CSharpImplementAbstractClassCodeFixProvider.cs (2)
18: AbstractImplementAbstractClassCodeFixProvider<TypeDeclarationSyntax>(CS0534) 22protected override SyntaxToken GetClassIdentifier(TypeDeclarationSyntax classNode)
src\Analyzers\CSharp\CodeFixes\ImplementInterface\CSharpImplementInterfaceService.cs (1)
64classOrStructDecl = interfaceNode.Parent.Parent.Parent as TypeDeclarationSyntax;
src\Analyzers\CSharp\CodeFixes\MakeRefStruct\MakeRefStructCodeFixProvider.cs (1)
45if (root.FindNode(span).GetAncestor<TypeDeclarationSyntax>() is not StructDeclarationSyntax structDeclaration)
src\Analyzers\CSharp\CodeFixes\MakeTypeAbstract\CSharpMakeTypeAbstractCodeFixProvider.cs (4)
17internal sealed class CSharpMakeTypeAbstractCodeFixProvider() : AbstractMakeTypeAbstractCodeFixProvider<TypeDeclarationSyntax> 22protected override bool IsValidRefactoringContext(SyntaxNode? node, [NotNullWhen(true)] out TypeDeclarationSyntax? typeDeclaration) 49var enclosingType = node.FirstAncestorOrSelf<TypeDeclarationSyntax>();
src\Analyzers\CSharp\CodeFixes\UsePrimaryConstructor\CSharpUsePrimaryConstructorCodeFixProvider.cs (10)
121var typeDeclaration = (TypeDeclarationSyntax)constructorDeclaration.GetRequiredParent(); 127var typeDeclarationNodes = namedType.DeclaringSyntaxReferences.Select(r => (TypeDeclarationSyntax)r.GetSyntax(cancellationToken)); 151var currentTypeDeclaration = (TypeDeclarationSyntax)current; 182TypeDeclarationSyntax WithCommentMoved(TypeDeclarationSyntax finalTypeDeclaration) 341TypeDeclarationSyntax typeDeclaration, 421var currentTypeDeclaration = (TypeDeclarationSyntax)current;
src\Analyzers\CSharp\CodeFixes\UsePrimaryConstructor\CSharpUsePrimaryConstructorCodeFixProvider_DocComments.cs (2)
65TypeDeclarationSyntax typeDeclaration, 100TypeDeclarationSyntax typeDeclaration,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\ConstructorGenerator.cs (2)
26internal static TypeDeclarationSyntax AddConstructorTo( 27TypeDeclarationSyntax destination,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\ConversionGenerator.cs (2)
21internal static TypeDeclarationSyntax AddConversionTo( 22TypeDeclarationSyntax destination,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationHelpers.cs (6)
72public static TypeDeclarationSyntax AddMembersTo( 73TypeDeclarationSyntax destination, SyntaxList<MemberDeclarationSyntax> members, CancellationToken cancellationToken) 78var node = ConditionallyAddFormattingAnnotationTo( 85return (TypeDeclarationSyntax)tree.GetRoot(cancellationToken); 88private static TypeDeclarationSyntax ReplaceUnterminatedConstructs(TypeDeclarationSyntax destination)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationService.cs (16)
48if (destination is TypeDeclarationSyntax typeDeclaration) 59private static IList<bool> GetInsertionIndices(TypeDeclarationSyntax destination, CancellationToken cancellationToken) 92CheckDeclarationNode<TypeDeclarationSyntax>(destination); 94return Cast<TDeclarationNode>(EventGenerator.AddEventTo(Cast<TypeDeclarationSyntax>(destination), @event, info, availableIndices, cancellationToken)); 99CheckDeclarationNode<EnumDeclarationSyntax, TypeDeclarationSyntax, CompilationUnitSyntax>(destination); 105else if (destination is TypeDeclarationSyntax) 107return Cast<TDeclarationNode>(FieldGenerator.AddFieldTo(Cast<TypeDeclarationSyntax>(destination), field, info, availableIndices, cancellationToken)); 123CheckDeclarationNode<TypeDeclarationSyntax, CompilationUnitSyntax, BaseNamespaceDeclarationSyntax>(destination); 143if (destination is TypeDeclarationSyntax typeDeclaration) 191CheckDeclarationNode<TypeDeclarationSyntax, CompilationUnitSyntax>(destination); 235if (destination is TypeDeclarationSyntax) 238Cast<TypeDeclarationSyntax>(destination), property, info, availableIndices, cancellationToken)); 249CheckDeclarationNode<TypeDeclarationSyntax, BaseNamespaceDeclarationSyntax, CompilationUnitSyntax>(destination); 253if (destination is TypeDeclarationSyntax typeDeclaration) 343CheckDeclarationNode<EnumDeclarationSyntax, TypeDeclarationSyntax, BaseNamespaceDeclarationSyntax, CompilationUnitSyntax>(destination); 350else if (destination is TypeDeclarationSyntax typeDeclaration)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\DestructorGenerator.cs (2)
24internal static TypeDeclarationSyntax AddDestructorTo( 25TypeDeclarationSyntax destination,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\EventGenerator.cs (2)
78internal static TypeDeclarationSyntax AddEventTo( 79TypeDeclarationSyntax destination,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\FieldGenerator.cs (2)
70internal static TypeDeclarationSyntax AddFieldTo( 71TypeDeclarationSyntax destination,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\MethodGenerator.cs (2)
58internal static TypeDeclarationSyntax AddMethodTo( 59TypeDeclarationSyntax destination,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\NamedTypeGenerator.cs (5)
25public static TypeDeclarationSyntax AddNamedTypeTo( 27TypeDeclarationSyntax destination, 174return ((TypeDeclarationSyntax)declaration).WithMembers(default); 195TypeDeclarationSyntax typeDeclaration; 215var result = typeDeclaration
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\OperatorGenerator.cs (2)
23internal static TypeDeclarationSyntax AddOperatorTo( 24TypeDeclarationSyntax destination,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\PropertyGenerator.cs (2)
52internal static TypeDeclarationSyntax AddPropertyTo( 53TypeDeclarationSyntax destination,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeRefactorings\CSharpRefactoringHelpersService.cs (1)
32var typeDecl = token.GetAncestor<TypeDeclarationSyntax>();
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\CSharpSyntaxContext.cs (2)
17public readonly TypeDeclarationSyntax? ContainingTypeDeclaration; 56TypeDeclarationSyntax? containingTypeDeclaration,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTokenExtensions.cs (1)
618if (node?.Parent is TypeDeclarationSyntax(SyntaxKind.InterfaceDeclaration) typeDecl)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTreeExtensions.cs (7)
439if (token.IsKind(SyntaxKind.OpenBraceToken) && token.Parent is NamespaceDeclarationSyntax or TypeDeclarationSyntax) 520if (container is CompilationUnitSyntax or BaseNamespaceDeclarationSyntax or TypeDeclarationSyntax) 603if (container is CompilationUnitSyntax or BaseNamespaceDeclarationSyntax or TypeDeclarationSyntax) 685public static bool IsPartialTypeDeclarationNameContext(this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken, [NotNullWhen(true)] out TypeDeclarationSyntax? declarationSyntax) 698declarationSyntax = token.GetAncestor<TypeDeclarationSyntax>(); 1130MethodDeclarationSyntax or LocalFunctionStatementSyntax or ConstructorDeclarationSyntax or DelegateDeclarationSyntax or TypeDeclarationSyntax => true, 1214var typeDecl = method.GetAncestorOrThis<TypeDeclarationSyntax>();
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\TypeDeclarationSyntaxExtensions.cs (6)
21public static IList<bool> GetInsertionIndices(this TypeDeclarationSyntax destination, CancellationToken cancellationToken) 71public static IEnumerable<BaseTypeSyntax> GetAllBaseListTypes(this TypeDeclarationSyntax typeNode, SemanticModel model, CancellationToken cancellationToken) 84if (syntaxRef.GetSyntax(cancellationToken) is TypeDeclarationSyntax { BaseList.Types: var baseTypes }) 148public static TypeDeclarationSyntax EnsureOpenAndCloseBraceTokens(this TypeDeclarationSyntax typeDeclaration) 150return (TypeDeclarationSyntax)EnsureHasBraces(typeDeclaration, typeDeclaration.Members.Count > 0);
Microsoft.CodeAnalysis.CSharp.EditorFeatures (3)
CompleteStatement\CompleteStatementCommandHandler.cs (1)
286if (currentNode is TypeDeclarationSyntax { OpenBraceToken.IsMissing: true })
EventHookup\EventHookupCommandHandler_TabKeyCommand.cs (2)
252var typeDecl = eventHookupExpression.GetAncestor<TypeDeclarationSyntax>(); 298var typeDecl = eventHookupExpression.GetAncestor<TypeDeclarationSyntax>();
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (8)
Structure\MetadataAsSource\TypeDeclarationStructureTests.cs (1)
16public class TypeDeclarationStructureTests : AbstractCSharpSyntaxNodeStructureTests<TypeDeclarationSyntax>
Structure\TypeDeclarationStructureTests.cs (1)
15public class TypeDeclarationStructureTests : AbstractCSharpSyntaxNodeStructureTests<TypeDeclarationSyntax>
Utilities\CSharpServiceTestExtensions.cs (2)
49internal static TypeDeclarationSyntax DigToFirstTypeDeclaration(this SyntaxTree syntaxTree) 50=> (syntaxTree.GetRoot() as CompilationUnitSyntax).Members.OfType<TypeDeclarationSyntax>().First();
Workspaces\WorkspaceTests_EditorFeatures.cs (4)
243var type = await GetRootTypeDeclarationAsync(currentSnapshot); 248private static async Task<TypeDeclarationSyntax> GetRootTypeDeclarationAsync(Solution currentSnapshot) 252var type = (TypeDeclarationSyntax)root.Members[0];
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (20)
Semantics\PrimaryConstructorTests.cs (20)
2652var typeDeclaration = tree.GetRoot().DescendantNodes().OfType<TypeDeclarationSyntax>().Single(); 20610var typeDeclaration = tree.GetRoot().ChildNodes().OfType<TypeDeclarationSyntax>().Single(); 20644var typeDeclaration1 = root.ChildNodes().OfType<TypeDeclarationSyntax>().First(); 20655var typeDeclaration2 = root.ChildNodes().OfType<TypeDeclarationSyntax>().Last(); 20688var typeDeclaration1 = root.ChildNodes().OfType<TypeDeclarationSyntax>().First(); 20699var typeDeclaration2 = root.ChildNodes().OfType<TypeDeclarationSyntax>().Last(); 20735var typeDeclaration1 = root.ChildNodes().OfType<TypeDeclarationSyntax>().First(); 20744var typeDeclaration2 = root.ChildNodes().OfType<TypeDeclarationSyntax>().Last(); 20785var typeDeclaration1 = root.ChildNodes().OfType<TypeDeclarationSyntax>().First(); 20796var typeDeclaration2 = root.ChildNodes().OfType<TypeDeclarationSyntax>().Last();
Microsoft.CodeAnalysis.CSharp.Features (147)
AddDebuggerDisplay\CSharpAddDebuggerDisplayCodeRefactoringProvider.cs (1)
20: AbstractAddDebuggerDisplayCodeRefactoringProvider<TypeDeclarationSyntax, MethodDeclarationSyntax>
ChangeSignature\CSharpChangeSignatureService.cs (1)
326if (updatedNode is TypeDeclarationSyntax { ParameterList: not null } typeWithParameters)
Completion\CompletionProviders\CrefCompletionProvider.cs (2)
187var typeDeclaration = token.Parent?.FirstAncestorOrSelf<TypeDeclarationSyntax>();
Completion\CompletionProviders\ExplicitInterfaceTypeCompletionProvider.cs (1)
99var typeDeclaration = typeNode.GetAncestor<TypeDeclarationSyntax>();
Completion\CompletionProviders\XmlDocCommentCompletionProvider.cs (1)
99var typeDeclaration = attachedToken.GetAncestor<TypeDeclarationSyntax>();
Completion\KeywordRecommenders\AbstractSpecialTypePreselectingKeywordRecommender.cs (1)
61var containingType = token.GetAncestor<TypeDeclarationSyntax>();
Completion\KeywordRecommenders\AliasKeywordRecommender.cs (1)
30return token.GetAncestor<TypeDeclarationSyntax>() == null;
Completion\KeywordRecommenders\MethodKeywordRecommender.cs (1)
30or TypeDeclarationSyntax(kind: SyntaxKind.ClassDeclaration or SyntaxKind.StructDeclaration) { ParameterList: not null }
Completion\KeywordRecommenders\NamespaceKeywordRecommender.cs (3)
128if (token.Parent is TypeDeclarationSyntax && 129token.Parent.Parent is not TypeDeclarationSyntax) 145token.Parent.Parent is not TypeDeclarationSyntax)
Completion\KeywordRecommenders\NewKeywordRecommender.cs (1)
67return token.GetAncestors<TypeDeclarationSyntax>()
Completion\KeywordRecommenders\PartialKeywordRecommender.cs (1)
42var decl = token.GetRequiredAncestor<TypeDeclarationSyntax>();
Completion\KeywordRecommenders\PrivateKeywordRecommender.cs (1)
67var typeDecl = context.ContainingTypeDeclaration;
Completion\KeywordRecommenders\ProtectedKeywordRecommender.cs (1)
53var typeDecl = context.ContainingTypeDeclaration;
Completion\KeywordRecommenders\ReadOnlyKeywordRecommender.cs (1)
61var type = context.ContainingTypeDeclaration;
Completion\KeywordRecommenders\TypeVarKeywordRecommender.cs (1)
27var type = typeParameters.GetAncestorOrThis<TypeDeclarationSyntax>();
Completion\KeywordRecommenders\WhereKeywordRecommender.cs (2)
48var decl = typeParameters.GetAncestorOrThis<TypeDeclarationSyntax>(); 89if (baseList?.Parent is TypeDeclarationSyntax typeDecl)
ConvertAutoPropertyToFullProperty\CSharpConvertAutoPropertyToFullPropertyCodeRefactoringProvider.cs (1)
32: AbstractConvertAutoPropertyToFullPropertyCodeRefactoringProvider<PropertyDeclarationSyntax, TypeDeclarationSyntax, CSharpCodeGenerationContextInfo>
ConvertPrimaryToRegularConstructor\ConvertPrimaryToRegularConstructorCodeRefactoringProvider.cs (7)
44var typeDeclaration = await context.TryGetRelevantNodeAsync<TypeDeclarationSyntax>().ConfigureAwait(false); 67TypeDeclarationSyntax typeDeclaration, 294var currentTypeDeclaration = (TypeDeclarationSyntax)current; 311var currentTypeDeclaration = (TypeDeclarationSyntax)current; 402TypeDeclarationSyntax typeDeclaration,
ConvertPrimaryToRegularConstructor\ConvertPrimaryToRegularConstructorCodeRefactoringProvider_DocumentationComments.cs (3)
33private static TypeDeclarationSyntax RemoveParamXmlElements(TypeDeclarationSyntax typeDeclaration) 109private static ConstructorDeclarationSyntax WithTypeDeclarationParamDocComments(TypeDeclarationSyntax typeDeclaration, ConstructorDeclarationSyntax constructor)
ConvertProgram\ConvertProgramTransform_ProgramMain.cs (1)
85var hasExistingPart = programType.DeclaringSyntaxReferences.Any(static (d, cancellationToken) => d.GetSyntax(cancellationToken) is TypeDeclarationSyntax, cancellationToken);
ConvertProgram\ConvertProgramTransform_TopLevelStatements.cs (4)
32var typeDeclaration = (TypeDeclarationSyntax?)methodDeclaration.Parent; 101TypeDeclarationSyntax typeDeclaration, 155TypeDeclarationSyntax typeDeclaration,
ConvertToRecord\CSharpConvertToRecordRefactoringProvider.cs (1)
23var typeDeclaration = await context.TryGetRelevantNodeAsync<TypeDeclarationSyntax>().ConfigureAwait(false);
ConvertTupleToStruct\CSharpConvertTupleToStructCodeRefactoringProvider.cs (1)
26TypeDeclarationSyntax,
EditAndContinue\BreakpointSpans.cs (4)
187var typeDeclaration = (TypeDeclarationSyntax)node; 483internal static TextSpan CreateSpanForImplicitPrimaryConstructorInitializer(TypeDeclarationSyntax typeDeclaration) 489internal static IEnumerable<SyntaxToken> GetActiveTokensForImplicitPrimaryConstructorInitializer(TypeDeclarationSyntax typeDeclaration)
EditAndContinue\CSharpEditAndContinueAnalyzer.cs (11)
86var typeDeclaration = (TypeDeclarationSyntax)current; 666case SyntaxKind.ParameterList when node.Parent is TypeDeclarationSyntax typeDeclaration: 943=> declaration.Parent is TypeDeclarationSyntax { ParameterList: var parameterList } && parameterList == declaration; 1019return symbol.Kind == SymbolKind.Method && syntax is TypeDeclarationSyntax { ParameterList: { } parameterList } ? parameterList : syntax; 1269if (oldNode is TypeDeclarationSyntax oldTypeDeclaration && 1270newNode is TypeDeclarationSyntax newTypeDeclaration && 1449if (declaration is BaseParameterListSyntax and not { Parent: TypeDeclarationSyntax }) 1651var typeDeclaration = (TypeDeclarationSyntax)node; 2131return node.Parent is TypeDeclarationSyntax ? FeaturesResources.constructor : null;
EditAndContinue\DeclarationBody\PrimaryConstructorDeclarationBody.cs (2)
15internal abstract class PrimaryConstructorDeclarationBody(TypeDeclarationSyntax typeDeclaration) 18public TypeDeclarationSyntax TypeDeclaration
EditAndContinue\DeclarationBody\PrimaryConstructorWithExplicitInitializerDeclarationBody.cs (1)
17internal sealed class PrimaryConstructorWithExplicitInitializerDeclarationBody(TypeDeclarationSyntax typeDeclaration)
EditAndContinue\DeclarationBody\PrimaryConstructorWithImplicitInitializerDeclarationBody.cs (1)
17internal sealed class PrimaryConstructorWithImplicitInitializerDeclarationBody(TypeDeclarationSyntax typeDeclaration)
EditAndContinue\SyntaxComparer.cs (1)
1430return ((TypeDeclarationSyntax)node).Identifier;
EditAndContinue\SyntaxUtilities.cs (1)
59ParameterListSyntax { Parent: TypeDeclarationSyntax typeDeclaration }
EncapsulateField\CSharpEncapsulateFieldService.cs (1)
154=> field.Parent is TypeDeclarationSyntax;
ExtractInterface\CSharpExtractInterfaceService.cs (4)
35var typeDeclarationNode = await document.TryGetRelevantNodeAsync<TypeDeclarationSyntax>(span, cancellationToken).ConfigureAwait(false); 43return relevantNode.GetAncestor<TypeDeclarationSyntax>(); 62var typeDeclaration = typeNode as TypeDeclarationSyntax;
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.CallSiteContainerRewriter.cs (1)
438private SyntaxNode GetUpdatedTypeDeclaration(TypeDeclarationSyntax node)
ExtractMethod\CSharpSelectionResult.cs (2)
113container is BaseListSyntax or TypeDeclarationSyntax or ConstructorDeclarationSyntax or CompilationUnitSyntax); 183return GetContainingScopeOf<TypeDeclarationSyntax>();
ExtractMethod\Extensions.cs (1)
100if (ancestor is TypeDeclarationSyntax)
GenerateType\CSharpGenerateTypeService.cs (5)
36AbstractGenerateTypeService<CSharpGenerateTypeService, SimpleNameSyntax, ObjectCreationExpressionSyntax, ExpressionSyntax, TypeDeclarationSyntax, ArgumentSyntax> 671node.Parent is TypeDeclarationSyntax) 673if (node.Parent is TypeDeclarationSyntax typeDecl) 684node.Parent is TypeDeclarationSyntax) 703var containingTypeDeclarations = node.GetAncestors<TypeDeclarationSyntax>();
InheritanceMargin\CSharpInheritanceMarginService.cs (3)
30var typeDeclarationNodes = nodesToSearch.OfType<TypeDeclarationSyntax>(); 33foreach (var typeDeclarationNode in typeDeclarationNodes) 72TypeDeclarationSyntax baseTypeDeclarationNode => baseTypeDeclarationNode.Identifier,
InitializeParameter\CSharpInitializeMemberFromPrimaryConstructorParameterCodeRefactoringProvider.cs (2)
47if (selectedParameter.Parent is not ParameterListSyntax { Parent: TypeDeclarationSyntax(kind: SyntaxKind.ClassDeclaration or SyntaxKind.StructDeclaration) typeDeclaration }) 280if (syntaxReference.GetSyntax(cancellationToken) is TypeDeclarationSyntax typeDeclaration)
InitializeParameter\CSharpInitializeMemberFromPrimaryConstructorParameterCodeRefactoringProvider_Update.cs (4)
26TypeDeclarationSyntax typeDeclaration, 49var currentTypeDeclaration = currentRoot.GetCurrentNode(typeDeclaration); 75TypeDeclarationSyntax typeDeclaration, 105var preferredTypeDeclaration = siblingSyntax?.GetAncestorOrThis<TypeDeclarationSyntax>() ?? typeDeclaration;
IntroduceVariable\CSharpIntroduceVariableService.cs (2)
23AbstractIntroduceVariableService<CSharpIntroduceVariableService, ExpressionSyntax, TypeSyntax, TypeDeclarationSyntax, QueryExpressionSyntax, NameSyntax> 137protected override IList<bool> GetInsertionIndices(TypeDeclarationSyntax destination, CancellationToken cancellationToken)
IntroduceVariable\CSharpIntroduceVariableService_IntroduceField.cs (8)
31var oldTypeDeclaration = expression.GetAncestorOrThis<TypeDeclarationSyntax>(); 61var finalTypeDeclaration = InsertMember(newTypeDeclaration, newFieldDeclaration, insertionIndex); 81protected override int DetermineConstantInsertPosition(TypeDeclarationSyntax oldType, TypeDeclarationSyntax newType) 121protected override int DetermineFieldInsertPosition(TypeDeclarationSyntax oldType, TypeDeclarationSyntax newType) 176private static TypeDeclarationSyntax InsertMember( 177TypeDeclarationSyntax typeDeclaration,
LineSeparators\CSharpLineSeparatorService.cs (3)
52case TypeDeclarationSyntax typeBlock: 97=> node is TypeDeclarationSyntax or BaseNamespaceDeclarationSyntax or CompilationUnitSyntax; 101if (node is TypeDeclarationSyntax typeDecl)
MetadataAsSource\CSharpMetadataAsSourceService.cs (3)
156TypeDeclarationSyntax type => (TSyntax)(object)AddNullableRegionsAroundTypeMembers(type, cancellationToken), 168private TypeDeclarationSyntax AddNullableRegionsAroundTypeMembers( 169TypeDeclarationSyntax type, CancellationToken cancellationToken)
Snippets\CSharpConstructorSnippetProvider.cs (1)
64var containingType = syntaxContext.ContainingTypeDeclaration;
Snippets\CSharpSnippetFunctionService.cs (1)
25var type = syntaxTree.FindTokenOnLeftOfPosition(position, cancellationToken).GetAncestor<TypeDeclarationSyntax>();
src\Analyzers\CSharp\Analyzers\AddAccessibilityModifiers\CSharpAddAccessibilityModifiersDiagnosticAnalyzer.cs (1)
47if (member is TypeDeclarationSyntax typeDeclaration)
src\Analyzers\CSharp\Analyzers\ConvertProgram\ConvertProgramAnalysis_TopLevelStatements.cs (2)
61methodDeclaration.Parent is not TypeDeclarationSyntax containingTypeDeclaration || 91private static bool TypeCanBeConverted(INamedTypeSymbol containingType, TypeDeclarationSyntax typeDeclaration)
src\Analyzers\CSharp\Analyzers\MakeStructReadOnly\CSharpMakeStructReadOnlyDiagnosticAnalyzer.cs (1)
92if (typeReference.GetSyntax(cancellationToken) is not TypeDeclarationSyntax typeDeclaration)
src\Analyzers\CSharp\Analyzers\RemoveUnnecessaryDiscardDesignation\CSharpRemoveUnnecessaryDiscardDesignationDiagnosticAnalyzer.cs (1)
67identifierName.GetAncestor<TypeDeclarationSyntax>() is { } containingTypeSyntax)
src\Analyzers\CSharp\Analyzers\RemoveUnusedMembers\CSharpRemoveUnusedMembersDiagnosticAnalyzer.cs (4)
21TypeDeclarationSyntax, 26protected override IEnumerable<TypeDeclarationSyntax> GetTypeDeclarations(INamedTypeSymbol namedType, CancellationToken cancellationToken) 30.OfType<TypeDeclarationSyntax>(); 33protected override SyntaxList<MemberDeclarationSyntax> GetMembers(TypeDeclarationSyntax typeDeclaration)
src\Analyzers\CSharp\Analyzers\UsePrimaryConstructor\CSharpUsePrimaryConstructorDiagnosticAnalyzer.cs (1)
315if (primaryConstructorDeclaration.Parent is not TypeDeclarationSyntax)
src\Analyzers\CSharp\CodeFixes\ConvertToRecord\ConvertToRecordEngine.cs (5)
34Document document, TypeDeclarationSyntax typeDeclaration, CancellationToken cancellationToken) 83TypeDeclarationSyntax typeDeclaration, 328CreateRecordDeclaration(type, (TypeDeclarationSyntax)declaration, modifiedClassTrivia, 377TypeDeclarationSyntax typeDeclaration, 575TypeDeclarationSyntax typeDeclaration,
src\Analyzers\CSharp\CodeFixes\ConvertToRecord\CSharpConvertToRecordCodeFixProvider.cs (1)
39var typeDeclaration = baseTypeSyntax?.GetAncestor<TypeDeclarationSyntax>();
src\Analyzers\CSharp\CodeFixes\GenerateDefaultConstructors\CSharpGenerateDefaultConstructorsService.cs (1)
46if (baseList.Parent is TypeDeclarationSyntax(SyntaxKind.ClassDeclaration or SyntaxKind.RecordDeclaration) parentTypeDecl &&
src\Analyzers\CSharp\CodeFixes\ImplementAbstractClass\CSharpImplementAbstractClassCodeFixProvider.cs (2)
18: AbstractImplementAbstractClassCodeFixProvider<TypeDeclarationSyntax>(CS0534) 22protected override SyntaxToken GetClassIdentifier(TypeDeclarationSyntax classNode)
src\Analyzers\CSharp\CodeFixes\ImplementInterface\CSharpImplementInterfaceService.cs (1)
64classOrStructDecl = interfaceNode.Parent.Parent.Parent as TypeDeclarationSyntax;
src\Analyzers\CSharp\CodeFixes\MakeRefStruct\MakeRefStructCodeFixProvider.cs (1)
45if (root.FindNode(span).GetAncestor<TypeDeclarationSyntax>() is not StructDeclarationSyntax structDeclaration)
src\Analyzers\CSharp\CodeFixes\MakeTypeAbstract\CSharpMakeTypeAbstractCodeFixProvider.cs (4)
17internal sealed class CSharpMakeTypeAbstractCodeFixProvider() : AbstractMakeTypeAbstractCodeFixProvider<TypeDeclarationSyntax> 22protected override bool IsValidRefactoringContext(SyntaxNode? node, [NotNullWhen(true)] out TypeDeclarationSyntax? typeDeclaration) 49var enclosingType = node.FirstAncestorOrSelf<TypeDeclarationSyntax>();
src\Analyzers\CSharp\CodeFixes\UsePrimaryConstructor\CSharpUsePrimaryConstructorCodeFixProvider.cs (10)
121var typeDeclaration = (TypeDeclarationSyntax)constructorDeclaration.GetRequiredParent(); 127var typeDeclarationNodes = namedType.DeclaringSyntaxReferences.Select(r => (TypeDeclarationSyntax)r.GetSyntax(cancellationToken)); 151var currentTypeDeclaration = (TypeDeclarationSyntax)current; 182TypeDeclarationSyntax WithCommentMoved(TypeDeclarationSyntax finalTypeDeclaration) 341TypeDeclarationSyntax typeDeclaration, 421var currentTypeDeclaration = (TypeDeclarationSyntax)current;
src\Analyzers\CSharp\CodeFixes\UsePrimaryConstructor\CSharpUsePrimaryConstructorCodeFixProvider_DocComments.cs (2)
65TypeDeclarationSyntax typeDeclaration, 100TypeDeclarationSyntax typeDeclaration,
src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpDeclarationComputer.cs (4)
108var typeDeclaration = (TypeDeclarationSyntax)node; 126var t = (TypeDeclarationSyntax)node;
Structure\CSharpStructureHelpers.cs (2)
283TypeDeclarationSyntax typeDeclaration => typeDeclaration.Modifiers.FirstOrNull() ?? typeDeclaration.Keyword, 291TypeDeclarationSyntax typeDeclaration => typeDeclaration.OpenBraceToken.GetPreviousToken(),
Structure\Providers\TypeDeclarationStructureProvider.cs (2)
14internal class TypeDeclarationStructureProvider : AbstractSyntaxNodeStructureProvider<TypeDeclarationSyntax> 18TypeDeclarationSyntax typeDeclaration,
Testing\CSharpTestMethodFinder.cs (1)
24return node is BaseNamespaceDeclarationSyntax or TypeDeclarationSyntax;
UseAutoProperty\CSharpUseAutoPropertyCodeFixProvider.cs (1)
36TypeDeclarationSyntax,
Microsoft.CodeAnalysis.CSharp.IOperation.UnitTests (2)
IOperation\IOperationTests.cs (2)
616var typeDecl = (TypeDeclarationSyntax)root.Members[0];
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (30)
Semantics\ConditionalOperatorTests.cs (2)
1289var classC = (TypeDeclarationSyntax)compUnit.Members.First();
Semantics\InteractiveSemanticModelTests.cs (2)
41var classB = (root.Members[1] as NamespaceDeclarationSyntax).Members[0] as TypeDeclarationSyntax;
Semantics\QueryTests.cs (22)
1453var classC = tree.GetCompilationUnitRoot().ChildNodes().OfType<TypeDeclarationSyntax>().Where(t => t.Identifier.ValueText == "Query").Single(); 1662var classC = tree.GetCompilationUnitRoot().ChildNodes().OfType<TypeDeclarationSyntax>().Where(t => t.Identifier.ValueText == "Query").Single(); 1722var classC = tree.GetCompilationUnitRoot().ChildNodes().OfType<TypeDeclarationSyntax>().Where(t => t.Identifier.ValueText == "Query").Single(); 1760var classC = tree.GetCompilationUnitRoot().ChildNodes().OfType<TypeDeclarationSyntax>().Where(t => t.Identifier.ValueText == "Query").Single(); 2897var classC = tree.GetCompilationUnitRoot().ChildNodes().OfType<TypeDeclarationSyntax>().Where(t => t.Identifier.ValueText == "C").Single(); 2930var classC = tree.GetCompilationUnitRoot().ChildNodes().OfType<TypeDeclarationSyntax>().Where(t => t.Identifier.ValueText == "C").Single(); 3420var classC = tree.GetCompilationUnitRoot().ChildNodes().OfType<TypeDeclarationSyntax>().Where(t => t.Identifier.ValueText == "Query").Single(); 3464var classC = tree.GetCompilationUnitRoot().ChildNodes().OfType<TypeDeclarationSyntax>().Where(t => t.Identifier.ValueText == "Query").Single(); 3511var classC = tree.GetCompilationUnitRoot().ChildNodes().OfType<TypeDeclarationSyntax>().Where(t => t.Identifier.ValueText == "Test").Single(); 3550var classC = tree.GetCompilationUnitRoot().ChildNodes().OfType<TypeDeclarationSyntax>().Where(t => t.Identifier.ValueText == "Test2").Single(); 3598var classC = tree.GetCompilationUnitRoot().ChildNodes().OfType<TypeDeclarationSyntax>().Where(t => t.Identifier.ValueText == "QueryExpressionTest").Single();
Semantics\SemanticErrorTests.cs (2)
3327var classError = (TypeDeclarationSyntax)compilationUnit.Members[2];
Semantics\TargetTypedConditionalOperatorTests.cs (2)
337var classC = (TypeDeclarationSyntax)compUnit.Members.First();
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (275)
Compilation\GetSemanticInfoTests.cs (12)
242var testClass = tree.GetCompilationUnitRoot().Members[1] as TypeDeclarationSyntax; 296var c = (TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]; 374var testClass = tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax; 477var testClass = tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax; 530var testClass = tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax; 973var methodDecl = (MethodDeclarationSyntax)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0]; 997var methodDecl = (MethodDeclarationSyntax)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0];
Compilation\SemanticModelAPITests.cs (92)
533var bdecl = tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax; 559var cdecl = tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax; 585var cdecl = tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax; 608var bdecl = tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax; 642var classProgram = tree2.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax; 673var decl = tree1.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax; 701var decl = tree1.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax; 724var bdecl = tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax; 750var adecl = tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax; 751var bdecl = adecl.Members[0] as TypeDeclarationSyntax; 783var mainDecl = root.Members[0] as TypeDeclarationSyntax; 786var aDecl = root.Members[1] as TypeDeclarationSyntax; 789var abDecl = aDecl.Members[0] as TypeDeclarationSyntax; 792var bDecl = root.Members[2] as TypeDeclarationSyntax; 820var cDecl = n2Decl.Members[0] as TypeDeclarationSyntax; 1409var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 1499var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 1548var interfaceDecl = (TypeDeclarationSyntax)root.Members[1]; 1587var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 1627var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 1645var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 1663var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 1776var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 1827var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 1877var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 1916var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 1953var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 1990var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 2169var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 2214var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 2256var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 2348var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 2443var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 2485var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 2530var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 2561var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 2633var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 2670var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 2761var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 2831var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 2861var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 2891var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 2920var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 2960var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 3005var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 3086var typeDecl = (TypeDeclarationSyntax)root.Members[0];
Compilation\SemanticModelGetDeclaredSymbolAPITests.cs (115)
147var classC = (root.Members[0] as NamespaceDeclarationSyntax).Members[0] as TypeDeclarationSyntax; 169var classY = ((root. 171Members[0] as TypeDeclarationSyntax); 210var classY = ((root. 212Members[0] as TypeDeclarationSyntax); 233var classY = ((root. 235Members[0] as TypeDeclarationSyntax); 257var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 277var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 300var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 333var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 380var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 406var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 451var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 473var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 498var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 520var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 542var typeDecl = (TypeDeclarationSyntax)root.Members[0]; 566var methodDecl = (MethodDeclarationSyntax)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0]; 588var methodDecl = (MethodDeclarationSyntax)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0]; 775var fieldDecl = (FieldDeclarationSyntax)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0]; 797var fieldDecl = (FieldDeclarationSyntax)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0]; 821var methodDecl = (MethodDeclarationSyntax)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0]; 857var methodDecl = (MethodDeclarationSyntax)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0]; 881var typeDecl = (TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]; 901var methodDecl = (MethodDeclarationSyntax)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0]; 941var typeDecl = (TypeDeclarationSyntax)nsDecl.Members[0]; 963typeDecl = (TypeDeclarationSyntax)nsDecl.Members[0]; 979typeDecl = (TypeDeclarationSyntax)nsDecl.Members[1]; 1082var typeDecl = (TypeDeclarationSyntax)cu.Members[1]; 1125var typeDeclB = (TypeDeclarationSyntax)cu.Members[1]; 1133var typeDeclC = (TypeDeclarationSyntax)cu.Members[2]; 1172var typeDecl = (TypeDeclarationSyntax)cu.Members[1]; 1211var typeDeclC = (TypeDeclarationSyntax)cu.Members[2]; 1247var typeDeclA = (TypeDeclarationSyntax)cu.Members[0]; 1281var typeDeclC = (TypeDeclarationSyntax)cu.Members[2]; 1331var typeDecl = (TypeDeclarationSyntax)cu.Members[4]; 1381var typeDeclC = (TypeDeclarationSyntax)cu.Members[2]; 1434var typeDecl = (TypeDeclarationSyntax)cu.Members[4]; 1594var typeDeclC = (TypeDeclarationSyntax)cu.Members[2]; 1628var typeDeclC = (TypeDeclarationSyntax)cu.Members[2]; 1666var typeDeclC = (TypeDeclarationSyntax)cu.Members[2]; 1711var typeDecl = (TypeDeclarationSyntax)namespaceDecl.Members[0]; 1814var typeDecl = (TypeDeclarationSyntax)cu.Members[0]; 1870var typeDecl = (TypeDeclarationSyntax)cu.Members[2]; 2007var typeDecl = (TypeDeclarationSyntax)cu.Members[0]; 2051var typeDeclA = (TypeDeclarationSyntax)cu.Members[0]; 2250var methodDecl = (MethodDeclarationSyntax)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0]; 2286var methodDecl = (MethodDeclarationSyntax)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0]; 2323var methodDecl = (MethodDeclarationSyntax)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0]; 2359var methodDecl = (MethodDeclarationSyntax)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0]; 2395var methodDecl = (MethodDeclarationSyntax)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0]; 2425var methodDecl = (MethodDeclarationSyntax)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0]; 2457var methodDecl = (MethodDeclarationSyntax)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0]; 2494var methodDecl = (MethodDeclarationSyntax)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0]; 2531var methodDecl = (MethodDeclarationSyntax)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0]; 2562var methodDecl = (MethodDeclarationSyntax)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[1]; 2591var methodDecl = (MethodDeclarationSyntax)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[1]; 2616var methodDecl = (MethodDeclarationSyntax)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0]; 2641var methodDecl = (MethodDeclarationSyntax)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0]; 2671var methodDecl = (MethodDeclarationSyntax)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0]; 2699var methodDecl = (MethodDeclarationSyntax)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0]; 2792var classB = model.GetDeclaredSymbol(nsSyntax.Members[0] as TypeDeclarationSyntax); 2844var classNode = (TypeDeclarationSyntax)root.Members[1]; 2973var node1 = (root.Members[0] as TypeDeclarationSyntax); 2981var node2 = (node1.Members[2] as TypeDeclarationSyntax); 2986var node3 = (node1.Members[3] as TypeDeclarationSyntax); 3023var declSym = model.GetDeclaredSymbol(nsSyntax.Members[0] as TypeDeclarationSyntax); 3051var dsym1 = model.GetDeclaredSymbol(nsSyntax.Members[0] as TypeDeclarationSyntax); 3052var dsym2 = model.GetDeclaredSymbol(nsSyntax.Members[1] as TypeDeclarationSyntax); 3080var dsym1 = model.GetDeclaredSymbol(nsSyntax.Members[0] as TypeDeclarationSyntax); 3145var synType = root.Members[0] as TypeDeclarationSyntax; 3211var methodDecl = (MethodDeclarationSyntax)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[2]).Members[0]; 3234var methodDecl = (MethodDeclarationSyntax)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0]; 3265var methodDecl = (MethodDeclarationSyntax)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0]; 3709var methodDecl = (MethodDeclarationSyntax)((TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]).Members[0]; 5174var typeDeclC = (TypeDeclarationSyntax)cu.Members.Single();
Symbols\MethodEqualityTests.cs (2)
209var cDecl = (TypeDeclarationSyntax)root.Members[0];
Symbols\Source\BaseClassTests.cs (4)
271var classA = (TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]; 308var classA = (TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0];
Symbols\Source\ExternAliasTests.cs (2)
357var a1 = root.Members[0] as TypeDeclarationSyntax;
Symbols\Source\UsingAliasTests.cs (48)
36var a1 = root.Members[0] as TypeDeclarationSyntax; 37var a2 = root.Members[1] as TypeDeclarationSyntax; 38var a3 = root.Members[2] as TypeDeclarationSyntax; 39var a4 = root.Members[3] as TypeDeclarationSyntax; 93var a1 = root.Members[0] as TypeDeclarationSyntax; 94var a2 = root.Members[1] as TypeDeclarationSyntax; 95var a3 = root.Members[2] as TypeDeclarationSyntax; 96var a4 = root.Members[3] as TypeDeclarationSyntax; 153var a1 = root.Members[0] as TypeDeclarationSyntax; 154var a2 = root.Members[1] as TypeDeclarationSyntax; 155var a3 = root.Members[2] as TypeDeclarationSyntax; 156var a4 = root.Members[3] as TypeDeclarationSyntax; 208var a1 = root.Members[0] as TypeDeclarationSyntax; 209var a2 = root.Members[1] as TypeDeclarationSyntax; 210var a3 = root.Members[2] as TypeDeclarationSyntax; 211var a4 = root.Members[3] as TypeDeclarationSyntax; 300var a1 = root.Members[0] as TypeDeclarationSyntax; 301var a2 = root.Members[1] as TypeDeclarationSyntax; 302var a3 = root.Members[2] as TypeDeclarationSyntax; 303var a4 = root.Members[3] as TypeDeclarationSyntax; 346var a1 = root.Members[0] as TypeDeclarationSyntax; 347var a2 = root.Members[1] as TypeDeclarationSyntax; 348var a3 = root.Members[2] as TypeDeclarationSyntax; 349var a4 = root.Members[3] as TypeDeclarationSyntax;
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (603)
IncrementalParsing\BinaryExpression.cs (4)
31var type = newTree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax; 207TypeDeclarationSyntax classType = newTree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax;
IncrementalParsing\ChangingIdentifiers.cs (2)
274TypeDeclarationSyntax classType = newTree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax;
IncrementalParsing\CompoundAssignment.cs (2)
146var classType = newTree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax;
IncrementalParsing\TypeChanges.cs (16)
32var classType = newTree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax; 47var classType = newTree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax; 62var classType = newTree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax; 77var classType = newTree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax; 92var classType = newTree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax; 108var classType = newTree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax; 124var classType = newTree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax; 140var classType = newTree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax;
IncrementalParsing\UnaryExpression.cs (2)
89var classType = newTree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax;
LexicalAndXml\PreprocessorTests.cs (2)
1686var td = (TypeDeclarationSyntax)node.Members[0];
LexicalAndXml\XmlDocCommentTests.cs (31)
1291var classdecl = (TypeDeclarationSyntax)tree.GetCompilationUnitRoot().ChildNodesAndTokens()[0].AsNode(); 1832Assert.Equal(typeof(MethodDeclarationSyntax), (tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax).Members[0].GetType()); 1834var keyword = ((tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax).Members[0] as MethodDeclarationSyntax).ReturnType; 1867Assert.Equal(typeof(MethodDeclarationSyntax), (tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax).Members[0].GetType()); 1869var keyword = ((tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax).Members[0] as MethodDeclarationSyntax).ReturnType; 1902Assert.Equal(typeof(PropertyDeclarationSyntax), (tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax).Members[0].GetType()); 1904var keyword = ((tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax).Members[0] as PropertyDeclarationSyntax).Type; 1937Assert.Equal(typeof(IndexerDeclarationSyntax), (tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax).Members[0].GetType()); 1939var keyword = ((tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax).Members[0] as IndexerDeclarationSyntax).Type; 1972Assert.Equal(typeof(MethodDeclarationSyntax), (tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax).Members[0].GetType()); 1975var method = (tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax).Members[0] as MethodDeclarationSyntax; 2012var typeParameter = (tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax).TypeParameterList.Parameters.Single(); 2047Assert.Equal(typeof(MethodDeclarationSyntax), (tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax).Members[0].GetType()); 2049var keyword = ((tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax).Members[0] as MethodDeclarationSyntax).ReturnType; 2082var bracket = (tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax).CloseBraceToken; 2114var classDecl = (TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]; 2257var classKeyword = (tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax).Keyword; 2384var classKeyword = (tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax).Keyword; 2414var classKeyword = (tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax).Keyword; 2441var classKeyword = (tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax).Keyword; 2467var classKeyword = (tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax).Keyword; 2494var classKeyword = (tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax).Keyword; 2519var classKeyword = (tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax).Keyword; 2541var classKeyword = (tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax).Keyword; 2567var classKeyword = (tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax).Keyword; 2637var classKeyword = (tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax).Keyword; 2655var classKeyword = (tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax).Keyword; 2745var classKeyword = (tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax).Keyword; 2769var classKeyword = (tree.GetCompilationUnitRoot().Members[0] as TypeDeclarationSyntax).Keyword;
Parsing\DeclarationParsingTests.cs (185)
781var cs = (TypeDeclarationSyntax)file.Members[0]; 807var cs = (TypeDeclarationSyntax)file.Members[0]; 834var cs = (TypeDeclarationSyntax)file.Members[0]; 861var cs = (TypeDeclarationSyntax)file.Members[0]; 888var cs = (TypeDeclarationSyntax)file.Members[0]; 915var cs = (TypeDeclarationSyntax)file.Members[0]; 942var cs = (TypeDeclarationSyntax)file.Members[0]; 969var cs = (TypeDeclarationSyntax)file.Members[0]; 996var cs = (TypeDeclarationSyntax)file.Members[0]; 1024var cs = (TypeDeclarationSyntax)file.Members[0]; 1051var cs = (TypeDeclarationSyntax)file.Members[0]; 1082var cs = (TypeDeclarationSyntax)file.Members[0]; 1114var cs = (TypeDeclarationSyntax)file.Members[0]; 1156var cs = (TypeDeclarationSyntax)file.Members[0]; 1217var cs = (TypeDeclarationSyntax)file.Members[0]; 1261var cs = (TypeDeclarationSyntax)file.Members[0]; 1302var cs = (TypeDeclarationSyntax)file.Members[0]; 1343var cs = (TypeDeclarationSyntax)file.Members[0]; 1399var cs = (TypeDeclarationSyntax)file.Members[0]; 1454var cs = (TypeDeclarationSyntax)file.Members[0]; 1500var cs = (TypeDeclarationSyntax)file.Members[0]; 1544var cs = (TypeDeclarationSyntax)file.Members[0]; 1604var cs = (TypeDeclarationSyntax)file.Members[0]; 1629var cs = (TypeDeclarationSyntax)file.Members[0]; 1659var cs = (TypeDeclarationSyntax)file.Members[0]; 1691var cs = (TypeDeclarationSyntax)file.Members[0]; 1716var cs = (TypeDeclarationSyntax)file.Members[0]; 1731cs = (TypeDeclarationSyntax)cs.Members[0]; 1756var cs = (TypeDeclarationSyntax)file.Members[0]; 1771cs = (TypeDeclarationSyntax)cs.Members[0]; 1797var cs = (TypeDeclarationSyntax)file.Members[0]; 1812cs = (TypeDeclarationSyntax)cs.Members[0]; 1838var cs = (TypeDeclarationSyntax)file.Members[0]; 1853cs = (TypeDeclarationSyntax)cs.Members[0]; 1880var cs = (TypeDeclarationSyntax)file.Members[0]; 1895cs = (TypeDeclarationSyntax)cs.Members[0]; 1922var cs = (TypeDeclarationSyntax)file.Members[0]; 1937cs = (TypeDeclarationSyntax)cs.Members[0]; 1963var cs = (TypeDeclarationSyntax)file.Members[0]; 1978cs = (TypeDeclarationSyntax)cs.Members[0]; 2442var cs = (TypeDeclarationSyntax)file.Members[0]; 2484var cs = (TypeDeclarationSyntax)file.Members[0]; 2530var cs = (TypeDeclarationSyntax)file.Members[0]; 2576var cs = (TypeDeclarationSyntax)file.Members[0]; 2621var cs = (TypeDeclarationSyntax)file.Members[0]; 2651var cs = (TypeDeclarationSyntax)file.Members[0]; 2679var cs = (TypeDeclarationSyntax)file.Members[0]; 2747var cs = (TypeDeclarationSyntax)file.Members[0]; 2794var structDecl = (TypeDeclarationSyntax)file.Members[0]; 2841var structDecl = (TypeDeclarationSyntax)file.Members[0]; 2891var structDecl = (TypeDeclarationSyntax)file.Members[0]; 2932var structDecl = (TypeDeclarationSyntax)file.Members[0]; 2993var cs = (TypeDeclarationSyntax)file.Members[0]; 3045var cs = (TypeDeclarationSyntax)file.Members[0]; 3106var cs = (TypeDeclarationSyntax)file.Members[0]; 3171var cs = (TypeDeclarationSyntax)file.Members[0]; 3245var cs = (TypeDeclarationSyntax)file.Members[0]; 3310var cs = (TypeDeclarationSyntax)file.Members[0]; 3362var cs = (TypeDeclarationSyntax)file.Members[0]; 3408var cs = (TypeDeclarationSyntax)file.Members[0]; 3489var cs = (TypeDeclarationSyntax)file.Members[0]; 3524var cs = (TypeDeclarationSyntax)file.Members[0]; 3571var cs = (TypeDeclarationSyntax)file.Members[0]; 3608var cs = (TypeDeclarationSyntax)file.Members[0]; 3668var cs = (TypeDeclarationSyntax)file.Members[0]; 3708var cs = (TypeDeclarationSyntax)file.Members[0]; 3762var cs = (TypeDeclarationSyntax)file.Members[0]; 3818var cs = (TypeDeclarationSyntax)file.Members[0]; 3863var cs = (TypeDeclarationSyntax)file.Members[0]; 3907var cs = (TypeDeclarationSyntax)file.Members[0]; 3952var cs = (TypeDeclarationSyntax)file.Members[0]; 4006var cs = (TypeDeclarationSyntax)file.Members[0]; 4069var cs = (TypeDeclarationSyntax)file.Members[0]; 4115var cs = (TypeDeclarationSyntax)file.Members[0]; 4169var cs = (TypeDeclarationSyntax)file.Members[0]; 4224var cs = (TypeDeclarationSyntax)file.Members[0]; 4297var cs = (TypeDeclarationSyntax)file.Members[0]; 4351var cs = (TypeDeclarationSyntax)file.Members[0]; 4489var cs = (TypeDeclarationSyntax)file.Members[0]; 4545var cs = (TypeDeclarationSyntax)file.Members[0]; 4601var cs = (TypeDeclarationSyntax)file.Members[0]; 4685var cs = (TypeDeclarationSyntax)file.Members[0]; 4741var cs = (TypeDeclarationSyntax)file.Members[0]; 4795var cs = (TypeDeclarationSyntax)file.Members[0]; 4878var cs = (TypeDeclarationSyntax)file.Members[0]; 4935var cs = (TypeDeclarationSyntax)file.Members[0]; 5002var cs = (TypeDeclarationSyntax)file.Members[0]; 5070var cs = (TypeDeclarationSyntax)file.Members[0]; 5137var cs = (TypeDeclarationSyntax)file.Members[0]; 5213var cs = (TypeDeclarationSyntax)file.Members[0]; 5281var cs = (TypeDeclarationSyntax)file.Members[0]; 5361var cs = (TypeDeclarationSyntax)file.Members[0]; 5475var cs = (TypeDeclarationSyntax)file.Members[0]; 5538var cs = (TypeDeclarationSyntax)file.Members[0]; 5586var cs = (TypeDeclarationSyntax)file.Members[0]; 5884var @class = (TypeDeclarationSyntax)file.Members[0];
Parsing\ParsingErrorRecoveryTests.cs (339)
1532var agg = (TypeDeclarationSyntax)file.Members[0]; 1550var agg = (TypeDeclarationSyntax)file.Members[0]; 1568var agg = (TypeDeclarationSyntax)file.Members[0]; 1587var agg = (TypeDeclarationSyntax)file.Members[0]; 1607var agg = (TypeDeclarationSyntax)file.Members[0]; 1626var agg = (TypeDeclarationSyntax)file.Members[0]; 1646var agg = (TypeDeclarationSyntax)file.Members[0]; 1663var agg = (TypeDeclarationSyntax)file.Members[0]; 1680var agg = (TypeDeclarationSyntax)file.Members[0]; 1698var agg = (TypeDeclarationSyntax)file.Members[0]; 1716var agg = (TypeDeclarationSyntax)file.Members[0]; 1735var agg = (TypeDeclarationSyntax)file.Members[0]; 1753var agg = (TypeDeclarationSyntax)file.Members[0]; 1773var agg = (TypeDeclarationSyntax)file.Members[0]; 1790var agg = (TypeDeclarationSyntax)file.Members[0]; 1807var agg = (TypeDeclarationSyntax)file.Members[0]; 1825var agg = (TypeDeclarationSyntax)file.Members[0]; 1842var agg = (TypeDeclarationSyntax)file.Members[0]; 1861var agg = (TypeDeclarationSyntax)file.Members[0]; 1880var agg = (TypeDeclarationSyntax)file.Members[0]; 1900var agg = (TypeDeclarationSyntax)file.Members[0]; 1919var agg = (TypeDeclarationSyntax)file.Members[0]; 1940var agg = (TypeDeclarationSyntax)file.Members[0]; 1958var agg = (TypeDeclarationSyntax)file.Members[0]; 1975var agg = (TypeDeclarationSyntax)file.Members[0]; 1992var agg = (TypeDeclarationSyntax)file.Members[0]; 2024var agg = (TypeDeclarationSyntax)file.Members[0]; 2063var agg = (TypeDeclarationSyntax)file.Members[0]; 2083var agg = (TypeDeclarationSyntax)file.Members[0]; 2102var agg = (TypeDeclarationSyntax)file.Members[0]; 2123var agg = (TypeDeclarationSyntax)file.Members[0]; 2141var agg = (TypeDeclarationSyntax)file.Members[0]; 2172var agg = (TypeDeclarationSyntax)file.Members[0]; 2190var agg = (TypeDeclarationSyntax)file.Members[0]; 2207var agg = (TypeDeclarationSyntax)file.Members[0]; 2226var agg = (TypeDeclarationSyntax)file.Members[0]; 2266var agg = (TypeDeclarationSyntax)file.Members[0]; 2287var agg = (TypeDeclarationSyntax)file.Members[0]; 2307var agg = (TypeDeclarationSyntax)file.Members[0]; 2329var agg = (TypeDeclarationSyntax)file.Members[0]; 2872var agg = (TypeDeclarationSyntax)file.Members[0]; 2889var agg = (TypeDeclarationSyntax)file.Members[0]; 2905var agg = (TypeDeclarationSyntax)file.Members[0]; 2923var agg = (TypeDeclarationSyntax)file.Members[0]; 2939var agg = (TypeDeclarationSyntax)file.Members[0]; 2955var agg = (TypeDeclarationSyntax)file.Members[0]; 2971var agg = (TypeDeclarationSyntax)file.Members[0]; 2987var agg = (TypeDeclarationSyntax)file.Members[0]; 3003var agg = (TypeDeclarationSyntax)file.Members[0]; 3021var agg = (TypeDeclarationSyntax)file.Members[0]; 3039var agg = (TypeDeclarationSyntax)file.Members[0]; 3062var agg = (TypeDeclarationSyntax)file.Members[0]; 3086var agg = (TypeDeclarationSyntax)file.Members[0]; 3110var agg = (TypeDeclarationSyntax)file.Members[0]; 3132var agg = (TypeDeclarationSyntax)file.Members[0]; 3155var agg = (TypeDeclarationSyntax)file.Members[0]; 3178var agg = (TypeDeclarationSyntax)file.Members[0]; 3201var agg = (TypeDeclarationSyntax)file.Members[0]; 3224var agg = (TypeDeclarationSyntax)file.Members[0]; 3247var agg = (TypeDeclarationSyntax)file.Members[0]; 3268var agg = (TypeDeclarationSyntax)file.Members[0]; 3289var agg = (TypeDeclarationSyntax)file.Members[0]; 3310var agg = (TypeDeclarationSyntax)file.Members[0]; 3331var agg = (TypeDeclarationSyntax)file.Members[0]; 3352var agg = (TypeDeclarationSyntax)file.Members[0]; 3373var agg = (TypeDeclarationSyntax)file.Members[0]; 3395var agg = (TypeDeclarationSyntax)file.Members[0]; 3418var agg = (TypeDeclarationSyntax)file.Members[0]; 3441var agg = (TypeDeclarationSyntax)file.Members[0]; 3464var agg = (TypeDeclarationSyntax)file.Members[0]; 3488var agg = (TypeDeclarationSyntax)file.Members[0]; 3511var agg = (TypeDeclarationSyntax)file.Members[0]; 3534var agg = (TypeDeclarationSyntax)file.Members[0]; 3554var md = (file.Members[0] as TypeDeclarationSyntax).Members[0] as MethodDeclarationSyntax; 3577var agg = (TypeDeclarationSyntax)file.Members[0]; 3602var agg = (TypeDeclarationSyntax)file.Members[0]; 3627var agg = (TypeDeclarationSyntax)file.Members[0]; 3653var agg = (TypeDeclarationSyntax)file.Members[0]; 3677var agg = (TypeDeclarationSyntax)file.Members[0]; 3701var agg = (TypeDeclarationSyntax)file.Members[0]; 3726var agg = (TypeDeclarationSyntax)file.Members[0]; 3750var agg = (TypeDeclarationSyntax)file.Members[0]; 3774var agg = (TypeDeclarationSyntax)file.Members[0]; 3798var agg = (TypeDeclarationSyntax)file.Members[0]; 3823var agg = (TypeDeclarationSyntax)file.Members[0]; 3847var agg = (TypeDeclarationSyntax)file.Members[0]; 3871var agg = (TypeDeclarationSyntax)file.Members[0]; 3896var agg = (TypeDeclarationSyntax)file.Members[0]; 3922var agg = (TypeDeclarationSyntax)file.Members[0]; 3948var agg = (TypeDeclarationSyntax)file.Members[0]; 3975var agg = (TypeDeclarationSyntax)file.Members[0]; 4000var agg = (TypeDeclarationSyntax)file.Members[0]; 4025var agg = (TypeDeclarationSyntax)file.Members[0]; 4051var agg = (TypeDeclarationSyntax)file.Members[0]; 4072var agg = (TypeDeclarationSyntax)file.Members[0]; 4117var agg = (TypeDeclarationSyntax)file.Members[0]; 4138var agg = (TypeDeclarationSyntax)file.Members[0]; 4159var agg = (TypeDeclarationSyntax)file.Members[0]; 4180var agg = (TypeDeclarationSyntax)file.Members[0]; 4202var agg = (TypeDeclarationSyntax)file.Members[0]; 4224var agg = (TypeDeclarationSyntax)file.Members[0]; 4247var agg = (TypeDeclarationSyntax)file.Members[0]; 4270var agg = (TypeDeclarationSyntax)file.Members[0]; 4291var agg = (TypeDeclarationSyntax)file.Members[0]; 4314var agg = (TypeDeclarationSyntax)file.Members[0]; 4337var agg = (TypeDeclarationSyntax)file.Members[0]; 4363var agg = (TypeDeclarationSyntax)file.Members[0]; 4385var agg = (TypeDeclarationSyntax)file.Members[0]; 4411var agg = (TypeDeclarationSyntax)file.Members[0]; 4438var agg = (TypeDeclarationSyntax)file.Members[0]; 4459var agg = (TypeDeclarationSyntax)file.Members[0]; 4482var agg = (TypeDeclarationSyntax)file.Members[0]; 4507var agg = (TypeDeclarationSyntax)file.Members[0]; 4532var agg = (TypeDeclarationSyntax)file.Members[0]; 4554var agg = (TypeDeclarationSyntax)file.Members[0]; 4579var agg = (TypeDeclarationSyntax)file.Members[0]; 4605var agg = (TypeDeclarationSyntax)file.Members[0]; 4632var agg = (TypeDeclarationSyntax)file.Members[0]; 4659var agg = (TypeDeclarationSyntax)file.Members[0]; 4687var agg = (TypeDeclarationSyntax)file.Members[0]; 4714var agg = (TypeDeclarationSyntax)file.Members[0]; 4741var agg = (TypeDeclarationSyntax)file.Members[0]; 4770var agg = (TypeDeclarationSyntax)file.Members[0]; 4799var agg = (TypeDeclarationSyntax)file.Members[0]; 4829var agg = (TypeDeclarationSyntax)file.Members[0]; 4858var agg = (TypeDeclarationSyntax)file.Members[0]; 4887var agg = (TypeDeclarationSyntax)file.Members[0]; 4914var agg = (TypeDeclarationSyntax)file.Members[0]; 4941var agg = (TypeDeclarationSyntax)file.Members[0]; 4968var agg = (TypeDeclarationSyntax)file.Members[0]; 4996var agg = (TypeDeclarationSyntax)file.Members[0]; 5023var agg = (TypeDeclarationSyntax)file.Members[0]; 5051var agg = (TypeDeclarationSyntax)file.Members[0]; 5077var agg = (TypeDeclarationSyntax)file.Members[0]; 5107var agg = (TypeDeclarationSyntax)file.Members[0]; 5136var agg = (TypeDeclarationSyntax)file.Members[0]; 5166var agg = (TypeDeclarationSyntax)file.Members[0]; 5819var agg = (TypeDeclarationSyntax)file.Members[0]; 5858var agg = (TypeDeclarationSyntax)file.Members[0]; 5887var agg = (TypeDeclarationSyntax)file.Members[0]; 5916var agg = (TypeDeclarationSyntax)file.Members[0]; 5946var agg = (TypeDeclarationSyntax)file.Members[0]; 5975var agg = (TypeDeclarationSyntax)file.Members[0]; 6009var agg = (TypeDeclarationSyntax)file.Members[0]; 6036var agg = (TypeDeclarationSyntax)file.Members[0]; 6063var agg = (TypeDeclarationSyntax)file.Members[0]; 6090var agg = (TypeDeclarationSyntax)file.Members[0]; 6118var agg = (TypeDeclarationSyntax)file.Members[0]; 6145var agg = (TypeDeclarationSyntax)file.Members[0]; 6175var agg = (TypeDeclarationSyntax)file.Members[0]; 6206var agg = (TypeDeclarationSyntax)file.Members[0]; 6234var agg = (TypeDeclarationSyntax)file.Members[0]; 6281var agg = (TypeDeclarationSyntax)file.Members[0]; 6315var agg = (TypeDeclarationSyntax)file.Members[0]; 6345var agg = (TypeDeclarationSyntax)file.Members[0]; 6403var agg = (TypeDeclarationSyntax)file.Members[0]; 6427var agg = (TypeDeclarationSyntax)file.Members[0]; 6452var agg = (TypeDeclarationSyntax)file.Members[0]; 6487var agg = (TypeDeclarationSyntax)file.Members[0]; 6526var agg = (TypeDeclarationSyntax)file.Members[0]; 6565var classDecl = (TypeDeclarationSyntax)file.Members[0]; 6597var classDecl = (TypeDeclarationSyntax)file.Members[0]; 6628var agg = (TypeDeclarationSyntax)file.Members[0]; 6673var agg = (TypeDeclarationSyntax)file.Members[0]; 6717var agg = (TypeDeclarationSyntax)file.Members[0]; 6766var agg = (TypeDeclarationSyntax)file.Members[0]; 6814var agg = (TypeDeclarationSyntax)file.Members[0]; 6861var agg = (TypeDeclarationSyntax)file.Members[0]; 6914var item1 = (TypeDeclarationSyntax)file.Members[0]; 6937var subitem2 = (TypeDeclarationSyntax)item1.Members[1];
Syntax\SyntaxDiffingTests.cs (6)
47var decl = (TypeDeclarationSyntax)(newTree.GetCompilationUnitRoot()).Members[0]; 67var decl1 = (TypeDeclarationSyntax)(newTree.GetCompilationUnitRoot()).Members[0]; 69var decl2 = (TypeDeclarationSyntax)(newTree.GetCompilationUnitRoot()).Members[1];
Syntax\SyntaxNodeTests.cs (14)
732var classDecl = (TypeDeclarationSyntax)root.ChildNodes().First(); 750var classDecl2 = (TypeDeclarationSyntax)root.ChildNodes().Last(); 846var m1 = ((TypeDeclarationSyntax)tree1.GetCompilationUnitRoot().Members[0]).Members[0]; 847var m2 = ((TypeDeclarationSyntax)tree2.GetCompilationUnitRoot().Members[0]).Members[0]; 1338var member = (TypeDeclarationSyntax)tree.GetCompilationUnitRoot().Members[0]; 2921var m = cu.DescendantNodes().OfType<TypeDeclarationSyntax>().LastOrDefault(); 2937var m = cu.DescendantNodes().OfType<TypeDeclarationSyntax>().LastOrDefault(); 3313var m = cu.DescendantNodes().OfType<TypeDeclarationSyntax>().FirstOrDefault();
Microsoft.CodeAnalysis.CSharp.Test.Utilities (3)
Extensions.cs (3)
37public static TypeDeclarationSyntax AsTypeDeclarationSyntax(this SyntaxNode node) 39return node as TypeDeclarationSyntax; 191return type.InstanceConstructors.Single(c => c.DeclaringSyntaxReferences.Any(r => r.GetSyntax() is TypeDeclarationSyntax));
Microsoft.CodeAnalysis.CSharp.Workspaces (95)
CodeGeneration\CSharpSyntaxGenerator.cs (10)
1220=> declaration is TypeDeclarationSyntax { ParameterList: { } parameterList } ? parameterList : null; 1257TypeDeclarationSyntax type => type.Members, 1364TypeDeclarationSyntax type => type.WithMembers(type.Members.AddRange(newMembers)), 1381TypeDeclarationSyntax typeDeclaration => AsClassMember(member, typeDeclaration.Identifier.Text), 1757TypeDeclarationSyntax type => type.WithTypeParameterList(typeParameterList), 1811TypeDeclarationSyntax type => type.WithConstraintClauses(WithTypeConstraints(type.ConstraintClauses, typeParameterName, kinds, isUnmanagedType, types)), 2243return ((TypeDeclarationSyntax)declaration).WithParameterList((ParameterListSyntax)list); 2688=> declaration is TypeDeclarationSyntax typeDeclaration 2693=> declaration is TypeDeclarationSyntax typeDeclaration 3616if (modifiedNode is TypeDeclarationSyntax declarationSyntax)
FindSymbols\CSharpDeclaredSymbolInfoFactoryService.cs (4)
32TypeDeclarationSyntax, 205TypeDeclarationSyntax typeDeclaration, 274Contract.ThrowIfTrue(node is TypeDeclarationSyntax); 464protected override SyntaxList<MemberDeclarationSyntax> GetChildren(TypeDeclarationSyntax node)
Recommendations\CSharpRecommendationServiceRunner.cs (1)
455if (reference.GetSyntax(cancellationToken) is not TypeDeclarationSyntax typeDeclaration)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\MemberDeclarationSyntaxExtensions.cs (3)
40return ((TypeDeclarationSyntax)member).Identifier; 79return ((TypeDeclarationSyntax)member).Arity; 101return ((TypeDeclarationSyntax)member).TypeParameterList;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SemanticModelExtensions.cs (1)
328var typeDeclarations = type.GetAncestors<TypeDeclarationSyntax>();
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs (2)
153TypeDeclarationSyntax typeDeclaration => typeDeclaration.ParameterList, 773case TypeDeclarationSyntax type:
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxTreeExtensions.cs (3)
41public static TypeDeclarationSyntax? GetContainingTypeDeclaration( 53public static IEnumerable<TypeDeclarationSyntax> GetContainingTypeDeclarations( 58return token.GetAncestors<TypeDeclarationSyntax>().Where(t =>
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\AnchorIndentationFormattingRule.cs (1)
60case TypeDeclarationSyntax typeNode:
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SelectedMembers\CSharpSelectedMembers.cs (2)
21TypeDeclarationSyntax, 42protected override SyntaxList<MemberDeclarationSyntax> GetMembers(TypeDeclarationSyntax containingType)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpHeaderFacts.cs (1)
31var lastToken = (node as TypeDeclarationSyntax)?.TypeParameterList?.GetLastToken() ?? node.Identifier;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (4)
752TypeDeclarationSyntax or 782var parent = node.GetAncestor<TypeDeclarationSyntax>() ?? node.Parent; 783while (parent is TypeDeclarationSyntax) 928=> ((TypeDeclarationSyntax)typeDeclaration).Members;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Utilities\FormattingRangeHelper.cs (1)
349previousToken.Parent is TypeDeclarationSyntax ||
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\ConstructorGenerator.cs (2)
26internal static TypeDeclarationSyntax AddConstructorTo( 27TypeDeclarationSyntax destination,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\ConversionGenerator.cs (2)
21internal static TypeDeclarationSyntax AddConversionTo( 22TypeDeclarationSyntax destination,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationHelpers.cs (6)
72public static TypeDeclarationSyntax AddMembersTo( 73TypeDeclarationSyntax destination, SyntaxList<MemberDeclarationSyntax> members, CancellationToken cancellationToken) 78var node = ConditionallyAddFormattingAnnotationTo( 85return (TypeDeclarationSyntax)tree.GetRoot(cancellationToken); 88private static TypeDeclarationSyntax ReplaceUnterminatedConstructs(TypeDeclarationSyntax destination)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\CSharpCodeGenerationService.cs (16)
48if (destination is TypeDeclarationSyntax typeDeclaration) 59private static IList<bool> GetInsertionIndices(TypeDeclarationSyntax destination, CancellationToken cancellationToken) 92CheckDeclarationNode<TypeDeclarationSyntax>(destination); 94return Cast<TDeclarationNode>(EventGenerator.AddEventTo(Cast<TypeDeclarationSyntax>(destination), @event, info, availableIndices, cancellationToken)); 99CheckDeclarationNode<EnumDeclarationSyntax, TypeDeclarationSyntax, CompilationUnitSyntax>(destination); 105else if (destination is TypeDeclarationSyntax) 107return Cast<TDeclarationNode>(FieldGenerator.AddFieldTo(Cast<TypeDeclarationSyntax>(destination), field, info, availableIndices, cancellationToken)); 123CheckDeclarationNode<TypeDeclarationSyntax, CompilationUnitSyntax, BaseNamespaceDeclarationSyntax>(destination); 143if (destination is TypeDeclarationSyntax typeDeclaration) 191CheckDeclarationNode<TypeDeclarationSyntax, CompilationUnitSyntax>(destination); 235if (destination is TypeDeclarationSyntax) 238Cast<TypeDeclarationSyntax>(destination), property, info, availableIndices, cancellationToken)); 249CheckDeclarationNode<TypeDeclarationSyntax, BaseNamespaceDeclarationSyntax, CompilationUnitSyntax>(destination); 253if (destination is TypeDeclarationSyntax typeDeclaration) 343CheckDeclarationNode<EnumDeclarationSyntax, TypeDeclarationSyntax, BaseNamespaceDeclarationSyntax, CompilationUnitSyntax>(destination); 350else if (destination is TypeDeclarationSyntax typeDeclaration)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\DestructorGenerator.cs (2)
24internal static TypeDeclarationSyntax AddDestructorTo( 25TypeDeclarationSyntax destination,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\EventGenerator.cs (2)
78internal static TypeDeclarationSyntax AddEventTo( 79TypeDeclarationSyntax destination,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\FieldGenerator.cs (2)
70internal static TypeDeclarationSyntax AddFieldTo( 71TypeDeclarationSyntax destination,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\MethodGenerator.cs (2)
58internal static TypeDeclarationSyntax AddMethodTo( 59TypeDeclarationSyntax destination,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\NamedTypeGenerator.cs (5)
25public static TypeDeclarationSyntax AddNamedTypeTo( 27TypeDeclarationSyntax destination, 174return ((TypeDeclarationSyntax)declaration).WithMembers(default); 195TypeDeclarationSyntax typeDeclaration; 215var result = typeDeclaration
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\OperatorGenerator.cs (2)
23internal static TypeDeclarationSyntax AddOperatorTo( 24TypeDeclarationSyntax destination,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeGeneration\PropertyGenerator.cs (2)
52internal static TypeDeclarationSyntax AddPropertyTo( 53TypeDeclarationSyntax destination,
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CodeRefactorings\CSharpRefactoringHelpersService.cs (1)
32var typeDecl = token.GetAncestor<TypeDeclarationSyntax>();
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\CSharpSyntaxContext.cs (3)
17public readonly TypeDeclarationSyntax? ContainingTypeDeclaration; 56TypeDeclarationSyntax? containingTypeDeclaration, 226var containingTypeDeclaration = syntaxTree.GetContainingTypeDeclaration(position, cancellationToken);
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTokenExtensions.cs (1)
618if (node?.Parent is TypeDeclarationSyntax(SyntaxKind.InterfaceDeclaration) typeDecl)
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTreeExtensions.cs (8)
439if (token.IsKind(SyntaxKind.OpenBraceToken) && token.Parent is NamespaceDeclarationSyntax or TypeDeclarationSyntax) 520if (container is CompilationUnitSyntax or BaseNamespaceDeclarationSyntax or TypeDeclarationSyntax) 538var typeDecl = context != null 603if (container is CompilationUnitSyntax or BaseNamespaceDeclarationSyntax or TypeDeclarationSyntax) 685public static bool IsPartialTypeDeclarationNameContext(this SyntaxTree syntaxTree, int position, CancellationToken cancellationToken, [NotNullWhen(true)] out TypeDeclarationSyntax? declarationSyntax) 698declarationSyntax = token.GetAncestor<TypeDeclarationSyntax>(); 1130MethodDeclarationSyntax or LocalFunctionStatementSyntax or ConstructorDeclarationSyntax or DelegateDeclarationSyntax or TypeDeclarationSyntax => true, 1214var typeDecl = method.GetAncestorOrThis<TypeDeclarationSyntax>();
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\TypeDeclarationSyntaxExtensions.cs (6)
21public static IList<bool> GetInsertionIndices(this TypeDeclarationSyntax destination, CancellationToken cancellationToken) 71public static IEnumerable<BaseTypeSyntax> GetAllBaseListTypes(this TypeDeclarationSyntax typeNode, SemanticModel model, CancellationToken cancellationToken) 84if (syntaxRef.GetSyntax(cancellationToken) is TypeDeclarationSyntax { BaseList.Types: var baseTypes }) 148public static TypeDeclarationSyntax EnsureOpenAndCloseBraceTokens(this TypeDeclarationSyntax typeDeclaration) 150return (TypeDeclarationSyntax)EnsureHasBraces(typeDeclaration, typeDeclaration.Members.Count > 0);
Microsoft.CodeAnalysis.EditorFeatures.UnitTests (1)
SymbolFinder\DependentTypeFinderTests.cs (1)
647var firstDecl = csRoot.DescendantNodes().First(d => d is CSharp.Syntax.TypeDeclarationSyntax);
Microsoft.CodeAnalysis.Workspaces.UnitTests (38)
SyntaxPathTests.cs (38)
148var classDecl = (TypeDeclarationSyntax)namespaceDecl.Members[0]; 186var class1 = (TypeDeclarationSyntax)namespaceDecl.Members[0]; 187var class2 = (TypeDeclarationSyntax)namespaceDecl.Members[1]; 197Assert.Equal("C", ((TypeDeclarationSyntax)n1).Identifier.ValueText); 199Assert.Equal("D", ((TypeDeclarationSyntax)n2).Identifier.ValueText); 219var classDecl = (TypeDeclarationSyntax)namespaceDecl.Members[0]; 251var class1 = (TypeDeclarationSyntax)namespaceDecl.Members[0]; 252var class2 = (TypeDeclarationSyntax)namespaceDecl.Members[1]; 262Assert.Equal("D", ((TypeDeclarationSyntax)n1).Identifier.ValueText); 279var class1 = (TypeDeclarationSyntax)namespaceDecl.Members[0]; 280var class2 = (TypeDeclarationSyntax)namespaceDecl.Members[1]; 293Assert.Equal("D", ((TypeDeclarationSyntax)n1).Identifier.ValueText); 310var class1 = (TypeDeclarationSyntax)namespaceDecl.Members[0]; 311var class2 = (TypeDeclarationSyntax)namespaceDecl.Members[1]; 321Assert.Equal("C", ((TypeDeclarationSyntax)n1).Identifier.ValueText); 323Assert.Equal("D", ((TypeDeclarationSyntax)n2).Identifier.ValueText); 339var class1 = (TypeDeclarationSyntax)namespaceDecl.Members[0]; 340var class2 = (TypeDeclarationSyntax)namespaceDecl.Members[1]; 350Assert.Equal("C", ((TypeDeclarationSyntax)n1).Identifier.ValueText); 352Assert.Equal("D", ((TypeDeclarationSyntax)n2).Identifier.ValueText); 378var class1 = (TypeDeclarationSyntax)namespaceDecl.Members[0]; 379var class2 = (TypeDeclarationSyntax)namespaceDecl.Members[1]; 389Assert.Equal("C", ((TypeDeclarationSyntax)n1).Identifier.ValueText); 391Assert.Equal("D", ((TypeDeclarationSyntax)n2).Identifier.ValueText);
Microsoft.DotNet.GenFacades (6)
NotSupportedAssemblyGenerator.cs (5)
198private string GetFullyQualifiedName(TypeDeclarationSyntax node) 207parent = GetFullyQualifiedName((TypeDeclarationSyntax)node.Parent); 215private string GetMethodDefinition(MethodDeclarationSyntax node) => GetFullyQualifiedName((TypeDeclarationSyntax)node.Parent) + "." + node.Identifier.ValueText; 217private string GetPropertyDefinition(PropertyDeclarationSyntax node) => GetFullyQualifiedName((TypeDeclarationSyntax)node.Parent) + "." + node.Identifier.ValueText; 219private string GetEventDefinition(EventDeclarationSyntax node) => GetFullyQualifiedName((TypeDeclarationSyntax)node.Parent) + "." + node.Identifier.ValueText;
TypeParser.cs (1)
110if (type is TypeDeclarationSyntax actualType)
Microsoft.Extensions.Logging.Generators (5)
LoggerMessageGenerator.Parser.cs (5)
544var parentLoggerClass = (classDec.Parent as TypeDeclarationSyntax); 562parentLoggerClass = (parentLoggerClass.Parent as TypeDeclarationSyntax); 604private static string GenerateClassName(TypeDeclarationSyntax typeDeclaration) 627private (string? loggerField, bool multipleLoggerFields) FindLoggerField(SemanticModel sm, TypeDeclarationSyntax classDec, ITypeSymbol loggerSymbol)
Microsoft.Extensions.Options.SourceGeneration (13)
Generator.cs (5)
20IncrementalValuesProvider<(TypeDeclarationSyntax? TypeSyntax, SemanticModel SemanticModel)> typeDeclarations = context.SyntaxProvider 23(node, _) => node is TypeDeclarationSyntax, 24(context, _) => (TypeSyntax:context.TargetNode as TypeDeclarationSyntax, SemanticModel: context.SemanticModel)) 27IncrementalValueProvider<(Compilation, ImmutableArray<(TypeDeclarationSyntax? TypeSyntax, SemanticModel SemanticModel)>)> compilationAndTypes = 33private static void HandleAnnotatedTypes(Compilation compilation, ImmutableArray<(TypeDeclarationSyntax? TypeSyntax, SemanticModel SemanticModel)> types, SourceProductionContext context)
Parser.cs (6)
46public IReadOnlyList<ValidatorType> GetValidatorTypes(IEnumerable<(TypeDeclarationSyntax TypeSyntax, SemanticModel SemanticModel)> classes) 55TypeDeclarationSyntax syntax = typeDec.TypeSyntax; 126var parent = syntax.Parent as TypeDeclarationSyntax; 131parent = parent.Parent as TypeDeclarationSyntax; 177private static string GetTypeKeyword(TypeDeclarationSyntax type) =>
TypeDeclarationSyntaxReceiver.cs (2)
20public ICollection<TypeDeclarationSyntax> TypeDeclarations { get; } = new List<TypeDeclarationSyntax>();
Microsoft.Gen.ComplianceReports (5)
Parser.cs (3)
30public IReadOnlyList<ClassifiedType> GetClassifiedTypes(IEnumerable<TypeDeclarationSyntax> classes) 35IEnumerable<IGrouping<SyntaxTree, TypeDeclarationSyntax>> typesBySyntaxTree = classes.GroupBy(x => x.SyntaxTree); 39foreach (TypeDeclarationSyntax typeSyntax in typeForSyntaxTree.Where(n => !n.IsKind(SyntaxKind.InterfaceDeclaration)))
src\Generators\Shared\TypeDeclarationSyntaxReceiver.cs (2)
25public ICollection<TypeDeclarationSyntax> TypeDeclarations { get; } = new List<TypeDeclarationSyntax>();
Microsoft.Gen.ContextualOptions (11)
ContextReceiver.cs (5)
24private readonly List<TypeDeclarationSyntax> _typeDeclarations = []; 30if (syntaxNode is TypeDeclarationSyntax type 37public bool TryGetTypeDeclarations(Compilation compilation, out Dictionary<INamedTypeSymbol, List<TypeDeclarationSyntax>>? typeDeclarations) 51.ToDictionary<IGrouping<ISymbol?, TypeDeclarationSyntax>, INamedTypeSymbol, List<TypeDeclarationSyntax>>(
ContextualOptionsGenerator.cs (3)
37var typeDeclarations = nodes.OfType<TypeDeclarationSyntax>() 43.ToDictionary<IGrouping<ISymbol?, TypeDeclarationSyntax>, INamedTypeSymbol, List<TypeDeclarationSyntax>>(
Model\OptionsContextType.cs (2)
15public readonly ImmutableArray<TypeDeclarationSyntax> Definitions; 27ImmutableArray<TypeDeclarationSyntax> definitions,
Parser.cs (1)
16public static IEnumerable<OptionsContextType> GetContextualOptionTypes(Dictionary<INamedTypeSymbol, List<TypeDeclarationSyntax>> types) =>
Microsoft.Gen.ContextualOptions.Unit.Tests (5)
EmitterTests.cs (5)
29.OfType<TypeDeclarationSyntax>() 48.OfType<TypeDeclarationSyntax>() 52.OfType<TypeDeclarationSyntax>()) 80.OfType<TypeDeclarationSyntax>() 108.OfType<TypeDeclarationSyntax>()
Microsoft.Gen.Logging (14)
LoggingGenerator.cs (6)
19IncrementalValuesProvider<TypeDeclarationSyntax> typeDeclarations = context.SyntaxProvider 22(syntaxNode, _) => syntaxNode.Parent is TypeDeclarationSyntax, 23(context, _) => (TypeDeclarationSyntax)context.TargetNode.Parent!); 25IncrementalValueProvider<(Compilation, ImmutableArray<TypeDeclarationSyntax>)> compilationAndTypes = 31private static void HandleAnnotatedTypes(Compilation compilation, ImmutableArray<TypeDeclarationSyntax> types, SourceProductionContext context) 39ImmutableHashSet<TypeDeclarationSyntax> distinctTypes = types.ToImmutableHashSet();
Parsing\Parser.cs (6)
35public IReadOnlyList<LoggingType> GetLogTypes(IEnumerable<TypeDeclarationSyntax> types) 56foreach (var typeDec in group) 329var parentLoggerClass = typeDec.Parent as TypeDeclarationSyntax; 348parentLoggerClass = parentLoggerClass.Parent as TypeDeclarationSyntax; 620private (string? member, ISymbol? secondMember, bool isNullable) FindLoggerMember(SemanticModel sm, TypeDeclarationSyntax classDec, ITypeSymbol loggerSymbol)
src\Generators\Shared\TypeDeclarationSyntaxReceiver.cs (2)
25public ICollection<TypeDeclarationSyntax> TypeDeclarations { get; } = new List<TypeDeclarationSyntax>();
Microsoft.Gen.Metrics (11)
MetricsGenerator.cs (2)
28GeneratorUtilities.Initialize(context, _attributeNames, m => m.Parent as TypeDeclarationSyntax, HandleAnnotatedTypes); 35var metricClasses = p.GetMetricClasses(nodes.OfType<TypeDeclarationSyntax>());
Parser.cs (7)
57public IReadOnlyList<MetricType> GetMetricClasses(IEnumerable<TypeDeclarationSyntax> types) 71foreach (var typeDeclaration in typeDeclarationGroup) 146var parentMetricClass = typeDeclaration.Parent as TypeDeclarationSyntax; 169parentMetricClass = parentMetricClass.Parent as TypeDeclarationSyntax; 190private static void UpdateMetricKeywordIfRequired(TypeDeclarationSyntax? typeDeclaration, MetricType metricType) 392TypeDeclarationSyntax typeDeclaration,
src\Generators\Shared\TypeDeclarationSyntaxReceiver.cs (2)
25public ICollection<TypeDeclarationSyntax> TypeDeclarations { get; } = new List<TypeDeclarationSyntax>();
Microsoft.Gen.MetricsReports (7)
src\Generators\Microsoft.Gen.Metrics\Parser.cs (7)
57public IReadOnlyList<MetricType> GetMetricClasses(IEnumerable<TypeDeclarationSyntax> types) 71foreach (var typeDeclaration in typeDeclarationGroup) 146var parentMetricClass = typeDeclaration.Parent as TypeDeclarationSyntax; 169parentMetricClass = parentMetricClass.Parent as TypeDeclarationSyntax; 190private static void UpdateMetricKeywordIfRequired(TypeDeclarationSyntax? typeDeclaration, MetricType metricType) 392TypeDeclarationSyntax typeDeclaration,
Microsoft.Interop.ComInterfaceGenerator (1)
VtableIndexStubGenerator.cs (1)
404for (SyntaxNode? parentNode = methodSyntax.Parent; parentNode is TypeDeclarationSyntax typeDecl; parentNode = parentNode.Parent)
Microsoft.Interop.JavaScript.JSImportGenerator (2)
JSExportGenerator.cs (1)
348for (SyntaxNode? parentNode = methodSyntax.Parent; parentNode is TypeDeclarationSyntax typeDecl; parentNode = parentNode.Parent)
JSImportGenerator.cs (1)
227for (SyntaxNode? parentNode = methodSyntax.Parent; parentNode is TypeDeclarationSyntax typeDecl; parentNode = parentNode.Parent)
Microsoft.Interop.LibraryImportGenerator (1)
LibraryImportGenerator.cs (1)
554if (methodSyntax.Parent is TypeDeclarationSyntax typeDecl && !typeDecl.IsInPartialContext(out var nonPartialIdentifier))
Microsoft.Interop.LibraryImportGenerator.Downlevel (1)
DownlevelLibraryImportGenerator.cs (1)
424if (methodSyntax.Parent is TypeDeclarationSyntax typeDecl && !typeDecl.IsInPartialContext(out var nonPartialIdentifier))
Microsoft.Interop.SourceGeneration (5)
ContainingSyntaxContext.cs (3)
53for (SyntaxNode? parent = memberDeclaration.Parent; parent is TypeDeclarationSyntax typeDeclaration; parent = parent.Parent) 107TypeDeclarationSyntax type = TypeDeclaration(containingType.TypeKind, containingType.Identifier) 133TypeDeclarationSyntax type = TypeDeclaration(containingType.TypeKind, containingType.Identifier)
SyntaxExtensions.cs (2)
120public static bool IsInPartialContext(this TypeDeclarationSyntax syntax, [NotNullWhen(false)] out SyntaxToken? nonPartialIdentifier) 122for (SyntaxNode? parentNode = syntax; parentNode is TypeDeclarationSyntax typeDecl; parentNode = parentNode.Parent)
Microsoft.VisualStudio.LanguageServices.CSharp (20)
CodeModel\CSharpCodeModelService.cs (17)
405else if (container is TypeDeclarationSyntax typeDecl) 928var typeNode = (TypeDeclarationSyntax)node; 2423var containingType = member.FirstAncestorOrSelf<TypeDeclarationSyntax>(); 3228else if (container is TypeDeclarationSyntax typeDeclaration) 3269else if (container is TypeDeclarationSyntax typeDeclaration) 3689private static TypeDeclarationSyntax InsertIntoBaseList(TypeDeclarationSyntax typeDeclaration, ITypeSymbol typeSymbol, SemanticModel semanticModel, int insertionIndex) 3728var typeDeclaration = (TypeDeclarationSyntax)node; 3761var typeDeclaration = (TypeDeclarationSyntax)node; 3827var typeDeclaration = (TypeDeclarationSyntax)node; 3856var typeDeclaration = (TypeDeclarationSyntax)node;
CodeModel\CSharpCodeModelService.NodeNameGenerator.cs (2)
176var typeDeclaration = (TypeDeclarationSyntax)node;
LanguageService\CSharpHelpContextService.cs (1)
390else if (token.Parent.GetAncestorOrThis<TypeDeclarationSyntax>() != null)
System.Text.Json.SourceGeneration (3)
Helpers\RoslynExtensions.cs (1)
258public static string GetTypeKindKeyword(this TypeDeclarationSyntax typeDeclaration)
JsonSourceGenerator.Parser.cs (2)
173for (TypeDeclarationSyntax? currentType = contextClassSyntax; currentType != null; currentType = currentType.Parent as TypeDeclarationSyntax)
System.Text.RegularExpressions.Generator (11)
RegexGenerator.Parser.cs (5)
50TypeDeclarationSyntax? typeDec = memberSyntax.Parent as TypeDeclarationSyntax; 228var parent = typeDec.Parent as TypeDeclarationSyntax; 238parent = parent.Parent as TypeDeclarationSyntax;
UpgradeToGeneratedRegexCodeFixer.cs (6)
102SyntaxNode? typeDeclarationOrCompilationUnit = nodeToFix.Ancestors().OfType<TypeDeclarationSyntax>().FirstOrDefault(); 109INamedTypeSymbol? typeSymbol = typeDeclarationOrCompilationUnit is TypeDeclarationSyntax typeDeclaration ? 127nodeToFix.Ancestors().OfType<TypeDeclarationSyntax>(), 147typeDeclarationOrCompilationUnit = typeDeclarationOrCompilationUnit is TypeDeclarationSyntax ? 148nodeToFix.Ancestors().OfType<TypeDeclarationSyntax>().FirstOrDefault() : 235newTypeDeclarationOrCompilationUnit = newTypeDeclarationOrCompilationUnit is TypeDeclarationSyntax newTypeDeclaration ?