Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In visual studio private variables have no _ #30626

Closed
andypoly opened this issue Aug 11, 2022 · 7 comments · Fixed by #36428
Closed

In visual studio private variables have no _ #30626

andypoly opened this issue Aug 11, 2022 · 7 comments · Fixed by #36428
Assignees
Labels
doc-enhancement Improve the current content [org][type][category] dotnet-csharp/svc fundamentals/subsvc Pri1 High priority, do before Pri2 and Pri3 📌 seQUESTered Identifies that an issue has been imported into Quest.

Comments

@andypoly
Copy link

andypoly commented Aug 11, 2022

You say here about using underscore on private and internal members (despite some dispute over the history of this).
Yet Visual Studio Community 2022 will not put an _ on private variables by default and converting an auto property to a full one with private member will simply use a lower case private variable as one would expect, but contrary to the tips here.

Is there a disconnect between Visual Studio team and the docs team here?


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.


Associated WorkItem - 123086

@dotnet-bot dotnet-bot added the ⌚ Not Triaged Not triaged label Aug 11, 2022
@PRMerger10 PRMerger10 added fundamentals/subsvc dotnet-csharp/svc Pri1 High priority, do before Pri2 and Pri3 labels Aug 11, 2022
@Youssef1313
Copy link
Member

See dotnet/roslyn#44699

@Youssef1313
Copy link
Member

Tagging @CyrusNajmabadi @sharwell to consider if Roslyn can/should change the default naming styles to match conventions.

@andypoly
Copy link
Author

hmm - yeah why would Microsoft's Visual Studio not have an option to enforce the naming convention they suggest for their language... without an editor config change...

@CyrusNajmabadi
Copy link
Member

Dotnet naming in no way represents the naming for the industry. Last time we looked (admittedly a few years back), camel cased variables was the norm. It wasn't even close. Personally, I think dotnet naming is super silly and literally how against our guidance around unnecessary sigils on identifiers. So I find it unlikely we would change here for this niche audience. If you want this naming convention, just specify it.

@BillWagner BillWagner added the doc-enhancement Improve the current content [org][type][category] label Aug 12, 2022
@dotnet-bot dotnet-bot removed the ⌚ Not Triaged Not triaged label Aug 12, 2022
@BillWagner
Copy link
Member

This is an area we should look at more holistically.

In general, our docs follow the dotnet/runtime coding style. We should update these articles to match that, and point liberally to the editorconfig section of the Visual Studio docs to enable each team to enforce their preferences.

@andypoly
Copy link
Author

Dotnet naming in no way represents the naming for the industry. Last time we looked (admittedly a few years back), camel cased variables was the norm. It wasn't even close. Personally, I think dotnet naming is super silly and literally how against our guidance around unnecessary sigils on identifiers. So I find it unlikely we would change here for this niche audience. If you want this naming convention, just specify it.

Actually my preferred solution is for Microsoft to drop their silly 2021 decision to bring in all the _ s_ t_ dotnet stuff, but bit late now! I don't want to use it, but many teams will want to follow the documented style.

@CyrusNajmabadi
Copy link
Member

Also, i have no issue with us shipping some sort of '.net naming' style that people could choose. Or an easy way to add all the right naming styles to an existing editorconfig.

I would just push back on any sort of step that made this the default for everyone if they moved to a new version of VS. This needs to be something people can opt-into, not something they're forced into that they need to opt-out of.

Thanks!

@amzwzw amzwzw mentioned this issue Sep 6, 2022
@dotnet dotnet deleted a comment from amzwzw Sep 6, 2022
@BillWagner BillWagner self-assigned this Jun 30, 2023
@BillWagner BillWagner added the 🗺️ reQUEST Triggers an issue to be imported into Quest. label Jun 30, 2023
@github-actions github-actions bot added 📌 seQUESTered Identifies that an issue has been imported into Quest. and removed 🗺️ reQUEST Triggers an issue to be imported into Quest. labels Jul 1, 2023
BillWagner added a commit to BillWagner/docs that referenced this issue Jul 27, 2023
Fixes dotnet#30626: Clarify (again) that these are our guidelines, not yours. Point out that it's not the VS default, but a configuration option.
Fixes dotnet#30642: Again, our style.
Fixes dotnet#30799: Change constant style from ALL_CAPS to PascalCase to match runtime repo.
Fixes dotnet#33959: Update variable names so delegate types are PascalCased and instances of a delegate are camelCase. Add clarifying text for the same.
@ghost ghost added the in-pr This issue will be closed (fixed) by an active pull request. label Jul 27, 2023
IEvangelist added a commit that referenced this issue Jul 31, 2023
* rearrange content

Make the new content organization follow better ordering.

* rewrite and update

Rewrite to match the docs team's accepted style.

* Edits to fix `var` issues

Fixes #26787: clarify "obvious"
Fixes #32633: add explanation, update variable names.
Fixes #34940: Explain that `var` is preferred in LINQ queries, despite other rules.

* Fix naming conventions

Fixes #30626: Clarify (again) that these are our guidelines, not yours. Point out that it's not the VS default, but a configuration option.
Fixes #30642: Again, our style.
Fixes #30799: Change constant style from ALL_CAPS to PascalCase to match runtime repo.
Fixes #33959: Update variable names so delegate types are PascalCased and instances of a delegate are camelCase. Add clarifying text for the same.

* Fix exception example

Fixes #31951 : Rewrite the exception example so that it's still obvious what can fail, but couldn't be easily anticipated before making the computation.

* Fixes #30897

Move the Generic type parameter naming conventions to the general naming conventions.

* Fix build warnings

* Reference runtime convention

The use of `_` and `s_` follow the runtime conventions. I'd missed that in the previous commit.

* Apply suggestions from code review

Co-authored-by: David Pine <[email protected]>

---------

Co-authored-by: David Pine <[email protected]>
@ghost ghost removed the in-pr This issue will be closed (fixed) by an active pull request. label Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-enhancement Improve the current content [org][type][category] dotnet-csharp/svc fundamentals/subsvc Pri1 High priority, do before Pri2 and Pri3 📌 seQUESTered Identifies that an issue has been imported into Quest.
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

6 participants