From 850af143e31b812db8064a8e3dcb2c50e1f351dd Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Mon, 9 Feb 2026 16:46:05 -0800 Subject: [PATCH 1/3] Checkpoint from Copilot CLI for coding agent session --- ...ction-emit-dynamicmethod-createdelegate.md | 53 ++++++++++++ ...stem-reflection-emit-dynamicmethod-ctor.md | 81 +++++++++++++++++++ ...tion-emit-dynamicmethod-defineparameter.md | 20 +++++ ...ction-emit-dynamicmethod-getilgenerator.md | 37 +++++++++ ...em-reflection-emit-dynamicmethod-invoke.md | 31 +++++++ ...n-emit-dynamicmethod-issecuritycritical.md | 41 ++++++++++ ...it-dynamicmethod-issecuritysafecritical.md | 41 ++++++++++ ...mit-dynamicmethod-issecuritytransparent.md | 41 ++++++++++ ...stem-reflection-emit-dynamicmethod-name.md | 19 +++++ 9 files changed, 364 insertions(+) create mode 100644 docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-createdelegate.md create mode 100644 docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-ctor.md create mode 100644 docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-defineparameter.md create mode 100644 docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-getilgenerator.md create mode 100644 docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-invoke.md create mode 100644 docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-issecuritycritical.md create mode 100644 docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-issecuritysafecritical.md create mode 100644 docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-issecuritytransparent.md create mode 100644 docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-name.md diff --git a/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-createdelegate.md b/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-createdelegate.md new file mode 100644 index 0000000000000..73b97a9bb51db --- /dev/null +++ b/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-createdelegate.md @@ -0,0 +1,53 @@ +--- +title: System.Reflection.Emit.DynamicMethod.CreateDelegate methods +description: Learn about the System.Reflection.Emit.DynamicMethod.CreateDelegate methods. +ms.date: 02/10/2026 +ai-usage: ai-assisted +--- +# System.Reflection.Emit.DynamicMethod.CreateDelegate methods + +[!INCLUDE [context](includes/context.md)] + +## + +Calling the method or the method completes the dynamic method. Any further attempt to alter the dynamic method, such as modifying parameter definitions or emitting more Microsoft intermediate language (MSIL), is ignored; no exception is thrown. + +To create a method body for a dynamic method when you have your own MSIL generator, call the method to obtain a object. If you don't have your own MSIL generator, call the method to obtain an object that can be used to generate the method body. + +### Examples + +The following code example creates a dynamic method that takes two parameters. The example emits a simple function body that prints the first parameter to the console, and the example uses the second parameter as the return value of the method. The example completes the method by creating a delegate, invokes the delegate with different parameters, and finally invokes the dynamic method using the method. + +:::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/DynamicMethod/.ctor/source1.cs" id="Snippet1"::: +:::code language="vb" source="~/snippets/visualbasic/System.Reflection.Emit/DynamicMethod/.ctor/source1.vb" id="Snippet1"::: + +## + +This method overload creates a delegate bound to a particular object. Such a delegate is said to be closed over its first argument. Although the method is static, it acts as if it were an instance method; the instance is `target`. + +This method overload requires `target` to be of the same type as the first parameter of the dynamic method, or to be assignable to that type (for example, a derived class). The signature of `delegateType` has all the parameters of the dynamic method except the first. For example, if the dynamic method has the parameters , , and , then `delegateType` has the parameters and ; `target` is of type . + +Calling the method or the method completes the dynamic method. Any further attempt to alter the dynamic method, such as modifying parameter definitions or emitting more Microsoft intermediate language (MSIL), is ignored; no exception is thrown. + +To create a method body for a dynamic method when you have your own MSIL generator, call the method to obtain a object. If you don't have your own MSIL generator, call the method to obtain an object that can be used to generate the method body. + +### Examples + +The following code example creates a delegate that binds a to an instance of a type, so that the method acts on the same instance each time it's invoked. + +The code example defines a class named `Example` with a private field, a class named `DerivedFromExample` that derives from the first class, a delegate type named `UseLikeStatic` that returns and has parameters of type `Example` and , and a delegate type named `UseLikeInstance` that returns and has one parameter of type . + +The example code then creates a that changes the private field of an instance of `Example` and returns the previous value. + +> [!NOTE] +> In general, changing the internal fields of classes isn't good object-oriented coding practice. + +The example code creates an instance of `Example` and then creates two delegates. The first is of type `UseLikeStatic`, which has the same parameters as the dynamic method. The second is of type `UseLikeInstance`, which lacks the first parameter (of type `Example`). This delegate is created using the method overload; the second parameter of that method overload is an instance of `Example`, in this case the instance just created, which is bound to the newly created delegate. Whenever that delegate is invoked, the dynamic method acts on the bound instance of `Example`. + +> [!NOTE] +> This is an example of the relaxed rules for delegate binding introduced in .NET Framework 2.0, along with new overloads of the method. For more information, see the class. + +The `UseLikeStatic` delegate is invoked, passing in the instance of `Example` that's bound to the `UseLikeInstance` delegate. Then the `UseLikeInstance` delegate is invoked, so that both delegates act on the same instance of `Example`. The changes in the values of the internal field are displayed after each call. Finally, a `UseLikeInstance` delegate is bound to an instance of `DerivedFromExample`, and the delegate calls are repeated. + +:::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/DynamicMethod/.ctor/source.cs" id="Snippet1"::: +:::code language="vb" source="~/snippets/visualbasic/System.Reflection.Emit/DynamicMethod/.ctor/source.vb" id="Snippet1"::: diff --git a/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-ctor.md b/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-ctor.md new file mode 100644 index 0000000000000..52d4369258275 --- /dev/null +++ b/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-ctor.md @@ -0,0 +1,81 @@ +--- +title: System.Reflection.Emit.DynamicMethod constructors +description: Learn about the System.Reflection.Emit.DynamicMethod constructors. +ms.date: 02/10/2026 +ai-usage: ai-assisted +--- +# System.Reflection.Emit.DynamicMethod constructors + +[!INCLUDE [context](includes/context.md)] + +## constructor + +The dynamic method that is created by this constructor is associated with an anonymous assembly instead of an existing type or module. The anonymous assembly exists only to provide a sandbox environment for dynamic methods, that is, to isolate them from other code. This environment makes it safe for the dynamic method to be emitted and executed by partially trusted code. + +Anonymously hosted dynamic methods don't have automatic access to any types or members that are `private`, `protected`, or `internal` (`Friend` in Visual Basic). This is different from dynamic methods that are associated with an existing type or module, which have access to hidden members in their associated scope. + +Specify `true` for `restrictedSkipVisibility` if your dynamic method has to access types or members that are `private`, `protected`, or `internal`. This gives the dynamic method restricted access to these members. That is, the members can be accessed only if the following conditions are met: + +- The target members belong to an assembly that has a level of trust equal to or lower than the call stack that emits the dynamic method. + +- The call stack that emits the dynamic method is granted with the flag. This is always true when the code is executed with full trust. For partially trusted code, it's true only if the host explicitly grants the permission. + + > [!IMPORTANT] + > If the permission hasn't been granted, a security exception is thrown when is called or when the dynamic method is invoked, not when this constructor is called. No special permissions are required to emit the dynamic method. + +For example, a dynamic method that's created with `restrictedSkipVisibility` set to `true` can access a private member of any assembly on the call stack if the call stack has been granted restricted member access. If the dynamic method is created with partially trusted code on the call stack, it can't access a private member of a type in a .NET Framework assembly, because such assemblies are fully trusted. + +If `restrictedSkipVisibility` is `false`, JIT visibility checks are enforced. The code in the dynamic method has access to public methods of public classes, and exceptions are thrown if it tries to access types or members that are `private`, `protected`, or `internal`. + +When an anonymously hosted dynamic method is constructed, the call stack of the emitting assembly is included. When the method is invoked, the permissions of the emitting call stack are used instead of the permissions of the actual caller. Thus, the dynamic method can't execute at a higher level of privilege than that of the assembly that emitted it, even if it's passed to and executed by an assembly that has a higher trust level. + +This constructor specifies the method attributes and , and the calling convention . + +> [!NOTE] +> This constructor was introduced in .NET Framework 3.5 or later. + +## constructor + +This constructor specifies method attributes and , calling convention , and doesn't skip just-in-time (JIT) visibility checks. + +The dynamic method created with this constructor has access to public and `internal` (`Friend` in Visual Basic) members of all the types contained in module `m`. + +> [!NOTE] +> For backward compatibility, this constructor demands with the flag if the following conditions are both true: `m` is a module other than the calling module, and the demand for with the flag has failed. If the demand for succeeds, the operation is allowed. + +### Examples + +The following code example creates a dynamic method that takes two parameters. The example emits a simple function body that prints the first parameter to the console, and the example uses the second parameter as the return value of the method. The example completes the method by creating a delegate, invokes the delegate with different parameters, and finally invokes the dynamic method using the method. + +:::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/DynamicMethod/.ctor/source1.cs" id="Snippet1"::: +:::code language="vb" source="~/snippets/visualbasic/System.Reflection.Emit/DynamicMethod/.ctor/source1.vb" id="Snippet1"::: + +## constructor + +The dynamic method created with this constructor has access to all members of the type `owner`, and to public and `internal` (`Friend` in Visual Basic) members of all the other types in the module that contains `owner`. + +This constructor specifies method attributes and , calling convention , and doesn't skip just-in-time (JIT) visibility checks. + +> [!NOTE] +> For backward compatibility, this constructor demands with the flag if the following conditions are both true: `owner` is in a module other than the calling module, and the demand for with the flag has failed. If the demand for succeeds, the operation is allowed. + +### Examples + +The following code example creates a that's logically associated with a type. This association gives it access to the private members of that type. + +The code example defines a class named `Example` with a private field, a class named `DerivedFromExample` that derives from the first class, a delegate type named `UseLikeStatic` that returns and has parameters of type `Example` and , and a delegate type named `UseLikeInstance` that returns and has one parameter of type . + +The example code then creates a that changes the private field of an instance of `Example` and returns the previous value. + +> [!NOTE] +> In general, changing the internal fields of classes isn't good object-oriented coding practice. + +The example code creates an instance of `Example` and then creates two delegates. The first is of type `UseLikeStatic`, which has the same parameters as the dynamic method. The second is of type `UseLikeInstance`, which lacks the first parameter (of type `Example`). This delegate is created using the method overload; the second parameter of that method overload is an instance of `Example`, in this case the instance just created, which is bound to the newly created delegate. Whenever that delegate is invoked, the dynamic method acts on the bound instance of `Example`. + +> [!NOTE] +> This is an example of the relaxed rules for delegate binding introduced in .NET Framework 2.0, along with new overloads of the method. For more information, see the class. + +The `UseLikeStatic` delegate is invoked, passing in the instance of `Example` that's bound to the `UseLikeInstance` delegate. Then the `UseLikeInstance` delegate is invoked, so that both delegates act on the same instance of `Example`. The changes in the values of the internal field are displayed after each call. Finally, a `UseLikeInstance` delegate is bound to an instance of `DerivedFromExample`, and the delegate calls are repeated. + +:::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/DynamicMethod/.ctor/source.cs" id="Snippet1"::: +:::code language="vb" source="~/snippets/visualbasic/System.Reflection.Emit/DynamicMethod/.ctor/source.vb" id="Snippet1"::: diff --git a/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-defineparameter.md b/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-defineparameter.md new file mode 100644 index 0000000000000..aa615217e02a8 --- /dev/null +++ b/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-defineparameter.md @@ -0,0 +1,20 @@ +--- +title: System.Reflection.Emit.DynamicMethod.DefineParameter method +description: Learn about the System.Reflection.Emit.DynamicMethod.DefineParameter method. +ms.date: 02/10/2026 +ai-usage: ai-assisted +--- +# System.Reflection.Emit.DynamicMethod.DefineParameter method + +[!INCLUDE [context](includes/context.md)] + +If `position` is 0, the method refers to the return value. Setting parameter information has no effect on the return value. + +If the dynamic method has already been completed, by calling the or method, the method has no effect. No exception is thrown. + +## Examples + +The following code example shows how to define parameter information for a dynamic method. This code example is part of a larger example provided for the class. + +:::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/DynamicMethod/Overview/source.cs" id="Snippet33"::: +:::code language="vb" source="~/snippets/visualbasic/System.Reflection.Emit/DynamicMethod/Overview/source.vb" id="Snippet33"::: diff --git a/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-getilgenerator.md b/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-getilgenerator.md new file mode 100644 index 0000000000000..cd3f38a6b613e --- /dev/null +++ b/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-getilgenerator.md @@ -0,0 +1,37 @@ +--- +title: System.Reflection.Emit.DynamicMethod.GetILGenerator methods +description: Learn about the System.Reflection.Emit.DynamicMethod.GetILGenerator methods. +ms.date: 02/10/2026 +ai-usage: ai-assisted +--- +# System.Reflection.Emit.DynamicMethod.GetILGenerator methods + +[!INCLUDE [context](includes/context.md)] + +## + +After a dynamic method has been completed, by calling the or method, any further attempt to add MSIL is ignored. No exception is thrown. + +> [!NOTE] +> There are restrictions on unverifiable code in dynamic methods, even in some full-trust scenarios. See the "Verification" section in Remarks for . + +### Examples + +The following code example creates a dynamic method that takes two parameters. The example emits a simple function body that prints the first parameter to the console, and the example uses the second parameter as the return value of the method. The example completes the method by creating a delegate, invokes the delegate with different parameters, and finally invokes the dynamic method using the method. + +:::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/DynamicMethod/.ctor/source1.cs" id="Snippet1"::: +:::code language="vb" source="~/snippets/visualbasic/System.Reflection.Emit/DynamicMethod/.ctor/source1.vb" id="Snippet1"::: + +## + +After a dynamic method has been completed, by calling the or method, any further attempt to add MSIL is ignored. No exception is thrown. + +> [!NOTE] +> There are restrictions on unverifiable code in dynamic methods, even in some full-trust scenarios. See the "Verification" section in Remarks for . + +### Examples + +The following code example demonstrates this method overload. This code example is part of a larger example provided for the class. + +:::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/DynamicMethod/Overview/source.cs" id="Snippet2"::: +:::code language="vb" source="~/snippets/visualbasic/System.Reflection.Emit/DynamicMethod/Overview/source.vb" id="Snippet2"::: diff --git a/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-invoke.md b/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-invoke.md new file mode 100644 index 0000000000000..9202c64d1c51a --- /dev/null +++ b/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-invoke.md @@ -0,0 +1,31 @@ +--- +title: System.Reflection.Emit.DynamicMethod.Invoke method +description: Learn about the System.Reflection.Emit.DynamicMethod.Invoke method. +ms.date: 02/10/2026 +ai-usage: ai-assisted +--- +# System.Reflection.Emit.DynamicMethod.Invoke method + +[!INCLUDE [context](includes/context.md)] + +In addition to the listed exceptions, the calling code should be prepared to catch any exceptions thrown by the dynamic method. + +Executing a dynamic method with a delegate created by the method is more efficient than executing it with the method. + +Calling the method or the method completes the dynamic method. Any further attempt to alter the dynamic method, such as modifying parameter definitions or emitting more Microsoft intermediate language (MSIL), is ignored; no exception is thrown. + +All dynamic methods are static, so the `obj` parameter is always ignored. To treat a dynamic method as if it were an instance method, use the overload that takes an object instance. + +If the dynamic method has no parameters, the value of `parameters` should be `null`. Otherwise the number, type, and order of elements in the parameters array should be identical to the number, type, and order of parameters of the dynamic method. + +> [!NOTE] +> This method overload is called by the method overload inherited from the class, so the preceding remarks apply to both overloads. + +This method doesn't demand permissions directly, but invoking the dynamic method can result in security demands, depending on the method. For example, no demands are made for anonymously hosted dynamic methods that are created with the `restrictedSkipVisibility` parameter set to `false`. On the other hand, if you create a method with `restrictedSkipVisibility` set to `true` so it can access a hidden member of a target assembly, the method causes a demand for the permissions of the target assembly plus with the flag. + +## Examples + +The following code example invokes a dynamic method with exact binding, using the US-English culture. This code example is part of a larger example provided for the class. + +:::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/DynamicMethod/Overview/source.cs" id="Snippet4"::: +:::code language="vb" source="~/snippets/visualbasic/System.Reflection.Emit/DynamicMethod/Overview/source.vb" id="Snippet4"::: diff --git a/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-issecuritycritical.md b/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-issecuritycritical.md new file mode 100644 index 0000000000000..6bae05b6ff73d --- /dev/null +++ b/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-issecuritycritical.md @@ -0,0 +1,41 @@ +--- +title: System.Reflection.Emit.DynamicMethod.IsSecurityCritical property +description: Learn about the System.Reflection.Emit.DynamicMethod.IsSecurityCritical property. +ms.date: 02/10/2026 +ai-usage: ai-assisted +--- +# System.Reflection.Emit.DynamicMethod.IsSecurityCritical property + +[!INCLUDE [context](includes/context.md)] + +The , , and properties report the transparency level of the dynamic method as determined by the common language runtime (CLR). The combinations of these properties are shown in the following table: + +| Security level | IsSecurityCritical | IsSecuritySafeCritical | IsSecurityTransparent | +|----------------|--------------------|-----------------------|-----------------------| +| Critical | `true` | `false` | `false` | +| Safe critical | `true` | `true` | `false` | +| Transparent | `false` | `false` | `true` | + +Using these properties is much simpler than examining the security annotations of an assembly and its types, checking the current trust level, and attempting to duplicate the runtime's rules. + +The transparency of a dynamic method depends on the module it's associated with. If the dynamic method is associated with a type rather than a module, its transparency depends on the module that contains the type. Dynamic methods don't have security annotations, so they're assigned the default transparency for the associated module. + +- Anonymously hosted dynamic methods are always transparent, because the system-provided module that contains them is transparent. + +- The transparency of a dynamic method that's associated with a trusted assembly (that is, a strong-named assembly that's installed in the global assembly cache) is described in the following table. + + | Assembly annotation | Level 1 transparency | Level 2 transparency | + |---------------------|----------------------|----------------------| + | Fully transparent | Transparent | Transparent | + | Fully critical | Critical | Critical | + | Mixed transparency | Transparent | Transparent | + | Security-agnostic | Safe-critical | Critical | + + For example, if you associate a dynamic method with a type that's in mscorlib.dll, which has level 2 mixed transparency, the dynamic method is transparent and can't execute critical code. For information about transparency levels, see [Security-Transparent Code, Level 1](/dotnet/framework/misc/security-transparent-code-level-1) and [Security-Transparent Code, Level 2](/dotnet/framework/misc/security-transparent-code-level-2). + + > [!NOTE] + > Associating a dynamic method with a module in a trusted level 1 assembly that's security-agnostic, such as System.dll, doesn't permit elevation of trust. If the grant set of the code that calls the dynamic method doesn't include the grant set of System.dll (that is, full trust), is thrown when the dynamic method is called. + +- The transparency of a dynamic method that's associated with a partially trusted assembly depends on how the assembly is loaded. If the assembly is loaded with partial trust (for example, into a sandboxed application domain), the runtime ignores the security annotations of the assembly. The assembly and all its types and members, including dynamic methods, are treated as transparent. The runtime pays attention to security annotations only if the partial-trust assembly is loaded with full trust (for example, into the default application domain of a desktop application). In that case, the runtime assigns the dynamic method the default transparency for methods according to the assembly's annotations. + +For more information about reflection emit and transparency, see [Security Issues in Reflection Emit](/dotnet/framework/reflection-and-codedom/security-issues-in-reflection-emit). For information about transparency, see [Security Changes](/dotnet/framework/security/security-changes). diff --git a/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-issecuritysafecritical.md b/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-issecuritysafecritical.md new file mode 100644 index 0000000000000..31e9004707e43 --- /dev/null +++ b/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-issecuritysafecritical.md @@ -0,0 +1,41 @@ +--- +title: System.Reflection.Emit.DynamicMethod.IsSecuritySafeCritical property +description: Learn about the System.Reflection.Emit.DynamicMethod.IsSecuritySafeCritical property. +ms.date: 02/10/2026 +ai-usage: ai-assisted +--- +# System.Reflection.Emit.DynamicMethod.IsSecuritySafeCritical property + +[!INCLUDE [context](includes/context.md)] + +The , , and properties report the transparency level of the dynamic method as determined by the common language runtime (CLR). The combinations of these properties are shown in the following table: + +| Security level | IsSecurityCritical | IsSecuritySafeCritical | IsSecurityTransparent | +|----------------|--------------------|-----------------------|-----------------------| +| Critical | `true` | `false` | `false` | +| Safe critical | `true` | `true` | `false` | +| Transparent | `false` | `false` | `true` | + +Using these properties is much simpler than examining the security annotations of an assembly and its types, checking the current trust level, and attempting to duplicate the runtime's rules. + +The transparency of a dynamic method depends on the module it's associated with. If the dynamic method is associated with a type rather than a module, its transparency depends on the module that contains the type. Dynamic methods don't have security annotations, so they're assigned the default transparency for the associated module. + +- Anonymously hosted dynamic methods are always transparent, because the system-provided module that contains them is transparent. + +- The transparency of a dynamic method that's associated with a trusted assembly (that is, a strong-named assembly that's installed in the global assembly cache) is described in the following table. + + | Assembly annotation | Level 1 transparency | Level 2 transparency | + |---------------------|----------------------|----------------------| + | Fully transparent | Transparent | Transparent | + | Fully critical | Critical | Critical | + | Mixed transparency | Transparent | Transparent | + | Security-agnostic | Safe-critical | Critical | + + For example, if you associate a dynamic method with a type that's in mscorlib.dll, which has level 2 mixed transparency, the dynamic method is transparent and can't execute critical code. For information about transparency levels, see [Security-Transparent Code, Level 1](/dotnet/framework/misc/security-transparent-code-level-1) and [Security-Transparent Code, Level 2](/dotnet/framework/misc/security-transparent-code-level-2). + + > [!NOTE] + > Associating a dynamic method with a module in a trusted level 1 assembly that's security-agnostic, such as System.dll, doesn't permit elevation of trust. If the grant set of the code that calls the dynamic method doesn't include the grant set of System.dll (that is, full trust), is thrown when the dynamic method is called. + +- The transparency of a dynamic method that's associated with a partially trusted assembly depends on how the assembly is loaded. If the assembly is loaded with partial trust (for example, into a sandboxed application domain), the runtime ignores the security annotations of the assembly. The assembly and all its types and members, including dynamic methods, are treated as transparent. The runtime pays attention to security annotations only if the partial-trust assembly is loaded with full trust (for example, into the default application domain of a desktop application). In that case, the runtime assigns the dynamic method the default transparency for methods according to the assembly's annotations. + +For more information about reflection emit and transparency, see [Security Issues in Reflection Emit](/dotnet/framework/reflection-and-codedom/security-issues-in-reflection-emit). For information about transparency, see [Security Changes](/dotnet/framework/security/security-changes). diff --git a/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-issecuritytransparent.md b/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-issecuritytransparent.md new file mode 100644 index 0000000000000..cf20060f09d53 --- /dev/null +++ b/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-issecuritytransparent.md @@ -0,0 +1,41 @@ +--- +title: System.Reflection.Emit.DynamicMethod.IsSecurityTransparent property +description: Learn about the System.Reflection.Emit.DynamicMethod.IsSecurityTransparent property. +ms.date: 02/10/2026 +ai-usage: ai-assisted +--- +# System.Reflection.Emit.DynamicMethod.IsSecurityTransparent property + +[!INCLUDE [context](includes/context.md)] + +The , , and properties report the transparency level of the dynamic method as determined by the common language runtime (CLR). The combinations of these properties are shown in the following table: + +| Security level | IsSecurityCritical | IsSecuritySafeCritical | IsSecurityTransparent | +|----------------|--------------------|-----------------------|-----------------------| +| Critical | `true` | `false` | `false` | +| Safe critical | `true` | `true` | `false` | +| Transparent | `false` | `false` | `true` | + +Using these properties is much simpler than examining the security annotations of an assembly and its types, checking the current trust level, and attempting to duplicate the runtime's rules. + +The transparency of a dynamic method depends on the module it's associated with. If the dynamic method is associated with a type rather than a module, its transparency depends on the module that contains the type. Dynamic methods don't have security annotations, so they're assigned the default transparency for the associated module. + +- Anonymously hosted dynamic methods are always transparent, because the system-provided module that contains them is transparent. + +- The transparency of a dynamic method that's associated with a trusted assembly (that is, a strong-named assembly that's installed in the global assembly cache) is described in the following table. + + | Assembly annotation | Level 1 transparency | Level 2 transparency | + |---------------------|----------------------|----------------------| + | Fully transparent | Transparent | Transparent | + | Fully critical | Critical | Critical | + | Mixed transparency | Transparent | Transparent | + | Security-agnostic | Safe-critical | Critical | + + For example, if you associate a dynamic method with a type that's in mscorlib.dll, which has level 2 mixed transparency, the dynamic method is transparent and can't execute critical code. For information about transparency levels, see [Security-Transparent Code, Level 1](/dotnet/framework/misc/security-transparent-code-level-1) and [Security-Transparent Code, Level 2](/dotnet/framework/misc/security-transparent-code-level-2). + + > [!NOTE] + > Associating a dynamic method with a module in a trusted level 1 assembly that's security-agnostic, such as System.dll, doesn't permit elevation of trust. If the grant set of the code that calls the dynamic method doesn't include the grant set of System.dll (that is, full trust), is thrown when the dynamic method is called. + +- The transparency of a dynamic method that's associated with a partially trusted assembly depends on how the assembly is loaded. If the assembly is loaded with partial trust (for example, into a sandboxed application domain), the runtime ignores the security annotations of the assembly. The assembly and all its types and members, including dynamic methods, are treated as transparent. The runtime pays attention to security annotations only if the partial-trust assembly is loaded with full trust (for example, into the default application domain of a desktop application). In that case, the runtime assigns the dynamic method the default transparency for methods according to the assembly's annotations. + +For more information about reflection emit and transparency, see [Security Issues in Reflection Emit](/dotnet/framework/reflection-and-codedom/security-issues-in-reflection-emit). For information about transparency, see [Security Changes](/dotnet/framework/security/security-changes). diff --git a/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-name.md b/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-name.md new file mode 100644 index 0000000000000..9846db7c93c33 --- /dev/null +++ b/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-name.md @@ -0,0 +1,19 @@ +--- +title: System.Reflection.Emit.DynamicMethod.Name property +description: Learn about the System.Reflection.Emit.DynamicMethod.Name property. +ms.date: 02/10/2026 +ai-usage: ai-assisted +--- +# System.Reflection.Emit.DynamicMethod.Name property + +[!INCLUDE [context](includes/context.md)] + +> [!NOTE] +> It's not necessary to name dynamic methods. + +## Examples + +The following code example displays the name of a dynamic method. This code example is part of a larger example provided for the class. + +:::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/DynamicMethod/Overview/source.cs" id="Snippet27"::: +:::code language="vb" source="~/snippets/visualbasic/System.Reflection.Emit/DynamicMethod/Overview/source.vb" id="Snippet27"::: From 416341dc31c2fbd3dcfa8ffc426fc035222fa421 Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Wed, 11 Feb 2026 10:54:04 -0800 Subject: [PATCH 2/3] Revert "Checkpoint from Copilot CLI for coding agent session" This reverts commit 850af143e31b812db8064a8e3dcb2c50e1f351dd. --- ...ction-emit-dynamicmethod-createdelegate.md | 53 ------------ ...stem-reflection-emit-dynamicmethod-ctor.md | 81 ------------------- ...tion-emit-dynamicmethod-defineparameter.md | 20 ----- ...ction-emit-dynamicmethod-getilgenerator.md | 37 --------- ...em-reflection-emit-dynamicmethod-invoke.md | 31 ------- ...n-emit-dynamicmethod-issecuritycritical.md | 41 ---------- ...it-dynamicmethod-issecuritysafecritical.md | 41 ---------- ...mit-dynamicmethod-issecuritytransparent.md | 41 ---------- ...stem-reflection-emit-dynamicmethod-name.md | 19 ----- 9 files changed, 364 deletions(-) delete mode 100644 docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-createdelegate.md delete mode 100644 docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-ctor.md delete mode 100644 docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-defineparameter.md delete mode 100644 docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-getilgenerator.md delete mode 100644 docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-invoke.md delete mode 100644 docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-issecuritycritical.md delete mode 100644 docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-issecuritysafecritical.md delete mode 100644 docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-issecuritytransparent.md delete mode 100644 docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-name.md diff --git a/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-createdelegate.md b/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-createdelegate.md deleted file mode 100644 index 73b97a9bb51db..0000000000000 --- a/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-createdelegate.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -title: System.Reflection.Emit.DynamicMethod.CreateDelegate methods -description: Learn about the System.Reflection.Emit.DynamicMethod.CreateDelegate methods. -ms.date: 02/10/2026 -ai-usage: ai-assisted ---- -# System.Reflection.Emit.DynamicMethod.CreateDelegate methods - -[!INCLUDE [context](includes/context.md)] - -## - -Calling the method or the method completes the dynamic method. Any further attempt to alter the dynamic method, such as modifying parameter definitions or emitting more Microsoft intermediate language (MSIL), is ignored; no exception is thrown. - -To create a method body for a dynamic method when you have your own MSIL generator, call the method to obtain a object. If you don't have your own MSIL generator, call the method to obtain an object that can be used to generate the method body. - -### Examples - -The following code example creates a dynamic method that takes two parameters. The example emits a simple function body that prints the first parameter to the console, and the example uses the second parameter as the return value of the method. The example completes the method by creating a delegate, invokes the delegate with different parameters, and finally invokes the dynamic method using the method. - -:::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/DynamicMethod/.ctor/source1.cs" id="Snippet1"::: -:::code language="vb" source="~/snippets/visualbasic/System.Reflection.Emit/DynamicMethod/.ctor/source1.vb" id="Snippet1"::: - -## - -This method overload creates a delegate bound to a particular object. Such a delegate is said to be closed over its first argument. Although the method is static, it acts as if it were an instance method; the instance is `target`. - -This method overload requires `target` to be of the same type as the first parameter of the dynamic method, or to be assignable to that type (for example, a derived class). The signature of `delegateType` has all the parameters of the dynamic method except the first. For example, if the dynamic method has the parameters , , and , then `delegateType` has the parameters and ; `target` is of type . - -Calling the method or the method completes the dynamic method. Any further attempt to alter the dynamic method, such as modifying parameter definitions or emitting more Microsoft intermediate language (MSIL), is ignored; no exception is thrown. - -To create a method body for a dynamic method when you have your own MSIL generator, call the method to obtain a object. If you don't have your own MSIL generator, call the method to obtain an object that can be used to generate the method body. - -### Examples - -The following code example creates a delegate that binds a to an instance of a type, so that the method acts on the same instance each time it's invoked. - -The code example defines a class named `Example` with a private field, a class named `DerivedFromExample` that derives from the first class, a delegate type named `UseLikeStatic` that returns and has parameters of type `Example` and , and a delegate type named `UseLikeInstance` that returns and has one parameter of type . - -The example code then creates a that changes the private field of an instance of `Example` and returns the previous value. - -> [!NOTE] -> In general, changing the internal fields of classes isn't good object-oriented coding practice. - -The example code creates an instance of `Example` and then creates two delegates. The first is of type `UseLikeStatic`, which has the same parameters as the dynamic method. The second is of type `UseLikeInstance`, which lacks the first parameter (of type `Example`). This delegate is created using the method overload; the second parameter of that method overload is an instance of `Example`, in this case the instance just created, which is bound to the newly created delegate. Whenever that delegate is invoked, the dynamic method acts on the bound instance of `Example`. - -> [!NOTE] -> This is an example of the relaxed rules for delegate binding introduced in .NET Framework 2.0, along with new overloads of the method. For more information, see the class. - -The `UseLikeStatic` delegate is invoked, passing in the instance of `Example` that's bound to the `UseLikeInstance` delegate. Then the `UseLikeInstance` delegate is invoked, so that both delegates act on the same instance of `Example`. The changes in the values of the internal field are displayed after each call. Finally, a `UseLikeInstance` delegate is bound to an instance of `DerivedFromExample`, and the delegate calls are repeated. - -:::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/DynamicMethod/.ctor/source.cs" id="Snippet1"::: -:::code language="vb" source="~/snippets/visualbasic/System.Reflection.Emit/DynamicMethod/.ctor/source.vb" id="Snippet1"::: diff --git a/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-ctor.md b/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-ctor.md deleted file mode 100644 index 52d4369258275..0000000000000 --- a/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-ctor.md +++ /dev/null @@ -1,81 +0,0 @@ ---- -title: System.Reflection.Emit.DynamicMethod constructors -description: Learn about the System.Reflection.Emit.DynamicMethod constructors. -ms.date: 02/10/2026 -ai-usage: ai-assisted ---- -# System.Reflection.Emit.DynamicMethod constructors - -[!INCLUDE [context](includes/context.md)] - -## constructor - -The dynamic method that is created by this constructor is associated with an anonymous assembly instead of an existing type or module. The anonymous assembly exists only to provide a sandbox environment for dynamic methods, that is, to isolate them from other code. This environment makes it safe for the dynamic method to be emitted and executed by partially trusted code. - -Anonymously hosted dynamic methods don't have automatic access to any types or members that are `private`, `protected`, or `internal` (`Friend` in Visual Basic). This is different from dynamic methods that are associated with an existing type or module, which have access to hidden members in their associated scope. - -Specify `true` for `restrictedSkipVisibility` if your dynamic method has to access types or members that are `private`, `protected`, or `internal`. This gives the dynamic method restricted access to these members. That is, the members can be accessed only if the following conditions are met: - -- The target members belong to an assembly that has a level of trust equal to or lower than the call stack that emits the dynamic method. - -- The call stack that emits the dynamic method is granted with the flag. This is always true when the code is executed with full trust. For partially trusted code, it's true only if the host explicitly grants the permission. - - > [!IMPORTANT] - > If the permission hasn't been granted, a security exception is thrown when is called or when the dynamic method is invoked, not when this constructor is called. No special permissions are required to emit the dynamic method. - -For example, a dynamic method that's created with `restrictedSkipVisibility` set to `true` can access a private member of any assembly on the call stack if the call stack has been granted restricted member access. If the dynamic method is created with partially trusted code on the call stack, it can't access a private member of a type in a .NET Framework assembly, because such assemblies are fully trusted. - -If `restrictedSkipVisibility` is `false`, JIT visibility checks are enforced. The code in the dynamic method has access to public methods of public classes, and exceptions are thrown if it tries to access types or members that are `private`, `protected`, or `internal`. - -When an anonymously hosted dynamic method is constructed, the call stack of the emitting assembly is included. When the method is invoked, the permissions of the emitting call stack are used instead of the permissions of the actual caller. Thus, the dynamic method can't execute at a higher level of privilege than that of the assembly that emitted it, even if it's passed to and executed by an assembly that has a higher trust level. - -This constructor specifies the method attributes and , and the calling convention . - -> [!NOTE] -> This constructor was introduced in .NET Framework 3.5 or later. - -## constructor - -This constructor specifies method attributes and , calling convention , and doesn't skip just-in-time (JIT) visibility checks. - -The dynamic method created with this constructor has access to public and `internal` (`Friend` in Visual Basic) members of all the types contained in module `m`. - -> [!NOTE] -> For backward compatibility, this constructor demands with the flag if the following conditions are both true: `m` is a module other than the calling module, and the demand for with the flag has failed. If the demand for succeeds, the operation is allowed. - -### Examples - -The following code example creates a dynamic method that takes two parameters. The example emits a simple function body that prints the first parameter to the console, and the example uses the second parameter as the return value of the method. The example completes the method by creating a delegate, invokes the delegate with different parameters, and finally invokes the dynamic method using the method. - -:::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/DynamicMethod/.ctor/source1.cs" id="Snippet1"::: -:::code language="vb" source="~/snippets/visualbasic/System.Reflection.Emit/DynamicMethod/.ctor/source1.vb" id="Snippet1"::: - -## constructor - -The dynamic method created with this constructor has access to all members of the type `owner`, and to public and `internal` (`Friend` in Visual Basic) members of all the other types in the module that contains `owner`. - -This constructor specifies method attributes and , calling convention , and doesn't skip just-in-time (JIT) visibility checks. - -> [!NOTE] -> For backward compatibility, this constructor demands with the flag if the following conditions are both true: `owner` is in a module other than the calling module, and the demand for with the flag has failed. If the demand for succeeds, the operation is allowed. - -### Examples - -The following code example creates a that's logically associated with a type. This association gives it access to the private members of that type. - -The code example defines a class named `Example` with a private field, a class named `DerivedFromExample` that derives from the first class, a delegate type named `UseLikeStatic` that returns and has parameters of type `Example` and , and a delegate type named `UseLikeInstance` that returns and has one parameter of type . - -The example code then creates a that changes the private field of an instance of `Example` and returns the previous value. - -> [!NOTE] -> In general, changing the internal fields of classes isn't good object-oriented coding practice. - -The example code creates an instance of `Example` and then creates two delegates. The first is of type `UseLikeStatic`, which has the same parameters as the dynamic method. The second is of type `UseLikeInstance`, which lacks the first parameter (of type `Example`). This delegate is created using the method overload; the second parameter of that method overload is an instance of `Example`, in this case the instance just created, which is bound to the newly created delegate. Whenever that delegate is invoked, the dynamic method acts on the bound instance of `Example`. - -> [!NOTE] -> This is an example of the relaxed rules for delegate binding introduced in .NET Framework 2.0, along with new overloads of the method. For more information, see the class. - -The `UseLikeStatic` delegate is invoked, passing in the instance of `Example` that's bound to the `UseLikeInstance` delegate. Then the `UseLikeInstance` delegate is invoked, so that both delegates act on the same instance of `Example`. The changes in the values of the internal field are displayed after each call. Finally, a `UseLikeInstance` delegate is bound to an instance of `DerivedFromExample`, and the delegate calls are repeated. - -:::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/DynamicMethod/.ctor/source.cs" id="Snippet1"::: -:::code language="vb" source="~/snippets/visualbasic/System.Reflection.Emit/DynamicMethod/.ctor/source.vb" id="Snippet1"::: diff --git a/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-defineparameter.md b/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-defineparameter.md deleted file mode 100644 index aa615217e02a8..0000000000000 --- a/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-defineparameter.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -title: System.Reflection.Emit.DynamicMethod.DefineParameter method -description: Learn about the System.Reflection.Emit.DynamicMethod.DefineParameter method. -ms.date: 02/10/2026 -ai-usage: ai-assisted ---- -# System.Reflection.Emit.DynamicMethod.DefineParameter method - -[!INCLUDE [context](includes/context.md)] - -If `position` is 0, the method refers to the return value. Setting parameter information has no effect on the return value. - -If the dynamic method has already been completed, by calling the or method, the method has no effect. No exception is thrown. - -## Examples - -The following code example shows how to define parameter information for a dynamic method. This code example is part of a larger example provided for the class. - -:::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/DynamicMethod/Overview/source.cs" id="Snippet33"::: -:::code language="vb" source="~/snippets/visualbasic/System.Reflection.Emit/DynamicMethod/Overview/source.vb" id="Snippet33"::: diff --git a/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-getilgenerator.md b/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-getilgenerator.md deleted file mode 100644 index cd3f38a6b613e..0000000000000 --- a/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-getilgenerator.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -title: System.Reflection.Emit.DynamicMethod.GetILGenerator methods -description: Learn about the System.Reflection.Emit.DynamicMethod.GetILGenerator methods. -ms.date: 02/10/2026 -ai-usage: ai-assisted ---- -# System.Reflection.Emit.DynamicMethod.GetILGenerator methods - -[!INCLUDE [context](includes/context.md)] - -## - -After a dynamic method has been completed, by calling the or method, any further attempt to add MSIL is ignored. No exception is thrown. - -> [!NOTE] -> There are restrictions on unverifiable code in dynamic methods, even in some full-trust scenarios. See the "Verification" section in Remarks for . - -### Examples - -The following code example creates a dynamic method that takes two parameters. The example emits a simple function body that prints the first parameter to the console, and the example uses the second parameter as the return value of the method. The example completes the method by creating a delegate, invokes the delegate with different parameters, and finally invokes the dynamic method using the method. - -:::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/DynamicMethod/.ctor/source1.cs" id="Snippet1"::: -:::code language="vb" source="~/snippets/visualbasic/System.Reflection.Emit/DynamicMethod/.ctor/source1.vb" id="Snippet1"::: - -## - -After a dynamic method has been completed, by calling the or method, any further attempt to add MSIL is ignored. No exception is thrown. - -> [!NOTE] -> There are restrictions on unverifiable code in dynamic methods, even in some full-trust scenarios. See the "Verification" section in Remarks for . - -### Examples - -The following code example demonstrates this method overload. This code example is part of a larger example provided for the class. - -:::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/DynamicMethod/Overview/source.cs" id="Snippet2"::: -:::code language="vb" source="~/snippets/visualbasic/System.Reflection.Emit/DynamicMethod/Overview/source.vb" id="Snippet2"::: diff --git a/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-invoke.md b/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-invoke.md deleted file mode 100644 index 9202c64d1c51a..0000000000000 --- a/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-invoke.md +++ /dev/null @@ -1,31 +0,0 @@ ---- -title: System.Reflection.Emit.DynamicMethod.Invoke method -description: Learn about the System.Reflection.Emit.DynamicMethod.Invoke method. -ms.date: 02/10/2026 -ai-usage: ai-assisted ---- -# System.Reflection.Emit.DynamicMethod.Invoke method - -[!INCLUDE [context](includes/context.md)] - -In addition to the listed exceptions, the calling code should be prepared to catch any exceptions thrown by the dynamic method. - -Executing a dynamic method with a delegate created by the method is more efficient than executing it with the method. - -Calling the method or the method completes the dynamic method. Any further attempt to alter the dynamic method, such as modifying parameter definitions or emitting more Microsoft intermediate language (MSIL), is ignored; no exception is thrown. - -All dynamic methods are static, so the `obj` parameter is always ignored. To treat a dynamic method as if it were an instance method, use the overload that takes an object instance. - -If the dynamic method has no parameters, the value of `parameters` should be `null`. Otherwise the number, type, and order of elements in the parameters array should be identical to the number, type, and order of parameters of the dynamic method. - -> [!NOTE] -> This method overload is called by the method overload inherited from the class, so the preceding remarks apply to both overloads. - -This method doesn't demand permissions directly, but invoking the dynamic method can result in security demands, depending on the method. For example, no demands are made for anonymously hosted dynamic methods that are created with the `restrictedSkipVisibility` parameter set to `false`. On the other hand, if you create a method with `restrictedSkipVisibility` set to `true` so it can access a hidden member of a target assembly, the method causes a demand for the permissions of the target assembly plus with the flag. - -## Examples - -The following code example invokes a dynamic method with exact binding, using the US-English culture. This code example is part of a larger example provided for the class. - -:::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/DynamicMethod/Overview/source.cs" id="Snippet4"::: -:::code language="vb" source="~/snippets/visualbasic/System.Reflection.Emit/DynamicMethod/Overview/source.vb" id="Snippet4"::: diff --git a/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-issecuritycritical.md b/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-issecuritycritical.md deleted file mode 100644 index 6bae05b6ff73d..0000000000000 --- a/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-issecuritycritical.md +++ /dev/null @@ -1,41 +0,0 @@ ---- -title: System.Reflection.Emit.DynamicMethod.IsSecurityCritical property -description: Learn about the System.Reflection.Emit.DynamicMethod.IsSecurityCritical property. -ms.date: 02/10/2026 -ai-usage: ai-assisted ---- -# System.Reflection.Emit.DynamicMethod.IsSecurityCritical property - -[!INCLUDE [context](includes/context.md)] - -The , , and properties report the transparency level of the dynamic method as determined by the common language runtime (CLR). The combinations of these properties are shown in the following table: - -| Security level | IsSecurityCritical | IsSecuritySafeCritical | IsSecurityTransparent | -|----------------|--------------------|-----------------------|-----------------------| -| Critical | `true` | `false` | `false` | -| Safe critical | `true` | `true` | `false` | -| Transparent | `false` | `false` | `true` | - -Using these properties is much simpler than examining the security annotations of an assembly and its types, checking the current trust level, and attempting to duplicate the runtime's rules. - -The transparency of a dynamic method depends on the module it's associated with. If the dynamic method is associated with a type rather than a module, its transparency depends on the module that contains the type. Dynamic methods don't have security annotations, so they're assigned the default transparency for the associated module. - -- Anonymously hosted dynamic methods are always transparent, because the system-provided module that contains them is transparent. - -- The transparency of a dynamic method that's associated with a trusted assembly (that is, a strong-named assembly that's installed in the global assembly cache) is described in the following table. - - | Assembly annotation | Level 1 transparency | Level 2 transparency | - |---------------------|----------------------|----------------------| - | Fully transparent | Transparent | Transparent | - | Fully critical | Critical | Critical | - | Mixed transparency | Transparent | Transparent | - | Security-agnostic | Safe-critical | Critical | - - For example, if you associate a dynamic method with a type that's in mscorlib.dll, which has level 2 mixed transparency, the dynamic method is transparent and can't execute critical code. For information about transparency levels, see [Security-Transparent Code, Level 1](/dotnet/framework/misc/security-transparent-code-level-1) and [Security-Transparent Code, Level 2](/dotnet/framework/misc/security-transparent-code-level-2). - - > [!NOTE] - > Associating a dynamic method with a module in a trusted level 1 assembly that's security-agnostic, such as System.dll, doesn't permit elevation of trust. If the grant set of the code that calls the dynamic method doesn't include the grant set of System.dll (that is, full trust), is thrown when the dynamic method is called. - -- The transparency of a dynamic method that's associated with a partially trusted assembly depends on how the assembly is loaded. If the assembly is loaded with partial trust (for example, into a sandboxed application domain), the runtime ignores the security annotations of the assembly. The assembly and all its types and members, including dynamic methods, are treated as transparent. The runtime pays attention to security annotations only if the partial-trust assembly is loaded with full trust (for example, into the default application domain of a desktop application). In that case, the runtime assigns the dynamic method the default transparency for methods according to the assembly's annotations. - -For more information about reflection emit and transparency, see [Security Issues in Reflection Emit](/dotnet/framework/reflection-and-codedom/security-issues-in-reflection-emit). For information about transparency, see [Security Changes](/dotnet/framework/security/security-changes). diff --git a/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-issecuritysafecritical.md b/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-issecuritysafecritical.md deleted file mode 100644 index 31e9004707e43..0000000000000 --- a/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-issecuritysafecritical.md +++ /dev/null @@ -1,41 +0,0 @@ ---- -title: System.Reflection.Emit.DynamicMethod.IsSecuritySafeCritical property -description: Learn about the System.Reflection.Emit.DynamicMethod.IsSecuritySafeCritical property. -ms.date: 02/10/2026 -ai-usage: ai-assisted ---- -# System.Reflection.Emit.DynamicMethod.IsSecuritySafeCritical property - -[!INCLUDE [context](includes/context.md)] - -The , , and properties report the transparency level of the dynamic method as determined by the common language runtime (CLR). The combinations of these properties are shown in the following table: - -| Security level | IsSecurityCritical | IsSecuritySafeCritical | IsSecurityTransparent | -|----------------|--------------------|-----------------------|-----------------------| -| Critical | `true` | `false` | `false` | -| Safe critical | `true` | `true` | `false` | -| Transparent | `false` | `false` | `true` | - -Using these properties is much simpler than examining the security annotations of an assembly and its types, checking the current trust level, and attempting to duplicate the runtime's rules. - -The transparency of a dynamic method depends on the module it's associated with. If the dynamic method is associated with a type rather than a module, its transparency depends on the module that contains the type. Dynamic methods don't have security annotations, so they're assigned the default transparency for the associated module. - -- Anonymously hosted dynamic methods are always transparent, because the system-provided module that contains them is transparent. - -- The transparency of a dynamic method that's associated with a trusted assembly (that is, a strong-named assembly that's installed in the global assembly cache) is described in the following table. - - | Assembly annotation | Level 1 transparency | Level 2 transparency | - |---------------------|----------------------|----------------------| - | Fully transparent | Transparent | Transparent | - | Fully critical | Critical | Critical | - | Mixed transparency | Transparent | Transparent | - | Security-agnostic | Safe-critical | Critical | - - For example, if you associate a dynamic method with a type that's in mscorlib.dll, which has level 2 mixed transparency, the dynamic method is transparent and can't execute critical code. For information about transparency levels, see [Security-Transparent Code, Level 1](/dotnet/framework/misc/security-transparent-code-level-1) and [Security-Transparent Code, Level 2](/dotnet/framework/misc/security-transparent-code-level-2). - - > [!NOTE] - > Associating a dynamic method with a module in a trusted level 1 assembly that's security-agnostic, such as System.dll, doesn't permit elevation of trust. If the grant set of the code that calls the dynamic method doesn't include the grant set of System.dll (that is, full trust), is thrown when the dynamic method is called. - -- The transparency of a dynamic method that's associated with a partially trusted assembly depends on how the assembly is loaded. If the assembly is loaded with partial trust (for example, into a sandboxed application domain), the runtime ignores the security annotations of the assembly. The assembly and all its types and members, including dynamic methods, are treated as transparent. The runtime pays attention to security annotations only if the partial-trust assembly is loaded with full trust (for example, into the default application domain of a desktop application). In that case, the runtime assigns the dynamic method the default transparency for methods according to the assembly's annotations. - -For more information about reflection emit and transparency, see [Security Issues in Reflection Emit](/dotnet/framework/reflection-and-codedom/security-issues-in-reflection-emit). For information about transparency, see [Security Changes](/dotnet/framework/security/security-changes). diff --git a/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-issecuritytransparent.md b/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-issecuritytransparent.md deleted file mode 100644 index cf20060f09d53..0000000000000 --- a/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-issecuritytransparent.md +++ /dev/null @@ -1,41 +0,0 @@ ---- -title: System.Reflection.Emit.DynamicMethod.IsSecurityTransparent property -description: Learn about the System.Reflection.Emit.DynamicMethod.IsSecurityTransparent property. -ms.date: 02/10/2026 -ai-usage: ai-assisted ---- -# System.Reflection.Emit.DynamicMethod.IsSecurityTransparent property - -[!INCLUDE [context](includes/context.md)] - -The , , and properties report the transparency level of the dynamic method as determined by the common language runtime (CLR). The combinations of these properties are shown in the following table: - -| Security level | IsSecurityCritical | IsSecuritySafeCritical | IsSecurityTransparent | -|----------------|--------------------|-----------------------|-----------------------| -| Critical | `true` | `false` | `false` | -| Safe critical | `true` | `true` | `false` | -| Transparent | `false` | `false` | `true` | - -Using these properties is much simpler than examining the security annotations of an assembly and its types, checking the current trust level, and attempting to duplicate the runtime's rules. - -The transparency of a dynamic method depends on the module it's associated with. If the dynamic method is associated with a type rather than a module, its transparency depends on the module that contains the type. Dynamic methods don't have security annotations, so they're assigned the default transparency for the associated module. - -- Anonymously hosted dynamic methods are always transparent, because the system-provided module that contains them is transparent. - -- The transparency of a dynamic method that's associated with a trusted assembly (that is, a strong-named assembly that's installed in the global assembly cache) is described in the following table. - - | Assembly annotation | Level 1 transparency | Level 2 transparency | - |---------------------|----------------------|----------------------| - | Fully transparent | Transparent | Transparent | - | Fully critical | Critical | Critical | - | Mixed transparency | Transparent | Transparent | - | Security-agnostic | Safe-critical | Critical | - - For example, if you associate a dynamic method with a type that's in mscorlib.dll, which has level 2 mixed transparency, the dynamic method is transparent and can't execute critical code. For information about transparency levels, see [Security-Transparent Code, Level 1](/dotnet/framework/misc/security-transparent-code-level-1) and [Security-Transparent Code, Level 2](/dotnet/framework/misc/security-transparent-code-level-2). - - > [!NOTE] - > Associating a dynamic method with a module in a trusted level 1 assembly that's security-agnostic, such as System.dll, doesn't permit elevation of trust. If the grant set of the code that calls the dynamic method doesn't include the grant set of System.dll (that is, full trust), is thrown when the dynamic method is called. - -- The transparency of a dynamic method that's associated with a partially trusted assembly depends on how the assembly is loaded. If the assembly is loaded with partial trust (for example, into a sandboxed application domain), the runtime ignores the security annotations of the assembly. The assembly and all its types and members, including dynamic methods, are treated as transparent. The runtime pays attention to security annotations only if the partial-trust assembly is loaded with full trust (for example, into the default application domain of a desktop application). In that case, the runtime assigns the dynamic method the default transparency for methods according to the assembly's annotations. - -For more information about reflection emit and transparency, see [Security Issues in Reflection Emit](/dotnet/framework/reflection-and-codedom/security-issues-in-reflection-emit). For information about transparency, see [Security Changes](/dotnet/framework/security/security-changes). diff --git a/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-name.md b/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-name.md deleted file mode 100644 index 9846db7c93c33..0000000000000 --- a/docs/fundamentals/runtime-libraries/system-reflection-emit-dynamicmethod-name.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -title: System.Reflection.Emit.DynamicMethod.Name property -description: Learn about the System.Reflection.Emit.DynamicMethod.Name property. -ms.date: 02/10/2026 -ai-usage: ai-assisted ---- -# System.Reflection.Emit.DynamicMethod.Name property - -[!INCLUDE [context](includes/context.md)] - -> [!NOTE] -> It's not necessary to name dynamic methods. - -## Examples - -The following code example displays the name of a dynamic method. This code example is part of a larger example provided for the class. - -:::code language="csharp" source="~/snippets/csharp/System.Reflection.Emit/DynamicMethod/Overview/source.cs" id="Snippet27"::: -:::code language="vb" source="~/snippets/visualbasic/System.Reflection.Emit/DynamicMethod/Overview/source.vb" id="Snippet27"::: From 217513c92c85eb99c36bdb3f06c844fa56b025b6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 11 Feb 2026 18:58:48 +0000 Subject: [PATCH 3/3] Bump Microsoft.Orleans.Client and 2 others Bumps Microsoft.Orleans.Client from 10.0.0 to 10.0.1 Bumps Microsoft.Orleans.Sdk from 10.0.0 to 10.0.1 Bumps Microsoft.Orleans.Server from 10.0.0 to 10.0.1 --- updated-dependencies: - dependency-name: Microsoft.Orleans.Client dependency-version: 10.0.1 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: dotnet - dependency-name: Microsoft.Orleans.Sdk dependency-version: 10.0.1 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: dotnet - dependency-name: Microsoft.Orleans.Sdk dependency-version: 10.0.1 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: dotnet - dependency-name: Microsoft.Orleans.Sdk dependency-version: 10.0.1 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: dotnet - dependency-name: Microsoft.Orleans.Server dependency-version: 10.0.1 dependency-type: direct:production update-type: version-update:semver-patch dependency-group: dotnet ... Signed-off-by: dependabot[bot] --- .../tutorials-and-samples/snippets/minimal/Client/Client.csproj | 2 +- .../snippets/minimal/GrainInterfaces/GrainInterfaces.csproj | 2 +- .../tutorials-and-samples/snippets/minimal/Grains/Grains.csproj | 2 +- .../tutorials-and-samples/snippets/minimal/Silo/Silo.csproj | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/orleans/tutorials-and-samples/snippets/minimal/Client/Client.csproj b/docs/orleans/tutorials-and-samples/snippets/minimal/Client/Client.csproj index f22beea3fe42c..f5574f1be7897 100644 --- a/docs/orleans/tutorials-and-samples/snippets/minimal/Client/Client.csproj +++ b/docs/orleans/tutorials-and-samples/snippets/minimal/Client/Client.csproj @@ -7,7 +7,7 @@ - + diff --git a/docs/orleans/tutorials-and-samples/snippets/minimal/GrainInterfaces/GrainInterfaces.csproj b/docs/orleans/tutorials-and-samples/snippets/minimal/GrainInterfaces/GrainInterfaces.csproj index 584c5d821eeef..a8fb1a4257cb0 100644 --- a/docs/orleans/tutorials-and-samples/snippets/minimal/GrainInterfaces/GrainInterfaces.csproj +++ b/docs/orleans/tutorials-and-samples/snippets/minimal/GrainInterfaces/GrainInterfaces.csproj @@ -4,7 +4,7 @@ - + diff --git a/docs/orleans/tutorials-and-samples/snippets/minimal/Grains/Grains.csproj b/docs/orleans/tutorials-and-samples/snippets/minimal/Grains/Grains.csproj index 97557c1611c9e..6a0733448c144 100644 --- a/docs/orleans/tutorials-and-samples/snippets/minimal/Grains/Grains.csproj +++ b/docs/orleans/tutorials-and-samples/snippets/minimal/Grains/Grains.csproj @@ -1,7 +1,7 @@ - + diff --git a/docs/orleans/tutorials-and-samples/snippets/minimal/Silo/Silo.csproj b/docs/orleans/tutorials-and-samples/snippets/minimal/Silo/Silo.csproj index 804cb640894a3..b430cf71ab909 100644 --- a/docs/orleans/tutorials-and-samples/snippets/minimal/Silo/Silo.csproj +++ b/docs/orleans/tutorials-and-samples/snippets/minimal/Silo/Silo.csproj @@ -8,7 +8,7 @@ - +