2 overrides of WithAccessibility
Microsoft.CodeAnalysis.CSharp.Workspaces (1)
CodeGeneration\CSharpSyntaxGenerator.cs (1)
1403
public override SyntaxNode
WithAccessibility
(SyntaxNode declaration, Accessibility accessibility)
Microsoft.CodeAnalysis.VisualBasic.Workspaces (1)
CodeGeneration\VisualBasicSyntaxGenerator.vb (1)
2512
Public Overrides Function
WithAccessibility
(declaration As SyntaxNode, accessibility As Accessibility) As SyntaxNode
60 references to WithAccessibility
Microsoft.CodeAnalysis.CodeStyle.Fixes (2)
src\Analyzers\Core\CodeFixes\AddAccessibilityModifiers\AddAccessibilityModifiersHelpers.cs (2)
36
? generator.
WithAccessibility
(declaration, preferredAccessibility)
37
: generator.
WithAccessibility
(declaration, Accessibility.NotApplicable);
Microsoft.CodeAnalysis.CSharp.Features (3)
ImplementInterface\CSharpImplementImplicitlyCodeRefactoringProvider.cs (1)
53
=> generator.
WithAccessibility
(WithoutExplicitImpl(decl), Accessibility.Public);
ReplaceMethodWithProperty\CSharpReplaceMethodWithPropertyService.cs (1)
256
accessor = (AccessorDeclarationSyntax)generator.
WithAccessibility
(accessor, setMethod.DeclaredAccessibility);
UseAutoProperty\CSharpUseAutoPropertyCodeFixProvider.cs (1)
124
accessor = (AccessorDeclarationSyntax)generator.
WithAccessibility
(accessor, fieldSymbol.DeclaredAccessibility);
Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests (27)
CodeGeneration\SyntaxGeneratorTests.cs (27)
2967
Assert.Equal(Accessibility.Private, Generator.GetAccessibility(Generator.
WithAccessibility
(Generator.ClassDeclaration("c", accessibility: Accessibility.Internal), Accessibility.Private)));
2968
Assert.Equal(Accessibility.Private, Generator.GetAccessibility(Generator.
WithAccessibility
(Generator.StructDeclaration("s", accessibility: Accessibility.Internal), Accessibility.Private)));
2969
Assert.Equal(Accessibility.Private, Generator.GetAccessibility(Generator.
WithAccessibility
(Generator.EnumDeclaration("i", accessibility: Accessibility.Internal), Accessibility.Private)));
2970
Assert.Equal(Accessibility.Private, Generator.GetAccessibility(Generator.
WithAccessibility
(Generator.EnumDeclaration("e", accessibility: Accessibility.Internal), Accessibility.Private)));
2971
Assert.Equal(Accessibility.Private, Generator.GetAccessibility(Generator.
WithAccessibility
(Generator.DelegateDeclaration("d", accessibility: Accessibility.Internal), Accessibility.Private)));
2972
Assert.Equal(Accessibility.Private, Generator.GetAccessibility(Generator.
WithAccessibility
(Generator.MethodDeclaration("m", accessibility: Accessibility.Internal), Accessibility.Private)));
2973
Assert.Equal(Accessibility.Private, Generator.GetAccessibility(Generator.
WithAccessibility
(Generator.ConstructorDeclaration(accessibility: Accessibility.Internal), Accessibility.Private)));
2974
Assert.Equal(Accessibility.NotApplicable, Generator.GetAccessibility(Generator.
WithAccessibility
(Generator.ParameterDeclaration("p"), Accessibility.Private)));
2975
Assert.Equal(Accessibility.Private, Generator.GetAccessibility(Generator.
WithAccessibility
(Generator.PropertyDeclaration("p", Generator.IdentifierName("t"), accessibility: Accessibility.Internal), Accessibility.Private)));
2977
Assert.Equal(Accessibility.Private, Generator.GetAccessibility(Generator.
WithAccessibility
(Generator.FieldDeclaration("f", Generator.IdentifierName("t"), accessibility: Accessibility.Internal), Accessibility.Private)));
2978
Assert.Equal(Accessibility.NotApplicable, Generator.GetAccessibility(Generator.
WithAccessibility
(Generator.EnumMember("v"), Accessibility.Private)));
2979
Assert.Equal(Accessibility.Private, Generator.GetAccessibility(Generator.
WithAccessibility
(Generator.EventDeclaration("ef", Generator.IdentifierName("t"), accessibility: Accessibility.Internal), Accessibility.Private)));
2980
Assert.Equal(Accessibility.Private, Generator.GetAccessibility(Generator.
WithAccessibility
(Generator.CustomEventDeclaration("ep", Generator.IdentifierName("t"), accessibility: Accessibility.Internal), Accessibility.Private)));
2981
Assert.Equal(Accessibility.NotApplicable, Generator.GetAccessibility(Generator.
WithAccessibility
(Generator.NamespaceDeclaration("n"), Accessibility.Private)));
2982
Assert.Equal(Accessibility.NotApplicable, Generator.GetAccessibility(Generator.
WithAccessibility
(Generator.NamespaceImportDeclaration("u"), Accessibility.Private)));
2983
Assert.Equal(Accessibility.NotApplicable, Generator.GetAccessibility(Generator.
WithAccessibility
(Generator.LocalDeclarationStatement(Generator.IdentifierName("t"), "loc"), Accessibility.Private)));
2984
Assert.Equal(Accessibility.NotApplicable, Generator.GetAccessibility(Generator.
WithAccessibility
(Generator.Attribute("a"), Accessibility.Private)));
2985
Assert.Equal(Accessibility.NotApplicable, Generator.GetAccessibility(Generator.
WithAccessibility
(TypeParameter("tp"), Accessibility.Private)));
2986
Assert.Equal(Accessibility.Private, Generator.GetAccessibility(Generator.
WithAccessibility
(AccessorDeclaration(SyntaxKind.InitAccessorDeclaration), Accessibility.Private)));
3105
var publicCtor = Generator.
WithAccessibility
(ctor, Accessibility.Public);
3139
var filePublicClass = Generator.
WithAccessibility
(fileClass, Accessibility.Public);
3374
Assert.Equal(Accessibility.Public, Generator.GetAccessibility(Generator.
WithAccessibility
(getAccessor, Accessibility.Public)));
3375
Assert.Equal(Accessibility.Private, Generator.GetAccessibility(Generator.
WithAccessibility
(setAccessor, Accessibility.Private)));
3392
var newProp = Generator.ReplaceNode(prop, getAccessor, Generator.
WithAccessibility
(getAccessor, Accessibility.Public));
3395
newProp = Generator.ReplaceNode(prop, setAccessor, Generator.
WithAccessibility
(setAccessor, Accessibility.Public));
3829
var xPrivate = Generator.
WithAccessibility
(declX, Accessibility.Private);
3919
Generator.ReplaceNode(declC, declX, Generator.
WithAccessibility
(declX, Accessibility.Private)),
Microsoft.CodeAnalysis.Features (2)
src\Analyzers\Core\CodeFixes\AddAccessibilityModifiers\AddAccessibilityModifiersHelpers.cs (2)
36
? generator.
WithAccessibility
(declaration, preferredAccessibility)
37
: generator.
WithAccessibility
(declaration, Accessibility.NotApplicable);
Microsoft.CodeAnalysis.VisualBasic.Workspaces.UnitTests (25)
CodeGeneration\SyntaxGeneratorTests.vb (25)
2669
Assert.Equal(Accessibility.Private, Generator.GetAccessibility(Generator.
WithAccessibility
(Generator.ClassDeclaration("c", accessibility:=Accessibility.Internal), Accessibility.Private)))
2670
Assert.Equal(Accessibility.Private, Generator.GetAccessibility(Generator.
WithAccessibility
(Generator.StructDeclaration("s", accessibility:=Accessibility.Internal), Accessibility.Private)))
2671
Assert.Equal(Accessibility.Private, Generator.GetAccessibility(Generator.
WithAccessibility
(Generator.EnumDeclaration("i", accessibility:=Accessibility.Internal), Accessibility.Private)))
2672
Assert.Equal(Accessibility.Private, Generator.GetAccessibility(Generator.
WithAccessibility
(Generator.EnumDeclaration("e", accessibility:=Accessibility.Internal), Accessibility.Private)))
2673
Assert.Equal(Accessibility.Private, Generator.GetAccessibility(Generator.
WithAccessibility
(Generator.DelegateDeclaration("d", accessibility:=Accessibility.Internal), Accessibility.Private)))
2674
Assert.Equal(Accessibility.Private, Generator.GetAccessibility(Generator.
WithAccessibility
(Generator.MethodDeclaration("m", accessibility:=Accessibility.Internal), Accessibility.Private)))
2675
Assert.Equal(Accessibility.Private, Generator.GetAccessibility(Generator.
WithAccessibility
(Generator.ConstructorDeclaration(accessibility:=Accessibility.Internal), Accessibility.Private)))
2676
Assert.Equal(Accessibility.NotApplicable, Generator.GetAccessibility(Generator.
WithAccessibility
(Generator.ParameterDeclaration("p"), Accessibility.Private)))
2677
Assert.Equal(Accessibility.Private, Generator.GetAccessibility(Generator.
WithAccessibility
(Generator.PropertyDeclaration("p", Generator.IdentifierName("t"), accessibility:=Accessibility.Internal), Accessibility.Private)))
2678
Assert.Equal(Accessibility.Private, Generator.GetAccessibility(Generator.
WithAccessibility
(Generator.IndexerDeclaration({Generator.ParameterDeclaration("i")}, Generator.IdentifierName("t"), accessibility:=Accessibility.Internal), Accessibility.Private)))
2679
Assert.Equal(Accessibility.Private, Generator.GetAccessibility(Generator.
WithAccessibility
(Generator.FieldDeclaration("f", Generator.IdentifierName("t"), accessibility:=Accessibility.Internal), Accessibility.Private)))
2680
Assert.Equal(Accessibility.NotApplicable, Generator.GetAccessibility(Generator.
WithAccessibility
(Generator.EnumMember("v"), Accessibility.Private)))
2681
Assert.Equal(Accessibility.Private, Generator.GetAccessibility(Generator.
WithAccessibility
(Generator.EventDeclaration("ef", Generator.IdentifierName("t"), accessibility:=Accessibility.Internal), Accessibility.Private)))
2682
Assert.Equal(Accessibility.Private, Generator.GetAccessibility(Generator.
WithAccessibility
(Generator.CustomEventDeclaration("ep", Generator.IdentifierName("t"), accessibility:=Accessibility.Internal), Accessibility.Private)))
2683
Assert.Equal(Accessibility.NotApplicable, Generator.GetAccessibility(Generator.
WithAccessibility
(Generator.NamespaceDeclaration("n"), Accessibility.Private)))
2684
Assert.Equal(Accessibility.NotApplicable, Generator.GetAccessibility(Generator.
WithAccessibility
(Generator.NamespaceImportDeclaration("u"), Accessibility.Private)))
2685
Assert.Equal(Accessibility.NotApplicable, Generator.GetAccessibility(Generator.
WithAccessibility
(Generator.LocalDeclarationStatement(Generator.IdentifierName("t"), "loc"), Accessibility.Private)))
2686
Assert.Equal(Accessibility.NotApplicable, Generator.GetAccessibility(Generator.
WithAccessibility
(Generator.Attribute("a"), Accessibility.Private)))
2687
Assert.Equal(Accessibility.NotApplicable, Generator.GetAccessibility(Generator.
WithAccessibility
(SyntaxFactory.TypeParameter("tp"), Accessibility.Private)))
2692
Assert.Equal(Accessibility.Internal, Generator.GetAccessibility(Generator.
WithAccessibility
(m, Accessibility.Internal)))
3078
Assert.Equal(Accessibility.Public, _g.GetAccessibility(_g.
WithAccessibility
(getAccessor, Accessibility.Public)))
3079
Assert.Equal(Accessibility.Private, _g.GetAccessibility(_g.
WithAccessibility
(setAccessor, Accessibility.Private)))
3091
Dim newProp = _g.ReplaceNode(prop, getAccessor, _g.
WithAccessibility
(getAccessor, Accessibility.Public))
3094
newProp = _g.ReplaceNode(prop, setAccessor, _g.
WithAccessibility
(setAccessor, Accessibility.Public))
3520
Dim xPrivate = Generator.
WithAccessibility
(declX, Accessibility.Private)
Microsoft.CodeAnalysis.Workspaces (1)
Editing\SyntaxEditorExtensions.cs (1)
14
=> editor.ReplaceNode(declaration, (d, g) => g.
WithAccessibility
(d, accessibility));