Skip to content

Instantly share code, notes, and snippets.

@BillWagner
Last active August 29, 2019 01:11
Show Gist options
  • Save BillWagner/047cb97f6c0fe542d3a1299e994b2acd to your computer and use it in GitHub Desktop.
Save BillWagner/047cb97f6c0fe542d3a1299e994b2acd to your computer and use it in GitHub Desktop.
Proposed new TOC for the C# Guide

Notes

Important: This is a point-in-time snapshot of background work used to create a formal plan. The updated issues in the docs repo more accurately reflect the plan.

Using this resource:

  • Consider the H2s as a good roadmap for where content should go.
  • Consider lower level headers inasmuch as they show where existing articles will move over time.
  • Articles will be combined and archived to keep the C# guide current.

The H2s are:

  • Get Started. This node focuses on the top tasks for those customers that are new to software development, or new to .NET and C#. It focuses on the core skills every C# developer needs to know, regardless of the workload or application they intend to build. It's heavily tilted toward introductory tutorials and beginner concepts. The articles are
  • What's new. This node is one of the most visited for those customers that are already using the .NET platform. It's the entry point to explore new features and new scenarios supported by the C# language. One of the key learnings from Ignite 2018 was that existing customers are not aware of recent improvements, many of which are aimed cloud scenarios. This project describes some of the work already done to increase awareness for these capabilities and scenarios.
  • Task asynchronous programming model. The TAP programming model has generated more issues and requests than any other area of the C# language. Locating all the information about TAP under a single TOC node enables customers to find this information quickly and easily.
  • Language Integrated Query (LINQ). LINQ remains one of the key value propositions for choosing the C# programming language. This H2 highlights this programming model for developers examining .NET for possible adoption.
  • Advanced. These techniques are specialized areas that apply to only some scenarios. Separating them from more common scenarios shields inexperienced developers from finding these scenarios until needed. We do need to publish these techniques because many of our key enterprise customers depend on these advanced scenarios.
  • .NET Compiler platform SDK. This is a large advanced SDK that enables partners and OSS library developers to ship tools that analyze code and offer suggestions. The content is primarily written by the product team.
  • Abridged reference. The abridged reference provides readers with "the flavor" of each feature, without providing all the details in the specification. This area concentrates on informative text, where the specification concentrates on normative text. For historical reasons, the current reference branched from the C# specification at version 2.0. Since then, the reference has added more informative text, while retaining the fork of the normative text. The result is significant duplication and numerous inconsistencies between the language reference and the specification. This separation addresses both of those concerns.
  • Specifications and proposals. The latest approved ECMA specification is C# 5.0. We publish the C# 6.0 draft, maintained by the product team. This draft will be submitted to the ECMA committee soon for adoption. The committee will determine if they want to work on C# 6 as a standard, or skip to C# 7.0. (Note: Bill is one of the members of the C# ECMA standards committee.) Microsoft has already shipped C# 7.0, 7.1, 7.2, 7.3, and C# 8.0 preview 2. For that reason, we are publishing the draft proposals for the features in those versions. We can link to them from other areas of the C# guide to direct users for detailed reference information.

The C# Guide is existing published content. This TOC represents a significant re-organization and consolidation of existing content, along with new content that addresses modern scenarios. The proposed TOC contains links where the nodes represent existing content. Nodes that include the wrench icon (🔧) represent new articles. Nodes with neither represent articles that will be created based on existing content. The TOC below has more depth where existing content is used.

Major sections are being re-organized out of existence in this proposed TOC:

  • C# Concepts (primarily moved to the "get started" task.)
  • Programming Guide (This section contains several subsections, numbering more than 500 articles)
  • How To Guides (The existing How to articles are short, focused answers, somewhat different from the C & AI How To articles)
  • Walkthroughs (Primarily moving to "tutorials" in different sections.)

Of these three, the "How To" section is the most interesting. In the proposed TOC, these articles are moved to the appropriate H2 by task. They are keeping the "How to" branding, even though these aren't strictly following the APEX content model definition of a "How to". We haven't found a more accurate term. Titles and H1's will be updated to focus more on the scenario / task, and less on the feature. (For example, "How to: use expression trees to make dynamic queries" will likely change to something similar to "How to dynamically query data sources using expression trees".) The existing titles are used in this TOC to provide a better roadmap on existing content.

The updated TOC with notes follows. The TOC is in markdown format to facilitate links to existing source, and provide an easier way to browse the outline.

C# Guide

🔧 Get Started

Tour of the C# Language

