dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
18.92k stars 4.01k forks source link

Event handler names are generated which cause naming rule errors #20999

Open jnm2 opened 7 years ago

jnm2 commented 7 years ago

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.

Pilchie commented 7 years ago

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?

CyrusNajmabadi commented 4 years ago

@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.

jnm2 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

tbolon commented 2 weeks ago

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.