roslyn
roslyn copied to clipboard
Event handler names are generated which cause naming rule errors
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.
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?
@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.
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.
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.
Ugh, I'm sorry for misleading everyone. 16.5.1 still has this problem.
As stated in VS Community, there is a now a VS setting to capitalize method names by default:
Related: https://developercommunity.visualstudio.com/t/naming-rule-violation-ide1006/37831
I think you can close this issue.