Skip to content

Commit 202ac20

Browse files
carlossanlopRon Petrusha
authored andcommitted
Document System.Reflection.MetadataAssemblyResolver and PathAssemblyResolver (#2871)
* Document System.Reflection.MetadataAssemblyResolver and PathAssemblyResolver * suggestions by rpetrusha Co-Authored-By: Ron Petrusha <[email protected]> * suggestion by rpetrusha Co-Authored-By: Ron Petrusha <[email protected]> * reference for "it" * clarify public key token * Fixed broken xref.
1 parent b81aad0 commit 202ac20

File tree

2 files changed

+63
-18
lines changed

2 files changed

+63
-18
lines changed

xml/System.Reflection/MetadataAssemblyResolver.xml

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</Base>
1515
<Interfaces />
1616
<Docs>
17-
<summary>To be added.</summary>
17+
<summary>Provides the base class for binding algorithms used by <see cref="T:System.Reflection.MetadataLoadContext"/>.</summary>
1818
<remarks>To be added.</remarks>
1919
</Docs>
2020
<Members>
@@ -31,7 +31,7 @@
3131
</AssemblyInfo>
3232
<Parameters />
3333
<Docs>
34-
<summary>To be added.</summary>
34+
<summary>Initializes an instance of <see cref="T:System.Reflection.MetadataAssemblyResolver" />.</summary>
3535
<remarks>To be added.</remarks>
3636
</Docs>
3737
</Member>
@@ -54,12 +54,31 @@
5454
<Parameter Name="assemblyName" Type="System.Reflection.AssemblyName" />
5555
</Parameters>
5656
<Docs>
57-
<param name="context">To be added.</param>
58-
<param name="assemblyName">To be added.</param>
59-
<summary>To be added.</summary>
60-
<returns>To be added.</returns>
61-
<remarks>To be added.</remarks>
57+
<param name="context">The metadata load context object that represents the closed universe of <see cref="T:System.Type" /> objects loaded for inspection-only purposes.</param>
58+
<param name="assemblyName">The name of the assembly.</param>
59+
<summary>Returns an assembly from a given assembly name.</summary>
60+
<returns>The assembly for the provided <paramref name="assemblyName" />.</returns>
61+
<remarks>
62+
<format type="text/markdown">
63+
<![CDATA[
64+
65+
## Remarks
66+
67+
Binding an assembly name to an assembly occurs when <xref:System.Reflection.MetadataLoadContext.LoadFromAssemblyName%2A> is called or when a type from one assembly has a dependency on another assembly. The handler that overrides `Resolve` should use <xref:System.Reflection.MetadataLoadContext.LoadFromStream%2A?displayProperty=nameWithType>, <xref:System.Reflection.MetadataLoadContext.LoadFromAssemblyPath%2A?displayProperty=nameWithType> or <xref:System.Reflection.MetadataLoadContext.LoadFromByteArray%2A?displayProperty=nameWithType> to load the requested assembly and return it.
68+
69+
To indicate the failure to find an assembly, the handler should return `null` rather than throwing an exception. Returning `null` commits the failure so that future attempts to load that name will fail without re-invoking the handler.
70+
71+
If the handler throws an exception, the exception will be passed through to the application that invoked the operation that triggered the binding. The <xref:System.Reflection.MetadataLoadContext> will not catch it, and no binding will occur.
72+
73+
The handler will generally not be called more than once for the same name, unless two threads race to load the same assembly. Even in that case, one result will win and be atomically bound to the name.
74+
75+
The <xref:System.Reflection.MetadataLoadContext> intentionally performs no ref-def matching on the returned assembly as what constitutes a ref-def match is a policy. It is also the kind of arbitrary restriction that <xref:System.Reflection.MetadataLoadContext> strives to avoid.
76+
77+
The <xref:System.Reflection.MetadataLoadContext> cannot consume assemblies from other metadata load contexts or other type providers (such as the underlying runtime's own reflection system). If a handler returns such an assembly, the <xref:System.Reflection.MetadataLoadContext> throws a <xref:System.IO.FileLoadException>.
78+
79+
]]></format>
80+
</remarks>
6281
</Docs>
6382
</Member>
6483
</Members>
65-
</Type>
84+
</Type>

xml/System.Reflection/PathAssemblyResolver.xml

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,24 @@
1414
</Base>
1515
<Interfaces />
1616
<Docs>
17-
<summary>To be added.</summary>
18-
<remarks>To be added.</remarks>
17+
<summary>Represents a metadata assembly resolver that uses paths to every assembly that may be loaded.</summary>
18+
<remarks>
19+
<format type="text/markdown">
20+
<![CDATA[
21+
22+
## Remarks
23+
24+
The file name is expected to be the same as the assembly's simple name. Multiple assemblies can exist on disk with the same name but in different directories. A single instance of `PathAssemblyResolver` can be used with multiple <xref:System.Reflection.MetadataAssemblyResolver> instances.
25+
26+
In order for an <xref:System.Reflection.AssemblyName> to match a loaded assembly, <xref:System.Reflection.AssemblyName.Name?displayProperty=nameWithType> must be equal (casing ignored).
27+
28+
* If a public key token is specified for the <xref:System.Reflection.AssemblyName>, it must be equal.
29+
* If a public key token is not specified for <xref:System.Reflection.AssemblyName>, assemblies with no public key token are selected over those with a public key token.
30+
* If more than one assembly matches, the assembly with the highest <xref:System.Reflection.AssemblyName.Version?displayProperty=nameWithType> is returned.
31+
* <xref:System.Reflection.AssemblyName.CultureName?displayProperty=nameWithType> is ignored.
32+
33+
]]></format>
34+
</remarks>
1935
</Docs>
2036
<Members>
2137
<Member MemberName=".ctor">
@@ -34,9 +50,11 @@
3450
<Parameter Name="assemblyPaths" Type="System.Collections.Generic.IEnumerable&lt;System.String&gt;" />
3551
</Parameters>
3652
<Docs>
37-
<param name="assemblyPaths">To be added.</param>
38-
<summary>To be added.</summary>
53+
<param name="assemblyPaths">A collection of assembly path strings.</param>
54+
<summary>Initializes a new instance of the <see cref="System.Reflection.PathAssemblyResolver"/> class.</summary>
3955
<remarks>To be added.</remarks>
56+
<exception cref="T:System.ArgumentNullException"><paramref name="assemblyPaths" /> is <see langword="null" />.</exception>
57+
<exception cref="T:System.ArgumentException">One of the paths in <paramref name="assemblyPaths" /> is invalid.</exception>
4058
</Docs>
4159
</Member>
4260
<Member MemberName="Resolve">
@@ -58,12 +76,20 @@
5876
<Parameter Name="assemblyName" Type="System.Reflection.AssemblyName" />
5977
</Parameters>
6078
<Docs>
61-
<param name="context">To be added.</param>
62-
<param name="assemblyName">To be added.</param>
63-
<summary>To be added.</summary>
64-
<returns>To be added.</returns>
65-
<remarks>To be added.</remarks>
79+
<param name="context">The metadata load context object that represents the closed universe of <see cref="System.Type" /> objects loaded for inspection-only purposes.</param>
80+
<param name="assemblyName">The name of the assembly.</param>
81+
<summary>Returns an assembly from a given assembly name.</summary>
82+
<returns>The assembly for the provided <paramref name="assemblyName" />.</returns>
83+
<remarks>
84+
<format type="text/markdown"><![CDATA[
85+
86+
## Remarks
87+
88+
See the <xref:System.Reflection.MetadataAssemblyResolver> remarks for more information.
89+
90+
]]></format>
91+
</remarks>
6692
</Docs>
6793
</Member>
6894
</Members>
69-
</Type>
95+
</Type>

0 commit comments

Comments
 (0)