System.Runtime.CompilerServices 命名空间

System.Runtime.CompilerServices 命名空间为使用托管代码的编译器编写器提供在元数据中指定属性(这些属性影响公共语言运行时的运行时行为)的功能。 The System.Runtime.CompilerServices namespace provides functionality for compiler writers who use managed code to specify attributes in metadata that affect the run-time behavior of the common language runtime.

AccessedThroughPropertyAttribute

指定访问属性化字段的属性的名称。Specifies the name of the property that accesses the attributed field.

AsyncIteratorStateMachineAttribute

指示方法是否为异步迭代器。Indicates whether a method is an asynchronous iterator.

AsyncMethodBuilderAttribute

指示在用作异步方法的返回类型时,应由语言编译器用于生成属性类型的异步方法生成器类型。Indicates the type of the async method builder that should be used by a language compiler to build the attributed type when used as the return type of an async method.

AsyncStateMachineAttribute

指示是否使用 Asyncasync 修饰符标记方法。Indicates whether a method is marked with either the Async or async modifier.

CallConvCdecl

指示方法应使用 Cdecl 调用约定。Indicates that a method should use the Cdecl calling convention.

CallConvFastcall

此版本的 .NET Framework 不支持该调用约定。This calling convention is not supported in this version of the .NET Framework.

CallConvStdcall

指示方法应使用 StdCall 调用约定。Indicates that a method should use the StdCall calling convention.

CallConvThiscall

指示方法应使用 ThisCall 调用约定。Indicates that a method should use the ThisCall calling convention.

CallerArgumentExpressionAttribute

允许捕获传递给方法的表达式。Allows capturing of the expressions passed to a method.

CallerFilePathAttribute

允许获取包含调用方的源文件的完整路径。Allows you to obtain the full path of the source file that contains the caller. 这是编译时的文件路径。This is the file path at the time of compile.

CallerLineNumberAttribute

允许获取源文件中调用方法的行号。Allows you to obtain the line number in the source file at which the method is called.

CallerMemberNameAttribute

允许您获取该方法的调用者方法或属性名称。Allows you to obtain the method or property name of the caller to the method.

CallSite

动态调用站点基类。A dynamic call site base class. 此类型用作动态站点目标的参数类型。This type is used as a parameter type to the dynamic site targets.

CallSite<T>

动态站点类型。Dynamic site type.

CallSiteBinder

负责动态调用站点上动态操作的运行时绑定的类。Class responsible for runtime binding of the dynamic operations on the dynamic call site.

CallSiteHelpers

包含 DLR 调用站点的帮助器方法的类。Class that contains helper methods for DLR CallSites.

CallSiteOps

创建和缓存绑定规则。Creates and caches binding rules.

Closure

表示动态生成方法的运行时状态。Represents the runtime state of a dynamically generated method.

CompilationRelaxationsAttribute

控制由公共语言运行时的实时 (JIT) 编译器生成的代码的严谨性。Controls the strictness of the code generated by the common language runtime's just-in-time (JIT) compiler.

CompilerGeneratedAttribute

区分编译器生成元素和用户生成的元素。Distinguishes a compiler-generated element from a user-generated element. 此类不能被继承。This class cannot be inherited.

CompilerGlobalScopeAttribute

指示某类应被视为具有全局范围。Indicates that a class should be treated as if it has global scope.

CompilerMarshalOverride

指示修饰的变量实例在封送时与其真实类型不同。Indicates that the modified instance of a variable differs from its true type when marshaling. 此类不能被继承。This class cannot be inherited.

ConditionalWeakTable<TKey,TValue>

使编译器可以将对象字段动态附加到托管对象。Enables compilers to dynamically attach object fields to managed objects.

ContractHelper

提供二进制重写工具用来处理协定失败的方法。Provides methods that the binary rewriter uses to handle contract failures.

CustomConstantAttribute

定义一个编译器可以为字段或方法参数永久保存的常数值。Defines a constant value that a compiler can persist for a field or method parameter.

DateTimeConstantAttribute

为字段或参数永久保存一个 8 字节的 DateTime 常数。Persists an 8-byte DateTime constant for a field or parameter.

DebugInfoGenerator

