'Filescoped namespaces in visual studio 2019

I am trying to use filescoped namespaces in visual studio 2019. So instead of:-

namespace my.namespace
{
    public class MyClass
    {
    }
}

I want:-

namespace my.namespace;

public class MyClass
{
}

Following online tutorials and going through other answers I have tried adding editorConfig file but the editorConfig visual studio is generating for me is different than what I am seeing online. My file is starting with this text:-

# Rules in this file were initially inferred by Visual Studio IntelliCode from the C:\myproject codebase based on best match to current usage at 3/25/2022
# You can modify the rules from these initially generated values to suit your own policies
# You can learn more about editorconfig here: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference
[*.cs]


#Core editorconfig formatting - indentation

#use soft tabs (spaces) for indentation
indent_style = space

#Formatting - indentation options

#indent switch case contents.
csharp_indent_case_contents = true
#indent switch labels
csharp_indent_switch_labels = true

And this file has no information on filescoped namespaces.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source