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?
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?
Two things you can do:
Modify the class file template. This is found in you VS installation:
<InstallRoot>\<Edition>\Common7\IDE\ItemTemplates\CSharp\Code\1033\Class
To confirm something has been specified: add the following to a .editorconfig
:
dotnet_style_require_accessibility_modifiers=always:suggestion
It can be done by editing the snippets of Class of your installed visual studio.
<Code Language="csharp"><![CDATA[ class $name$ { $selected$$end$ }]]> </Code>
to
<Code Language="csharp"><![CDATA[internal class $name$ { $selected$$end$ }]]> </Code>
You can use Code Snippet to do that (https://learn.microsoft.com/en-us/visualstudio/ide/code-snippets?view=vs-2019)
Code snippets are small blocks of reusable code that can be inserted in a code file using a right-click menu (context menu) command or a combination of hotkeys. They typically contain commonly used code blocks such as try-finally or if-else blocks, but they can be used to insert entire classes or methods.