为表达式树中的 lambda 表达式生成调试信息。Generates debug information for lambda expressions in an expression tree.

DecimalConstantAttribute

在元数据中存储 Decimal 常数的值。Stores the value of a Decimal constant in metadata. 此类不能被继承。This class cannot be inherited.

DefaultDependencyAttribute

向公共语言运行时 (CLR) 提供提示,指示加载依赖项的可能性。Provides a hint to the common language runtime (CLR) indicating how likely a dependency is to be loaded. 此类用在依赖程序集中,用于指示当父级未指定 DependencyAttribute 特性时应使用的提示。This class is used in a dependent assembly to indicate what hint should be used when the parent does not specify the DependencyAttribute attribute. 此类不能被继承。This class cannot be inherited.

DependencyAttribute

指示引用程序集将在何时加载依赖项。Indicates when a dependency is to be loaded by the referring assembly. 此类不能被继承。This class cannot be inherited.

DisablePrivateReflectionAttribute

指示程序集的类型中所含的任何私有成员均不可用于映射。Indicates that any private members contained in an assembly's types are not available to reflection.

DiscardableAttribute

将类型定义标记为可放弃。Marks a type definition as discardable.

DynamicAttribute

指示在成员上使用 Object 应被视为动态调度的类型。Indicates that the use of Object on a member is meant to be treated as a dynamically dispatched type.

EnumeratorCancellationAttribute

允许采用异步枚举方法的用户标记应从 GetAsyncEnumerator(CancellationToken) 接收取消令牌值的参数。Allows users of async-enumerable methods to mark the parameter that should receive the cancellation token value from GetAsyncEnumerator(CancellationToken).

ExecutionScope

表示动态生成方法的运行时状态。Represents the runtime state of a dynamically generated method.

ExtensionAttribute

指示某个方法为扩展方法,或某个类或程序集包含扩展方法。Indicates that a method is an extension method, or that a class or assembly contains extension methods.

FixedAddressValueTypeAttribute

在静态值类型字段的整个生存期内固定其地址。Fixes the address of a static value type field throughout its lifetime. 此类不能被继承。This class cannot be inherited.

FixedBufferAttribute

指示应将字段视为包含固定数量的指定基元类型元素。Indicates that a field should be treated as containing a fixed number of elements of the specified primitive type. 此类不能被继承。This class cannot be inherited.

FormattableStringFactory

提供一个静态方法,用于从复合格式字符串及其参数创建 FormattableString 对象。Provides a static method to create a FormattableString object from a composite format string and its arguments.

HasCopySemanticsAttribute

.NET Framework 2.0 版不使用此类,它被保留以备将来之用。This class is not used in the .NET Framework version 2.0 and is reserved for future use. 此类不能被继承。This class cannot be inherited.

IDispatchConstantAttribute

指示特性化字段或参数的默认值是 DispatchWrapper 的实例,其中 WrappedObjectnullIndicates that the default value for the attributed field or parameter is an instance of DispatchWrapper, where the WrappedObject is null.

IndexerNameAttribute

指示使索引器在不直接支持索引器的编程语言中已知的名称。Indicates the name by which an indexer is known in programming languages that do not support indexers directly.

InternalsVisibleToAttribute

指定通常仅在当前程序集中可见的类型对指定程序集可见。Specifies that types that are ordinarily visible only within the current assembly are visible to a specified assembly.

IsBoxed

指示修饰的引用类型是装箱的值类型。Indicates that the modified reference type is a boxed value type. 此类不能被继承。This class cannot be inherited.

IsByRefLikeAttribute

指示结构类似 byref。Indicates that a structure is byref-like.

IsByValue

指示修饰的方法参数应解释为具有按值传递对象的语义。Indicates that a modified method argument should be interpreted as having object passed-by-value semantics. 此修饰应用于引用类型。This modifier is applied to reference types. 此类不能被继承。This class cannot be inherited.

IsConst

指示修饰的类型有一个 const 修饰符。Indicates that the modified type has a const modifier. 此类不能被继承。This class cannot be inherited.

IsCopyConstructed

指示对此类型的值的任何复制操作都必须使用由该类型提供的复制构造函数。Indicates that any copying of values of this type must use the copy constructor provided by the type. 此类不能被继承。This class cannot be inherited.