🔧 C# and the .NET environment

🔧 Structure of a C# program

🔧 The C# typesystem

🔧 Query data sources with LINQ

🔧 Error reporting and handling with exceptions

🔧 Common workloads

  • one page that points to other guides for .NET Core based workloads (ASP.NET, WPF, Windows Forms, etc).

Object Oriented techniques

Encapsulation

Abstraction

Inheritance

Polymorphism

Lambda expressions

Delegates and callbacks

Events

Errors and Exceptions

What's new in C#

Tutorials

🔧 Fundamental concepts

🔧 The .NET and C# memory model

🔧 API design for classes and NuGet packages

🔧 Reuse code with inheritance

🔧 Promote independence with generics

🔧 Create outbound interfaces with delegates and events

Update your skills

🔧 Explore C# 7 interactively

🔧 Explore C# 7.1 interactively

🔧 Explore C# 7.2 interactively

🔧 Explore C# 7.3 interactively

🔧 Explore C# 8 interactively

🔧 Implement data related algorithms using pattern matching

🔧 Explore common workloads

🔧 Create your first .NET Core console application

🔧 Create your first ASP.NET Core web application

🔧 Create your first .NET Core Azure function

🔧 Create your first Xamarin mobile application

🔧 Create your first NET Core Windows Forms application

🔧 Create your first NET Core WPF application

Language Integrated Query (LINQ)

🔧 Query relational data sources

  • Tutorial will use EF Core.

🔧 Query cloud based data sources

  • This is likely multiple tutorials for each Azure based storage model where the API includes a LINQ provider.

Asynchronous Programming

🔧 Introduction to async / await and Task

🔧 Composition of Tasks

🔧 Client / mobile async scenario

  • all about keeping the UI responsive

🔧 Server and cloud async scenario

  • all about not blocking threads for scale out

🔧 Reporting and handling asynchronous esceptions

Task asynchronous programming model

This is a stacked TOC H1. The compiler platform SDK is specialized use of the compiler APIs to write static analysis tools.

Overview

  • PR open for an updated overview.

Tutorials

🔧 Introduction to async / await and Task

🔧 Composition of Tasks

🔧 Client / mobile async scenario

  • all about keeping the UI responsive

🔧 Server and cloud async scenario

  • all about not blocking threads for scale out

🔧 Reporting and handling asynchronous exceptions

Concepts

Async vs. multi-threaded programming

  • where we explain that locks are often not needed for asyn

How-To

  • Short focused answers toc common async questions. Examples include WhenAll vs. WhenAny, when to use ConfigureAwait, when to consider ContinueWith, when to use ValueTask, and so on.

This is a stacked TOC H1. LINQ is a major set of language features and APIs that enables querying data sources. It uses its own techniques and style.

Overview

####Query expression basics ####LINQ in C#

Tutorials

🔧 Query relational data sources

  • Tutorial will use EF Core.

🔧 Query cloud based data sources

  • This is likely multiple tutorials for each Azure based storage model where the API includes a LINQ provider.

Concepts

How-to

  • This section catalogs the current content of short samples and how to content. Many of these are likely cancidates for consolidation or archival.

Advanced

🔧 Performance considerations

🔧 Overview

🔧 Boxing and unboxing

🔧 References and structures

🔧 Choose numeric type

🔧 Optimize memory usage

  • unsafe code and pointers
  • stack allocations
  • ref safe to escape

Overview

Examine assemblies and their metadata

These two existing article provide source material

Interop with native code

  • Cover all .NET Core platforms

🔧 Load and execute code at runtime

🔧 Generate code dynamically

This is a stacked TOC H1. The compiler platform SDK is specialized use of the compiler APIs to write static analysis tools.

Tutorials

🔧 Deploy your analyzer as a VSIX
🔧 Deploy your analyzer as a NuGet package
🔧 Async packages
🔧 Console classifier
🔧 Convert to auto property
🔧 Format solution
🔧 Implement notify property changed
🔧 Make const

Concepts

🔧 Syntax models explained
🔧 Semantic models explained
🔧 Transformations and immutable trees

Samples

The roslyn-analyzers project contains many analyzers and code fixes that ship with Visual Studio. this is a great resource to learn more about writing analyzers, code fixes, and refactorings. This article will provide information about those analyzers and links to the source.

🔧 Reference

The purpose of this section is for readers to find summary information on the C# language. As such, each topic is a short definition for the token, operator, statement or expression. A common scenario or two will be shown as a sample. Links direct those readers that want more detail to the spec or updated spec proposal.

