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
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 @@ -953,11 +954,11 @@
> ```csharp
> #nullable enable
> public class X
> {

Check warning on line 957 in standard/attributes.md

View workflow job for this annotation

GitHub Actions / Markdown to Word Converter

standard/attributes.md#L957

MDC032::Line length 86 > maximum 81
> private void ThrowIfNull([DoesNotReturnIf(true)] bool isNull, string argumentName)
> {
> if (!isNull)
> {

Check warning on line 961 in standard/attributes.md

View workflow job for this annotation

GitHub Actions / Markdown to Word Converter

standard/attributes.md#L961

MDC032::Line length 96 > maximum 81
> throw new ArgumentException(argumentName, $"argument {argumentName} can't be null");
> }
> }
Expand Down Expand Up @@ -1003,7 +1004,7 @@
>
> <!-- Example: {template:"code-in-class-lib", name:"NotNullAttribute"} -->
> ```csharp
> #nullable enable

Check warning on line 1007 in standard/attributes.md

View workflow job for this annotation

GitHub Actions / Markdown to Word Converter

standard/attributes.md#L1007

MDC032::Line length 89 > maximum 81
> public static void ThrowWhenNull([NotNull] object? value, string valueExpression = "") =>
> _ = value ?? throw new ArgumentNullException(valueExpression);
>
Expand Down Expand Up @@ -1085,7 +1086,7 @@
> }
> }
> }
>

Check warning on line 1089 in standard/attributes.md

View workflow job for this annotation

GitHub Actions / Markdown to Word Converter

standard/attributes.md#L1089

MDC032::Line length 103 > maximum 81
> static async IAsyncEnumerable<string> GetStringsAsync([EnumeratorCancellation] CancellationToken token)
> {
> for (int i = 0; i < 10; i++)
Expand All @@ -1099,6 +1100,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 @@ -44,6 +44,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 @@ -190,7 +190,7 @@
public class NullReferenceException : Exception
{
public NullReferenceException();
public NullReferenceException(string? message);

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

View workflow job for this annotation

GitHub Actions / Markdown to Word Converter

standard/standard-library.md#L193

MDC032::Line length 82 > maximum 81
public NullReferenceException(string? message, Exception? innerException);
}

Expand Down Expand Up @@ -238,7 +238,7 @@
public sealed class StackOverflowException : Exception
{
public StackOverflowException();
public StackOverflowException(string? message);

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

View workflow job for this annotation

GitHub Actions / Markdown to Word Converter

standard/standard-library.md#L241

MDC032::Line length 82 > maximum 81
public StackOverflowException(string? message, Exception? innerException);
}

Expand Down Expand Up @@ -405,7 +405,7 @@
public class OperationCanceledException : Exception
{
public OperationCanceledException();
public OperationCanceledException(string? message);

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

View workflow job for this annotation

GitHub Actions / Markdown to Word Converter

standard/standard-library.md#L408

MDC032::Line length 86 > maximum 81
public OperationCanceledException(string? message, Exception? innerException);
}

Expand Down Expand Up @@ -678,7 +678,7 @@
}

public interface IAsyncEnumerable<out T>
{

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

View workflow job for this annotation

GitHub Actions / Markdown to Word Converter

standard/standard-library.md#L681

MDC032::Line length 82 > maximum 81
IAsyncEnumerator<T> GetAsyncEnumerator(CancellationToken token = default);
}

Expand Down Expand Up @@ -816,6 +816,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 @@ -1367,6 +1373,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<T>`
- `global::System.Runtime.CompilerServices.ValueTaskAwaiter`
Expand Down
Loading