410 references to AccessorDeclarationSyntax
Microsoft.CodeAnalysis.CSharp (69)
Binder\Binder.CapturedParametersFinder.cs (1)
128case AccessorDeclarationSyntax s:
Binder\Binder_Statements.cs (2)
3449AccessorDeclarationSyntax => MessageID.IDS_FeatureExpressionBodiedAccessor, 3533case AccessorDeclarationSyntax accessor:
Binder\BinderFactory.BinderFactoryVisitor.cs (1)
256public override Binder VisitAccessorDeclaration(AccessorDeclarationSyntax parent)
Binder\LocalBinderFactory.cs (1)
194public override void VisitAccessorDeclaration(AccessorDeclarationSyntax node)
Compilation\AttributeSemanticModel.cs (1)
164internal override bool TryGetSpeculativeSemanticModelForMethodBodyCore(SyntaxTreeSemanticModel parentModel, int position, AccessorDeclarationSyntax accessor, out PublicSemanticModel? speculativeModel)
Compilation\CSharpSemanticModel.cs (4)
2529public bool TryGetSpeculativeSemanticModelForMethodBody(int position, AccessorDeclarationSyntax accessor, out SemanticModel speculativeModel) 2537internal abstract bool TryGetSpeculativeSemanticModelForMethodBodyCore(SyntaxTreeSemanticModel parentModel, int position, AccessorDeclarationSyntax accessor, out PublicSemanticModel speculativeModel); 3136public abstract IMethodSymbol GetDeclaredSymbol(AccessorDeclarationSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken)); 5057case AccessorDeclarationSyntax accessor:
Compilation\InitializerSemanticModel.cs (1)
247internal override bool TryGetSpeculativeSemanticModelForMethodBodyCore(SyntaxTreeSemanticModel parentModel, int position, AccessorDeclarationSyntax accessor, out PublicSemanticModel speculativeModel)
Compilation\MemberSemanticModel.cs (1)
658public override IMethodSymbol GetDeclaredSymbol(AccessorDeclarationSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
Compilation\MemberSemanticModel.SpeculativeMemberSemanticModel.cs (1)
95internal override bool TryGetSpeculativeSemanticModelForMethodBodyCore(SyntaxTreeSemanticModel parentModel, int position, AccessorDeclarationSyntax accessor, out PublicSemanticModel speculativeModel)
Compilation\MethodBodySemanticModel.cs (1)
199internal override bool TryGetSpeculativeSemanticModelForMethodBodyCore(SyntaxTreeSemanticModel parentModel, int position, AccessorDeclarationSyntax accessor, out PublicSemanticModel speculativeModel)
Compilation\PublicSemanticModel.cs (1)
43AccessorDeclarationSyntax or
Compilation\SpeculativeSemanticModelWithMemberModel.cs (2)
316public override IMethodSymbol GetDeclaredSymbol(AccessorDeclarationSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken)) 546internal override bool TryGetSpeculativeSemanticModelForMethodBodyCore(SyntaxTreeSemanticModel parentModel, int position, AccessorDeclarationSyntax accessor, out PublicSemanticModel? speculativeModel)
Compilation\SyntaxTreeSemanticModel.cs (9)
177case AccessorDeclarationSyntax accessor: 654internal sealed override bool TryGetSpeculativeSemanticModelForMethodBodyCore(SyntaxTreeSemanticModel parentModel, int position, AccessorDeclarationSyntax accessor, out PublicSemanticModel speculativeModel) 790outsideMemberDecl = !LookupPosition.IsInBody(position, (AccessorDeclarationSyntax)memberDecl); 892var accessorDecl = (AccessorDeclarationSyntax)memberDecl; 1105var accessorDecl = (AccessorDeclarationSyntax)node; 1297return (node is MemberDeclarationSyntax) || (node is AccessorDeclarationSyntax) || 1573public override IMethodSymbol GetDeclaredSymbol(AccessorDeclarationSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
Compiler\MethodCompiler.cs (2)
2024case AccessorDeclarationSyntax: 2049case AccessorDeclarationSyntax s:
CSharpDeclarationComputer.cs (5)
174foreach (var decl in t.AccessorList.Accessors) 214foreach (var decl in t.AccessorList.Accessors) 236foreach (var decl in t.AccessorList.Accessors) 261var t = (AccessorDeclarationSyntax)node;
CSharpExtensions.cs (2)
1108public static bool TryGetSpeculativeSemanticModelForMethodBody([NotNullWhen(true)] this SemanticModel? semanticModel, int position, AccessorDeclarationSyntax accessor, [NotNullWhen(true)] out SemanticModel? speculativeModel) 1467public static IMethodSymbol? GetDeclaredSymbol(this SemanticModel? semanticModel, AccessorDeclarationSyntax declarationSyntax, CancellationToken cancellationToken = default(CancellationToken))
Lowering\Instrumentation\CodeCoverageInstrumenter.cs (2)
608AccessorDeclarationSyntax accessorSyntax = (AccessorDeclarationSyntax)syntax;
Parser\LanguageParser.cs (1)
4815return ((CSharp.Syntax.AccessorDeclarationSyntax)decl).Modifiers;
Symbols\Source\ModifierUtils.cs (1)
30if (readonlyToken.Parent is MethodDeclarationSyntax or AccessorDeclarationSyntax or BasePropertyDeclarationSyntax or EventDeclarationSyntax)
Symbols\Source\SourceCustomEventAccessorSymbol.cs (4)
25AccessorDeclarationSyntax syntax, 61internal AccessorDeclarationSyntax GetSyntax() 64return (AccessorDeclarationSyntax)syntaxReferenceOpt.GetSyntax(); 99var syntax = GetSyntax();
Symbols\Source\SourceCustomEventSymbol.cs (4)
76AccessorDeclarationSyntax? addSyntax = null; 77AccessorDeclarationSyntax? removeSyntax = null; 81foreach (AccessorDeclarationSyntax accessor in syntax.AccessorList.Accessors) 233private SourceCustomEventAccessorSymbol? CreateAccessorSymbol(CSharpCompilation compilation, AccessorDeclarationSyntax? syntaxOpt,
Symbols\Source\SourceMemberMethodSymbol.cs (1)
611case AccessorDeclarationSyntax accessor:
Symbols\Source\SourceMethodSymbolWithAttributes.cs (1)
47case AccessorDeclarationSyntax accessor:
Symbols\Source\SourcePropertyAccessorSymbol.cs (2)
33AccessorDeclarationSyntax syntax, 641return OneOrMany.Create(((AccessorDeclarationSyntax)syntax).AttributeLists);
Symbols\Source\SourcePropertySymbol.cs (6)
183foreach (var accessor in syntax.AccessorList!.Accessors) 238private static AccessorDeclarationSyntax GetGetAccessorDeclaration(BasePropertyDeclarationSyntax syntax) 240foreach (var accessor in syntax.AccessorList!.Accessors) 252private static AccessorDeclarationSyntax GetSetAccessorDeclaration(BasePropertyDeclarationSyntax syntax) 254foreach (var accessor in syntax.AccessorList!.Accessors) 401AccessorDeclarationSyntax syntax,
Syntax\CSharpSyntaxNode.cs (1)
543if (parent is MemberDeclarationSyntax || parent is AccessorDeclarationSyntax)
Syntax\LookupPosition.cs (2)
65internal static bool IsInBody(int position, AccessorDeclarationSyntax method) 140internal static bool IsInMethodDeclaration(int position, AccessorDeclarationSyntax accessorDecl)
Syntax\PropertyDeclarationSyntax.cs (2)
34public AccessorDeclarationSyntax Update(SyntaxList<AttributeListSyntax> attributeLists, SyntaxTokenList modifiers, SyntaxToken keyword, BlockSyntax? body, SyntaxToken semicolonToken) 44public static AccessorDeclarationSyntax AccessorDeclaration(SyntaxKind kind, BlockSyntax? body)
Syntax\SyntaxExtensions.cs (1)
44arrowExpr = ((AccessorDeclarationSyntax)node).ExpressionBody;
Syntax\SyntaxFactory.cs (4)
2675public static AccessorDeclarationSyntax AccessorDeclaration(SyntaxKind kind, SyntaxList<AttributeListSyntax> attributeLists, SyntaxTokenList modifiers, BlockSyntax body) 2677public static AccessorDeclarationSyntax AccessorDeclaration(SyntaxKind kind, SyntaxList<AttributeListSyntax> attributeLists, SyntaxTokenList modifiers, SyntaxToken keyword, BlockSyntax body, SyntaxToken semicolonToken) 2679public static AccessorDeclarationSyntax AccessorDeclaration(SyntaxKind kind, SyntaxList<AttributeListSyntax> attributeLists, SyntaxTokenList modifiers, ArrowExpressionClauseSyntax expressionBody) 2681public static AccessorDeclarationSyntax AccessorDeclaration(SyntaxKind kind, SyntaxList<AttributeListSyntax> attributeLists, SyntaxTokenList modifiers, SyntaxToken keyword, ArrowExpressionClauseSyntax expressionBody, SyntaxToken semicolonToken)
Syntax\SyntaxNormalizer.cs (2)
433else if (currentToken.Parent is AccessorDeclarationSyntax && 1364node is AccessorDeclarationSyntax ||
Microsoft.CodeAnalysis.CSharp.CodeStyle (40)
AnchorIndentationFormattingRule.cs (1)
66case AccessorDeclarationSyntax accessorDeclNode:
ArrowExpressionClausePlacementDiagnosticAnalyzer.cs (1)
63if (arrowExpressionClause.Parent is AccessorDeclarationSyntax)
CSharpAccessibilityFacts.cs (1)
315AccessorDeclarationSyntax accessor => accessor.Modifiers,
CSharpMakeStructMemberReadOnlyAnalyzer.cs (1)
101AccessorDeclarationSyntax accessorDeclaration => accessorDeclaration.Keyword,
CSharpOrderModifiersDiagnosticAnalyzer.cs (1)
52foreach (var accessor in accessorList.Accessors)
CSharpSyntaxFacts.cs (1)
263AccessorDeclarationSyntax;
CSharpUseAutoPropertyAnalyzer.cs (5)
176AccessorDeclarationSyntax accessorDeclaration => 184private static T? GetSingleStatementFromAccessor<T>(AccessorDeclarationSyntax? accessorDeclaration) where T : StatementSyntax 196var setAccessor = setMethod.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken) as AccessorDeclarationSyntax; 209private static ExpressionSyntax? GetExpressionFromSetter(AccessorDeclarationSyntax? setAccessor)
CSharpUseImplicitObjectCreationDiagnosticAnalyzer.cs (1)
95AccessorDeclarationSyntax(SyntaxKind.GetAccessorDeclaration) { Parent: AccessorListSyntax { Parent: BasePropertyDeclarationSyntax baseProperty } } accessor => baseProperty.Type,
EmbeddedStatementPlacementDiagnosticAnalyzer.cs (1)
110AccessorDeclarationSyntax or
FormattingRangeHelper.cs (1)
134if (parent is AccessorDeclarationSyntax)
NewLineUserSettingFormattingRule.cs (2)
160if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && currentTokenParentParent is AccessorDeclarationSyntax) 366if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && currentTokenParentParent is AccessorDeclarationSyntax)
SuppressFormattingRule.cs (1)
177if (node is AccessorDeclarationSyntax accessorDeclNode)
SyntaxNodeExtensions.cs (3)
183AccessorDeclarationSyntax accessor => accessor.AttributeLists, 867AccessorDeclarationSyntax accessor => accessor.Modifiers, 881case AccessorDeclarationSyntax accessor: return accessor.WithModifiers(modifiers);
TokenBasedFormattingRule.cs (2)
205AccessorDeclarationSyntax) 377previousToken.IsLastTokenOfNode<AccessorDeclarationSyntax>())
UseExpressionBodyForAccessorsHelper.cs (11)
15UseExpressionBodyHelper<AccessorDeclarationSyntax> 32protected override BlockSyntax? GetBody(AccessorDeclarationSyntax declaration) 35protected override ArrowExpressionClauseSyntax? GetExpressionBody(AccessorDeclarationSyntax declaration) 38protected override SyntaxToken GetSemicolonToken(AccessorDeclarationSyntax declaration) 41protected override AccessorDeclarationSyntax WithSemicolonToken(AccessorDeclarationSyntax declaration, SyntaxToken token) 44protected override AccessorDeclarationSyntax WithExpressionBody(AccessorDeclarationSyntax declaration, ArrowExpressionClauseSyntax? expressionBody) 47protected override AccessorDeclarationSyntax WithBody(AccessorDeclarationSyntax declaration, BlockSyntax? body) 50protected override bool CreateReturnStatementForExpression(SemanticModel semanticModel, AccessorDeclarationSyntax declaration)
UseExpressionBodyForIndexersHelper.cs (1)
85var getAccessor = GetSingleGetAccessor(declaration.AccessorList);
UseExpressionBodyForPropertiesHelper.cs (1)
85var getAccessor = GetSingleGetAccessor(declaration.AccessorList);
UseExpressionBodyHelper`1.cs (4)
50protected static AccessorDeclarationSyntax? GetSingleGetAccessor(AccessorListSyntax? accessorList) 156var getAccessor = GetSingleGetAccessor(declaration.AccessorList); 198if (declaration is AccessorDeclarationSyntax or ConstructorDeclarationSyntax) 296var accessor = SyntaxFactory.AccessorDeclaration(SyntaxKind.GetAccessorDeclaration);
WrappingFormattingRule.cs (1)
169if (node is AccessorDeclarationSyntax accessorDeclaration && accessorDeclaration.Body != null)
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (21)
CSharpCodeGenerationService.cs (4)
335AccessorDeclarationSyntax accessor => Cast<TDeclarationNode>(accessor.AddAttributeLists(attributeSyntaxList)), 406case AccessorDeclarationSyntax accessor: 410var newAccessor = accessor.WithAttributeLists(newAttributeLists); 500else if (destinationMember is AccessorDeclarationSyntax accessorDeclaration)
CSharpMakeStructMemberReadOnlyCodeFixProvider.cs (3)
59else if (declaration is AccessorDeclarationSyntax { Parent: AccessorListSyntax { Parent: BasePropertyDeclarationSyntax property } accessorList } accessor) 81var currentAccessor = currentAccessorList.Accessors.First(a => a.Kind() == accessor.Kind()); 82var otherAccessor = currentAccessorList.Accessors.Single(a => a != currentAccessor);
CSharpMakeTypeAbstractCodeFixProvider.cs (1)
42case AccessorDeclarationSyntax accessor:
EventGenerator.cs (3)
141var accessors = new List<AccessorDeclarationSyntax?> 150private static AccessorDeclarationSyntax? GenerateAccessorDeclaration( 163private static AccessorDeclarationSyntax GenerateAccessorDeclaration(
J\s\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTokenExtensions.cs\SyntaxTokenExtensions.cs (3)
587targetToken.Parent.Parent is AccessorDeclarationSyntax) 594targetToken.Parent is AccessorDeclarationSyntax) 602targetToken.Parent.Parent is AccessorDeclarationSyntax)
PropertyGenerator.cs (7)
161var accessor = accessorList.Accessors[0]; 214private static AccessorDeclarationSyntax UseExpressionBodyIfDesired( 215CSharpCodeGenerationContextInfo info, AccessorDeclarationSyntax declaration) 233SyntaxKind declaratoinKind, AccessorDeclarationSyntax accessor, LanguageVersion languageVersion, ExpressionBodyPreference preference, 272private static AccessorDeclarationSyntax? GenerateAccessorDeclaration( 285private static AccessorDeclarationSyntax GenerateAccessorDeclaration( 292var declaration = SyntaxFactory.AccessorDeclaration(kind)
Microsoft.CodeAnalysis.CSharp.EditorFeatures (12)
AutomaticCompletion\AutomaticLineEnderCommandHandler.cs (2)
334or AccessorDeclarationSyntax 410or AccessorDeclarationSyntax)
AutomaticCompletion\AutomaticLineEnderCommandHandler_Helpers.cs (10)
468AccessorDeclarationSyntax accessorDeclarationNode => ShouldAddBraceForAccessorDeclaration(accessorDeclarationNode), 547private static bool ShouldAddBraceForAccessorDeclaration(AccessorDeclarationSyntax accessorDeclarationNode) 776AccessorDeclarationSyntax accessorDeclarationNode => ShouldRemoveBraceForAccessorDeclaration(accessorDeclarationNode, caretPosition), 795private static bool ShouldRemoveBraceForAccessorDeclaration(AccessorDeclarationSyntax accessorDeclarationNode, int caretPosition) 876AccessorDeclarationSyntax accessorDeclarationNode => AddBlockToAccessorDeclaration(accessorDeclarationNode, formattingOptions), 921private static AccessorDeclarationSyntax AddBlockToAccessorDeclaration( 922AccessorDeclarationSyntax accessorDeclarationNode, 972AccessorDeclarationSyntax accessorDeclarationNode => RemoveBodyForAccessorDeclarationNode(accessorDeclarationNode), 1029private static AccessorDeclarationSyntax RemoveBodyForAccessorDeclarationNode(AccessorDeclarationSyntax accessorDeclarationNode)
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (4)
Structure\AccessorDeclarationStructureTests.cs (1)
17public class AccessorDeclarationStructureTests : AbstractCSharpSyntaxNodeStructureTests<AccessorDeclarationSyntax>
Structure\MetadataAsSource\AccessorDeclarationStructureTests.cs (1)
17public class AccessorDeclarationStructureTests : AbstractCSharpSyntaxNodeStructureTests<AccessorDeclarationSyntax>
SymbolKey\SymbolKeyTestBase.cs (2)
135else if (node is AccessorDeclarationSyntax accessor) 303else if (node is AccessorDeclarationSyntax accessor)
Microsoft.CodeAnalysis.CSharp.Features (117)
ArrowExpressionClausePlacementDiagnosticAnalyzer.cs (1)
63if (arrowExpressionClause.Parent is AccessorDeclarationSyntax)
BraceCompletion\CurlyBraceCompletionService.cs (1)
159if (currentTokenParentParent is AccessorDeclarationSyntax)
Completion\CompletionProviders\OverrideCompletionProvider.cs (1)
229var firstAccessor = propertyDeclaration.AccessorList.Accessors[0];
ConvertAutoPropertyToFullProperty\CSharpConvertAutoPropertyToFullPropertyCodeRefactoringProvider.cs (7)
72private static (AccessorDeclarationSyntax getAccessor, AccessorDeclarationSyntax setAccessor) 82var accessorDeclarationSyntax = (AccessorDeclarationSyntax)newAccessor; 110.WithTrailingTrivia(((AccessorDeclarationSyntax)accessor).SemicolonToken.TrailingTrivia)); 112return ((AccessorDeclarationSyntax)accessor).WithBody(blockSyntax); 130var getAccessor = propertyDeclaration.AccessorList.Accessors[0];
CSharpDeclarationComputer.cs (5)
174foreach (var decl in t.AccessorList.Accessors) 214foreach (var decl in t.AccessorList.Accessors) 236foreach (var decl in t.AccessorList.Accessors) 261var t = (AccessorDeclarationSyntax)node;
CSharpMakeStructMemberReadOnlyAnalyzer.cs (1)
101AccessorDeclarationSyntax accessorDeclaration => accessorDeclaration.Keyword,
CSharpMakeStructMemberReadOnlyCodeFixProvider.cs (3)
59else if (declaration is AccessorDeclarationSyntax { Parent: AccessorListSyntax { Parent: BasePropertyDeclarationSyntax property } accessorList } accessor) 81var currentAccessor = currentAccessorList.Accessors.First(a => a.Kind() == accessor.Kind()); 82var otherAccessor = currentAccessorList.Accessors.Single(a => a != currentAccessor);
CSharpMakeTypeAbstractCodeFixProvider.cs (1)
42case AccessorDeclarationSyntax accessor:
CSharpOrderModifiersDiagnosticAnalyzer.cs (1)
52foreach (var accessor in accessorList.Accessors)
CSharpUseAutoPropertyAnalyzer.cs (5)
176AccessorDeclarationSyntax accessorDeclaration => 184private static T? GetSingleStatementFromAccessor<T>(AccessorDeclarationSyntax? accessorDeclaration) where T : StatementSyntax 196var setAccessor = setMethod.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken) as AccessorDeclarationSyntax; 209private static ExpressionSyntax? GetExpressionFromSetter(AccessorDeclarationSyntax? setAccessor)
CSharpUseImplicitObjectCreationDiagnosticAnalyzer.cs (1)
95AccessorDeclarationSyntax(SyntaxKind.GetAccessorDeclaration) { Parent: AccessorListSyntax { Parent: BasePropertyDeclarationSyntax baseProperty } } accessor => baseProperty.Type,
Debugging\CSharpProximityExpressionsService.Worker.cs (2)
62if (_parentStatement.GetAncestorOrThis<AccessorDeclarationSyntax>() is (kind: 140block.Parent is AccessorDeclarationSyntax &&
Debugging\LocationInfoGetter.cs (2)
62var accessor = memberDeclaration.GetAncestorOrThis<AccessorDeclarationSyntax>();
EditAndContinue\BreakpointSpans.cs (3)
214var accessor = (AccessorDeclarationSyntax)node; 776private static TextSpan? CreateSpanForAccessors(SyntaxList<AccessorDeclarationSyntax> accessors, int position)
EditAndContinue\CSharpEditAndContinueAnalyzer.cs (3)
1221if (declaration is AccessorDeclarationSyntax { Parent: AccessorListSyntax { Parent: PropertyDeclarationSyntax property } list } && 1686var accessorDeclaration = (AccessorDeclarationSyntax)node;
EditAndContinue\SyntaxComparer.cs (1)
761case AccessorDeclarationSyntax accessorDeclarationSyntax: return accessorDeclarationSyntax.Body ?? (SyntaxNode?)accessorDeclarationSyntax.ExpressionBody?.Expression;
EditAndContinue\SyntaxUtilities.cs (3)
46var accessorDeclaration = (AccessorDeclarationSyntax)node; 217var firstGetter = accessorList?.Accessors.Where(a => a.IsKind(SyntaxKind.GetAccessorDeclaration)).FirstOrDefault();
EmbeddedStatementPlacementDiagnosticAnalyzer.cs (1)
110AccessorDeclarationSyntax or
ExtractMethod\CSharpMethodExtractor.cs (2)
105var accessorNode = basePosition.GetAncestor<AccessorDeclarationSyntax>();
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.CallSiteContainerRewriter.cs (2)
324private SyntaxList<AccessorDeclarationSyntax> ReplaceAccessors(SyntaxList<AccessorDeclarationSyntax> accessors)
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.cs (1)
184=> node is AccessorDeclarationSyntax accessor && accessor.ExpressionBody != null;
ExtractMethod\CSharpSelectionResult.StatementResult.cs (4)
40AccessorDeclarationSyntax _ => false, 58return n is AccessorDeclarationSyntax or 61AccessorDeclarationSyntax or 78case AccessorDeclarationSyntax access:
ExtractMethod\Extensions.cs (2)
59case AccessorDeclarationSyntax a: return a.Body; 81AccessorDeclarationSyntax or
GenerateConstructorFromMembers\CSharpGenerateConstructorFromMembersCodeRefactoringProvider.cs (1)
69var getAccessor = propertyDeclaration.AccessorList?.Accessors.FirstOrDefault(a => a.Kind() == SyntaxKind.GetAccessorDeclaration);
InitializeParameter\CSharpInitializeMemberFromParameterCodeRefactoringProvider.cs (4)
61if (node is AccessorDeclarationSyntax accessorDeclaration) 99private static AccessorDeclarationSyntax RemoveThrowNotImplemented(AccessorDeclarationSyntax accessorDeclaration) 101var result = accessorDeclaration
IntroduceVariable\CSharpIntroduceVariableService_IntroduceLocal.cs (1)
260case AccessorDeclarationSyntax accessor:
InvertIf\CSharpInvertIfCodeRefactoringProvider.cs (2)
73case AccessorDeclarationSyntax: 99LocalFunctionStatementSyntax or AccessorDeclarationSyntax or MemberDeclarationSyntax
ReplaceMethodWithProperty\CSharpReplaceMethodWithPropertyService.cs (14)
98var accessor = 119var getAccessor = CreateGetAccessor(getAndSetMethods, options, languageVersion); 120var setAccessor = CreateSetAccessor(semanticModel, generator, getAndSetMethods, options, languageVersion); 162private static AccessorDeclarationSyntax CreateGetAccessor( 165var accessorDeclaration = CreateGetAccessorWorker(getAndSetMethods); 171private static AccessorDeclarationSyntax UseExpressionOrBlockBodyIfDesired( 173AccessorDeclarationSyntax accessorDeclaration) 205private static AccessorDeclarationSyntax CreateGetAccessorWorker(GetAndSetMethods getAndSetMethods) 209var accessor = SyntaxFactory.AccessorDeclaration(SyntaxKind.GetAccessorDeclaration); 230private static AccessorDeclarationSyntax CreateSetAccessor( 234var accessorDeclaration = CreateSetAccessorWorker(semanticModel, generator, getAndSetMethods); 238private static AccessorDeclarationSyntax CreateSetAccessorWorker( 248var accessor = SyntaxFactory.AccessorDeclaration(SyntaxKind.SetAccessorDeclaration); 252accessor = (AccessorDeclarationSyntax)generator.WithAccessibility(accessor, setMethod.DeclaredAccessibility);
ReplacePropertyWithMethods\CSharpReplacePropertyWithMethodsService.cs (4)
125var setAccessorDeclaration = (AccessorDeclarationSyntax)setMethod.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken); 198var getAccessorDeclaration = (AccessorDeclarationSyntax)getMethod.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken);
Snippets\AbstractCSharpAutoPropertySnippetProvider.cs (6)
27protected virtual AccessorDeclarationSyntax? GenerateGetAccessorDeclaration(CSharpSyntaxContext syntaxContext, SyntaxGenerator generator) 28=> (AccessorDeclarationSyntax)generator.GetAccessorDeclaration(); 30protected virtual AccessorDeclarationSyntax? GenerateSetAccessorDeclaration(CSharpSyntaxContext syntaxContext, SyntaxGenerator generator) 31=> (AccessorDeclarationSyntax)generator.SetAccessorDeclaration(); 49var accessors = new AccessorDeclarationSyntax?[] 69accessorList: SyntaxFactory.AccessorList(new SyntaxList<AccessorDeclarationSyntax>(accessors.Where(a => a is not null)!)));
Snippets\CSharpPropgSnippetProvider.cs (2)
29protected override AccessorDeclarationSyntax? GenerateSetAccessorDeclaration(CSharpSyntaxContext syntaxContext, SyntaxGenerator generator) 47return (AccessorDeclarationSyntax)generator.SetAccessorDeclaration(Accessibility.Private);
Snippets\CSharpPropiSnippetProvider.cs (1)
29protected override AccessorDeclarationSyntax? GenerateSetAccessorDeclaration(CSharpSyntaxContext syntaxContext, SyntaxGenerator generator)
Snippets\CSharpPropSnippetProvider.cs (1)
29protected override AccessorDeclarationSyntax? GenerateSetAccessorDeclaration(CSharpSyntaxContext syntaxContext, SyntaxGenerator generator)
Structure\CSharpBlockStructureProvider.cs (1)
20builder.Add<AccessorDeclarationSyntax, AccessorDeclarationStructureProvider>();
Structure\Providers\AccessorDeclarationStructureProvider.cs (3)
12internal class AccessorDeclarationStructureProvider : AbstractSyntaxNodeStructureProvider<AccessorDeclarationSyntax> 16AccessorDeclarationSyntax accessorDeclaration, 38&& (!nextSibling.IsNode || nextSibling.AsNode() is AccessorDeclarationSyntax);
UseAutoProperty\CSharpUseAutoPropertyCodeFixProvider.cs (6)
58var accessor = SyntaxFactory.AccessorDeclaration(SyntaxKind.SetAccessorDeclaration) 64accessor = (AccessorDeclarationSyntax)generator.WithAccessibility(accessor, fieldSymbol.DeclaredAccessibility); 167var getter = SyntaxFactory.AccessorDeclaration(SyntaxKind.GetAccessorDeclaration) 175private static IEnumerable<AccessorDeclarationSyntax> GetAccessors(SyntaxList<AccessorDeclarationSyntax> accessors) 177foreach (var accessor in accessors)
UseExpressionBody\UseExpressionBodyCodeRefactoringProvider.cs (1)
181var parent = declaration is AccessorDeclarationSyntax
UseExpressionBodyForAccessorsHelper.cs (11)
15UseExpressionBodyHelper<AccessorDeclarationSyntax> 32protected override BlockSyntax? GetBody(AccessorDeclarationSyntax declaration) 35protected override ArrowExpressionClauseSyntax? GetExpressionBody(AccessorDeclarationSyntax declaration) 38protected override SyntaxToken GetSemicolonToken(AccessorDeclarationSyntax declaration) 41protected override AccessorDeclarationSyntax WithSemicolonToken(AccessorDeclarationSyntax declaration, SyntaxToken token) 44protected override AccessorDeclarationSyntax WithExpressionBody(AccessorDeclarationSyntax declaration, ArrowExpressionClauseSyntax? expressionBody) 47protected override AccessorDeclarationSyntax WithBody(AccessorDeclarationSyntax declaration, BlockSyntax? body) 50protected override bool CreateReturnStatementForExpression(SemanticModel semanticModel, AccessorDeclarationSyntax declaration)
UseExpressionBodyForIndexersHelper.cs (1)
85var getAccessor = GetSingleGetAccessor(declaration.AccessorList);
UseExpressionBodyForPropertiesHelper.cs (1)
85var getAccessor = GetSingleGetAccessor(declaration.AccessorList);
UseExpressionBodyHelper`1.cs (4)
50protected static AccessorDeclarationSyntax? GetSingleGetAccessor(AccessorListSyntax? accessorList) 156var getAccessor = GetSingleGetAccessor(declaration.AccessorList); 198if (declaration is AccessorDeclarationSyntax or ConstructorDeclarationSyntax) 296var accessor = SyntaxFactory.AccessorDeclaration(SyntaxKind.GetAccessorDeclaration);
Microsoft.CodeAnalysis.CSharp.IOperation.UnitTests (10)
IOperation\IOperationTests_IMethodBodyOperation.cs (10)
978var node1 = tree.GetRoot().DescendantNodes().OfType<AccessorDeclarationSyntax>().Single(); 1000var node1 = tree.GetRoot().DescendantNodes().OfType<AccessorDeclarationSyntax>().Single(); 1035var node1 = tree.GetRoot().DescendantNodes().OfType<AccessorDeclarationSyntax>().First(); 1080var node1 = tree.GetRoot().DescendantNodes().OfType<AccessorDeclarationSyntax>().First(); 1124var node1 = tree.GetRoot().DescendantNodes().OfType<AccessorDeclarationSyntax>().Single();
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (11)
Semantics\InitOnlyMemberTests.cs (3)
3135AccessorDeclarationSyntax accessorDecl = root.DescendantNodes().OfType<AccessorDeclarationSyntax>().Single(); 3137var speculatedMethod = accessorDecl.ReplaceNode(accessorDecl.Body, blockStatement);
Semantics\OutVarTests.cs (2)
36116var declarationSyntax = tree.GetRoot().DescendantNodes().OfType<AccessorDeclarationSyntax>().Single();
Semantics\QueryTests.cs (1)
2357var unknownAccessorDecls = tree.GetCompilationUnitRoot().DescendantNodes().OfType<AccessorDeclarationSyntax>();
Semantics\SuppressAccessibilityChecksTests.cs (3)
215AccessorDeclarationSyntax accessorDecl = root.DescendantNodes().OfType<AccessorDeclarationSyntax>().Single(); 217var speculatedMethod = accessorDecl.ReplaceNode(accessorDecl.Body, blockStatement);
SourceGeneration\GeneratorDriverTests_Attributes_FullyQualifiedName.cs (2)
749var input = ctx.ForAttributeWithMetadataName<AccessorDeclarationSyntax>("System.CLSCompliantAttribute"); 758step => Assert.True(step.Outputs.Single().Value is AccessorDeclarationSyntax { RawKind: (int)SyntaxKind.GetAccessorDeclaration }));
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (15)
Compilation\SemanticModelAPITests.cs (8)
2310var accessorSyntax = tree.GetRoot().DescendantNodes().OfType<AccessorDeclarationSyntax>().Single(); 2445var methodDecl = indexerDecl.AccessorList.Accessors[0]; 2448var speculatedMethod = methodDecl.ReplaceNode(methodDecl.Body, blockStatement); 2487var methodDecl = propertyDecl.AccessorList.Accessors[0]; 2490var speculatedMethod = methodDecl.ReplaceNode(methodDecl.Body, blockStatement); 2532var methodDecl = eventDecl.AccessorList.Accessors[0]; 2535var speculatedMethod = methodDecl.ReplaceNode(methodDecl.Body, blockStatement);
Compilation\SemanticModelGetDeclaredSymbolAPITests.cs (7)
309foreach (var accessorDecl in accessorList) 336var getterDecl = indexerDecl.AccessorList.Accessors[0]; 337var setterDecl = indexerDecl.AccessorList.Accessors[1]; 2869var explicitPropertyGetterNode = explicitPropertyAccessors[0]; 2879var explicitPropertySetterNode = explicitPropertyAccessors[1]; 3177var accessorDecl = tree.GetCompilationUnitRoot().DescendantNodes().OfType<AccessorDeclarationSyntax>().Single();
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (13)
Generated\Syntax.Test.xml.Generated.cs (6)
10551=> SyntaxFactory.AccessorList(SyntaxFactory.Token(SyntaxKind.OpenBraceToken), new SyntaxList<AccessorDeclarationSyntax>(), SyntaxFactory.Token(SyntaxKind.CloseBraceToken)); 10553private static AccessorDeclarationSyntax GenerateAccessorDeclaration() 13120var node = GenerateAccessorDeclaration(); 13128var newNode = node.WithAttributeLists(node.AttributeLists).WithModifiers(node.Modifiers).WithKeyword(node.Keyword).WithBody(node.Body).WithExpressionBody(node.ExpressionBody).WithSemicolonToken(node.SemicolonToken); 18663var oldNode = GenerateAccessorDeclaration(); 18679var oldNode = GenerateAccessorDeclaration();
Parsing\ParsingErrorRecoveryTests.cs (6)
5659var acc = pd.AccessorList.Accessors[0]; 5694var acc = pd.AccessorList.Accessors[0]; 5733var acc = pd.AccessorList.Accessors[0]; 5767var getDecl = accessorDecls[0]; 5799var getDecl = accessorDecls[0]; 5804var setDecl = accessorDecls[1];
Syntax\SyntaxTests.cs (1)
153var t = SyntaxFactory.AccessorDeclaration(SyntaxKind.UnknownAccessorDeclaration);
Microsoft.CodeAnalysis.CSharp.Workspaces (69)
AnchorIndentationFormattingRule.cs (1)
66case AccessorDeclarationSyntax accessorDeclNode:
CodeGeneration\CSharpSyntaxGenerator.cs (29)
379var accessors = new List<AccessorDeclarationSyntax>(); 381accessors.AddIfNotNull((AccessorDeclarationSyntax?)getAccessor); 382accessors.AddIfNotNull((AccessorDeclarationSyntax?)setAccessor); 406var accessor = SyntaxFactory.AccessorDeclaration(kind); 433var list = SyntaxFactory.List(accessorDeclarations.Cast<AccessorDeclarationSyntax>()); 447var accessors = new List<AccessorDeclarationSyntax>(); 497private static AccessorDeclarationSyntax AccessorDeclaration(SyntaxKind kind, IEnumerable<SyntaxNode>? statements) 499var ad = SyntaxFactory.AccessorDeclaration( 535var accessors = new List<AccessorDeclarationSyntax>(); 654private static AccessorDeclarationSyntax WithBody(AccessorDeclarationSyntax accessor) 669private static AccessorDeclarationSyntax WithoutBody(AccessorDeclarationSyntax accessor) 1191AccessorDeclarationSyntax accessor => accessor.AttributeLists, 1202AccessorDeclarationSyntax accessor => accessor.WithAttributeLists(attributeLists), 1652AccessorDeclarationSyntax accessor => accessor.WithModifiers(modifiers), 2491return ((AccessorDeclarationSyntax)declaration).Body?.Statements ?? s_EmptyList; 2527return ((AccessorDeclarationSyntax)declaration).WithBody(somebody).WithSemicolonToken(semicolon).WithExpressionBody(null); 2585private static AccessorDeclarationSyntax? AsAccessor(SyntaxNode node, SyntaxKind parentKind) 2595return (AccessorDeclarationSyntax)node; 2604return (AccessorDeclarationSyntax)node; 2613private static AccessorDeclarationSyntax? GetAccessor(SyntaxNode declaration, SyntaxKind kind) 2619private SyntaxNode WithAccessor(SyntaxNode declaration, SyntaxKind kind, AccessorDeclarationSyntax accessor) 2622private SyntaxNode WithAccessor(SyntaxNode declaration, AccessorListSyntax? accessorList, SyntaxKind kind, AccessorDeclarationSyntax? accessor) 2626var acc = accessorList.Accessors.FirstOrDefault(a => a.IsKind(kind)); 2642var accessor = GetAccessor(declaration, SyntaxKind.GetAccessorDeclaration); 2648var accessor = GetAccessor(declaration, SyntaxKind.SetAccessorDeclaration); 2660var accessor = GetAccessor(declaration, kind); 2668return this.WithAccessor(declaration, kind, (AccessorDeclarationSyntax)this.WithStatements(accessor, statements));
CSharpAccessibilityFacts.cs (1)
315AccessorDeclarationSyntax accessor => accessor.Modifiers,
CSharpCodeGenerationService.cs (4)
335AccessorDeclarationSyntax accessor => Cast<TDeclarationNode>(accessor.AddAttributeLists(attributeSyntaxList)), 406case AccessorDeclarationSyntax accessor: 410var newAccessor = accessor.WithAttributeLists(newAttributeLists); 500else if (destinationMember is AccessorDeclarationSyntax accessorDeclaration)
CSharpSyntaxFacts.cs (1)
263AccessorDeclarationSyntax;
EventGenerator.cs (3)
141var accessors = new List<AccessorDeclarationSyntax?> 150private static AccessorDeclarationSyntax? GenerateAccessorDeclaration( 163private static AccessorDeclarationSyntax GenerateAccessorDeclaration(
FormattingRangeHelper.cs (1)
134if (parent is AccessorDeclarationSyntax)
J\s\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Extensions\SyntaxNodeExtensions.cs\SyntaxNodeExtensions.cs (3)
183AccessorDeclarationSyntax accessor => accessor.AttributeLists, 867AccessorDeclarationSyntax accessor => accessor.Modifiers, 881case AccessorDeclarationSyntax accessor: return accessor.WithModifiers(modifiers);
J\s\src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\Extensions\ContextQuery\SyntaxTokenExtensions.cs\SyntaxTokenExtensions.cs (3)
587targetToken.Parent.Parent is AccessorDeclarationSyntax) 594targetToken.Parent is AccessorDeclarationSyntax) 602targetToken.Parent.Parent is AccessorDeclarationSyntax)
NewLineUserSettingFormattingRule.cs (2)
160if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && currentTokenParentParent is AccessorDeclarationSyntax) 366if (currentToken.IsKind(SyntaxKind.OpenBraceToken) && currentTokenParentParent is AccessorDeclarationSyntax)
PropertyGenerator.cs (7)
161var accessor = accessorList.Accessors[0]; 214private static AccessorDeclarationSyntax UseExpressionBodyIfDesired( 215CSharpCodeGenerationContextInfo info, AccessorDeclarationSyntax declaration) 233SyntaxKind declaratoinKind, AccessorDeclarationSyntax accessor, LanguageVersion languageVersion, ExpressionBodyPreference preference, 272private static AccessorDeclarationSyntax? GenerateAccessorDeclaration( 285private static AccessorDeclarationSyntax GenerateAccessorDeclaration( 292var declaration = SyntaxFactory.AccessorDeclaration(kind)
Rename\CSharpRenameRewriterLanguageService.cs (4)
265&& IsNameConflictWithProperty("get", token.Parent as AccessorDeclarationSyntax); 269&& IsNameConflictWithProperty("set", token.Parent as AccessorDeclarationSyntax); 274&& IsNameConflictWithProperty("set", token.Parent as AccessorDeclarationSyntax); 276private bool IsNameConflictWithProperty(string prefix, AccessorDeclarationSyntax? accessor)
SemanticModelReuse\CSharpSemanticModelReuseLanguageService.cs (6)
23AccessorDeclarationSyntax> 33protected override BasePropertyDeclarationSyntax GetBasePropertyDeclaration(AccessorDeclarationSyntax accessor) 40protected override SyntaxList<AccessorDeclarationSyntax> GetAccessors(BasePropertyDeclarationSyntax baseProperty) 51if (current is AccessorDeclarationSyntax accessor) 68if (previousBodyNode is AccessorDeclarationSyntax previousAccessorDeclaration && 69currentBodyNode is AccessorDeclarationSyntax currentAccessorDeclaration &&
SuppressFormattingRule.cs (1)
177if (node is AccessorDeclarationSyntax accessorDeclNode)
TokenBasedFormattingRule.cs (2)
205AccessorDeclarationSyntax) 377previousToken.IsLastTokenOfNode<AccessorDeclarationSyntax>())
WrappingFormattingRule.cs (1)
169if (node is AccessorDeclarationSyntax accessorDeclaration && accessorDeclaration.Body != null)
Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests (8)
CodeGeneration\SyntaxGeneratorTests.cs (7)
1362SyntaxFactory.SingletonList<AccessorDeclarationSyntax>( 1421SyntaxFactory.SingletonList<AccessorDeclarationSyntax>( 1445SyntaxFactory.List<AccessorDeclarationSyntax>( 1446new AccessorDeclarationSyntax[] { 3254VerifySyntax<AccessorDeclarationSyntax>(getAccessor, 3278VerifySyntax<AccessorDeclarationSyntax>(newGetAccessor, 3282VerifySyntax<AccessorDeclarationSyntax>(newNewGetAccessor,
Formatting\FormattingTests.cs (1)
4515new AccessorDeclarationSyntax[]
Microsoft.VisualStudio.LanguageServices.CSharp (21)
CodeModel\CSharpCodeModelService.cs (14)
341else if (parent is AccessorDeclarationSyntax accessor) 1148if (node is AccessorDeclarationSyntax or 1523foreach (var accessor in basePropertyDeclaration.AccessorList.Accessors) 2320var updatedAccessors = new List<AccessorDeclarationSyntax>(); 2321foreach (var accessor in property.AccessorList.Accessors) 2332var updatedAccessor = accessor.WithBody(null).WithSemicolonToken(SyntaxFactory.Token(SyntaxTriviaList.Create(SyntaxFactory.ElasticMarker), SyntaxKind.SemicolonToken, accessor.Body.CloseBraceToken.TrailingTrivia)); 2336var updatedAccessorList = property.AccessorList.WithAccessors(SyntaxFactory.List<AccessorDeclarationSyntax>(updatedAccessors)); 2360var updatedAccessors = new List<AccessorDeclarationSyntax>(); 2361foreach (var accessor in property.AccessorList.Accessors) 2372var updatedAccessor = accessor.WithSemicolonToken(default).WithBody(newBody); 2376var updatedAccessorList = property.AccessorList.WithAccessors(SyntaxFactory.List<AccessorDeclarationSyntax>(updatedAccessors)); 3557AccessorDeclarationSyntax? getAccessor = null; 3558AccessorDeclarationSyntax? setAccessor = null; 3560foreach (var accessor in propertyDeclaration.AccessorList.Accessors)
CodeModel\CSharpCodeModelService.NodeLocator.cs (7)
65return GetStartPoint(text, options, (AccessorDeclarationSyntax)node, part); 116return GetEndPoint(text, (AccessorDeclarationSyntax)node, part); 433private static AccessorDeclarationSyntax FindFirstAccessorNode(BasePropertyDeclarationSyntax node) 470var firstAccessorNode = FindFirstAccessorNode(node); 508private static VirtualTreePoint GetStartPoint(SourceText text, LineFormattingOptions options, AccessorDeclarationSyntax node, EnvDTE.vsCMPart part) 1024var firstAccessorNode = FindFirstAccessorNode(node); 1056private static VirtualTreePoint GetEndPoint(SourceText text, AccessorDeclarationSyntax node, EnvDTE.vsCMPart part)