IsExplicitlyDereferenced

指示托管指针表示某方法签名内的指针参数。Indicates that a managed pointer represents a pointer parameter within a method signature. 此类不能被继承。This class cannot be inherited.

IsImplicitlyDereferenced

指示修饰的垃圾回收引用表示某方法签名内的引用参数。Indicates that the modified garbage collection reference represents a reference parameter within a method signature. 此类不能被继承。This class cannot be inherited.

IsJitIntrinsic

指示某一修饰的方法是一个内部值,实时 (JIT) 编译器可对它执行特殊代码生成。Indicates that a modified method is an intrinsic value for which the just-in-time (JIT) compiler can perform special code generation. 此类不能被继承。This class cannot be inherited.

IsLong

指示修饰的整数是标准 C++ long 值。Indicates that a modified integer is a standard C++ long value. 此类不能被继承。This class cannot be inherited.

IsPinned

指示修饰的实例固定在内存中。Indicates that a modified instance is pinned in memory. 此类不能被继承。This class cannot be inherited.

IsReadOnlyAttribute

将程序元素标记为只读。Marks a program element as read-only.

IsSignUnspecifiedByte

指示修饰符既非有符号,也非无符号。Indicates that a modifier is neither signed nor unsigned. 此类不能被继承。This class cannot be inherited.

IsUdtReturn

指示返回类型是用户定义的类型。Indicates that a return type is a user-defined type. 此类不能被继承。This class cannot be inherited.

IsVolatile

将字段标记为易失。Marks a field as volatile. 此类不能被继承。This class cannot be inherited.

IteratorStateMachineAttribute

指示是否使用 Iterator 修饰符标记 Visual Basic 中的方法。Indicates whether a method in Visual Basic is marked with the Iterator modifier.

IUnknownConstantAttribute

指示特性化字段或参数的默认值是 UnknownWrapper 的实例,其中 WrappedObjectnullIndicates that the default value for the attributed field or parameter is an instance of UnknownWrapper, where the WrappedObject is null. 此类不能被继承。This class cannot be inherited.

MethodImplAttribute

指定如何实现方法的详细信息。Specifies the details of how a method is implemented. 此类不能被继承。This class cannot be inherited.

NativeCppClassAttribute

将指示类型为非托管类型的元数据应用到程序集。Applies metadata to an assembly that indicates that a type is an unmanaged type. 此类不能被继承。This class cannot be inherited.

ReadOnlyCollectionBuilder<T>

只读集合的生成器。The builder for read only collection.

ReferenceAssemblyAttribute

将程序集标识为包含元数据但不包含可执行代码的引用程序集。Identifies an assembly as a reference assembly, which contains metadata but no executable code.

RequiredAttributeAttribute

指定导入编译器必须完全理解类型定义的语义,或拒绝使用它。Specifies that an importing compiler must fully understand the semantics of a type definition, or refuse to use it. 此类不能被继承。This class cannot be inherited.

RuleCache<T>

表示运行时绑定规则的缓存。Represents a cache of runtime binding rules.

RuntimeCompatibilityAttribute

指定是否使用 Exception 对象包装不是从 RuntimeWrappedException 类派生的异常。Specifies whether to wrap exceptions that do not derive from the Exception class with a RuntimeWrappedException object. 此类不能被继承。This class cannot be inherited.

RuntimeFeature

一个类,其静态 IsSupported(String) 方法检查公共语言运行时是否支持指定功能。A class whose static IsSupported(String) method checks whether a specified feature is supported by the common language runtime.

RuntimeHelpers

提供一组为编译器提供支持的静态方法和属性。Provides a set of static methods and properties that provide support for compilers. 此类不能被继承。This class cannot be inherited.

RuntimeOps

包含从动态生成的方法调用的帮助器方法。Contains helper methods called from dynamically generated methods.

RuntimeWrappedException

包装不是从 Exception 类派生的异常。Wraps an exception that does not derive from the Exception class. 此类不能被继承。This class cannot be inherited.

ScopelessEnumAttribute

