Skip to content

Commit aaff0ea

Browse files
authored
Cleanup Delegate docs (#8956)
- Delete mentions of MemberAccessException. This exception has not been thrown by these methods since .NET Framework 2.0. It could have been thrown in some cases in .NET Framework 1.x that is not a relevant information anymore. - Delete documentation of other .NET Framework 1.x specific quirks. - Fix list of exceptions thrown by DynamicInvoke method.
1 parent 0142031 commit aaff0ea

File tree

2 files changed

+12
-68
lines changed

2 files changed

+12
-68
lines changed

xml/System/Delegate.xml

Lines changed: 10 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,6 @@
9797
9898
For more information on delegate binding, see the <xref:System.Delegate.CreateDelegate%28System.Type%2CSystem.Object%2CSystem.Reflection.MethodInfo%2CSystem.Boolean%29> method overload.
9999
100-
> [!NOTE]
101-
> In the .NET Framework versions 1.0 and 1.1, a delegate can represent a method only if the signature of the method exactly matches the signature specified by the delegate type. Thus, only the first and third bullets in the preceding list are supported, and the first bullet requires an exact type match.
102-
103100
When a delegate represents an instance method closed over its first argument (the most common case), the delegate stores a reference to the method's entry point and a reference to an object, called the target, which is of a type assignable to the type that defined the method. When a delegate represents an open instance method, it stores a reference to the method's entry point. The delegate signature must include the hidden `this` parameter in its formal parameter list; in this case, the delegate does not have a reference to a target object, and a target object must be supplied when the delegate is invoked.
104101
105102
When a delegate represents a static method, the delegate stores a reference to the method's entry point. When a delegate represents a static method closed over its first argument, the delegate stores a reference to the method's entry point and a reference to a target object assignable to the type of the method's first argument. When the delegate is invoked, the first argument of the static method receives the target object. This first argument must be a reference type.
@@ -633,9 +630,9 @@
633630
</Parameters>
634631
<Docs>
635632
<param name="type">The <see cref="T:System.Type" /> of delegate to create.</param>
636-
<param name="method">The <see cref="T:System.Reflection.MethodInfo" /> describing the static or instance method the delegate is to represent. Only static methods are supported in the .NET Framework version 1.0 and 1.1.</param>
637-
<summary>Creates a delegate of the specified type to represent the specified static method.</summary>
638-
<returns>A delegate of the specified type to represent the specified static method.</returns>
633+
<param name="method">The <see cref="T:System.Reflection.MethodInfo" /> describing the static or instance method the delegate is to represent.</param>
634+
<summary>Creates a delegate of the specified type to represent the specified method.</summary>
635+
<returns>A delegate of the specified type to represent the specified method.</returns>
639636
<remarks>
640637
<format type="text/markdown"><![CDATA[
641638
@@ -723,10 +720,6 @@
723720

724721
-or-
725722

726-
<paramref name="method" /> is not a static method, and the .NET Framework version is 1.0 or 1.1.
727-
728-
-or-
729-
730723
<paramref name="method" /> cannot be bound.
731724

732725
-or-
@@ -822,9 +815,6 @@
822815
## Compatible Parameter Types and Return Type
823816
The parameter types and return type of a delegate must be compatible with the parameter types and return type of the method the delegate represents; the types do not have to match exactly.
824817
825-
> [!NOTE]
826-
> In the .NET Framework version 1.0 and 1.1, the types must match exactly.
827-
828818
A parameter of a delegate is compatible with the corresponding parameter of a method if the type of the delegate parameter is more restrictive than the type of the method parameter, because this guarantees that an argument passed to the delegate can be passed safely to the method.
829819
830820
Similarly, the return type of a delegate is compatible with the return type of a method if the return type of the method is more restrictive than the return type of the delegate, because this guarantees that the return value of the method can be cast safely to the return type of the delegate.
@@ -1114,9 +1104,6 @@
11141104
## Compatible Parameter Types and Return Type
11151105
The parameter types and return type of a delegate must be compatible with the parameter types and return type of the method the delegate represents; the types do not have to match exactly.
11161106
1117-
> [!NOTE]
1118-
> In the .NET Framework version 1.0 and 1.1, the types must match exactly.
1119-
11201107
A parameter of a delegate is compatible with the corresponding parameter of a method if the type of the delegate parameter is more restrictive than the type of the method parameter, because this guarantees that an argument passed to the delegate can be passed safely to the method.
11211108
11221109
Similarly, the return type of a delegate is compatible with the return type of a method if the return type of the method is more restrictive than the return type of the delegate, because this guarantees that the return value of the method can be cast safely to the return type of the delegate.
@@ -1404,9 +1391,6 @@
14041391
## Compatible Parameter Types and Return Type
14051392
The parameter types and return type of a delegate must be compatible with the parameter types and return type of the method the delegate represents; the types do not have to match exactly.
14061393
1407-
> [!NOTE]
1408-
> In the .NET Framework version 1.0 and 1.1 the types must match exactly.
1409-
14101394
A parameter of a delegate is compatible with the corresponding parameter of a method if the type of the delegate parameter is more restrictive than the type of the method parameter, because this guarantees that an argument passed to the delegate can be passed safely to the method.
14111395
14121396
Similarly, the return type of a delegate is compatible with the return type of a method if the return type of the method is more restrictive than the return type of the delegate, because this guarantees that the return value of the method can be cast safely to the return type of the delegate.
@@ -2039,12 +2023,8 @@
20392023
20402024
]]></format>
20412025
</remarks>
2042-
<exception cref="T:System.MemberAccessException">The caller does not have access to the method represented by the delegate (for example, if the method is private).
2043-
2044-
-or-
2045-
2046-
The number, order, or type of parameters listed in <paramref name="args" /> is invalid.</exception>
2047-
<exception cref="T:System.ArgumentException">The method represented by the delegate is invoked on an object or a class that does not support it.</exception>
2026+
<exception cref="T:System.Reflection.TargetParameterCountException">The <paramref name="args" /> array does not have the correct number of arguments.</exception>
2027+
<exception cref="T:System.ArgumentException">The elements of the <paramref name="args" /> array do not match the signature of the delegate.</exception>
20482028
<exception cref="T:System.Reflection.TargetInvocationException">The method represented by the delegate is an instance method and the target object is <see langword="null" />.
20492029

20502030
-or-
@@ -2113,12 +2093,8 @@
21132093
21142094
]]></format>
21152095
</remarks>
2116-
<exception cref="T:System.MemberAccessException">The caller does not have access to the method represented by the delegate (for example, if the method is private).
2117-
2118-
-or-
2119-
2120-
The number, order, or type of parameters listed in <paramref name="args" /> is invalid.</exception>
2121-
<exception cref="T:System.ArgumentException">The method represented by the delegate is invoked on an object or a class that does not support it.</exception>
2096+
<exception cref="T:System.Reflection.TargetParameterCountException">The <paramref name="args" /> array does not have the correct number of arguments.</exception>
2097+
<exception cref="T:System.ArgumentException">The elements of the <paramref name="args" /> array do not match the signature of the delegate.</exception>
21222098
<exception cref="T:System.Reflection.TargetInvocationException">The method represented by the delegate is an instance method and the target object is <see langword="null" />.
21232099

