Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting to explicitly write default access modifier in Visual Studio

When I generate a new class, I would like to have the default access modifier written down explicitly like:

internal class Foo
{
}

instead of:

class Foo
{
}

Is that possible with a setting and if so - how?

like image 980
Athanviel Avatar asked Jun 10 '26 01:06

Athanviel


1 Answers

Two things you can do:

  1. Modify the class file template. This is found in you VS installation:

    <InstallRoot>\<Edition>\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class
    
  2. To confirm something has been specified: add the following to a .editorconfig:

    dotnet_style_require_accessibility_modifiers=always:suggestion
    
like image 136
Richard Avatar answered Jun 11 '26 14:06

Richard