2 overrides of WithModifiers
Microsoft.CodeAnalysis.CSharp.Workspaces (1)
CodeGeneration\CSharpSyntaxGenerator.cs (1)
1616
public override SyntaxNode
WithModifiers
(SyntaxNode declaration, DeclarationModifiers modifiers)
Microsoft.CodeAnalysis.VisualBasic.Workspaces (1)
CodeGeneration\VisualBasicSyntaxGenerator.vb (1)
2421
Public Overrides Function
WithModifiers
(declaration As SyntaxNode, modifiers As DeclarationModifiers) As SyntaxNode
92 references to WithModifiers
Microsoft.CodeAnalysis.CodeStyle.Fixes (4)
src\Analyzers\Core\CodeFixes\MakeFieldReadonly\AbstractMakeFieldReadonlyCodeFixProvider.cs (1)
72
generator.
WithModifiers
(fieldDeclaration.WithoutTrivia(), modifiers).WithTriviaFrom(fieldDeclaration));
src\Analyzers\Core\CodeFixes\MakeMemberStatic\AbstractMakeMemberStaticCodeFixProvider.cs (1)
42
var newNode = generator.
WithModifiers
(memberDeclaration, generator.GetModifiers(declaration).WithIsStatic(true));
src\Analyzers\Core\CodeFixes\MakeTypeAbstract\AbstractMakeTypeAbstractCodeFixProvider.cs (1)
40
(currentTypeDeclaration, generator) => generator.
WithModifiers
(currentTypeDeclaration, generator.GetModifiers(currentTypeDeclaration).WithIsAbstract(true)));
src\Analyzers\Core\CodeFixes\MakeTypePartial\AbstractMakeTypePartialCodeFixProvider.cs (1)
54
editor.ReplaceNode(node, generator.
WithModifiers
(node, fixedModifiers));
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (7)
src\Analyzers\CSharp\CodeFixes\MakeAnonymousFunctionStatic\CSharpMakeAnonymousFunctionStaticCodeFixProvider.cs (1)
45
editor.ReplaceNode(anonymousFunction, static (node, generator) => generator.
WithModifiers
(node, generator.GetModifiers(node).WithIsStatic(true)));
src\Analyzers\CSharp\CodeFixes\MakeLocalFunctionStatic\MakeLocalFunctionStaticCodeFixHelper.cs (1)
201
=> generator.
WithModifiers
(
src\Analyzers\CSharp\CodeFixes\MakeMemberRequired\CSharpMakeMemberRequiredCodeFixProvider.cs (1)
140
editor.ReplaceNode(memberDeclarator, generator.
WithModifiers
(memberDeclarator, newDeclarationModifiers));
src\Analyzers\CSharp\CodeFixes\MakeRefStruct\MakeRefStructCodeFixProvider.cs (1)
71
var newStruct = generator.
WithModifiers
(
src\Analyzers\CSharp\CodeFixes\MakeStructMemberReadOnly\CSharpMakeStructMemberReadOnlyCodeFixProvider.cs (1)
103
return (TNode)generator.
WithModifiers
(node, generator.GetModifiers(node).WithIsReadOnly(add));
src\Analyzers\CSharp\CodeFixes\MakeStructReadOnly\CSharpMakeStructReadOnlyCodeFixProvider.cs (1)
46
(current, generator) => generator.
WithModifiers
(current, generator.GetModifiers(current).WithIsReadOnly(true)));
src\Analyzers\CSharp\CodeFixes\RemoveNewModifier\RemoveNewModifierCodeFixProvider.cs (1)
66
generator.
WithModifiers
(
Microsoft.CodeAnalysis.CSharp.Features (7)
src\Analyzers\CSharp\CodeFixes\MakeAnonymousFunctionStatic\CSharpMakeAnonymousFunctionStaticCodeFixProvider.cs (1)
45
editor.ReplaceNode(anonymousFunction, static (node, generator) => generator.
WithModifiers
(node, generator.GetModifiers(node).WithIsStatic(true)));
src\Analyzers\CSharp\CodeFixes\MakeLocalFunctionStatic\MakeLocalFunctionStaticCodeFixHelper.cs (1)
201
=> generator.
WithModifiers
(
src\Analyzers\CSharp\CodeFixes\MakeMemberRequired\CSharpMakeMemberRequiredCodeFixProvider.cs (1)
140
editor.ReplaceNode(memberDeclarator, generator.
WithModifiers
(memberDeclarator, newDeclarationModifiers));
src\Analyzers\CSharp\CodeFixes\MakeRefStruct\MakeRefStructCodeFixProvider.cs (1)
71
var newStruct = generator.
WithModifiers
(
src\Analyzers\CSharp\CodeFixes\MakeStructMemberReadOnly\CSharpMakeStructMemberReadOnlyCodeFixProvider.cs (1)
103
return (TNode)generator.
WithModifiers
(node, generator.GetModifiers(node).WithIsReadOnly(add));
src\Analyzers\CSharp\CodeFixes\MakeStructReadOnly\CSharpMakeStructReadOnlyCodeFixProvider.cs (1)
46
(current, generator) => generator.
WithModifiers
(current, generator.GetModifiers(current).WithIsReadOnly(true)));
src\Analyzers\CSharp\CodeFixes\RemoveNewModifier\RemoveNewModifierCodeFixProvider.cs (1)
66
generator.
WithModifiers
(
Microsoft.CodeAnalysis.CSharp.Workspaces.UnitTests (39)
CodeGeneration\SyntaxGeneratorTests.cs (39)
3015
Assert.Equal(DeclarationModifiers.Abstract, Generator.GetModifiers(Generator.
WithModifiers
(Generator.ClassDeclaration("c"), DeclarationModifiers.Abstract)));
3016
Assert.Equal(DeclarationModifiers.Partial, Generator.GetModifiers(Generator.
WithModifiers
(Generator.StructDeclaration("s"), DeclarationModifiers.Partial)));
3017
Assert.Equal(DeclarationModifiers.New, Generator.GetModifiers(Generator.
WithModifiers
(Generator.EnumDeclaration("e"), DeclarationModifiers.New)));
3018
Assert.Equal(DeclarationModifiers.New, Generator.GetModifiers(Generator.
WithModifiers
(Generator.DelegateDeclaration("d"), DeclarationModifiers.New)));
3019
Assert.Equal(DeclarationModifiers.Static, Generator.GetModifiers(Generator.
WithModifiers
(Generator.MethodDeclaration("m"), DeclarationModifiers.Static)));
3020
Assert.Equal(DeclarationModifiers.Static, Generator.GetModifiers(Generator.
WithModifiers
(Generator.ConstructorDeclaration(), DeclarationModifiers.Static)));
3021
Assert.Equal(DeclarationModifiers.None, Generator.GetModifiers(Generator.
WithModifiers
(Generator.ParameterDeclaration("p"), DeclarationModifiers.Abstract)));
3022
Assert.Equal(DeclarationModifiers.Abstract, Generator.GetModifiers(Generator.
WithModifiers
(Generator.PropertyDeclaration("p", Generator.IdentifierName("t")), DeclarationModifiers.Abstract)));
3024
Assert.Equal(DeclarationModifiers.Const, Generator.GetModifiers(Generator.
WithModifiers
(Generator.FieldDeclaration("f", Generator.IdentifierName("t")), DeclarationModifiers.Const)));
3025
Assert.Equal(DeclarationModifiers.Static, Generator.GetModifiers(Generator.
WithModifiers
(Generator.EventDeclaration("ef", Generator.IdentifierName("t")), DeclarationModifiers.Static)));
3026
Assert.Equal(DeclarationModifiers.Static, Generator.GetModifiers(Generator.
WithModifiers
(Generator.CustomEventDeclaration("ep", Generator.IdentifierName("t")), DeclarationModifiers.Static)));
3027
Assert.Equal(DeclarationModifiers.None, Generator.GetModifiers(Generator.
WithModifiers
(Generator.EnumMember("v"), DeclarationModifiers.Partial)));
3028
Assert.Equal(DeclarationModifiers.None, Generator.GetModifiers(Generator.
WithModifiers
(Generator.NamespaceDeclaration("n"), DeclarationModifiers.Abstract)));
3029
Assert.Equal(DeclarationModifiers.None, Generator.GetModifiers(Generator.
WithModifiers
(Generator.NamespaceImportDeclaration("u"), DeclarationModifiers.Abstract)));
3030
Assert.Equal(DeclarationModifiers.None, Generator.GetModifiers(Generator.
WithModifiers
(Generator.LocalDeclarationStatement(Generator.IdentifierName("t"), "loc"), DeclarationModifiers.Abstract)));
3031
Assert.Equal(DeclarationModifiers.None, Generator.GetModifiers(Generator.
WithModifiers
(Generator.Attribute("a"), DeclarationModifiers.Abstract)));
3032
Assert.Equal(DeclarationModifiers.None, Generator.GetModifiers(Generator.
WithModifiers
(TypeParameter("tp"), DeclarationModifiers.Abstract)));
3042
Generator.GetModifiers(Generator.
WithModifiers
(Generator.ClassDeclaration("c"), allModifiers)));
3046
Generator.GetModifiers(Generator.
WithModifiers
(Generator.StructDeclaration("s"), allModifiers)));
3050
Generator.GetModifiers(Generator.
WithModifiers
(Generator.InterfaceDeclaration("i"), allModifiers)));
3054
Generator.GetModifiers(Generator.
WithModifiers
(Generator.DelegateDeclaration("d"), allModifiers)));
3058
Generator.GetModifiers(Generator.
WithModifiers
(Generator.EnumDeclaration("e"), allModifiers)));
3062
Generator.GetModifiers(Generator.
WithModifiers
(Generator.FieldDeclaration("f", Generator.IdentifierName("t")), allModifiers)));
3066
Generator.GetModifiers(Generator.
WithModifiers
(Generator.ConstructorDeclaration("c"), allModifiers)));
3070
Generator.GetModifiers(Generator.
WithModifiers
(DestructorDeclaration("c"), allModifiers)));
3074
Generator.GetModifiers(Generator.
WithModifiers
(Generator.MethodDeclaration("m"), allModifiers)));
3078
Generator.GetModifiers(Generator.
WithModifiers
(Generator.PropertyDeclaration("p", Generator.IdentifierName("t")), allModifiers)));
3086
Generator.GetModifiers(Generator.
WithModifiers
(Generator.EventDeclaration("ef", Generator.IdentifierName("t")), allModifiers)));
3090
Generator.GetModifiers(Generator.
WithModifiers
(Generator.CustomEventDeclaration("ep", Generator.IdentifierName("t")), allModifiers)));
3094
Generator.GetModifiers(Generator.
WithModifiers
(AccessorDeclaration(SyntaxKind.GetAccessorDeclaration), allModifiers)));
3119
var staticCtor = Generator.
WithModifiers
(ctor, DeclarationModifiers.Static);
3129
var fileAbstractClass = Generator.
WithModifiers
(fileClass, Generator.GetModifiers(fileClass).WithIsAbstract(true));
3149
var fileAbstractClass = Generator.
WithModifiers
(abstractClass, Generator.GetModifiers(abstractClass).WithIsFile(true));
3159
var filePublicClass = Generator.
WithModifiers
(publicClass, Generator.GetModifiers(publicClass).WithIsFile(true));
3169
var updatedProperty = Generator.
WithModifiers
(property, Generator.GetModifiers(property).WithIsRequired(true));
3177
var updatedProperty = Generator.
WithModifiers
(property, Generator.GetModifiers(property).WithIsVirtual(true));
3187
var updatedProperty = Generator.
WithModifiers
(property, Generator.GetModifiers(property).WithIsRequired(true));
3834
var xReadOnly = Generator.
WithModifiers
(declX, DeclarationModifiers.ReadOnly);
3927
Generator.ReplaceNode(declC, declX, Generator.
WithModifiers
(declX, DeclarationModifiers.None)),
Microsoft.CodeAnalysis.Features (5)
PullMemberUp\MembersPuller.cs (1)
346
originalMemberEditor.ReplaceNode(declarationSyntax, (node, generator) => generator.
WithModifiers
(node, DeclarationModifiers.Override));
src\Analyzers\Core\CodeFixes\MakeFieldReadonly\AbstractMakeFieldReadonlyCodeFixProvider.cs (1)
72
generator.
WithModifiers
(fieldDeclaration.WithoutTrivia(), modifiers).WithTriviaFrom(fieldDeclaration));
src\Analyzers\Core\CodeFixes\MakeMemberStatic\AbstractMakeMemberStaticCodeFixProvider.cs (1)
42
var newNode = generator.
WithModifiers
(memberDeclaration, generator.GetModifiers(declaration).WithIsStatic(true));
src\Analyzers\Core\CodeFixes\MakeTypeAbstract\AbstractMakeTypeAbstractCodeFixProvider.cs (1)
40
(currentTypeDeclaration, generator) => generator.
WithModifiers
(currentTypeDeclaration, generator.GetModifiers(currentTypeDeclaration).WithIsAbstract(true)));
src\Analyzers\Core\CodeFixes\MakeTypePartial\AbstractMakeTypePartialCodeFixProvider.cs (1)
54
editor.ReplaceNode(node, generator.
WithModifiers
(node, fixedModifiers));
Microsoft.CodeAnalysis.VisualBasic.Features (2)
RemoveSharedFromModuleMembers\VisualBasicRemoveSharedFromModuleMembersCodeFixProvider.vb (1)
74
Return generator.
WithModifiers
(node, generator.GetModifiers(node).WithIsStatic(False))
UseAutoProperty\VisualBasicUseAutoPropertyCodeFixProvider.vb (1)
63
statement = DirectCast(generator.
WithModifiers
(statement, generator.GetModifiers(propertyDeclaration).WithIsReadOnly(canBeReadOnly)), PropertyStatementSyntax)
Microsoft.CodeAnalysis.VisualBasic.Workspaces.UnitTests (22)
CodeGeneration\SyntaxGeneratorTests.vb (22)
2719
Assert.Equal(DeclarationModifiers.Abstract, Generator.GetModifiers(Generator.
WithModifiers
(Generator.ClassDeclaration("c"), DeclarationModifiers.Abstract)))
2720
Assert.Equal(DeclarationModifiers.Partial, Generator.GetModifiers(Generator.
WithModifiers
(Generator.StructDeclaration("s"), DeclarationModifiers.Partial)))
2721
Assert.Equal(DeclarationModifiers.[New], Generator.GetModifiers(Generator.
WithModifiers
(Generator.EnumDeclaration("e"), DeclarationModifiers.[New])))
2722
Assert.Equal(DeclarationModifiers.[New], Generator.GetModifiers(Generator.
WithModifiers
(Generator.DelegateDeclaration("d"), DeclarationModifiers.[New])))
2723
Assert.Equal(DeclarationModifiers.Static, Generator.GetModifiers(Generator.
WithModifiers
(Generator.MethodDeclaration("m"), DeclarationModifiers.Static)))
2724
Assert.Equal(DeclarationModifiers.Static, Generator.GetModifiers(Generator.
WithModifiers
(Generator.ConstructorDeclaration(), DeclarationModifiers.Static)))
2725
Assert.Equal(DeclarationModifiers.None, Generator.GetModifiers(Generator.
WithModifiers
(Generator.ParameterDeclaration("p"), DeclarationModifiers.Abstract)))
2726
Assert.Equal(DeclarationModifiers.Abstract, Generator.GetModifiers(Generator.
WithModifiers
(Generator.PropertyDeclaration("p", Generator.IdentifierName("t")), DeclarationModifiers.Abstract)))
2727
Assert.Equal(DeclarationModifiers.Abstract, Generator.GetModifiers(Generator.
WithModifiers
(Generator.IndexerDeclaration({Generator.ParameterDeclaration("i")}, Generator.IdentifierName("t")), DeclarationModifiers.Abstract)))
2728
Assert.Equal(DeclarationModifiers.Const, Generator.GetModifiers(Generator.
WithModifiers
(Generator.FieldDeclaration("f", Generator.IdentifierName("t")), DeclarationModifiers.Const)))
2729
Assert.Equal(DeclarationModifiers.Static, Generator.GetModifiers(Generator.
WithModifiers
(Generator.EventDeclaration("ef", Generator.IdentifierName("t")), DeclarationModifiers.Static)))
2730
Assert.Equal(DeclarationModifiers.Static, Generator.GetModifiers(Generator.
WithModifiers
(Generator.CustomEventDeclaration("ep", Generator.IdentifierName("t")), DeclarationModifiers.Static)))
2731
Assert.Equal(DeclarationModifiers.None, Generator.GetModifiers(Generator.
WithModifiers
(Generator.EnumMember("v"), DeclarationModifiers.Partial)))
2732
Assert.Equal(DeclarationModifiers.None, Generator.GetModifiers(Generator.
WithModifiers
(Generator.NamespaceDeclaration("n"), DeclarationModifiers.Abstract)))
2733
Assert.Equal(DeclarationModifiers.None, Generator.GetModifiers(Generator.
WithModifiers
(Generator.NamespaceImportDeclaration("u"), DeclarationModifiers.Abstract)))
2734
Assert.Equal(DeclarationModifiers.None, Generator.GetModifiers(Generator.
WithModifiers
(Generator.LocalDeclarationStatement(Generator.IdentifierName("t"), "loc"), DeclarationModifiers.Abstract)))
2735
Assert.Equal(DeclarationModifiers.None, Generator.GetModifiers(Generator.
WithModifiers
(Generator.Attribute("a"), DeclarationModifiers.Abstract)))
2736
Assert.Equal(DeclarationModifiers.None, Generator.GetModifiers(Generator.
WithModifiers
(SyntaxFactory.TypeParameter("tp"), DeclarationModifiers.Abstract)))
2742
Dim classBlockWithModifiers = Generator.
WithModifiers
(classBlock, DeclarationModifiers.Sealed)
2747
Dim classStatementWithModifiers = Generator.
WithModifiers
(classStatement, DeclarationModifiers.Sealed)
2754
classBlock = DirectCast(Generator.AddMembers(classBlock, Generator.
WithModifiers
(Generator.MethodDeclaration("Goo"), DeclarationModifiers.Sealed)), ClassBlockSyntax)
3525
Dim xReadOnly = Generator.
WithModifiers
(declX, DeclarationModifiers.ReadOnly)
Microsoft.CodeAnalysis.Workspaces (1)
Editing\SyntaxEditorExtensions.cs (1)
17
=> editor.ReplaceNode(declaration, (d, g) => g.
WithModifiers
(d, modifiers));
Microsoft.Interop.ComInterfaceGenerator (3)
Analyzers\AddGeneratedComClassFixer.cs (1)
33
updatedNode = gen.
WithModifiers
(updatedNode, declarationModifiers.WithPartial(true));
Analyzers\ConvertComImportToGeneratedComInterfaceFixer.cs (1)
138
editor.ReplaceNode(node, (node, gen) => gen.
WithModifiers
(node, gen.GetModifiers(node).WithPartial(true)));
src\libraries\System.Runtime.InteropServices\gen\Common\ConvertToSourceGeneratedInteropFixer.cs (1)
236
editor.ReplaceNode(node, (node, gen) => gen.
WithModifiers
(node, gen.GetModifiers(node).WithPartial(true)));
Microsoft.Interop.LibraryImportGenerator (2)
Analyzers\ConvertToLibraryImportFixer.cs (1)
260
generatedDeclaration = generator.
WithModifiers
(
src\libraries\System.Runtime.InteropServices\gen\Common\ConvertToSourceGeneratedInteropFixer.cs (1)
236
editor.ReplaceNode(node, (node, gen) => gen.
WithModifiers
(node, gen.GetModifiers(node).WithPartial(true)));