1

I'm using Visual Studio 2022, the language is C#.

I have such a class and its nested class like this:

class Peer
{
    public class ServerCommandQuit {}
    public Peer(int id) {}
}

To construct an instance of Peer.ServerCommandQuit I will type:

new Peer.ServerCommandQuit();
        ^

The problem is when I press the dot . key, Visual Studio will automatically append a pair of parentheses after the outer class name:

new Peer().

How can I disable this feature? I have tried to uncheck Automatic brace completion and all 4 options in IntelliCode.

Jiale Xue - MSFT
  • 3,560
  • 1
  • 6
  • 21
shingo
  • 18,436
  • 5
  • 23
  • 42
  • What happens when you keep typing? (suggestions are shown in grey and will disappear when you keep typing something else) – TaW Sep 13 '22 at 08:27
  • The parentheses are not suggestions, they are actually inserted. When I keep typing they remain. And I can see the red wavy underline under **Peer** because it doesn't have a default constructor. – shingo Sep 13 '22 at 08:37
  • That's annoying. Pressing tab after typing `Peer` stops the parentheses from turning up but I can't see a way to switch that feature off completely. – Yitz Sep 13 '22 at 09:48
  • Also, see [this](https://stackoverflow.com/questions/68128803/is-it-possible-to-disable-automatic-constructor-completion) question – Yitz Sep 13 '22 at 09:55
  • 1
    There's a pull request in the Roslyn project [here](https://github.com/dotnet/roslyn/pull/63015) – Yitz Sep 13 '22 at 09:57
  • Thanks @Yitz, the tab key helps, I am disappointed to hear that the problem has not been fixed. – shingo Sep 14 '22 at 04:08

1 Answers1

1

After typing peer, press esc and then type "." the brackets will not appear.

The method in the link provided by Yitz can also solve this problem:

enter image description here

Jingmiao Xu-MSFT
  • 2,076
  • 1
  • 3
  • 10