0

How can I restrict Visual Studio 2019 to allow only latin characters in identifiers? That means, I want method names and variable names to be in latin characters, and not for example in greek characters. The following code compiles in Visual Studio 2019:

Module Module1

    Private Sub MethodLatin()
        Console.WriteLine("MethodLatin")
    End Sub

    Private Sub ΜέθοδοςΕλληνική()
        Dim αβγ = "ΜέθοδοςΕλληνική"
        Console.WriteLine(αβγ)
    End Sub

    Sub Main()
        MethodLatin()
        ΜέθοδοςΕλληνική()
        Console.ReadKey()
    End Sub

End Module

I would like to forbid to write the second method (ΜέθοδοςΕλληνική) in greek characters. How can I do that?

jmcilhinney
  • 50,448
  • 5
  • 26
  • 46
Alex
  • 419
  • 1
  • 5
  • 14
  • I'm not aware of anything to do this. In theory, you should be able to dictate this via the code-style or formatting rule options, but I don't see a setting for Latin only names: https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/code-style-rule-options?view=vs-2019 – David Oct 12 '22 at 13:55
  • That's legal code so VS won't forbid it by any option. You could write a custom analyzer to flag them. – Alejandro Oct 12 '22 at 14:29
  • Allowing non-latin characters in identifiers, makes the code unreadable in US and probably other regional settings. As an improvement to Visual Studio, I propose a setting that allows non-latin characters in identifiers. – Alex Oct 13 '22 at 07:05

0 Answers0