roslyn icon indicating copy to clipboard operation
roslyn copied to clipboard

Event handler names are generated which cause naming rule errors

Open jnm2 opened this issue 8 years ago • 6 comments

In VS2017.2, if I double-click to create an event in the Windows Forms designer, it inserts a method name similar to btnFoo_Click which causes an error since the editorconfig enforces that method names be Pascal-cased. However, if I type btnFoo.Click += Tab, it correctly generates the name BtnFoo_Click.

I would expect the Windows Forms designer to delegate to the same logic.

jnm2 avatar Jul 20 '17 14:07 jnm2

I swear we've seen this before, but can't find it on GitHub right now. Maybe it's just on developer community right now?

Pilchie avatar Jul 20 '17 20:07 Pilchie

@jinujoseph @DustinCampbell this isn't in Roslyn unfortunately, i'ts called into us by the VsCodeDomGenerator.

Unfortunately, i don't much in the way to fix this. The code-dom-generator would need to know about naming styles (which it doesn't), and all Roslyn hears from it is "generate a method called btn_Click".

The only way i can see to fix this is to have a new interface that winforms uses to say "name the method with this name, but make the name fit the user naming style". We'd have to define that and get winforms to then call that.

Not sure what would be the next best steps here.

CyrusNajmabadi avatar Mar 22 '20 01:03 CyrusNajmabadi

This was fixed in the meantime a while again (and broken and fixed again IIRC). I didn't remember this issue existed and I thought I was discussing this somewhere else, but I can't find it.

jnm2 avatar Mar 22 '20 02:03 jnm2

Maybe I was just following https://developercommunity.visualstudio.com/content/problem/286625/naming-rule-violation-these-words-must-begin-with-1.html.

It was fixed most recently in VS 16.3.

jnm2 avatar Mar 22 '20 02:03 jnm2

Ugh, I'm sorry for misleading everyone. 16.5.1 still has this problem.

jnm2 avatar Mar 27 '20 23:03 jnm2

As stated in VS Community, there is a now a VS setting to capitalize method names by default:

image

Related: https://developercommunity.visualstudio.com/t/naming-rule-violation-ide1006/37831

I think you can close this issue.

tbolon avatar Aug 27 '24 09:08 tbolon