21242100
-or-
@@ -2193,9 +2169,6 @@
21932169
## Remarks
21942170
If the two delegates are not of the same type, they are not considered equal.
21952171
2196-
> [!IMPORTANT]
2197-
> In the .NET Framework version 1.0 and 1.1, two delegates were considered equal if their targets, methods, and invocation list were equal, even if the delegates were of different types.
2198-
21992172
The methods and targets are compared for equality as follows:
22002173
22012174
- If the two methods being compared are both static and are the same method on the same class, the methods are considered equal and the targets are also considered equal.
@@ -2208,7 +2181,6 @@
22082181
22092182
]]></format>
22102183
</remarks>
2211-
<exception cref="T:System.MemberAccessException">The caller does not have access to the method represented by the delegate (for example, if the method is private).</exception>
22122184
<altmember cref="T:System.Object" />
22132185
</Docs>
22142186
</Member>
@@ -2367,17 +2339,16 @@
23672339
</ReturnValue>
23682340
<Parameters />
23692341
<Docs>
2370-
<summary>Gets the static method represented by the current delegate.</summary>
2371-
<returns>A <see cref="T:System.Reflection.MethodInfo" /> describing the static method represented by the current delegate.</returns>
2342+
<summary>Gets the method represented by the current delegate.</summary>
2343+
<returns>A <see cref="T:System.Reflection.MethodInfo" /> describing the method represented by the current delegate.</returns>
23722344
<remarks>
23732345
<format type="text/markdown"><![CDATA[
23742346
23752347
## Remarks
2376-
This method applies only if the current delegate represents a static method.
2348+
This method implements the <xref:System.Delegate.Method%2A> property.
23772349
23782350
]]></format>
23792351
</remarks>
2380-
<exception cref="T:System.MemberAccessException">The caller does not have access to the method represented by the delegate (for example, if the method is private).</exception>
23812352
<altmember cref="T:System.Reflection.MethodInfo" />
23822353
<altmember cref="P:System.Delegate.Method" />
23832354
</Docs>
@@ -2482,7 +2453,6 @@
24822453
<summary>Gets the method represented by the delegate.</summary>
24832454
<value>A <see cref="T:System.Reflection.MethodInfo" /> describing the method represented by the delegate.</value>
24842455
<remarks>To be added.</remarks>
2485-
<exception cref="T:System.MemberAccessException">The caller does not have access to the method represented by the delegate (for example, if the method is private).</exception>
24862456
<altmember cref="T:System.Reflection.MethodInfo" />
24872457
<altmember cref="M:System.Delegate.GetMethodImpl" />
24882458
</Docs>
@@ -2549,9 +2519,6 @@
25492519
25502520
If the two delegates are not of the same type, they are not considered equal.
25512521
2552-
> [!IMPORTANT]
2553-
> In the .NET Framework version 1.0 and 1.1, two delegates were considered equal if their targets, methods, and invocation list were equal, even if the delegates were of different types.
2554-
25552522
The methods and targets are compared for equality as follows:
25562523
25572524
- If the two methods being compared are both static and are the same method on the same class, the methods are considered equal and the targets are also considered equal.
@@ -2623,9 +2590,6 @@
26232590
26242591
If the two delegates are not of the same type, they are not considered equal.
26252592
2626-
> [!IMPORTANT]
2627-
> In the .NET Framework version 1.0 and 1.1, two delegates are considered equal if their targets, methods, and invocation list were equal, even if the delegates were of different types.
2628-
26292593
The methods and targets are compared for equality as follows:
26302594
26312595
- If the two methods being compared are both static and are the same method on the same class, the methods are considered equal and the targets are also considered equal.
@@ -2702,7 +2666,6 @@
27022666
27032667
]]></format>
27042668
</remarks>
2705-
<exception cref="T:System.MemberAccessException">The caller does not have access to the method represented by the delegate (for example, if the method is private).</exception>
27062669
<exception cref="T:System.ArgumentException">The delegate types do not match.</exception>
27072670
<altmember cref="M:System.Delegate.RemoveAll(System.Delegate,System.Delegate)" />
27082671
<altmember cref="M:System.Delegate.RemoveImpl(System.Delegate)" />
@@ -2764,7 +2727,6 @@
27642727
27652728
]]></format>
27662729
</remarks>
2767-
<exception cref="T:System.MemberAccessException">The caller does not have access to the method represented by the delegate (for example, if the method is private).</exception>
27682730
<exception cref="T:System.ArgumentException">The delegate types do not match.</exception>
27692731
<altmember cref="M:System.Delegate.Remove(System.Delegate,System.Delegate)" />
27702732
<altmember cref="M:System.Delegate.RemoveImpl(System.Delegate)" />
@@ -2820,7 +2782,6 @@
28202782
28212783
]]></format>
28222784
</remarks>
2823-
<exception cref="T:System.MemberAccessException">The caller does not have access to the method represented by the delegate (for example, if the method is private).</exception>
28242785
<altmember cref="M:System.Delegate.Remove(System.Delegate,System.Delegate)" />
28252786
<altmember cref="M:System.Delegate.Equals(System.Object)" />
28262787
</Docs>

