@Rick-Anderson @wadepickett @scottaddie @serpent5
We'll be reverting work done on issues/PRs such as Alignment on underscores in Blazor examples (dotnet/AspNetCore.Docs #15853).
The subject came up at least three different times since Blazor started. Each convo led to using underscores on private fields. However, we're gong to revert and avoid underscores on members in the future. Reference
I can handle this change for Blazor because it's a small subset of topics, snippets, and sample apps.
I just looked at the whole doc set. There are several hundred underscore prefixes across text, snippets, and sample apps. There are so many that I can't reasonably set aside the time to manually fix them all. I suppose that they can be massaged out over time as the topics are addressed for other reasons.
@guardrex Thanks for including me in this.
Just to note that the quote from the comment thread you referenced comes from a section that also says this:
The field-naming guidelines apply to static public and protected fields. Internal and private fields are not covered by guidelines
That doesn't change anything here, but it's not really telling us to avoid _ on our private fields.
How do you want to proceed with this? Should there be an issue that tracks the work being done over time, or is it just a case of fix-it-as-we-go? I'd be happy to start working through some of the topics to make the change, if that's useful.
FWIW, I can see it being reasonable to keep the _ for the usual private fields, but drop it for the @code sections you mention, cos that doesn't really look like it's part of a class in the same way. I do say that as someone that hasn't worked with Blazor, though.
I don't recommend a tracking issue. It would be kind'a silly given that it would likely never be closed. 馃槃 It's going to take many months (_years?_ 馃檲) to get them all updated.
are not covered by guidelines
Yes, but the product unit doesn't want them used. For same names used on private fields and vars passed into ctors; AFAICT, they want the this keyword used. Ryan said (publicly) that it's under "civil debate" as to how to handle it and that there are "camps" of devs who want to go one way or the other. 鈿旓笍 _Attaaaaack!!!!_ 鈿旓笍 lol ..... small war brewing there perhaps. 馃榿
Now ... after this morning's PR ... all Blazor examples and samples are off of underscores, and that consistency feels good. I really didn't care either way. I just want consistency.
We should avoid _ in the future but not take any action at this point.
Most helpful comment
We should avoid
_in the future but not take any action at this point.