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
17 changes: 17 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 @@ -496,6 +496,7 @@
- `System.Runtime.CompilerServices.AsyncMethodBuilderAttribute` ([§23.5.5](attributes.md#2355-the-asyncmethodbuilder-attribute)), which is used to establish a task builder for an async method.
- `System.Runtime.CompilerServices.CallerLineNumberAttribute` ([§23.5.6.2](attributes.md#23562-the-callerlinenumber-attribute)), `System.Runtime.CompilerServices.CallerFilePathAttribute` ([§23.5.6.3](attributes.md#23563-the-callerfilepath-attribute)), and `System.Runtime.CompilerServices.CallerMemberNameAttribute` ([§23.5.6.4](attributes.md#23564-the-callermembername-attribute)), which are used to supply information about the calling context to optional parameters.
- `System.Runtime.CompilerServices.EnumeratorCancellationAttribute` ([§23.5.8](attributes.md#2358-the-enumeratorcancellation-attribute)), which is used to specify parameter for the cancellation token in an asynchronous iterator.
- `System.Runtime.CompilerServices.ModuleInitializer` (§module-init-attr), which is used to mark a method as a module initializer.

The Nullable static analysis attributes ([§23.5.7](attributes.md#2357-code-analysis-attributes)) can improve the correctness of warnings generated for nullabilities and null states ([§8.9.5](types.md#895-nullabilities-and-null-states)).

Expand Down Expand Up @@ -1148,6 +1149,22 @@
>
> *end example*

### §module-init-attr The ModuleInitializer attribute

The attribute `ModuleInitializer` is used to mark a method as a ***module initializer***. Such a method is called during initialization of the containing module. A module may have multiple initializers, which are called in an implementation-defined order.

There are no limitations on what code is permitted in a module initializer.

A module initializer shall have the following characteristics:

- The *method_modifier* `static`.
- No *parameter_list*.
- A *return_type* of `void`.
- No *type_parameter_list*.
- Not be declared inside a *class_declaration* having a *type_parameter_list*.
- Be accessible from the containing module (that is, have an access modifier `internal` or `public`).
- Not be a local function.

## 23.6 Attributes for interoperation

For interoperation with other languages, an indexer may be implemented using indexed properties. If no `IndexerName` attribute is present for an indexer, then the name `Item` is used by default. The `IndexerName` attribute enables a developer to override this default and specify a different name.
Expand Down
1 change: 1 addition & 0 deletions standard/portability-issues.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ A conforming implementation is required to document its choice of behavior in ea
1. The impact of thread termination when a thread has no handler for an exception, and the thread is itself terminated. ([§13.10.6](statements.md#13106-the-throw-statement))
1. The mechanism by which linkage to an external method is achieved. ([§15.6.8](classes.md#1568-external-methods))
1. The impact of thread termination when no matching `catch` clause is found for an exception and the code that initially started that thread is reached. ([§22.4](exceptions.md#224-how-exceptions-are-handled)).
1. The order of execution of module initializers in a module (§module-init-attr).
1. An execution environment may provide additional attributes that affect the execution of a C# program. ([§23.5.1](attributes.md#2351-general))
1. The mappings between pointers and integers. ([§24.5.1](unsafe-code.md#2451-general))
1. The effect of applying the unary `*` operator to a `null` pointer. ([§24.6.2](unsafe-code.md#2462-pointer-indirection))
Expand Down
7 changes: 7 additions & 0 deletions standard/standard-library.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
The standard library is intended to be the minimum set of types and members required by a conforming C# implementation. As such, it contains only those members that are explicitly required by the C# language specification.

It is expected that a conforming C# implementation will supply a significantly more extensive library that enables useful programs to be written. For example, a conforming implementation might extend this library by

Check warning on line 14 in standard/standard-library.md

View workflow job for this annotation

GitHub Actions / Markdown to Word Converter

standard/standard-library.md#L14

MDC032::Line length 86 > maximum 81
- Adding namespaces.
- Adding types.
- Adding members to non-interface types.
Expand Down Expand Up @@ -162,7 +162,7 @@
{
public InvalidCastException();
public InvalidCastException(string? message);
public InvalidCastException(string? message, Exception? innerException);

Check warning on line 165 in standard/standard-library.md

View workflow job for this annotation

GitHub Actions / Markdown to Word Converter

standard/standard-library.md#L165

MDC032::Line length 82 > maximum 81
}

public class InvalidOperationException : Exception
Expand Down Expand Up @@ -210,7 +210,7 @@
AttributeTargets.Property | AttributeTargets.Field |
AttributeTargets.Event | AttributeTargets.Delegate, Inherited = false)]
public sealed class ObsoleteAttribute : Attribute
{

Check warning on line 213 in standard/standard-library.md

View workflow job for this annotation

GitHub Actions / Markdown to Word Converter

standard/standard-library.md#L213

MDC032::Line length 82 > maximum 81
public ObsoleteAttribute();
public ObsoleteAttribute(string? message);
public ObsoleteAttribute(string? message, bool error);
Expand All @@ -219,7 +219,7 @@
}

public class OutOfMemoryException : Exception
{

Check warning on line 222 in standard/standard-library.md

View workflow job for this annotation

GitHub Actions / Markdown to Word Converter

standard/standard-library.md#L222

MDC032::Line length 87 > maximum 81
public OutOfMemoryException();
public OutOfMemoryException(string? message);
public OutOfMemoryException(string? message, Exception? innerException);
Expand Down Expand Up @@ -279,7 +279,7 @@

namespace System.Collections
{
public interface ICollection : IEnumerable

Check warning on line 282 in standard/standard-library.md

View workflow job for this annotation

GitHub Actions / Markdown to Word Converter

standard/standard-library.md#L282

MDC032::Line length 82 > maximum 81
{
int Count { get; }
bool IsSynchronized { get; }
Expand Down Expand Up @@ -346,7 +346,7 @@
}
}

namespace System.Diagnostics

Check warning on line 349 in standard/standard-library.md

View workflow job for this annotation

GitHub Actions / Markdown to Word Converter

standard/standard-library.md#L349

MDC032::Line length 87 > maximum 81
{
[AttributeUsageAttribute(AttributeTargets.Method | AttributeTargets.Class,
AllowMultiple = true)]
Expand Down Expand Up @@ -494,7 +494,7 @@
/// Indicates whether the current Index value is
/// equal to another Index value.
/// </summary>
/// <param name="other">

Check warning on line 497 in standard/standard-library.md

View workflow job for this annotation

GitHub Actions / Markdown to Word Converter

standard/standard-library.md#L497

MDC032::Line length 85 > maximum 81
/// The value to compare with this Index.
/// </param>
public bool Equals(Index other);
Expand Down Expand Up @@ -829,6 +829,12 @@
void OnCompleted(Action continuation);
}

[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public sealed class ModuleInitializerAttribute : Attribute
{
public ModuleInitializerAttribute() { }
}

public readonly struct TaskAwaiter : ICriticalNotifyCompletion,
INotifyCompletion
{
Expand Down Expand Up @@ -1382,6 +1388,7 @@
- `global::System.Runtime.CompilerServices.ICriticalNotifyCompletion`
- `global::System.Runtime.CompilerServices.IndexerNameAttribute`
- `global::System.Runtime.CompilerServices.INotifyCompletion`
- `global::System.Runtime.CompilerServices.ModuleInitializerAttribute`
- `global::System.Runtime.CompilerServices.TaskAwaiter`
- `global::System.Runtime.CompilerServices.TaskAwaiter<TResult>`
- `global::System.Runtime.CompilerServices.ValueTaskAwaiter`
Expand Down
Loading