Skip to content

Commit 0048802

Browse files
committed
Code review comments
1 parent 0e30e9a commit 0048802

File tree

1 file changed

+13
-23
lines changed

1 file changed

+13
-23
lines changed

xml/System/Type.xml

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9036,15 +9036,11 @@ You can use the <xref:System.Type.GetType%2A> method to obtain a <xref:System.Ty
90369036
> [!NOTE]
90379037
> If `typeName` cannot be found, the call to the <xref:System.Type.GetType%28System.String%29> method returns `null`. It does not throw an exception. To control whether an exception is thrown, call an overload of the <xref:System.Type.GetType%2A> method that has a `throwOnError` parameter.
90389038

9039-
> [!NOTE]
9040-
> .NET Framework only
9041-
> <xref:System.Type.GetType%2A> only works on assemblies loaded from disk. If you call <xref:System.Type.GetType%2A> to look up a type defined in a dynamic assembly defined using the <xref:System.Reflection.Emit> services, you might get inconsistent behavior. The behavior depends on whether the dynamic assembly is persistent, that is, created using the `RunAndSave` or `Save` access modes of the <xref:System.Reflection.Emit.AssemblyBuilderAccess?displayProperty=nameWithType> enumeration. If the dynamic assembly is persistent and has been written to disk before `GetType` is called, the loader finds the saved assembly on disk, loads that assembly, and retrieves the type from that assembly. If the assembly has not been saved to disk when `GetType` is called, the method returns `null`. `GetType` does not understand transient dynamic assemblies; therefore, calling `GetType` to retrieve a type in a transient dynamic assembly returns `null`.
9042-
>
9043-
> To use `GetType` on a dynamic module, subscribe to the <xref:System.AppDomain.AssemblyResolve?displayProperty=nameWithType> event and call `GetType` before saving. Otherwise, you will get two copies of the assembly in memory.
9044-
9045-
> [!NOTE]
9046-
> .NET Core 3.0, .NET Core 3.1 and .NET 5+: Assembly loads triggered by this api are affected by the current value of <xref:System.Runtime.Loader.AssemblyLoadContext.CurrentContextualReflectionContext%2A?displayProperty=nameWithType>.
9039+
.NET Framework only: <xref:System.Type.GetType%2A> only works on assemblies loaded from disk. If you call <xref:System.Type.GetType%2A> to look up a type defined in a dynamic assembly defined using the <xref:System.Reflection.Emit> services, you might get inconsistent behavior. The behavior depends on whether the dynamic assembly is persistent, that is, created using the `RunAndSave` or `Save` access modes of the <xref:System.Reflection.Emit.AssemblyBuilderAccess?displayProperty=nameWithType> enumeration. If the dynamic assembly is persistent and has been written to disk before `GetType` is called, the loader finds the saved assembly on disk, loads that assembly, and retrieves the type from that assembly. If the assembly has not been saved to disk when `GetType` is called, the method returns `null`. `GetType` does not understand transient dynamic assemblies; therefore, calling `GetType` to retrieve a type in a transient dynamic assembly returns `null`.
9040+
9041+
In .NET Framework, to use `GetType` on a dynamic module, subscribe to the <xref:System.AppDomain.AssemblyResolve?displayProperty=nameWithType> event and call `GetType` before saving. Otherwise, you will get two copies of the assembly in memory.
90479042

9043+
On .NET Core 3.0 and later versions, assembly loads triggered by this API are affected by the current value of <xref:System.Runtime.Loader.AssemblyLoadContext.CurrentContextualReflectionContext%2A?displayProperty=nameWithType>.
90489044

90499045
The following table shows what members of a base class are returned by the `Get` methods when reflecting on a type.
90509046

@@ -9250,14 +9246,11 @@ Note: In <see href="https://go.microsoft.com/fwlink/?LinkID=247912">.NET for Win
92509246
## Remarks
92519247
You can use the <xref:System.Type.GetType%2A> method to obtain a <xref:System.Type> object for a type in another assembly if you know its assembly-qualified name, which can be obtained from <xref:System.Type.AssemblyQualifiedName>. <xref:System.Type.GetType%2A> causes loading of the assembly specified in `typeName`. You can also load an assembly using the <xref:System.Reflection.Assembly.Load%2A?displayProperty=nameWithType> method, and then use the <xref:System.Reflection.Assembly.GetType%2A?displayProperty=nameWithType> or <xref:System.Reflection.Assembly.GetTypes%2A?displayProperty=nameWithType> method to get <xref:System.Type> objects. If a type is in an assembly known to your program at compile time, it's more efficient to use `typeof` in C# or the `GetType` operator in Visual Basic.
92529248

