dotnet / docs

This repository contains .NET Documentation.
https://learn.microsoft.com/dotnet
Creative Commons Attribution 4.0 International
4.27k stars 5.9k forks source link

Relate coding conventions to diagnostics and editorconfig settings #33341

Open BillWagner opened 1 year ago

BillWagner commented 1 year ago

This article contains a set of guidelines that have different levels of adoption across the C# community. Some are almost universal (interfaces start with a capital I). Some are more common, but not universal (starting fields with _). Some have fallen out of favor in recent times.

This page needs to be updated to reflect current styles.

Furthermore, we should categorize coding conventions to the kinds of diagnostics available:

In addition, we should reference the preferred style used by the runtime. That's a common style seen by .NET developers browsing our source, and it's generally consistent with what we use in docs.


Document Details

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


Associated WorkItem - 58354

BillWagner commented 1 year ago

While doing this work, note that this article has a recommendation that local functions should be PascalCased. That's the current recommendation, because they are methods. However, the justification is that they are "public", like classes, interfaces and structs. That justification is incorrect.

We've generally preferred PascalCasing for methods because we chose PascalCase for all methods, regardless of access. We think of local functions as functions first. The fact they their scope is local is less important for the name.