Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion standard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
- [§6.5.9](lexical-structure.md#659-nullable-directive) Nullable directive
- [§6.5.10](lexical-structure.md#6510-pragma-directives) Pragma directives
- [§7](basic-concepts.md#7-basic-concepts) Basic concepts
- [§7.1](basic-concepts.md#71-application-startup) Application startup
- [§7.1](basic-concepts.md#71-application-startup-and-termination) Application startup
- [§7.2](basic-concepts.md#72-application-termination) Application termination
- [§7.3](basic-concepts.md#73-declarations) Declarations
- [§7.4](basic-concepts.md#74-members) Members
Expand Down
2 changes: 2 additions & 0 deletions standard/attributes.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 23 Attributes

## 23.1 General

Check warning on line 4 in standard/attributes.md

View workflow job for this annotation

GitHub Actions / Markdown to Word Converter

standard/attributes.md#L4

MDC032::Line length 86 > maximum 81
Much of the C# language enables the programmer to specify declarative information about the entities defined in the program. For example, the accessibility of a method in a class is specified by decorating it with the *method_modifier*s `public`, `protected`, `internal`, and `private`.

C# enables programmers to invent new kinds of declarative information, called ***attribute***s. Programmers can then attach attributes to various program entities, and retrieve attribute information in a run-time environment.
Expand Down Expand Up @@ -833,6 +833,8 @@

If a function invocation from a location within the body of a function member or within an attribute applied to the function member itself or its return type, parameters or type parameters in source code omits an optional parameter with the `CallerMemberNameAttribute`, then a string literal representing the name of that member is used as an argument to the invocation instead of the default parameter value.

> *Note*: In the case of a function invocation from a top-level statement the string is a representation of the implementation provided name (§using-top-level-statements). *end note*

For invocations that occur within generic methods, only the method name itself is used, without the type parameter list.

For invocations that occur within explicit interface member implementations, only the method name itself is used, without the preceding interface qualification.
Expand Down
141 changes: 112 additions & 29 deletions standard/basic-concepts.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions standard/classes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@
## 15.1 General

A class is a data structure that may contain data members (constants and fields), function members (methods, properties, events, indexers, operators, instance constructors, finalizers, and static constructors), and nested types. Class types support inheritance, a mechanism whereby a ***derived class*** can extend and specialize a ***base class***.

Check warning on line 6 in standard/classes.md

View workflow job for this annotation

GitHub Actions / Markdown to Word Converter

standard/classes.md#L6

MDC032::Line length 83 > maximum 81
Structs ([§16](structs.md#16-structs)) and interfaces ([§19](interfaces.md#19-interfaces)) have members similar to classes but with certain restrictions. This clause defines the declarations for classes and class members. The clauses for structs and interfaces define the restrictions for those types in terms of the corresponding declarations in class types.

## 15.2 Class declarations

Check warning on line 10 in standard/classes.md

View workflow job for this annotation

GitHub Actions / Markdown to Word Converter

standard/classes.md#L10

MDC032::Line length 83 > maximum 81
### 15.2.1 General

Check warning on line 12 in standard/classes.md

View workflow job for this annotation

GitHub Actions / Markdown to Word Converter

standard/classes.md#L12

MDC032::Line length 87 > maximum 81
A *class_declaration* is a *type_declaration* ([§14.7](namespaces.md#147-type-declarations)) that declares a new class.

```ANTLR
class_declaration

Check warning on line 16 in standard/classes.md

View workflow job for this annotation

GitHub Actions / Markdown to Word Converter

standard/classes.md#L16

MDC032::Line length 86 > maximum 81
: attributes? class_modifier* 'partial'? 'class' identifier
type_parameter_list? class_base? type_parameter_constraints_clause*

Check warning on line 18 in standard/classes.md

View workflow job for this annotation

GitHub Actions / Markdown to Word Converter

standard/classes.md#L18

MDC032::Line length 84 > maximum 81
class_body ';'?
;

Check warning on line 20 in standard/classes.md

View workflow job for this annotation

GitHub Actions / Markdown to Word Converter

standard/classes.md#L20

MDC032::Line length 82 > maximum 81
```

A *class_declaration* consists of an optional set of *attributes* ([§23](attributes.md#23-attributes)), followed by an optional set of *class_modifier*s ([§15.2.2](classes.md#1522-class-modifiers)), followed by an optional `partial` modifier ([§15.2.7](classes.md#1527-partial-type-declarations)), followed by the keyword `class` and an *identifier* that names the class, followed by an optional *type_parameter_list* ([§15.2.3](classes.md#1523-type-parameters)), followed by an optional *class_base* specification ([§15.2.4](classes.md#1524-class-base-specification)), followed by an optional set of *type_parameter_constraints_clause*s ([§15.2.5](classes.md#1525-type-parameter-constraints)), followed by a *class_body* ([§15.2.6](classes.md#1526-class-body)), optionally followed by a semicolon.

A class declaration shall not supply *type_parameter_constraints_clause*s unless it also supplies a *type_parameter_list*.

A class declaration that supplies a *type_parameter_list* is a generic class declaration. Additionally, any class nested inside a generic class declaration or a generic struct declaration is itself a generic class declaration, since type arguments for the containing type shall be supplied to create a constructed type ([§8.4](types.md#84-constructed-types)).

Check warning on line 27 in standard/classes.md

View workflow job for this annotation

GitHub Actions / Markdown to Word Converter

standard/classes.md#L27

MDC032::Line length 82 > maximum 81

### 15.2.2 Class modifiers

Expand Down Expand Up @@ -3083,7 +3083,7 @@

- Expressions occurring as part of an invocation of `M` do not affect the definite assignment state ([§9.4](variables.md#94-definite-assignment)), which can potentially lead to compile-time errors.

- `M` cannot be the entry point for an application ([§7.1](basic-concepts.md#71-application-startup)).
- `M` cannot be the entry point for an application ([§7.1](basic-concepts.md#71-application-startup-and-termination)).

Partial methods are useful for allowing one part of a type declaration to customize the behavior of another part, e.g., one that is generated by a tool. Consider the following partial class declaration:

Expand Down Expand Up @@ -5154,7 +5154,7 @@
- An instance of the class is created.
- Any of the static members of the class are referenced.

If a class contains the `Main` method ([§7.1](basic-concepts.md#71-application-startup)) in which execution begins, the static constructor for that class executes before the `Main` method is called.
If a class contains the application entry point ([§7.1](basic-concepts.md#71-application-startup-and-termination)) the static constructor for that class executes before the entry point is called.

To initialize a new closed class type, first a new set of static fields ([§15.5.2](classes.md#1552-static-and-instance-fields)) for that particular closed type shall be created. Each of the static fields shall be initialized to its default value ([§15.5.5](classes.md#1555-field-initialization)). Following this:

Expand Down
4 changes: 2 additions & 2 deletions standard/interfaces.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 19 Interfaces

## 19.1 General

Check warning on line 3 in standard/interfaces.md

View workflow job for this annotation

GitHub Actions / Markdown to Word Converter

standard/interfaces.md#L3

MDC032::Line length 86 > maximum 81

An interface defines a contract. A class or struct that implements an interface shall adhere to its contract. An interface may inherit from multiple base interfaces, and a class or struct may implement multiple interfaces.

Expand Down Expand Up @@ -487,14 +487,14 @@
The static constructor for a closed ([§8.4.3](types.md#843-open-and-closed-types)) interface executes at most once in a given application domain. The execution of a static constructor is triggered by the first of the following actions to occur within an application domain:

- Any of the static members of the interface are referenced.
- Before the `Main` method is called for an interface containing the `Main` method ([§7.1](basic-concepts.md#71-application-startup)) in which execution begins.
- Before the entry-point method is called for an interface containing the application entry-point method ([§7.1](basic-concepts.md#71-application-startup-and-termination)).
- That interface provides an implementation for a member, and that implementation is accessed as the most specific implementation ([§19.4.10](interfaces.md#19410-most-specific-implementation)) for that member.

> *Note*: In the case where none of the preceding actions take place, the static constructor for an interface may not execute for a program where instances of types that implement the interface are created and used. *end note*

To initialize a new closed interface type, first a new set of static fields for that particular closed type is created. Each of the static fields is initialized to its default value. Next, the static field initializers are executed for those static fields. Finally, the static constructor is executed.

> *Note*: See [§19.4.2](interfaces.md#1942-interface-fields) for an example of using various kinds of static members (including a Main method) declared within an interface. *end note*
> *Note*: See [§19.4.2](interfaces.md#1942-interface-fields) for an example of using various kinds of static members (including an entry-point method) declared within an interface. *end note*

### 19.4.9 Interface nested types

Expand Down
16 changes: 9 additions & 7 deletions standard/namespaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,26 @@ Using directives ([§14.5](namespaces.md#145-using-directives)) are provided to

## 14.2 Compilation units

A *compilation_unit* consists of zero or more *extern_alias_directive*s followed by zero or more *using_directive*s followed by zero or one *global_attributes* followed by zero or more *namespace_member_declaration*s. The *compilation_unit* defines the overall structure of the input.
A C# program consists of one or more compilation units. When a C# program is compiled, all of the compilation units are processed together. Thus, compilation units can depend on each other, possibly in a circular fashion.

The structure of a single compilation unit is defined by *compilation_unit*:

```ANTLR
compilation_unit
: extern_alias_directive* using_directive* global_attributes?
namespace_member_declaration*
statement_list? namespace_member_declaration*
;
```

A C# program consists of one or more compilation units. When a C# program is compiled, all of the compilation units are processed together. Thus, compilation units can depend on each other, possibly in a circular fashion.
The *extern_alias_directive*s ([§14.4](namespaces.md#144-extern-alias-directives)) of a compilation unit affect the *using_directive*s, *global_attributes* and *namespace_member_declaration*s of that compilation unit, but have no effect on other compilation units.

The *extern_alias_directive*s of a compilation unit affect the *using_directive*s, *global_attributes* and *namespace_member_declaration*s of that compilation unit, but have no effect on other compilation units.

The *using_directive*s of a compilation unit affect the *global_attributes* and *namespace_member_declaration*s of that compilation unit, but have no effect on other compilation units.
The *using_directive*s ([§14.5](namespaces.md#145-using-directives)) of a compilation unit affect the *global_attributes* and *namespace_member_declaration*s of that compilation unit, but have no effect on other compilation units.

The *global_attributes* ([§23.3](attributes.md#233-attribute-specification)) of a compilation unit permit the specification of attributes for the target assembly and module. Assemblies and modules act as physical containers for types. An assembly may consist of several physically separate modules.

The *namespace_member_declaration*s of each compilation unit of a program contribute members to a single declaration space called the global namespace.
The optional *statement_list* ([§13.3.2](statements.md#1332-statement-lists)) specifies statements to be used as an application entry point (§using-top-level-statements). Only one compilation unit in a program may contain a *statement_list*.

The *namespace_member_declaration*s ([§14.6](namespaces.md#146-namespace-member-declarations)) of each compilation unit of a program contribute members to a single declaration space called the global namespace.

> *Example*:
>
Expand Down
11 changes: 6 additions & 5 deletions standard/portability-issues.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ A conforming implementation is required to document its choice of behavior in ea
1. The behavior when an identifier not in Normalization Form C is encountered. ([§6.4.3](lexical-structure.md#643-identifiers))
1. The maximum value allowed for `Decimal_Digit+` in `PP_Line_Indicator`. ([§6.5.8](lexical-structure.md#658-line-directives))
1. The interpretation of the *input_characters* in the *pp_pragma-text* of a #pragma directive. ([§6.5.10](lexical-structure.md#6510-pragma-directives))
1. The values of any application parameters passed to `Main` by the host environment prior to application startup. ([§7.1](basic-concepts.md#71-application-startup))
1. The mechanism for determining whether a program is compiled as a class library or as an application. ([§7.1](basic-concepts.md#71-application-startup))
1. The policy or mechanisms used by an implementation for the creation and destruction of application domains. ([§7.1](basic-concepts.md#71-application-startup))
1. The exit code if the effective entry point method terminates due to an exception. ([§7.2](basic-concepts.md#72-application-termination))
1. Whether or not finalizers are run as part of application termination. ([§7.2](basic-concepts.md#72-application-termination), [§7.9](basic-concepts.md#79-automatic-memory-management))
1. The values of any application parameters passed to the application entry-point method by the host environment prior to application startup. ([§7.1](basic-concepts.md#71-application-startup-and-termination))
1. The mechanism for determining whether a program is compiled as a class library or as an application. ([§7.1](basic-concepts.md#71-application-startup-and-termination))
1. The policy or mechanisms used by an implementation for the creation and destruction of application domains. ([§7.1](basic-concepts.md#71-application-startup-and-termination))
1. The exit code if the application terminates due to an exception. ([§7.1](basic-concepts.md#71-application-startup-and-termination))
1. Whether or not finalizers are run as part of application termination. ([§7.1](basic-concepts.md#71-application-startup-and-termination), [§7.9](basic-concepts.md#79-automatic-memory-management))
1. Whether APIs allow a finalizer to be run more than once. ([§7.9](basic-concepts.md#79-automatic-memory-management))
1. The API surface provided by `Expression<TDelegate>` beyond the requirement for a `Compile` method. ([§8.6](types.md#86-expression-tree-types))
1. The precise structure of the expression tree, as well as the exact process for creating it, when an anonymous function is converted to an expression-tree. ([§10.7.3](conversions.md#1073-evaluation-of-lambda-expression-conversions-to-expression-tree-types))
Expand All @@ -53,6 +53,7 @@ A conforming implementation is required to document its choice of behavior in ea

## B.4 Unspecified behavior

1. The name of the entry-point method generated to contain top-level statements (§using-top-level-statements).
1. The time at which the finalizer (if any) for an object is run, once that object has become eligible for finalization ([§7.9](basic-concepts.md#79-automatic-memory-management)).
1. The representation of `true` ([§8.3.9](types.md#839-the-bool-type)).
1. The value of the result when converting out-of-range values from `float` or `double` values to an integral type in an `unchecked` context ([§10.3.2](conversions.md#1032-explicit-numeric-conversions)).
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Sample: Top-level statements

Simple sample which uses top-level statements, calls `Main`, and displays the compiler-generated name for the TLS method.
Loading
Loading