9253-
> [!NOTE]
9254-
> .NET Framework only
9255-
> <xref:System.Type.GetType%2A> only works on assemblies loaded from disk. If you call <xref:System.Type.GetType%2A> to look up a type defined in a dynamic assembly defined using the <xref:System.Reflection.Emit> services, you might get inconsistent behavior. The behavior depends on whether the dynamic assembly is persistent, that is, created using the `RunAndSave` or `Save` access modes of the <xref:System.Reflection.Emit.AssemblyBuilderAccess?displayProperty=nameWithType> enumeration. If the dynamic assembly is persistent and has been written to disk before `GetType` is called, the loader finds the saved assembly on disk, loads that assembly, and retrieves the type from that assembly. If the assembly has not been saved to disk when `GetType` is called, the method returns `null`. `GetType` does not understand transient dynamic assemblies; therefore, calling `GetType` to retrieve a type in a transient dynamic assembly returns `null`.
9256-
>
9257-
> To use `GetType` on a dynamic module, subscribe to the <xref:System.AppDomain.AssemblyResolve?displayProperty=nameWithType> event and call `GetType` before saving. Otherwise, you will get two copies of the assembly in memory.
9249+
.NET Framework only: <xref:System.Type.GetType%2A> only works on assemblies loaded from disk. If you call <xref:System.Type.GetType%2A> to look up a type defined in a dynamic assembly defined using the <xref:System.Reflection.Emit> services, you might get inconsistent behavior. The behavior depends on whether the dynamic assembly is persistent, that is, created using the `RunAndSave` or `Save` access modes of the <xref:System.Reflection.Emit.AssemblyBuilderAccess?displayProperty=nameWithType> enumeration. If the dynamic assembly is persistent and has been written to disk before `GetType` is called, the loader finds the saved assembly on disk, loads that assembly, and retrieves the type from that assembly. If the assembly has not been saved to disk when `GetType` is called, the method returns `null`. `GetType` does not understand transient dynamic assemblies; therefore, calling `GetType` to retrieve a type in a transient dynamic assembly returns `null`.
9250+
9251+
In .NET Framework, to use `GetType` on a dynamic module, subscribe to the <xref:System.AppDomain.AssemblyResolve?displayProperty=nameWithType> event and call `GetType` before saving. Otherwise, you will get two copies of the assembly in memory.
92589252

9259-
> [!NOTE]
9260-
> .NET Core 3.0, .NET Core 3.1 and .NET 5+: Assembly loads triggered by this api are affected by the current value of <xref:System.Runtime.Loader.AssemblyLoadContext.CurrentContextualReflectionContext%2A?displayProperty=nameWithType>.
9253+
On .NET Core 3.0 and later versions, assembly loads triggered by this API are affected by the current value of <xref:System.Runtime.Loader.AssemblyLoadContext.CurrentContextualReflectionContext%2A?displayProperty=nameWithType>.
92619254

92629255
The `throwOnError` parameter specifies what happens when the type is not found, and also suppresses certain other exception conditions, as described in the Exceptions section. Some exceptions are thrown regardless of the value of `throwOnError`. For example, if the type is found but cannot be loaded, a <xref:System.TypeLoadException> is thrown even if `throwOnError` is `false`.
92639256

@@ -9490,14 +9483,11 @@ Note: In <see href="https://go.microsoft.com/fwlink/?LinkID=247912">.NET for Win
94909483
## Remarks
94919484
You can use the <xref:System.Type.GetType%2A> method to obtain a <xref:System.Type> object for a type in another assembly if you know its assembly-qualified name, which can be obtained from <xref:System.Type.AssemblyQualifiedName>. <xref:System.Type.GetType%2A> causes loading of the assembly specified in `typeName`. You can also load an assembly using the <xref:System.Reflection.Assembly.Load%2A?displayProperty=nameWithType> method, and then use the <xref:System.Reflection.Assembly.GetType%2A?displayProperty=nameWithType> or <xref:System.Reflection.Assembly.GetTypes%2A?displayProperty=nameWithType> method to get <xref:System.Type> objects. If a type is in an assembly known to your program at compile time, it's more efficient to use `typeof` in C# or the `GetType` operator in Visual Basic.
94929485