指示本机枚举未由枚举类型名称限定。Indicates that a native enumeration is not qualified by the enumeration type name. 此类不能被继承。This class cannot be inherited.

SpecialNameAttribute

指示类型或成员由运行时或工具以一种特殊的方式进行处理。Indicates that a type or member is treated in a special way by the runtime or tools. 此类不能被继承。This class cannot be inherited.

StateMachineAttribute

允许确定方法是否是状态机方法。Allows you to determine whether a method is a state machine method.

StringFreezingAttribute

已否决。Deprecated. 在使用 Ngen.exe (Native Image Generator) 创建本机映像时冻结字符串。Freezes a string literal when creating native images using the Ngen.exe (Native Image Generator). 此类不能被继承。This class cannot be inherited.

StrongBox<T>

保存对某个值的引用。Holds a reference to a value.

SuppressIldasmAttribute

防止 Ildasm.exe(IL 反汇编程序)反汇编程序集。Prevents the Ildasm.exe (IL Disassembler) from disassembling an assembly. 此类不能被继承。This class cannot be inherited.

SwitchExpressionException

表示非穷举的 switch 表达式无法在运行时匹配其输入。Indicates that a switch expression that was non-exhaustive failed to match its input at runtime. 异常可能包含表示不匹配值的对象。The exception optionally contains an object representing the unmatched value.

TupleElementNamesAttribute

指示应将所使用的成员上的值元组视为具有元素名称的元组。Indicates that the use of a value tuple on a member is meant to be treated as a tuple with element names.

TypeForwardedFromAttribute

指定另一个程序集中的源 TypeSpecifies a source Type in another assembly.

TypeForwardedToAttribute

指定另一个程序集中的目标 TypeSpecifies a destination Type in another assembly.

Unsafe

包含用于操作指针的通用低级别功能。Contains generic, low-level functionality for manipulating pointers.

UnsafeValueTypeAttribute

指定某个类型包含可能溢出的非托管数组。Specifies that a type contains an unmanaged array that might potentially overflow. 此类不能被继承。This class cannot be inherited.

结构

AsyncIteratorMethodBuilder

表示异步迭代器的生成器。Represents a builder for asynchronous iterators.

AsyncTaskMethodBuilder

表示返回任务的异步方法生成器。Represents a builder for asynchronous methods that return a task.

AsyncTaskMethodBuilder<TResult>

表示异步方法的生成器,该生成器将返回任务并提供结果的参数。Represents a builder for asynchronous methods that returns a task and provides a parameter for the result.

AsyncValueTaskMethodBuilder

表示返回 ValueTask 的异步方法生成器。Represents a builder for asynchronous methods that return a ValueTask.

AsyncValueTaskMethodBuilder<TResult>

表示返回 ValueTask<TResult> 的异步方法生成器。Represents a builder for asynchronous methods that returns a ValueTask<TResult>.

AsyncVoidMethodBuilder

表示不返回值的异步方法生成器。Represents a builder for asynchronous methods that do not return a value.

ConfiguredAsyncDisposable

提供一个类型,该类型可用于配置 IAsyncDisposable 上的等待的执行方式。Provides a type that can be used to configure how awaits on an IAsyncDisposable are performed.

ConfiguredCancelableAsyncEnumerable<T>.Enumerator

提供可等待的异步枚举器,用于实现可取消的迭代和配置的等待。Provides an awaitable async enumerator that enables cancelable iteration and configured awaits.

ConfiguredCancelableAsyncEnumerable<T>

提供可等待的异步可枚举项,用于实现可取消的迭代和配置的等待。Provides an awaitable async enumerable that enables cancelable iteration and configured awaits.

ConfiguredTaskAwaitable

提供用于启用任务上的已配置等待的可等待对象。Provides an awaitable object that enables configured awaits on a task.

ConfiguredTaskAwaitable.ConfiguredTaskAwaiter

提供可等待 (ConfiguredTaskAwaitable) 对象的 Awaiter。Provides an awaiter for an awaitable (ConfiguredTaskAwaitable) object.

ConfiguredTaskAwaitable<TResult>.ConfiguredTaskAwaiter

提供可等待对象 (ConfiguredTaskAwaitable<TResult>) 的 Awaiter。Provides an awaiter for an awaitable object(ConfiguredTaskAwaitable<TResult>).

