Skip to content

Commit 958a161

Browse files
authored
clarify accessibility of types returned by GetTypes and GetExported trypes, and point them to each other (dotnet#8652)
1 parent bbad0e7 commit 958a161

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

xml/System.Reflection/Assembly.xml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,11 +1615,8 @@ In .NET 5 and later versions, for bundled assemblies, this property throws an ex
16151615
<returns>An array that represents the types defined in this assembly that are visible outside the assembly.</returns>
16161616
<remarks>
16171617
<format type="text/markdown"><![CDATA[
1618-
16191618
## Remarks
1620-
The only types visible outside an assembly are public types and public types nested within other public types.
1621-
1622-
1619+
The only types visible outside an assembly are public types and public types nested within other public types. To retrieve all types within an assembly, including those that are non-public, use the <xref:System.Reflection.Assembly.GetTypes%2A> method.
16231620

16241621
## Examples
16251622
The following code sample defines a number of classes with various access levels, and calls <xref:System.Reflection.Assembly.GetExportedTypes%2A> to display the ones that are visible from outside the assembly.
@@ -3313,13 +3310,12 @@ Note: In <see href="https://go.microsoft.com/fwlink/?LinkID=247912">.NET for Win
33133310
</ReturnValue>
33143311
<Parameters />
33153312
<Docs>
3316-
<summary>Gets the types defined in this assembly.</summary>
3313+
<summary>Gets all types defined in this assembly.</summary>
33173314
<returns>An array that contains all the types that are defined in this assembly.</returns>
33183315
<remarks>
33193316
<format type="text/markdown"><![CDATA[
3320-
33213317
## Remarks
3322-
The returned array includes nested types.
3318+
The returned array includes nested and non-public types. To retrieve only public types, use the <xref:System.Reflection.Assembly.GetExportedTypes%2A> method.
33233319

33243320
If the <xref:System.Reflection.Assembly.GetTypes%2A> method is called on an assembly and a type in that assembly is dependent on a type in an assembly that has not been loaded (for example, if it derives from a type in the second assembly), a <xref:System.Reflection.ReflectionTypeLoadException> is thrown. For example, this can happen if the first assembly was loaded with the <xref:System.Reflection.Assembly.ReflectionOnlyLoad%2A> or <xref:System.Reflection.Assembly.ReflectionOnlyLoadFrom%2A> methods, and the second assembly was not loaded. It can also happen with assemblies loaded using the <xref:System.Reflection.Assembly.Load%2A> and <xref:System.Reflection.Assembly.LoadFile%2A> methods if the second assembly cannot be located when the <xref:System.Reflection.Assembly.GetTypes%2A> method is called.
33253321

@@ -3328,8 +3324,6 @@ Note: In <see href="https://go.microsoft.com/fwlink/?LinkID=247912">.NET for Win
33283324

33293325
To retrieve a collection of <xref:System.Reflection.TypeInfo> objects instead of an array of <xref:System.Type> objects, use the <xref:System.Reflection.Assembly.DefinedTypes%2A?displayProperty=nameWithType> property.
33303326

3331-
3332-
33333327
## Examples
33343328
The following example displays parameters of one method on a type in the specified assembly.
33353329

0 commit comments

Comments
 (0)