xml/System/MulticastDelegate.xml

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@
152152
153153
]]></format>
154154
</remarks>
155-
<exception cref="T:System.MemberAccessException">Cannot create an instance of an abstract class, or this member was invoked with a late-binding mechanism.</exception>
156155
</Docs>
157156
</Member>
158157
<Member MemberName=".ctor">
@@ -208,7 +207,6 @@
208207
209208
]]></format>
210209
</remarks>
211-
<exception cref="T:System.MemberAccessException">Cannot create an instance of an abstract class, or this member was invoked with a late-binding mechanism.</exception>
212210
</Docs>
213211
</Member>
214212
<Member MemberName="CombineImpl">
@@ -261,7 +259,6 @@
261259
<remarks>To be added.</remarks>
262260
<exception cref="T:System.ArgumentException">
263261
<paramref name="follow" /> does not have the same type as this instance.</exception>
264-
<exception cref="T:System.MemberAccessException">Cannot create an instance of an abstract class, or this member was invoked with a late-binding mechanism.</exception>
265262
</Docs>
266263
</Member>
267264
<Member MemberName="DynamicInvokeImpl">
@@ -295,13 +292,6 @@
295292
<summary>Processes the full invocation list.</summary>
296293
<returns>An array of type <see cref="T:System.Object" /> that contains the return value of the encapsulated method.</returns>
297294
<remarks>To be added.</remarks>
298-
<exception cref="T:System.MemberAccessException">
299-
Cannot create an instance of an abstract class, or this member was invoked with a late-binding mechanism.
300-
301-
-or-
302-
303-
There is an attempt to invoke a method to which the caller does not have access (that is, a private method).
304-
</exception>
305295
<exception cref="T:System.ArgumentException">The number, order, or type of parameters is invalid.</exception>
306296
<exception cref="T:System.Reflection.TargetException">
307297
An encapsulated method is not static, and the target object is null.
@@ -382,7 +372,6 @@
382372
383373
]]></format>
384374
</remarks>
385-
<exception cref="T:System.MemberAccessException">Cannot create an instance of an abstract class, or this member was invoked with a late-binding mechanism.</exception>
386375
</Docs>
387376
</Member>
388377
<Member MemberName="GetHashCode">
@@ -433,7 +422,6 @@
433422
<summary>Returns the hash code for this instance.</summary>
434423
<returns>A 32-bit signed integer hash code.</returns>
435424
<remarks>To be added.</remarks>
436-
<exception cref="T:System.MemberAccessException">Cannot create an instance of an abstract class, or this member was invoked with a late-binding mechanism.</exception>
437425
</Docs>
438426
</Member>
439427
<Member MemberName="GetInvocationList">
@@ -491,7 +479,6 @@
491479
492480
]]></format>
493481
</remarks>
494-
<exception cref="T:System.MemberAccessException">Cannot create an instance of an abstract class, or this member was invoked with a late-binding mechanism.</exception>
495482
</Docs>
496483
</Member>
497484
<Member MemberName="GetMethodImpl">
@@ -534,8 +521,8 @@
534521
</ReturnValue>
535522
<Parameters />
536523
<Docs>
537-
<summary>Returns a static method represented by the current <see cref="T:System.MulticastDelegate" />.</summary>
538-
<returns>A static method represented by the current <see cref="T:System.MulticastDelegate" />.</returns>
524+
<summary>Returns a method represented by the current <see cref="T:System.MulticastDelegate" />.</summary>
525+
<returns>A method represented by the current <see cref="T:System.MulticastDelegate" />.</returns>
539526
<remarks>
540527
<format type="text/markdown"><![CDATA[
541528
@@ -605,7 +592,6 @@
605592
</remarks>
606593
<exception cref="T:System.ArgumentNullException">
607594
<paramref name="info" /> is <see langword="null" />.</exception>
608-
<exception cref="T:System.MemberAccessException">Cannot create an instance of an abstract class, or this member was invoked with a late-binding mechanism.</exception>
609595
<exception cref="T:System.Runtime.Serialization.SerializationException">A serialization error occurred.</exception>
610596
<altmember cref="T:System.Object" />
611597
<altmember cref="T:System.Runtime.Serialization.SerializationInfo" />
@@ -669,7 +655,6 @@
669655
670656
The equivalent method for this operator is <xref:System.MulticastDelegate.Equals%28System.Object%29?displayProperty=nameWithType>]]></format>
671657
</remarks>
672-
<exception cref="T:System.MemberAccessException">Cannot create an instance of an abstract class, or this member was invoked with a late-binding mechanism.</exception>
673658
</Docs>
674659
</Member>
675660
<Member MemberName="op_Inequality">
@@ -730,7 +715,6 @@
730715
731716
The equivalent method for this operator is <xref:System.MulticastDelegate.Equals%28System.Object%29?displayProperty=nameWithType>]]></format>
732717
</remarks>
733-
<exception cref="T:System.MemberAccessException">Cannot create an instance of an abstract class, or this member was invoked with a late-binding mechanism.</exception>
734718
</Docs>
735719
</Member>
736720
<Member MemberName="RemoveImpl">
@@ -781,7 +765,6 @@
781765
<summary>Removes an element from the invocation list of this <see cref="T:System.MulticastDelegate" /> that is equal to the specified delegate.</summary>
782766
<returns>If <paramref name="value" /> is found in the invocation list for this instance, then a new <see cref="T:System.Delegate" /> without <paramref name="value" /> in its invocation list; otherwise, this instance with its original invocation list.</returns>
783767
<remarks>To be added.</remarks>
784-
<exception cref="T:System.MemberAccessException">Cannot create an instance of an abstract class, or this member was invoked with a late-binding mechanism.</exception>
785768
</Docs>
786769
</Member>
787770
</Members>

0 commit comments

Comments
 (0)