Skip to content

Commit 5ce4075

Browse files
carlossanlopRon Petrusha
authored andcommitted
Port System.Reflection source comments to Docs (#2317)
* Port System.Reflection source comments to Docs * Fixed bad cref tag * Added description for type * Added type description and remarks. * Apply suggestions from code review Applying suggestions by rpetrusha in PR. Co-Authored-By: carlossanlop <[email protected]> * Fixed broken xrefs * Fixed bad cref.
1 parent 1534f9a commit 5ce4075

File tree

2 files changed

+131
-40
lines changed

2 files changed

+131
-40
lines changed

xml/System.Reflection/DispatchProxy.xml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
</Base>
2525
<Interfaces />
2626
<Docs>
27-
<summary>To be added.</summary>
27+
<summary>Provides a mechanism for instantiating proxy objects and handling their method dispatch.</summary>
2828
<remarks>To be added.</remarks>
2929
</Docs>
3030
<Members>
@@ -90,11 +90,12 @@
9090
</TypeParameters>
9191
<Parameters />
9292
<Docs>
93-
<typeparam name="T">To be added.</typeparam>
94-
<typeparam name="TProxy">To be added.</typeparam>
95-
<summary>To be added.</summary>
96-
<returns>To be added.</returns>
93+
<typeparam name="T">The interface the proxy should implement.</typeparam>
94+
<typeparam name="TProxy">The base class to use for the proxy class.</typeparam>
95+
<summary>Creates an object instance that derives from class <typeparamref name="TProxy" /> and implements interface <typeparamref name="T" />.</summary>
96+
<returns>An object instance that implements <typeparamref name="T" />.</returns>
9797
<remarks>To be added.</remarks>
98+
<exception cref="T:System.ArgumentException"><typeparamref name="T" /> is a class, or <typeparamref name="TProxy" /> is sealed or does not have a parameterless constructor.</exception>
9899
</Docs>
99100
</Member>
100101
<Member MemberName="Invoke">
@@ -127,12 +128,12 @@
127128
<Parameter Name="args" Type="System.Object[]" />
128129
</Parameters>
129130
<Docs>
130-
<param name="targetMethod">To be added.</param>
131-
<param name="args">To be added.</param>
132-
<summary>To be added.</summary>
133-
<returns>To be added.</returns>
131+
<param name="targetMethod">The method the caller invoked.</param>
132+
<param name="args">The arguments the caller passed to the method.</param>
133+
<summary>Whenever any method on the generated proxy type is called. Rhis method will be invoked to dispatch control.</summary>
134+
<returns>The object to return to the caller, or <see langword="null" /> for void methods.</returns>
134135
<remarks>To be added.</remarks>
135136
</Docs>
136137
</Member>
137138
</Members>
138-
</Type>
139+
</Type>

xml/System.Reflection/MetadataLoadContext.xml

Lines changed: 120 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,16 @@
1818
</Interface>
1919
</Interfaces>
2020
<Docs>
21-
<summary>To be added.</summary>
22-
<remarks>To be added.</remarks>
21+
<summary>Represents a closed universe of Type objects loaded for inspection-only purposes. Each MetadataLoadContext can have its own binding rules and is isolated from all other MetadataLoadContexts.</summary>
22+
<remarks>
23+
<format type="text/markdown"><![CDATA[
24+
25+
A `MetadataLoadContext` serves as a dictionary that binds assembly names to <xref:System.Reflection.Assembly> instances that were previously loaded into the context or need to be loaded.
26+
27+
Assemblies are treated strictly as metadata. There are no restrictions on loading assemblies based on target platform, CPU architecture, or pointer size. There are no restrictions on the assembly designated as the core assembly (**mscorlib**).
28+
29+
]]></format>
30+
</remarks>
2331
</Docs>
2432
<Members>
2533
<Member MemberName=".ctor">
@@ -38,9 +46,9 @@
3846
<Parameter Name="coreAssemblyName" Type="System.String" />
3947
</Parameters>
4048
<Docs>
41-
<param name="resolver">To be added.</param>
42-
<param name="coreAssemblyName">To be added.</param>
43-
<summary>To be added.</summary>
49+
<param name="resolver">A <see cref="T:System.Reflection.MetadataAssemblyResolver" /> instance.</param>
50+
<param name="coreAssemblyName">The name of the assembly that contains the core types such as <see cref="T:System.Object" />. Typically, this would be "mscorlib".</param>
51+
<summary>Creates a new <see cref="T:System.Reflection.MetadataLoadContext" /> object.</summary>
4452
<remarks>To be added.</remarks>
4553
</Docs>
4654
</Member>
@@ -60,9 +68,57 @@
6068
<ReturnType>System.Reflection.Assembly</ReturnType>
6169
</ReturnValue>
6270
<Docs>
63-
<summary>To be added.</summary>
64-
<value>To be added.</value>
65-
<remarks>To be added.</remarks>
71+
<summary>Gets or sets the assembly that denotes the "system assembly" that houses the well-known types such as <see cref="T:System.Int32" />.</summary>
72+
<value>An <see cref="T:System.Reflection.Assembly" /> instance.</value>
73+
<remarks>
74+
<format type="text/markdown">
75+
<![CDATA[
76+
## Remarks
77+
78+
The core assembly is treated differently than other assemblies because references to these well-known types do not include the assembly reference, unlike normal types.
79+
80+
Typically, this assembly is named "mscorlib" or "netstandard". If the core assembly cannot be found, the value will be `null`, and many other reflection methods, including those that parse method signatures, will throw an exception.
81+
82+
The `CoreAssembly` is determined by passing the `coreAssemblyName` parameter passed to the <xref:System.Reflection.MetadataAssemblyResolver> constructor
83+
to the <xref:System.Reflection.MetadataAssemblyResolver.Resolve%2A?displayProperty=nameWithType> method.
84+
85+
If no `coreAssemblyName` argument was specified in the constructor of <xref:System.Reflection.MetadataLoadContext>, then default values are used, including "mscorlib", "System.Runtime" and "netstandard".
86+
87+
The designated core assembly does not need to contain the core types directly. It can type forward them to other assemblies. Thus, it is perfectly permissible to use the mscorlib facade as the designated core assembly.
88+
89+
Note that <xref:System.Runtime> is not an ideal core assembly because it excludes some of the interop-related pseudo-custom attribute types such as <xref:System.Runtime.InteropServices.DllImportAttribute>. However, it can serve if you have no interest in those attributes. The CustomAttributes API will skip those attributes if the core assembly does not include the necessary types.
90+
91+
The core assembly is not loaded until necessary. The following APIs do not trigger the search for the core assembly:
92+
93+
* <xref:System.Reflection.MetadataLoadContext.LoadFromStream%2A?displayProperty=nameWithType>
94+
* <xref:System.Reflection.MetadataLoadContext.LoadFromAssemblyPath%2A?displayProperty=nameWithType>
95+
* <xref:System.Reflection.MetadataLoadContext.LoadFromByteArray%2A?displayProperty=nameWithType>
96+
* <System.Reflection.Assembly.GetName%2A?displayProperty=nameWithType>
97+
* <System.Reflection.Assembly.FullName?displayProperty=nameWithType>
98+
* <System.Reflection.Assembly.GetReferencedAssemblies%2A?displayProperty=nameWithType>
99+
* <System.Reflection.Assembly.GetTypes%2A?displayProperty=nameWithType>
100+
* <System.Reflection.Assembly.DefinedTypes?displayProperty=nameWithType>
101+
* <System.Reflection.Assembly.GetExportedTypes%2A?displayProperty=nameWithType>
102+
* <System.Reflection.Assembly.GetForwardedTypes%2A?displayProperty=nameWithType>
103+
* <System.Reflection.Assembly.GetType(System.String,System.Boolean,System.Boolean)?displayProperty=nameWithType>
104+
* <xref:System.Type.Name?displayProperty=nameWithType>
105+
* <xref:System.Type.FullName?displayProperty=nameWithType>
106+
* <xref:System.Type.AssemblyQualifiedName?displayProperty=nameWithType>
107+
108+
If a core assembly cannot be found or if the core assembly is missing types, this will affect the behavior of the <xref:System.Reflection.MetadataLoadContext> as follows:
109+
110+
* APIs that need to parse signatures or typespecs and return the results as <xref:System.Type> objects will throw an exception. For example:
111+
112+
* <xref:System.Reflection.MethodInfo.ReturnType?displayProperty=nameWithType>
113+
* System.Reflection.MethodBase.GetParameters%2A?displayProperty=nameWithType>
114+
* <xref:System.Type.BaseType?displayProperty-nameWithType>
115+
* <xref:System.Type.GetInterfaces%2A?displayProperty=nameWithType>
116+
117+
* APIs that need to compare types to well-known core types will not throw an exception, and the comparison will evaluate to `false`. For example, if you do not specify a core assembly, <xref:System.Type.IsPrimitive> will return `false` for everything, even types named <xref:System.Int32>. Similarly, <xref:System.Type.GetTypeCode%2A?displayProperty=nameWithType> will return <xref:System.TypeCode.Object> for everything.
118+
119+
* If a metadata entity sets flags that surface as a pseudo-custom attribute, and the core assembly does not contain the pseudo-custom attribute type, the necessary constructor or any of the parameter types of the constructor, the <xref:System.Reflection.MetadataLoadContext> will not throw. It will omit the pseudo-custom attribute from the list of returned attributes.
120+
]]></format>
121+
</remarks>
66122
</Docs>
67123
</Member>
68124
<Member MemberName="Dispose">
@@ -85,8 +141,17 @@
85141
</ReturnValue>
86142
<Parameters />
87143
<Docs>
88-
<summary>To be added.</summary>
89-
<remarks>To be added.</remarks>
144+
<summary>Releases any native resources (such as file locks on assembly files). </summary>
145+
<remarks>
146+
<format type="text/markdown"><![CDATA[
147+
148+
After disposal, it is not safe to use any <xref:System.Reflection.Assembly> objects dispensed by the <xref:System.Reflection.MetadataLoadContext> or any reflection objects dispensed by those <xref:System.Reflection.Assembly> objects.
149+
150+
Though objects provided by the <xref:System.Reflection.MetadataLoadContext> strive to throw an <xref:System.ObjectDisposedException>, this is not guaranteed.
151+
152+
Some APIs may return fixed or previously cached data. Accessing objects *during* a <xref:System.Reflection.MetadataLoadContext.Dispose%2A> method call may result in an unmanaged access violation and failfast.
153+
]]></format>
154+
</remarks>
90155
</Docs>
91156
</Member>
92157
<Member MemberName="GetAssemblies">
@@ -106,8 +171,8 @@
106171
</ReturnValue>
107172
<Parameters />
108173
<Docs>
109-
<summary>To be added.</summary>
110-
<returns>To be added.</returns>
174+
<summary>Return an atomic snapshot of the assemblies that have been loaded into the <see cref="T:System.Reflection.MetadataLoadContext" />.</summary>
175+
<returns>An enumerable collection of <see xref="T:System.Reflection.Assembly" /> objects.</returns>
111176
<remarks>To be added.</remarks>
112177
</Docs>
113178
</Member>
@@ -129,10 +194,16 @@
129194
<Parameter Name="assemblyName" Type="System.Reflection.AssemblyName" />
130195
</Parameters>
131196
<Docs>
132-
<param name="assemblyName">To be added.</param>
133-
<summary>To be added.</summary>
134-
<returns>To be added.</returns>
135-
<remarks>To be added.</remarks>
197+
<param name="assemblyName">An <see cref="T:System.Reflection.AssemblyName" /> instance.</param>
198+
<summary>Resolves the supplied assembly name to an assembly. If an assembly was previously bound to this name, that assembly is returned. Otherwise, the <see cref="T:System.Reflection.MetadataLoadContext" /> calls the specified <see cref="T:System.Reflection.MetadataAssemblyResolver" />.</summary>
199+
<returns>An <see cref="T:System.Reflection.Assembly" /> instance.</returns>
200+
<remarks>
201+
<format type="text/markdown"><![CDATA[
202+
## Remarks
203+
Note that the behavior of this method matches the behavior of the <xref:System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyName%2A?displayProperty=nameWithType> resolve event but does not match the behavior of <xref:System.Reflection.Assembly.ReflectionOnlyLoad%2A?displayProperty=nameWithType>. (The latter gives up without raising its resolve event.)
204+
]]></format>
205+
</remarks>
206+
<exception cref="T:System.IO.FileNotFoundException">The resolver returns <see langword="null" />.</exception>
136207
</Docs>
137208
</Member>
138209
<Member MemberName="LoadFromAssemblyName">
@@ -154,10 +225,18 @@
154225
<Parameter Name="assemblyName" Type="System.String" />
155226
</Parameters>
156227
<Docs>
157-
<param name="assemblyName">To be added.</param>
158-
<summary>To be added.</summary>
159-
<returns>To be added.</returns>
160-
<remarks>To be added.</remarks>
228+
<param name="assemblyName">A <see cref="T:System.String" /> representing the assembly name.</param>
229+
<summary>Resolves the supplied assembly name to an assembly. If an assembly was previously bound to this name, that assembly is returned. Otherwise, the <see cref="T:System.Reflection.MetadataLoadContext" /> calls the specified <see cref="T:System.Reflection.MetadataAssemblyResolver" />.</summary>
230+
<returns>An <see cref="T:System.Reflection.Assembly" /> instance.</returns>
231+
<remarks>
232+
<format type="text/markdown">
233+
<![CDATA[
234+
## Remarks
235+
Note that the behavior of this method matches the behavior of <xref:System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyName%2A?displayProperty=nameWithType> resolve event but does not match the behavior of <xxref:System.Reflection.Assembly.ReflectionOnlyLoad%2A?displayProperty=nameWithType>. (The latter gives up without raising its resolve event.)
236+
]]>
237+
</format>
238+
</remarks>
239+
<exception cref="T:System.IO.FileNotFoundException">The resolver returns <see langword="null" />.</exception>
161240
</Docs>
162241
</Member>
163242
<Member MemberName="LoadFromAssemblyPath">
@@ -179,10 +258,11 @@
179258
<Parameter Name="assemblyPath" Type="System.String" />
180259
</Parameters>
181260
<Docs>
182-
<param name="assemblyPath">To be added.</param>
183-
<summary>To be added.</summary>
184-
<returns>To be added.</returns>
261+
<param name="assemblyPath">A <see cref="T:System.String" /> representing the path to the assembly.</param>
262+
<summary>Loads an assembly from a specific path on the disk and binds its assembly name to it in the <see cref="T:System.Reflection.MetadataLoadContext" />. If a prior assembly with the same name was already loaded into the <see cref="T:System.Reflection.MetadataLoadContext" />, the prior assembly will be returned.</summary>
263+
<returns>An <see cref="T:System.Reflection.Assembly" /> instance.</returns>
185264
<remarks>To be added.</remarks>
265+
<exception cref="T:System.IO.FileLoadException">The two assemblies do not have the same Mvid.</exception>
186266
</Docs>
187267
</Member>
188268
<Member MemberName="LoadFromByteArray">
@@ -203,10 +283,11 @@
203283
<Parameter Name="assembly" Type="System.Byte[]" />
204284
</Parameters>
205285
<Docs>
206-
<param name="assembly">To be added.</param>
207-
<summary>To be added.</summary>
208-
<returns>To be added.</returns>
286+
<param name="assembly">A <see cref="T:System.Byte[]" /> holding an assembly.</param>
287+
<summary>Loads an assembly from a byte array and binds its assembly name to it in the <see cref="T:System.Reflection.MetadataLoadContext" />. If a prior assembly with the same name was already loaded into the <see cref="T:System.Reflection.MetadataLoadContext" />, the prior assembly will be returned.</summary>
288+
<returns>An <see cref="T:System.Reflection.Assembly" /> instance.</returns>
209289
<remarks>To be added.</remarks>
290+
<exception cref="T:System.IO.FileLoadException">The two assemblies do not have the same Mvid.</exception>
210291
</Docs>
211292
</Member>
212293
<Member MemberName="LoadFromStream">
@@ -227,11 +308,20 @@
227308
<Parameter Name="assembly" Type="System.IO.Stream" />
228309
</Parameters>
229310
<Docs>
230-
<param name="assembly">To be added.</param>
231-
<summary>To be added.</summary>
311+
<param name="assembly">A <see cref="T:System.IO.Stream" /> holding an assembly.</param>
312+
<summary>Loads an assembly from a stream and binds its assembly name to it in the <see cref="T:System.Reflection.MetadataLoadContext" />. If a prior assembly with the same name was already loaded into the <see cref="T:System.Reflection.MetadataLoadContext" />, the prior assembly will be returned.</summary>
232313
<returns>To be added.</returns>
233-
<remarks>To be added.</remarks>
314+
<remarks>
315+
<format type="text/markdown">
316+
<![CDATA[
317+
## Remarks
318+
319+
> [!IMPORTANT]
320+
> The <xref:System.Reflection.MetadataLoadContext> takes ownership of the <xref:System.IO.Stream> passed into this method. The original owner must not mutate its position, dispose the <xref:System.IO.Stream>, or assume that its position will stay unchanged.
321+
]]></format>
322+
</remarks>
323+
<exception cref="T:System.IO.FileLoadException">The two assemblies do not have the same Mvid.</exception>
234324
</Docs>
235325
</Member>
236326
</Members>
237-
</Type>
327+
</Type>

0 commit comments

Comments
 (0)