System.Runtime.CompilerServices Namespace

.NET API Reference Documentation

Namespace: System.Runtime.CompilerServices

Summary

Provides a set of attributes and types that are used by the compiler and by the .NET Framework runtime to support compiler services, such as code generation, debugging, and interoperability.

This namespace is fundamental for many advanced .NET features, including asynchronous programming (async/await), expression trees, and custom attributes that control runtime behavior.

Types in this Namespace

Attribute: CompilerGeneratedAttribute

Indicates that the attributed code was generated by the compiler.

Members:
  • CompilerGeneratedAttribute()

Attribute: AsyncIteratorAttribute

Indicates that the attributed method is an asynchronous iterator method.

Members:
  • AsyncIteratorAttribute()

Attribute: IteratorAttribute

Indicates that the attributed method is an iterator method.

Members:
  • IteratorAttribute()

Attribute: CallableAttribute

Indicates that the attributed method can be called from unmanaged code.

Members:
  • CallableAttribute()

Attribute: ExtensionAttribute

Marks a method as an extension method, which allows it to be invoked as if it were an instance method of its first parameter.

Members:
  • ExtensionAttribute()

Attribute: MethodImplAttribute

Specifies the implementation details of a method.

Members:
  • MethodImplAttribute(MethodImplOptions methodImplOptions)
  • MethodImplAttribute(short flags)
  • Options { get; }

Attribute: YieldReturnAttribute

Marks a method as a generator method, indicating that it uses the `yield return` statement.

Members:
  • YieldReturnAttribute()

Class: RuntimeHelpers

Provides a collection of static methods that help compilers emit efficient code and that help the runtime to support language features.

Static Methods:
  • EnsureSufficientExecutionStack(Int32 stackSlots)
  • GetObjectData(Object obj, SerializationInfo info, StreamingContext context)
  • PrepareConstrainedRegions()
  • RunClassConstructor(RuntimeTypeHandle typeHandle)
  • RunModuleConstructor(ModuleHandle moduleHandle)
  • TryEnsureSufficientExecutionStack(Int32 stackSlots)
  • InitializeArray(Array array, RuntimeFieldHandle field)
Static Properties:
  • OffsetToStringData { get; }

Enum: TaskContinuationsOptions

Specifies options for `Task` continuations.

Members:
  • None
  • PreferFairness
  • LongRunning
  • DenyChildAttach
  • ExecuteSynchronously
  • NotOnRanToCompletion
  • NotOnFaulted
  • NotOnCanceled

Attribute: CompilationRelaxationsAttribute

Specifies relaxation rules for the Just-In-Time (JIT) compiler.

Members:
  • CompilationRelaxationsAttribute(Int32 relaxations)
  • Relaxations { get; }

Attribute: OrderedDictionaryItemAttribute

Specifies that a field or property represents an item in an ordered dictionary.

Members:
  • OrderedDictionaryItemAttribute()

Attribute: OrderedDictionaryTypeAttribute

Specifies that a type represents an ordered dictionary.

Members:
  • OrderedDictionaryTypeAttribute()

Attribute: ForeignMethodAttribute

Specifies that a method is defined in unmanaged code.

Members:
  • ForeignMethodAttribute()