diff --git a/standard/attributes.md b/standard/attributes.md index 21d681e30..6e0f94372 100644 --- a/standard/attributes.md +++ b/standard/attributes.md @@ -526,6 +526,7 @@ A number of attributes affect the language in some way. These attributes include - `System.ObsoleteAttribute` ([§22.5.4](attributes.md#2254-the-obsolete-attribute)), which is used to mark a member as obsolete. - `System.Runtime.CompilerServices.AsyncMethodBuilderAttribute` ([§22.5.5](attributes.md#2255-the-asyncmethodbuilder-attribute)), which is used to establish a task builder for an async method. - `System.Runtime.CompilerServices.CallerLineNumberAttribute` ([§22.5.6.2](attributes.md#22562-the-callerlinenumber-attribute)), `System.Runtime.CompilerServices.CallerFilePathAttribute` ([§22.5.6.3](attributes.md#22563-the-callerfilepath-attribute)), and `System.Runtime.CompilerServices.CallerMemberNameAttribute` ([§22.5.6.4](attributes.md#22564-the-callermembername-attribute)), which are used to supply information about the calling context to optional parameters. +- `System.Runtime.CompilerServices.ModuleInitializer` (§module-init-attr), which is used to mark a method as a module initializer. The Nullable static analysis attributes ([§22.5.7](attributes.md#2257-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)). @@ -860,6 +861,22 @@ For invocations that occur within field or event initializers, the member name u For invocations that occur within declarations of instance constructors, static constructors, finalizers and operators the member name used is implementation-dependent. +### §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. + ### 22.5.7 Code analysis attributes #### 22.5.7.1 General diff --git a/standard/portability-issues.md b/standard/portability-issues.md index 6383d4fb7..f440d8bf5 100644 --- a/standard/portability-issues.md +++ b/standard/portability-issues.md @@ -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. ([§21.4](exceptions.md#214-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. ([§22.5.1](attributes.md#2251-general)) 1. The mappings between pointers and integers. ([§23.5.1](unsafe-code.md#2351-general)) 1. The effect of applying the unary `*` operator to a `null` pointer. ([§23.6.2](unsafe-code.md#2362-pointer-indirection)) @@ -51,6 +52,7 @@ A conforming implementation is required to document its choice of behavior in ea 1. The result of the `sizeof` operator for non-pre-defined value types. ([§23.6.9](unsafe-code.md#2369-the-sizeof-operator)) 1. The behavior of the `fixed` statement if the array expression is `null` or if the array has zero elements. ([§23.7](unsafe-code.md#237-the-fixed-statement)) 1. The behavior of the `fixed` statement if the string expression is `null`. ([§23.7](unsafe-code.md#237-the-fixed-statement)) +1. The value returned when a stack allocation of size zero is made ([§12.8.21](expressions.md#12821-stack-allocation)). ## B.4 Unspecified behavior diff --git a/standard/standard-library.md b/standard/standard-library.md index 29d0279cf..70e6f14b7 100644 --- a/standard/standard-library.md +++ b/standard/standard-library.md @@ -544,6 +544,12 @@ namespace System.Runtime.CompilerServices void OnCompleted(Action continuation); } + [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] + public sealed class ModuleInitializerAttribute : Attribute + { + public ModuleInitializerAttribute() { } + } + public readonly struct TaskAwaiter : ICriticalNotifyCompletion, INotifyCompletion {