Open
Description
A number of C# tokens have different semantics depending on where they appear in the syntax tree. Historically, these tokens have gone to a page for the token, and the reader needs to select a link to the page with the correct content. We can do better. Here are the tokens that have multiple uses, the current page, and the list of uses for that token:
-
class
: goes to class declaration page.- declare a class
- specify the class constraint on a generic type parameter.
-
default
: goes to a landing page to select the use.- default label of a
switch
statement - default operator or default literal.
- default label of a
-
enum
: destination describes declaring an enum.- declare an
enum
type - generic constraint where the base type must be an
enum
(derived fromSystem.Enum
)
- declare an
-
in
: destination is a landing page for user to decide.- specify contravariance in a generic type parameter
- parameter or argument modifier, meaning pass by read-only reference
in
as part of aforeach
statement.- part of a
from
clause in a LINQ query expression - part of a
join
clause in a LINQ query expression
-
internal
: destination is the page forinternal
access.internal
access- part of
protected internal
access
-
new
: goes to thenew
expression page, with a link to the method modifier.- new expressions
- new method declaration modifier
new
constraint on generic type parameter
-
out
: landing page for the user to specify- specify covariance on a generic type parameter
- parameter or argument modifier meaning pass by reference, set by called method
-
private
: goes toprivate
access modifierprivate
access- part of
private protected
access modifier
-
protected
: goes to the protected access modifierprotected
access- part of
protected internal
access - part of
private protected
access
-
ref
: goes to the page forref
parameter / argument modifier,ref
return andref
local. Page has link toref struct
usage.ref
parameter / argument modifierref
return valueref
local variable.ref
struct declaration
-
static
page goes to static modifier on class, field, method, local function, or lambda declarationstatic
modifier.- part of the
using static
directive.
-
struct
: page goes tostruct
declarations (which includesref struct
andreadonly struct
.- declare a struct
- specify the
struct
constraint on a generic type parameter.
-
this
page is forthis
referring to the current instance of a type- refer to the current instance of a type
- parameter modifier for first argument of an extension method
-
using
goes to a landing page for different uses.using
directive-
using static
directive using
statement
-
partial
: already has separate pages for type and methodpartial
typepartial
method
-
where
: already has separate pages for both usageswhere
LINQ query expressionwhere
generic constraint
The readonly
modifier can be used in different contexts, but the meaning is generally the same. It makes sense to keep them on one page.
The first step would be to add F1 token meta data for all the correct destination pages. Then, the Visual Studio IDE could update its F1 source to send readers to the updated pages.