ConfiguredTaskAwaitable<TResult>

提供用于启用任务上的已配置等待的可等待对象。Provides an awaitable object that enables configured awaits on a task.

ConfiguredValueTaskAwaitable

提供用于启用 ValueTask 上的已配置等待的可等待类型。Provides an awaitable type that enables configured awaits on a ValueTask.

ConfiguredValueTaskAwaitable.ConfiguredValueTaskAwaiter

ConfiguredValueTaskAwaitable 提供一个 awaiter。Provides an awaiter for a ConfiguredValueTaskAwaitable.

ConfiguredValueTaskAwaitable<TResult>.ConfiguredValueTaskAwaiter

ConfiguredValueTaskAwaitable<TResult> 提供一个 awaiter。Provides an awaiter for a ConfiguredValueTaskAwaitable<TResult>.

ConfiguredValueTaskAwaitable<TResult>

提供用于启用 ValueTask<TResult> 上的已配置等待的可等待类型。Provides an awaitable type that enables configured awaits on a ValueTask<TResult>.

TaskAwaiter

提供等待异步任务完成的对象。Provides an object that waits for the completion of an asynchronous task.

TaskAwaiter<TResult>

表示等待完成的异步任务的对象,并提供结果的参数。Represents an object that waits for the completion of an asynchronous task and provides a parameter for the result.

ValueTaskAwaiter

ValueTask 提供一个 awaiter。Provides an awaiter for a ValueTask.

ValueTaskAwaiter<TResult>

ValueTask<TResult> 提供一个 awaiter。Provides an awaiter for a ValueTask<TResult>.

YieldAwaitable

提供上下文,用于在异步切换到目标环境时等待。Provides the context for waiting when asynchronously switching into a target environment.

YieldAwaitable.YieldAwaiter

提供用于切换到目标环境的 awaiter。Provides an awaiter for switching into a target environment.

接口

IAsyncStateMachine

表示为异步方法生成的状态机。Represents state machines that are generated for asynchronous methods. 此类别仅供编译器使用。This type is intended for compiler use only.

ICriticalNotifyCompletion

表示等候程序,其计划等待操作完成时的后续部分。Represents an awaiter that schedules continuations when an await operation completes.

INotifyCompletion

表示操作,其计划等待操作完成时的后续部分。Represents an operation that schedules continuations when it completes.

IRuntimeVariables

表示运行时变量的值。Represents the values of run-time variables.

IStrongBox

定义一个用于访问某个对象引用的值的属性。Defines a property for accessing the value that an object references.

ITuple

定义通用元组实现,它允许在不知道基础元组类型的情况下访问元组实例。Defines a general-purpose Tuple implementation that allows access to Tuple instance members without knowing the underlying Tuple type.

枚举

CompilationRelaxations

指定一些参数,这些参数控制由公共语言运行时的实时 (JIT) 编译器生成的代码的严格性。Specifies parameters that control the strictness of the code generated by the common language runtime's just-in-time (JIT) compiler.

LoadHint

指定依赖程序集的首选默认绑定。Specifies the preferred default binding for a dependent assembly.

MethodCodeType

定义如何实现方法。Defines how a method is implemented.

MethodImplOptions

定义如何实现方法的详细信息。Defines the details of how a method is implemented.

委托

ConditionalWeakTable<TKey,TValue>.CreateValueCallback

表示一种方法,用于创建作为键/值对的一部分添加到 ConditionalWeakTable<TKey,TValue> 对象的非默认值。Represents a method that creates a non-default value to add as part of a key/value pair to a ConditionalWeakTable<TKey,TValue> object.

RuntimeHelpers.CleanupCode

表示在发生异常时要运行的方法。Represents a method to run when an exception occurs.

RuntimeHelpers.TryCode

表示应该在 try 块中运行的代码的委托。Represents a delegate to code that should be run in a try block.

注解

尽管此命名空间是主要的编译器编写器,几个及其类,如InternalsVisibleToAttribute,各种应用程序中使用。This namespace is primarily for compiler writers, although several of its classes, such as InternalsVisibleToAttribute, are used in a wide variety of applications.