🔧 Builtin types

🔧 Simple types

  • bool
  • enum

🔧 Numeric types

  • sbyte
  • byte
  • short
  • ushort
  • int
  • uint
  • long
  • ulong
  • char
  • decimal
  • float
  • double

🔧 Reference types

  • object
  • dynamic
  • string
  • array
  • delegate

🔧 Literal constants

  • null
  • true
  • false
  • default

🔧 Operators

🔧 Arithmetic operators

  • ++ (prefix and postfix)
  • -- (prefix and postfix)
  • + (unary and binary addition of numeric operands)
  • - (unary and binary subtraction of numeric operands)
  • * (multiplication)
  • / (division)
  • % (remainder)
  • corresponding compound assignment operators
  • checked/unchecked

🔧 Bitwise operations

  • & (bitwise AND for integral operands)
  • | (bitwise OR for integral operands)
  • ^ (bitwise exclusive-OR for integral operands)
  • ~ (bitwise negation)
  • << and >> (shift operators)
  • corresponding compound assignment operators

🔧 Logical operations (limited to bool)

  • & (logical AND for bool operands)
  • | (logical OR for bool operands)
  • ^ (logical exclusive-OR for bool operands)
  • ! (logical negation)
  • && and || (conditional logical AND and OR operators)
  • true and false operators (note: it's still might be a separate article on its own and only referenced from the overview)

🔧 Relational operators

  • < (less than)
  • > (greater than)
  • <= (less than or equal)
  • >= (greater than or equal)

🔧 Equality operators

  • == (equal)
  • != (not equal)

🔧 Pointer-related operators

  • & (address-of)
  • * (pointer indirection)
  • -> (pointer member access)

Pointer arithmetic with ++, --, +, and - might also be included into the overview.

🔧 Member access

  • . (member access)
  • [] (array or indexer access)
  • ?. and ?[] (null-conditional access)
  • () (method call)

🔧 Type testing, conversion and assignment

  • = (assignment)
  • ? (nullable) ! (null forgiveness)
  • typeof operator
  • (T) explicit cast

🔧 Pattern matching

  • is (and is with assignment)
  • as
  • switch expressions

🔧 Not-in-any-group operators

  • ? : (conditional operator). Somehow, it feels out of tune with the logical operators.
  • ?? (null coalescing). It also feels not in the logical operations group. Most probably, it's because I limit logical operations to those on bool operands.
  • +, += (string concatenation and delegate combination)
  • -, -= (delegate removal)
  • :: (namespace alias qualifier)
  • nameof
  • sizeof
  • await
  • => (lambda declaration)
  • @ string literal token
  • $ interpolated string token

🔧 Defining types, members and variables

🔧 Declaring types

  • namespace
  • class
  • struct
  • interface
  • partial (class and method)
  • where (generic constraint)
  • abstract
  • in / out (variance)
  • sealed
  • static

Includes discussion of boxing structs.

🔧 Declaring members

  • add / remove (event handlers)
  • get / set (properties and indexers)
  • value
  • partial (class and method)
  • where (generic constraint)
  • yield (iterator method)
  • void
  • var
  • abstract
  • async
  • const
  • event
  • extern
  • in / out (variance)
  • override
  • sealed
  • static
  • virtual
  • volatile
  • in / ref / out (parameter, local, return value)
  • stackalloc
  • unsafe
  • explicit, implicit
  • operator

Cover default value of variables

🔧 Controlling access

  • public
  • protected
  • internal
  • private
  • protected internal
  • private protected
  • readonly
  • base
  • this
  • using, static using
  • lock

🔧 Statements

🔧 Selection and jump statements

  • if / else
  • switch
  • break
  • continue
  • goto
  • return

🔧 Iteration statements

  • do
  • for
  • foreach, in
  • while

🔧 Exception statements

  • throw
  • try / catch
  • try / finally
  • try / catch / finally
  • when (exception filter)

🔧 LINQ query expressions

  • from
  • where
  • select
  • group
  • into
  • orderby / ascending / descending
  • join
  • let
  • on
  • equals
  • by
  • in

🔧 Conversions

  • Implicit conversions
  • Explicit conversions
  • Standard conversions
  • User-defined conversions
  • Anonymous function conversions
  • Method group conversions

🔧 Attributes

  • Attribute classes
  • Attribute specification
  • Attribute instances
  • Reserved attributes
  • Attributes for Interoperation

🔧 Unsafe code

  • Unsafe contexts
  • Pointer types
  • Fixed and moveable variables
  • Pointer conversions
  • Pointers in expressions
  • Fixed size buffers
  • Stack allocation
  • Dynamic memory allocation

🔧 Compiler options

The current TOC has a page for each option. (59 in total). I propose consolidating into one larger page and using H2s for each option:

Errors and warnings

Some of these are in the TOC, many are not. They are also in two folders: csharp/misc (793 files) and csharp/language-reference/compiler-messages.md (135 files). The articles have not been updated since version 5.0. There are roughly 700 errors and warnings that have not been documented. None of these pages get significant traffic, but the readers that land here do so because they are completely blocked. I propose the following:

  • Create one index page with a scoped search for message keys (e.g. CS5001)
  • Create and migrate pages to that single folder.
  • Only have the single index page in the TOC.

Note that adding currently undocumented messages is a P2 issue, and could be assigned to a vendor once this reorganization is done. See dotnet/docs#5410 for details.

C# language specification proposals

[C# 7.2: Non-trailing named arguments](https://github.com/dotnet/csharplang/blob/master/proposals/csharp-7.2/non-trailing named arguments.md)

🔧 Contribute

  • short one pager that directs people to the external contributor guide + the .NET specific pages in the external contributor guide.
@pkulikov
Copy link

@BillWagner my thoughts throughout reading this gist:

  • I like the fact that both C# concepts and C# programming guide sections disappear.

  • The Get started TOC item contains two similar nodes: "Error reporting and handling with exceptions" and "Errors and Exceptions". Is this intentional or an accident?

  • The Get started -> Object oriented techniques. What if to show another side as well by adding the article about functional programming approach? Latest tutorials about pattern matching seem to be more on a FP side.

  • I'm missing this tutorial on string interpolation. Though, it's more a how-to type article.

  • Async tutorials are duplicated: I see them in the Tutorials part and the Task asynchronous programming model section. The same comment applies to the LINQ tutorials. Is that by design to make those tutorials easier to find?

  • As for LINQ and TAP, shouldn't they be in the .NET guide? Now, the .NET guide doesn't contain a lot about LINQ, only this page: https://docs.microsoft.com/en-us/dotnet/standard/using-linq

    However, tasks and TPL have a bigger coverage there:
    https://docs.microsoft.com/en-us/dotnet/standard/parallel-programming/
    https://docs.microsoft.com/en-us/dotnet/standard/async-in-depth

    Definitely, both concepts should be mentioned in both guides. The question is which of the guides contains detailed coverage of the feature and which one serves as an introduction and a portal to another guide. Also, the Visual Basic guide covers those features as well.

  • By the way, is there a line between a how-to article and a tutorial. I guess, now, some tutorials might be renamed to how-to.

  • As for the C# reference, we've discussed earlier that the "simple types" term is taken, so better not to make an article about them that excludes numeric types. Conclusion was to have separate TOC nodes for both enum and bool. Also, for char, effectively removing it from the numeric types article.

  • I suggest one more article for the types section: Unmanaged types. That would contain the list of unmanaged types and refer to places where those types are used (pointer types, sizeof operator, unmanaged constraint (?)). Also, those places would refer to that article for the definition of an unmanaged type. Currently, this information is duplicated throughout the docs.

  • According to this issue the pattern matching operators are merged with assignment and conversion operators. Is it still the case and this gist a bit out-of-date? Or vice versa?

  • Not-in-any-group operators should include new (didn't find it in this TOC) and stackalloc (this one now in Declaring members)

  • The lock statement really stands out in its Controlling access group.

  • I didn't check all statements, but where do checked and unchecked statements (not operators) go?

@aprilspeight
Copy link

Hi Bill,

Thanks for sharing this with me. I have 3 areas of feedback:

  1. For someone new to the language, I'm not quite sure where to start if I came to our docs to learn. Should I read all the docs in 'Tour of the C# Language' first? Or do I hop right into the Tutorials? What is the path/journey that you want new learners to take?

  2. I would consider the articles under Tutorials > Introduction to C# to appear in 'Get Started' based on the description provided for that section (i.e. Get Started. This node focuses on the top tasks for those customers that are new to software development, or new to .NET and C#. It focuses on the core skills every C# developer needs to know, regardless of the workload or application they intend to build. It's heavily tilted toward introductory tutorials and beginner concepts.) Aren't the concepts covered in the Tutorials 'core skills'?

  3. What will become of the docs that are currently under A Tour of the C# Language? I'm assuming that 'Program Structure' becomes 'Structure of a C# Program'. But what about everything else?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment