Author Topic: C# Syntax Expansion is confusing me  (Read 2233 times)

evanratt

  • Senior Community Member
  • Posts: 300
  • Hero Points: 23
C# Syntax Expansion is confusing me
« on: March 19, 2015, 03:43:52 PM »
Maybe I'm being a dunce, but Syntax Expansion is confusing me when I'm working with C#--I can't find how to configure it to my liking.

I have a file test.cs. When I type "class" and hit space, it automatically fills in:
Code: [Select]
class test {

}

(If the class is inside a namespace, it still fills it in like that, but the final hotspot indicator is distorted; see Image1.jpg)

Even if the class is a nested class, it tries to fill in the filename as the class name.

I want no class names being created for me automatically, but the options controlling Syntax Expansion don't seem to operate as I expect. Under C#->Auto-completion, under "Enable auto-completion", if I uncheck "Syntax expansion", it does not affect this behavior. Under "Syntax expansion", if I uncheck everything but "Use Syntax Expansion on space", it does not affect this behavior. If I uncheck "Use Syntax Expansion on space", it stops this from happening, but that's the nuclear option and disables Syntax Expansion entirely, which I don't want.

Is there any way to just disable the auto-naming of my classes?

I just realized that if I type "public class", (which I should be doing anyway--still getting used to C#), it does not auto-fill the class name. This also seems odd; if I am configured to auto-name classes, it should work on "public class" as well, right?

Dennis

  • Senior Community Member
  • Posts: 3966
  • Hero Points: 517
Re: C# Syntax Expansion is confusing me
« Reply #1 on: March 19, 2015, 03:55:52 PM »
I agree the completion is probably being a bit over-exuberant.  It is operating under the one-class-per-file stylistic assumption that C# inherited from Java programming style conventions.  We should probably remove that, or add a little bit more intelligence to when it does that.

You can override how "class" is expanded on space by defining a "class" alias for C#.

evanratt

  • Senior Community Member
  • Posts: 300
  • Hero Points: 23
Re: C# Syntax Expansion is confusing me
« Reply #2 on: March 19, 2015, 03:58:24 PM »
Thanks for the tip--that's a workable workaround.

It seems like a reasonable feature, if it's configurable by the user, but just a bit crude in the current implementation.