Json.More Reads and converts the JSON to type . The reader. The type to convert. An object that specifies serialization options to use. The converted value. Element was not a string or could not identify the JSON value as a known enum value. Reads a dictionary key from a JSON property name. The to read from. The type to convert. The options to use when reading the value. The value that was converted. Writes a specified value as JSON. The writer to write to. The value to convert to JSON. An object that specifies serialization options to use. Writes a dictionary key as a JSON property name. The to write to. The value to convert. The value of determines if the converter handles values. The options to use when writing the value. Provides JSON serialization for the family of types. WARNING: This converter is not AOT-friendly. When overridden in a derived class, determines whether the converter instance can convert the specified object type. The type of the object to check whether it can be converted by this converter instance. if the instance can convert the specified object type; otherwise, . Creates a converter for a specified type. The type handled by the converter. The serialization options to use. A converter which is compatible with . Calculates equality between two s. This comparison is compliant with the ideals expressed by JSON: - Objects are unordered. - Arrays are ordered. A singleton instance for convenience. Determines whether the specified objects are equal. The first object of type T to compare. The second object of type T to compare. true if the specified objects are equal; otherwise, false. Returns a hash code for the specified object. The for which a hash code is to be returned. A hash code for the specified object. The type of obj is a reference type and obj is null. Provides extension functionality for . Determines JSON-compatible equivalence. The first document. The second document. `true` if the documents are equivalent; `false` otherwise. Converts an object to a . The type of the object. The value to convert. (optional) JSON serialization options. A representing the vale. Calculates equality between two s. This comparison is compliant with the ideals expressed by JSON: - Objects are unordered. - Arrays are ordered. A singleton instance for convenience. Determines whether the specified objects are equal. The first object of type T to compare. The second object of type T to compare. true if the specified objects are equal; otherwise, false. Returns a hash code for the specified object. The for which a hash code is to be returned. A hash code for the specified object. The type of obj is a reference type and obj is null. Provides extension functionality for . Determines JSON-compatible equivalence. The first element. The second element. `true` if the element are equivalent; `false` otherwise. The is not valid. Generate a consistent JSON-value-based hash code for the element. The element. Maximum depth to calculate. Default is -1 which utilizes the entire structure without limitation. The hash code. See the following for discussion on why the default implementation is insufficient: - https://github.com/json-everything/json-everything/issues/76 - https://github.com/dotnet/runtime/issues/33388 Just a shortcut for calling `JsonSerializer.Serialize()` because `.ToString()` doesn't do what you might expect. The value to convert. A JSON string. See https://github.com/dotnet/runtime/issues/42502 Converts a to a . The value to convert. A representing the value. This is a workaround for lack of native support in the System.Text.Json namespace. Converts a to a . The value to convert. A representing the value. This is a workaround for lack of native support in the System.Text.Json namespace. Converts a to a . The value to convert. A representing the value. This is a workaround for lack of native support in the System.Text.Json namespace. Converts a to a . The value to convert. A representing the value. This is a workaround for lack of native support in the System.Text.Json namespace. Converts a to a . The value to convert. A representing the value. This is a workaround for lack of native support in the System.Text.Json namespace. Converts a to a . The value to convert. A representing the value. This is a workaround for lack of native support in the System.Text.Json namespace. Converts a to a . The value to convert. A representing the value. This is a workaround for lack of native support in the System.Text.Json namespace. Converts a to a . Can also be used to get a `null` element. The value to convert. A representing the value. This is a workaround for lack of native support in the System.Text.Json namespace. Converts a to a . The array of values to convert. A representing the value. This is a workaround for lack of native support in the System.Text.Json namespace. Converts a to a . The value to convert. A representing the value. This is a workaround for lack of native support in the System.Text.Json namespace. Converts a to a . The element. An equivalent node. This provides a single point of conversion as one is not provided by .Net. See https://github.com/dotnet/runtime/issues/70427 for more information. Defines the source generated JSON serialization contract metadata for a given type. Defines the source generated JSON serialization contract metadata for a given type. The default associated with a default instance. The source-generated options associated with this context. Acts as an intermediary that allows an "implicit casting"-like behavior between native JSON types and . Converts an `int` to a . The value. Converts an `long` to a . The value. Converts an `short` to a . The value. Converts an `float` to a . The value. Converts an `double` to a . The value. Converts an `decimal` to a . The value. Converts an `string` to a . The value. Converts an `bool` to a . The value. Converts a to a . The proxy. Calculates equality between two s. This comparison is compliant with the ideals expressed by JSON: - Objects are unordered. - Arrays are ordered. A singleton instance for convenience. Determines whether the specified objects are equal. The first object of type T to compare. The second object of type T to compare. true if the specified objects are equal; otherwise, false. Returns a hash code for the specified object. The for which a hash code is to be returned. A hash code for the specified object. The type of obj is a reference type and obj is null. Provides extension functionality for . Determines JSON-compatible equivalence. The first element. The second element. `true` if the element are equivalent; `false` otherwise. has trouble testing numeric equality when `decimal` is involved. As such, it is still advised to use this method instead. See https://github.com/dotnet/runtime/issues/97490. Generate a consistent JSON-value-based hash code for the element. The element. Maximum depth to calculate. Default is -1 which utilizes the entire structure without limitation. The hash code. See the following for discussion on why the default implementation is insufficient: - https://github.com/json-everything/json-everything/issues/76 - https://github.com/dotnet/runtime/issues/33388 Gets JSON string representation for , including null support. A node. Serializer options JSON string representation. Gets a node's underlying numeric value. A JSON value. Gets the underlying numeric value, or null if the node represented a non-numeric value. Gets a node's underlying numeric value if it's an integer. A JSON value. Gets the underlying numeric value if it's an integer, or null if the node represented a non-integer value. Gets a node's underlying string value. A JSON value. Gets the underlying string value, or null. JsonNode may use a under the hood which subsequently contains a string. This means that `JsonNode.GetValue<string>()` will not work as expected. Gets a node's underlying boolean value. A JSON value. Gets the underlying boolean value, or null. JsonNode may use a under the hood which subsequently contains a boolean. This means that `JsonNode.GetValue<bool>()` will not work as expected. Convenience method that wraps and catches argument exceptions. The JSON object. The property name The node under the property name if it exists and is singular; null otherwise. An exception if one was thrown during the access attempt. true if the property exists and is singular within the JSON data. throws an if the node was parsed from data that has duplicate keys. Please see https://github.com/dotnet/runtime/issues/70604 for more information. Creates a new by copying from an enumerable of nodes. The nodes. A JSON array. `JsonNode` may only be part of a single JSON tree, i.e. have a single parent. Copying a node allows its value to be saved to another JSON tree. Gets a JSON Path string that indicates the node's location within its JSON structure. The node to find. Determines whether shorthand syntax is used when possible, e.g. `$.foo`. Null nodes cannot be located as the parent cannot be determined. A string containing a JSON Path. Gets a JSON Pointer string that indicates the node's location within its JSON structure. The node to find. Null nodes cannot be located as the parent cannot be determined. A string containing a JSON Pointer. Provides extension functionality for . Most (if not all) of these extension methods are workarounds for https://github.com/dotnet/runtime/issues/50205. Returns the converter for the specified type. The to convert. The being used. An explicit typeInfo to use for looking up the Converter. If not provided, options.GetTypeInfo will be used. An implementation of as determined by the provided options Read and convert the JSON to T. A converter may throw any Exception, but should throw JsonException when the JSON is invalid. The to convert. The being used. The to read from. An explicit typeInfo to use for looking up the Converter. If not provided, options.GetTypeInfo will be used. The value that was converted. Write a T to JSON. A converter may throw any Exception, but should throw JsonException when the JSON is invalid. The to convert. The being used. The to read from. The value to serialize. An explicit typeInfo to use for looking up the Converter. If not provided, options.GetTypeInfo will be used. The value that was converted. Read and convert the JSON to multiple T. A converter may throw any Exception, but should throw JsonException when the JSON is invalid. The to convert. The being used. The to read from. An explicit typeInfo to use for looking up the Converter. If not provided, options.GetTypeInfo will be used. The value that was converted. Read and convert the JSON to multiple T. A converter may throw any Exception, but should throw JsonException when the JSON is invalid. The to convert. The being used. The to read from. An explicit typeInfo to use for looking up the Converter. If not provided, options.GetTypeInfo will be used. The value that was converted. Convert and write multiple T to JSON The to convert. The being used. The to write to. The collection of values to convert. An explicit typeInfo to use for looking up the Converter. If not provided, options.GetTypeInfo will be used. Read and convert string/T dictionary to JSON The to convert. The being used. The to read from. An explicit typeInfo to use for looking up the Converter. If not provided, options.GetTypeInfo will be used. The value that was converted. The JSON is not valid for this type. Read and convert string/list-T dictionary to JSON The to convert. The being used. The to read from. An explicit typeInfo to use for looking up the Converter. If not provided, options.GetTypeInfo will be used. The value that was converted. Convert and write string/T dictionary to JSON The to convert. The being used. The to write to. The collection of values to convert. An explicit typeInfo to use for looking up the Converter. If not provided, options.GetTypeInfo will be used. Convert and write string/list-T dictionary to JSON The to convert. The being used. The to write to. The collection of values to convert. An explicit typeInfo to use for looking up the Converter. If not provided, options.GetTypeInfo will be used. Write an object to JSON. If the type is known, prefer Write]]> A converter may throw any Exception, but should throw JsonException when the JSON is invalid. The being used. The to read from. The value to serialize. The type to serialize. The value that was converted. Provides informative methods for types. Determines whether the type is considered an integer. The type. true if it represents an integer; false otherwise. Determines whether the type is a non-integer floating point number. The type. true if it represents a floating-point number; false otherwise. Determines whether the type is a number. The type. true if it represents a number; false otherwise. Provides extension functionality for . Writes a to the stream. The JSON stream writer. The element to write. The is not valid. Interface to enable JsonConverter implementations to call other JsonConverter's Read methods without statically being aware of their type parameters. Reads and converts the JSON to object?. The reader. The type to convert. An object that specifies serialization options to use. The converted value. Writes a specified value as JSON. The writer to write to. The value to convert to JSON. An object that specifies serialization options to use. The for the value being serialized. Abstract base class of JsonConverter that helps external code call a JsonConverter without statically knowing about T. Specifies that null is allowed as an input even if the corresponding type disallows it. Indicates that the specified method parameter expects a constant. This can be used to inform tooling that a constant should be used as an argument for the annotated parameter. Indicates the minimum bound of the expected constant, inclusive. Indicates the maximum bound of the expected constant, inclusive. Specifies that null is disallowed as an input even if the corresponding type allows it. Applied to a method that will never return under any circumstance. Specifies that the method will not return if the associated Boolean parameter is passed the specified value. Initializes the attribute with the specified parameter value. The condition parameter value. Code after the method will be considered unreachable by diagnostics if the argument to the associated parameter matches this value. Gets the condition parameter value. Indicates that an API is experimental and it may change in the future. This attribute allows call sites to be flagged with a diagnostic that indicates that an experimental feature is used. Authors can use this attribute to ship preview features in their assemblies. Initializes a new instance of the class, specifying the ID that the compiler will use when reporting a use of the API the attribute applies to. The ID that the compiler will use when reporting a use of the API the attribute applies to. Gets the ID that the compiler will use when reporting a use of the API the attribute applies to. The unique diagnostic ID. The diagnostic ID is shown in build output for warnings and errors. This property represents the unique ID that can be used to suppress the warnings or errors, if needed. Gets or sets the URL for corresponding documentation. The API accepts a format string instead of an actual URL, creating a generic URL that includes the diagnostic ID. The format string that represents a URL to corresponding documentation. An example format string is https://contoso.com/obsoletion-warnings/{0}. Specifies that an output may be null even if the corresponding type disallows it. Specifies that when a method returns , the parameter may be null even if the corresponding type disallows it. Initializes the attribute with the specified return value condition. The return value condition. If the method returns this value, the associated parameter may be null. Gets the return value condition. Specifies that the method or property will ensure that the listed field and property members have not-null values. Initializes the attribute with a field or property member. The field or property member that is promised to be not-null. Initializes the attribute with the list of field and property members. The list of field and property members that are promised to be not-null. Gets field or property member names. Specifies that the method or property will ensure that the listed field and property members have not-null values when returning with the specified return value condition. Initializes the attribute with the specified return value condition and a field or property member. The return value condition. If the method returns this value, the associated parameter will not be null. The field or property member that is promised to be not-null. Initializes the attribute with the specified return value condition and list of field and property members. The return value condition. If the method returns this value, the associated parameter will not be null. The list of field and property members that are promised to be not-null. Gets the return value condition. Gets field or property member names. Specifies that an output will not be null even if the corresponding type allows it. Specifies that an input argument was not null when the call returns. Specifies that the output will be non-null if the named parameter is non-null. Initializes the attribute with the associated parameter name. The associated parameter name. The output will be non-null if the argument to the parameter specified is non-null. Gets the associated parameter name. Specifies that when a method returns , the parameter will not be null even if the corresponding type allows it. Initializes the attribute with the specified return value condition. The return value condition. If the method returns this value, the associated parameter will not be null. Gets the return value condition. Specifies that this constructor sets all required members for the current type, and callers do not need to set any required members themselves. Specifies the syntax used in a string. Initializes the with the identifier of the syntax used. The syntax identifier. Initializes the with the identifier of the syntax used. The syntax identifier. Optional arguments associated with the specific syntax employed. Gets the identifier of the syntax used. Optional arguments associated with the specific syntax employed. The syntax identifier for strings containing composite formats for string formatting. The syntax identifier for strings containing date format specifiers. The syntax identifier for strings containing date and time format specifiers. The syntax identifier for strings containing format specifiers. The syntax identifier for strings containing format specifiers. The syntax identifier for strings containing JavaScript Object Notation (JSON). The syntax identifier for strings containing numeric format specifiers. The syntax identifier for strings containing regular expressions. The syntax identifier for strings containing time format specifiers. The syntax identifier for strings containing format specifiers. The syntax identifier for strings containing URIs. The syntax identifier for strings containing XML. Used to indicate a byref escapes and is not scoped. There are several cases where the C# compiler treats a as implicitly - where the compiler does not allow the to escape the method. For example: for instance methods. parameters that refer to types. parameters. This attribute is used in those instances where the should be allowed to escape. Applying this attribute, in any form, has impact on consumers of the applicable API. It is necessary for API authors to understand the lifetime implications of applying this attribute and how it may impact their users. Indicates that certain members on a specified are accessed dynamically, for example through . This allows tools to understand which members are being accessed during the execution of a program. This attribute is valid on members whose type is or . When this attribute is applied to a location of type , the assumption is that the string represents a fully qualified type name. When this attribute is applied to a class, interface, or struct, the members specified can be accessed dynamically on instances returned from calling on instances of that class, interface, or struct. If the attribute is applied to a method it's treated as a special case and it implies the attribute should be applied to the "this" parameter of the method. As such the attribute should only be used on instance methods of types assignable to System.Type (or string, but no methods will use it there). Initializes a new instance of the class with the specified member types. The types of members dynamically accessed. Gets the which specifies the type of members dynamically accessed. Specifies the types of members that are dynamically accessed. This enumeration has a attribute that allows a bitwise combination of its member values. Specifies no members. Specifies the default, parameterless public constructor. Specifies all public constructors. Specifies all non-public constructors. Specifies all public methods. Specifies all non-public methods. Specifies all public fields. Specifies all non-public fields. Specifies all public nested types. Specifies all non-public nested types. Specifies all public properties. Specifies all non-public properties. Specifies all public events. Specifies all non-public events. Specifies all interfaces implemented by the type. Specifies all members. States a dependency that one member has on another. This can be used to inform tooling of a dependency that is otherwise not evident purely from metadata and IL, for example a member relied on via reflection. Initializes a new instance of the class with the specified signature of a member on the same type as the consumer. The signature of the member depended on. Initializes a new instance of the class with the specified signature of a member on a . The signature of the member depended on. The containing . Initializes a new instance of the class with the specified signature of a member on a type in an assembly. The signature of the member depended on. The full name of the type containing the specified member. The assembly name of the type containing the specified member. Initializes a new instance of the class with the specified types of members on a . The types of members depended on. The containing the specified members. Initializes a new instance of the class with the specified types of members on a type in an assembly. The types of members depended on. The full name of the type containing the specified members. The assembly name of the type containing the specified members. Gets the signature of the member depended on. Either must be a valid string or must not equal , but not both. Gets the which specifies the type of members depended on. Either must be a valid string or must not equal , but not both. Gets the containing the specified member. If neither nor are specified, the type of the consumer is assumed. Gets the full name of the type containing the specified member. If neither nor are specified, the type of the consumer is assumed. Gets the assembly name of the specified type. is only valid when is specified. Gets or sets the condition in which the dependency is applicable, e.g. "DEBUG". Indicates that the specified public static boolean get-only property guards access to the specified feature. Analyzers can use this to prevent warnings on calls to code that is annotated as requiring that feature, when the callsite is guarded by a call to the property. Initializes a new instance of the class with the specified feature type. The type that represents the feature guarded by the property. The type that represents the feature guarded by the property. Indicates that the specified public static boolean get-only property corresponds to the feature switch specified by name. IL rewriters and compilers can use this to substitute the return value of the specified property with the value of the feature switch. Initializes a new instance of the class with the specified feature switch name. The name of the feature switch that provides the value for the specified property. The name of the feature switch that provides the value for the specified property. Indicates that the specified member requires assembly files to be on disk. Initializes a new instance of the class. Initializes a new instance of the class. A message that contains information about the need for assembly files to be on disk. Gets an optional message that contains information about the need for assembly files to be on disk. Gets or sets an optional URL that contains more information about the member, why it requires assembly files to be on disk, and what options a consumer has to deal with it. Indicates that the specified method requires the ability to generate new code at runtime, for example through . This allows tools to understand which methods are unsafe to call when compiling ahead of time. Initializes a new instance of the class with the specified message. A message that contains information about the usage of dynamic code. Gets a message that contains information about the usage of dynamic code. Gets or sets an optional URL that contains more information about the method, why it requires dynamic code, and what options a consumer has to deal with it. Indicates that the specified method requires dynamic access to code that is not referenced statically, for example through . This allows tools to understand which methods are unsafe to call when removing unreferenced code from an application. Initializes a new instance of the class with the specified message. A message that contains information about the usage of unreferenced code. Gets a message that contains information about the usage of unreferenced code. Gets or sets an optional URL that contains more information about the method, why it requires unreferenced code, and what options a consumer has to deal with it. Suppresses reporting of a specific rule violation, allowing multiple suppressions on a single code artifact. is different than in that it doesn't have a . So it is always preserved in the compiled assembly. Initializes a new instance of the class, specifying the category of the tool and the identifier for an analysis rule. The category for the attribute. The identifier of the analysis rule the attribute applies to. Gets the category identifying the classification of the attribute. The property describes the tool or tool analysis category for which a message suppression attribute applies. Gets the identifier of the analysis tool rule to be suppressed. Concatenated together, the and properties form a unique check identifier. Gets or sets the scope of the code that is relevant for the attribute. The Scope property is an optional argument that specifies the metadata scope for which the attribute is relevant. Gets or sets a fully qualified path that represents the target of the attribute. The property is an optional argument identifying the analysis target of the attribute. An example value is "System.IO.Stream.ctor():System.Void". Because it is fully qualified, it can be long, particularly for targets such as parameters. The analysis tool user interface should be capable of automatically formatting the parameter. Gets or sets an optional argument expanding on exclusion criteria. The property is an optional argument that specifies additional exclusion where the literal metadata target is not sufficiently precise. For example, the cannot be applied within a method, and it may be desirable to suppress a violation against a statement in the method that will give a rule violation, but not against all statements in the method. Gets or sets the justification for suppressing the code analysis message. If a .NET Debugger is attached which supports the Debugger.BreakForUserUnhandledException(Exception) API, this attribute will prevent the debugger from breaking on user-unhandled exceptions when the exception is caught by a method with this attribute, unless BreakForUserUnhandledException is called. Types and Methods attributed with StackTraceHidden will be omitted from the stack trace text shown in StackTrace.ToString() and Exception.StackTrace Initializes a new instance of the class. Represent a type can be used to index a collection either from the start or the end. Index is used by the C# compiler to support the new index syntax int[] someArray = new int[5] { 1, 2, 3, 4, 5 } ; int lastElement = someArray[^1]; // lastElement = 5 Construct an Index using a value and indicating if the index is from the start or from the end. The index value. it has to be zero or positive number. Indicating if the index is from the start or from the end. If the Index constructed from the end, index value 1 means pointing at the last element and index value 0 means pointing at beyond last element. Create an Index pointing at first element. Create an Index pointing at beyond last element. Create an Index from the start at the position indicated by the value. The index value from the start. Create an Index from the end at the position indicated by the value. The index value from the end. Returns the index value. Indicates whether the index is from the start or the end. Calculate the offset from the start using the giving collection length. The length of the collection that the Index will be used with. length has to be a positive value For performance reason, we don't validate the input length parameter and the returned offset value against negative values. we don't validate either the returned offset is greater than the input length. It is expected Index will be used with collections which always have non negative length/count. If the returned offset is negative and then used to index a collection will get out of range exception which will be same affect as the validation. Indicates whether the current Index object is equal to another object of the same type. An object to compare with this object Indicates whether the current Index object is equal to another Index object. An object to compare with this object Returns the hash code for this instance. Converts integer number to an Index. Converts the value of the current Index object to its equivalent string representation. Represent a range has start and end indexes. Range is used by the C# compiler to support the range syntax. int[] someArray = new int[5] { 1, 2, 3, 4, 5 }; int[] subArray1 = someArray[0..2]; // { 1, 2 } int[] subArray2 = someArray[1..^0]; // { 2, 3, 4, 5 } Represent the inclusive start index of the Range. Represent the exclusive end index of the Range. Construct a Range object using the start and end indexes. Represent the inclusive start index of the range. Represent the exclusive end index of the range. Indicates whether the current Range object is equal to another object of the same type. An object to compare with this object Indicates whether the current Range object is equal to another Range object. An object to compare with this object Returns the hash code for this instance. Converts the value of the current Range object to its equivalent string representation. Create a Range object starting from start index to the end of the collection. Create a Range object starting from first element in the collection to the end Index. Create a Range object starting from first element to the end. Calculate the start offset and length of range object using a collection length. The length of the collection that the range will be used with. length has to be a positive value. For performance reason, we don't validate the input length parameter against negative values. It is expected Range will be used with collections which always have non negative length/count. We validate the range is inside the length scope though. An attribute that allows parameters to receive the expression of other parameters. Initializes a new instance of the class. The condition parameter value. Gets the parameter name the expression is retrieved from. Initialize the attribute to refer to the method on the type. The type of the builder to use to construct the collection. The name of the method on the builder to use to construct the collection. must refer to a static method that accepts a single parameter of type and returns an instance of the collection being built containing a copy of the data from that span. In future releases of .NET, additional patterns may be supported. Gets the type of the builder to use to construct the collection. Gets the name of the method on the builder to use to construct the collection. This should match the metadata name of the target method. For example, this might be ".ctor" if targeting the type's constructor. Indicates that compiler support for a particular feature is required for the location where this attribute is applied. Creates a new instance of the type. The name of the feature to indicate. The name of the compiler feature. If true, the compiler can choose to allow access to the location where this attribute is applied if it does not understand . The used for the ref structs C# feature. The used for the required members C# feature. Indicates which arguments to a method involving an interpolated string handler should be passed to that handler. Initializes a new instance of the class. The name of the argument that should be passed to the handler. may be used as the name of the receiver in an instance method. Initializes a new instance of the class. The names of the arguments that should be passed to the handler. may be used as the name of the receiver in an instance method. Gets the names of the arguments that should be passed to the handler. may be used as the name of the receiver in an instance method. Indicates the attributed type is to be used as an interpolated string handler. Reserved to be used by the compiler for tracking metadata. This class should not be used by developers in source code. Used to indicate to the compiler that a method should be called in its containing module's initializer. When one or more valid methods with this attribute are found in a compilation, the compiler will emit a module initializer which calls each of the attributed methods. Certain requirements are imposed on any method targeted with this attribute: - The method must be `static`. - The method must be an ordinary member method, as opposed to a property accessor, constructor, local function, etc. - The method must be parameterless. - The method must return `void`. - The method must not be generic or be contained in a generic type. - The method's effective accessibility must be `internal` or `public`. The specification for module initializers in the .NET runtime can be found here: https://github.com/dotnet/runtime/blob/main/docs/design/specs/Ecma-335-Augments.md#module-initializer Specifies the priority of a member in overload resolution. When unspecified, the default priority is 0. Initializes a new instance of the class. The priority of the attributed member. Higher numbers are prioritized, lower numbers are deprioritized. 0 is the default if no attribute is present. The priority of the member. Indicates that a method will allow a variable number of arguments in its invocation. Specifies that a type has required members or that a member is required. Reserved for use by a compiler for tracking metadata. This attribute should not be used by developers in source code. Used to indicate to the compiler that the .locals init flag should not be set in method headers. Disables the built-in runtime managed/unmanaged marshalling subsystem for P/Invokes, Delegate types, and unmanaged function pointer invocations. The built-in marshalling subsystem has some behaviors that cannot be changed due to backward-compatibility requirements. This attribute allows disabling the built-in subsystem and instead uses the following rules for P/Invokes, Delegates, and unmanaged function pointer invocations: - All value types that do not contain reference type fields recursively (unmanaged in C#) are blittable - Value types that recursively have any fields that have [StructLayout(LayoutKind.Auto)] are disallowed from interop. - All reference types are disallowed from usage in interop scenarios. - SetLastError support in P/Invokes is disabled. - varargs support is disabled. - LCIDConversionAttribute support is disabled. Provides access to an inaccessible member of a specific type. This attribute may be applied to an extern static method. The implementation of the extern static method annotated with this attribute will be provided by the runtime based on the information in the attribute and the signature of the method that the attribute is applied to. The runtime will try to find the matching method or field and forward the call to it. If the matching method or field is not found, the body of the extern method will throw or . Only the specific type defined will be examined for inaccessible members. The type hierarchy is not walked looking for a match. For , , , and , the type of the first argument of the annotated extern method identifies the owning type. The value of the first argument is treated as this pointer for instance fields and methods. The first argument must be passed as ref for instance fields and methods on structs. The value of the first argument is not used by the implementation for static fields and methods. Return type is considered for the signature match. modreqs and modopts are initially not considered for the signature match. However, if an ambiguity exists ignoring modreqs and modopts, a precise match is attempted. If an ambiguity still exists is thrown. By default, the attributed method's name dictates the name of the method/field. This can cause confusion in some cases since language abstractions, like C# local functions, generate mangled IL names. The solution to this is to use the nameof mechanism and define the property. public void Method(Class c) { PrivateMethod(c); [UnsafeAccessor(UnsafeAccessorKind.Method, Name = nameof(PrivateMethod))] extern static void PrivateMethod(Class c); } Instantiates an providing access to a member of kind . The kind of the target to which access is provided. Gets the kind of member to which access is provided. Gets or sets the name of the member to which access is provided. The name defaults to the annotated method name if not specified. The name must be unset/null for . Specifies the kind of target to which an is providing access. Provide access to a constructor. Provide access to a method. Provide access to a static method. Provide access to a field. Provide access to a static field. Initializes a new instance of the class. Initializes a new instance of the class with the specified message. An optional message associated with this attribute instance. Returns the optional message associated with this attribute instance. Returns the optional URL associated with this attribute instance. Marks APIs that were obsoleted in a given operating system version. Primarily used by OS bindings to indicate APIs that should not be used anymore. Records the operating system (and minimum version) that supports an API. Multiple attributes can be applied to indicate support on multiple operating systems. Callers can apply a or use guards to prevent calls to APIs on unsupported operating systems. A given platform should only be specified once. Annotates a custom guard field, property or method with a supported platform name and optional version. Multiple attributes can be applied to indicate guard for multiple supported platforms. Callers can apply a to a field, property or method and use that field, property or method in a conditional or assert statements in order to safely call platform specific APIs. The type of the field or property should be boolean, the method return type should be boolean in order to be used as platform guard. Records the platform that the project targeted. Marks APIs that were removed in a given operating system version. Primarily used by OS bindings to indicate APIs that are only available in earlier versions. Annotates the custom guard field, property or method with an unsupported platform name and optional version. Multiple attributes can be applied to indicate guard for multiple unsupported platforms. Callers can apply a to a field, property or method and use that field, property or method in a conditional or assert statements as a guard to safely call APIs unsupported on those platforms. The type of the field or property should be boolean, the method return type should be boolean in order to be used as platform guard. Indicates that the instance's storage is sequentially replicated "length" times. This attribute can be used to annotate a type with a single field. The runtime will replicate that field in the actual type layout as many times as is specified. Here's an example of how an inline array type with 8 values can be declared: [InlineArray(8)] struct Float8InlineArray { private float _value; } Creates a new instance with the specified length. The number of sequential fields to replicate in the inline array type. Gets the number of sequential fields to replicate in the inline array type. An attribute used to indicate a GC transition should be skipped when making an unmanaged function call. Example of a valid use case. The Win32 `GetTickCount()` function is a small performance related function that reads some global memory and returns the value. In this case, the GC transition overhead is significantly more than the memory read. using System; using System.Runtime.InteropServices; class Program { [DllImport("Kernel32")] [SuppressGCTransition] static extern int GetTickCount(); static void Main() { Console.WriteLine($"{GetTickCount()}"); } } This attribute is ignored if applied to a method without the . Forgoing this transition can yield benefits when the cost of the transition is more than the execution time of the unmanaged function. However, avoiding this transition removes some of the guarantees the runtime provides through a normal P/Invoke. When exiting the managed runtime to enter an unmanaged function the GC must transition from Cooperative mode into Preemptive mode. Full details on these modes can be found at https://github.com/dotnet/runtime/blob/main/docs/coding-guidelines/clr-code-guide.md#2.1.8. Suppressing the GC transition is an advanced scenario and should not be done without fully understanding potential consequences. One of these consequences is an impact to Mixed-mode debugging (https://docs.microsoft.com/visualstudio/debugger/how-to-debug-in-mixed-mode). During Mixed-mode debugging, it is not possible to step into or set breakpoints in a P/Invoke that has been marked with this attribute. A workaround is to switch to native debugging and set a breakpoint in the native function. In general, usage of this attribute is not recommended if debugging the P/Invoke is important, for example stepping through the native code or diagnosing an exception thrown from the native code. The runtime may load the native library for method marked with this attribute in advance before the method is called for the first time. Usage of this attribute is not recommended for platform neutral libraries with conditional platform specific code. The P/Invoke method that this attribute is applied to must have all of the following properties: * Native function always executes for a trivial amount of time (less than 1 microsecond). * Native function does not perform a blocking syscall (e.g. any type of I/O). * Native function does not call back into the runtime (e.g. Reverse P/Invoke). * Native function does not throw exceptions. * Native function does not manipulate locks or other concurrency primitives. Consequences of invalid uses of this attribute: * GC starvation. * Immediate runtime termination. * Data corruption. Any method marked with can be directly called from native code. The function token can be loaded to a local variable using the address-of operator in C# and passed as a callback to a native method. Methods marked with this attribute have the following restrictions: * Method must be marked "static". * Must not be called from managed code. * Must only have blittable arguments. Optional. If omitted, the runtime will use the default platform calling convention. Supplied types must be from the official "System.Runtime.CompilerServices" namespace and be of the form "CallConvXXX". Optional. If omitted, no named export is emitted during compilation. Specifies that the P/Invoke marked with this attribute should be linked in as a WASM import. See https://webassembly.github.io/spec/core/syntax/modules.html#imports. Instance constructor.