9493-
> [!NOTE]
9494-
> .NET Framework only
9495-
> <xref:System.Type.GetType%2A> only works on assemblies loaded from disk. If you call <xref:System.Type.GetType%2A> to look up a type defined in a dynamic assembly defined using the <xref:System.Reflection.Emit> services, you might get inconsistent behavior. The behavior depends on whether the dynamic assembly is persistent, that is, created using the `RunAndSave` or `Save` access modes of the <xref:System.Reflection.Emit.AssemblyBuilderAccess?displayProperty=nameWithType> enumeration. If the dynamic assembly is persistent and has been written to disk before `GetType` is called, the loader finds the saved assembly on disk, loads that assembly, and retrieves the type from that assembly. If the assembly has not been saved to disk when `GetType` is called, the method returns `null`. `GetType` does not understand transient dynamic assemblies; therefore, calling `GetType` to retrieve a type in a transient dynamic assembly returns `null`.
9496-
>
9497-
> To use `GetType` on a dynamic module, subscribe to the <xref:System.AppDomain.AssemblyResolve?displayProperty=nameWithType> event and call `GetType` before saving. Otherwise, you will get two copies of the assembly in memory.
9486+
.NET Framework only: <xref:System.Type.GetType%2A> only works on assemblies loaded from disk. If you call <xref:System.Type.GetType%2A> to look up a type defined in a dynamic assembly defined using the <xref:System.Reflection.Emit> services, you might get inconsistent behavior. The behavior depends on whether the dynamic assembly is persistent, that is, created using the `RunAndSave` or `Save` access modes of the <xref:System.Reflection.Emit.AssemblyBuilderAccess?displayProperty=nameWithType> enumeration. If the dynamic assembly is persistent and has been written to disk before `GetType` is called, the loader finds the saved assembly on disk, loads that assembly, and retrieves the type from that assembly. If the assembly has not been saved to disk when `GetType` is called, the method returns `null`. `GetType` does not understand transient dynamic assemblies; therefore, calling `GetType` to retrieve a type in a transient dynamic assembly returns `null`.
9487+
9488+
In .NET Framework, to use `GetType` on a dynamic module, subscribe to the <xref:System.AppDomain.AssemblyResolve?displayProperty=nameWithType> event and call `GetType` before saving. Otherwise, you will get two copies of the assembly in memory.
94989489

9499-
> [!NOTE]
9500-
> .NET Core 3.0, .NET Core 3.1 and .NET 5+: Assembly loads triggered by this api are affected by the current value of <xref:System.Runtime.Loader.AssemblyLoadContext.CurrentContextualReflectionContext%2A?displayProperty=nameWithType>.
9490+
On .NET Core 3.0 and later versions, assembly loads triggered by this API are affected by the current value of <xref:System.Runtime.Loader.AssemblyLoadContext.CurrentContextualReflectionContext%2A?displayProperty=nameWithType>.
95019491

95029492
The `throwOnError` parameter specifies what happens when the type is not found, and also suppresses certain other exception conditions, as described in the Exceptions section. Some exceptions are thrown regardless of the value of `throwOnError`. For example, if the type is found but cannot be loaded, a <xref:System.TypeLoadException> is thrown even if `throwOnError` is `false`.
95039493

@@ -9994,7 +9984,7 @@ Calling this method overload is the same as calling the <xref:System.Type.GetTyp
99949984
<format type="text/markdown"><![CDATA[
99959985

99969986
## Remarks
9997-
.NET Core 3.0, .NET Core 3.1 and .NET 5+: If `assemblyResolver` is null, then assembly loads triggered by this api are affected by the current value of <xref:System.Runtime.Loader.AssemblyLoadContext.CurrentContextualReflectionContext%2A?displayProperty=nameWithType>.
9987+
On .NET Core 3.0 and later versions, if `assemblyResolver` is null, then assembly loads triggered by this API are affected by the current value of <xref:System.Runtime.Loader.AssemblyLoadContext.CurrentContextualReflectionContext%2A?displayProperty=nameWithType>.
99989988

99999989
For more information about this API, see [Supplemental API remarks for Type.GetType](/dotnet/fundamentals/runtime-libraries/system-type-gettype).
100009990
]]></format>

0 commit comments

Comments
 (0)