You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Replace MethodParameterInfo with ParameterDescriptor types
Refactored parameter representation by introducing ParameterDescriptor and ParameterDescriptorList, replacing MethodParameterInfo and MethodParameterInfoList. Updated all usages, builders, and equality comparers to use the new types. ParameterDescriptor provides richer metadata and improved ambiguity handling; ParameterDescriptorList ensures immutability, uniqueness, and consistency. Updated documentation and comments. Improves accuracy, performance, and maintainability of reflection-based parameter lookups.
Copy file name to clipboardExpand all lines: src/BionicCode.Utilities.Reflection/AnonymousConstructorDescriptor.cs
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@
19
19
/// <para/>For best accuracy and performance always use the <see cref="WellKnownConstructorDescriptor"/>, which requires the caller to have direct access to the <see cref="MethodInfo"/> or <see cref="ConstructorInfo"/> representation of the method or constructor.
20
20
/// </remarks>
21
21
/// <param name="declaringTypeHandle">The runtime type handle representing the declaring type of the anonymous constructor.</param>
22
-
/// <param name="constructorParameters">The list of parameters for the anonymous method. Can be <see cref="MethodParameterInfoList.Empty"/> or <see langword="null"/> to indicate no parameters.</param>
22
+
/// <param name="constructorParameters">The list of parameters for the anonymous method. Can be <see cref="ParameterDescriptorList.Empty"/> or <see langword="null"/> to indicate no parameters.</param>
23
23
/// <returns>A new instance of <see cref="AnonymousConstructorDescriptor"/> representing the specified anonymous method.</returns>
24
24
/// <exception cref="ArgumentNullException">Thrown when
Copy file name to clipboardExpand all lines: src/BionicCode.Utilities.Reflection/AnonymousPropertyDescriptor.cs
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -31,8 +31,8 @@
31
31
/// then the <paramref name="implementingTypeHandle"/> can be <see langword="null"/> since it will be ignored.</param>
32
32
/// <param name="propertyName">The name of the anonymous property. Cannot be null, empty, or consist only of white-space characters.</param>
33
33
/// <param name="declaredPropertyAccessors">Specifies the accessor that the property declares. Can't be <see cref="PropertyAccessors.None"/> or <see cref="PropertyAccessors.None"/>.</param>
34
-
/// <param name="indexerGetterParameters">The list of parameters for the anonymous indexer getter. Can be <see cref="MethodParameterInfoList.Empty"/> or <see langword="null"/> to indicate no parameters in case of a normal property. For normal properties, this parameter is ignored.</param>
35
-
/// <param name="indexerSetterParameters">The list of parameters for the anonymous indexer setter. Can be <see cref="MethodParameterInfoList.Empty"/> or <see langword="null"/> to indicate no parameters in case of a normal property. For normal properties, this parameter is ignored.</param>
34
+
/// <param name="indexerGetterParameters">The list of parameters for the anonymous indexer getter. Can be <see cref="ParameterDescriptorList.Empty"/> or <see langword="null"/> to indicate no parameters in case of a normal property. For normal properties, this parameter is ignored.</param>
35
+
/// <param name="indexerSetterParameters">The list of parameters for the anonymous indexer setter. Can be <see cref="ParameterDescriptorList.Empty"/> or <see langword="null"/> to indicate no parameters in case of a normal property. For normal properties, this parameter is ignored.</param>
36
36
/// <param name="isExplicitInterfaceImplementation"><see langword="true"/> if the property is an explicit interface implementation; otherwise, <see langword="false"/>. If set to <see langword="true"/>, the <paramref name="declaringTypeHandle"/> must represent an interface type.
37
37
/// </param>
38
38
/// <returns>A new instance of <see cref="AnonymousPropertyDescriptor"/> representing the specified anonymous property.</returns>
@@ -57,8 +57,8 @@ public AnonymousPropertyDescriptor(
57
57
RuntimeTypeHandledeclaringTypeHandle,
58
58
stringpropertyName,
59
59
PropertyAccessorsdeclaredPropertyAccessors,
60
-
MethodParameterInfoList?indexerGetterParameters,
61
-
MethodParameterInfoList?indexerSetterParameters,
60
+
ParameterDescriptorList?indexerGetterParameters,
61
+
ParameterDescriptorList?indexerSetterParameters,
62
62
boolisExplicitInterfaceImplementation,
63
63
RuntimeTypeHandle?implementingTypeHandle)
64
64
{
@@ -121,8 +121,8 @@ public AnonymousPropertyDescriptor(
// Parameter is valid if it matches position in method signature, parameter type and modifier.
185
201
// Since parameter collections are always ordered by parameter position in ascending order, we don't have to check the order explicitly (only count - see above).
202
+
203
+
// TODO:: Split algorithm into two separate algorithms:
204
+
// - one for the case when ALL parameter descriptors have an explicitly specified parameter position
205
+
// - and one for the case when parameter position information is missing for at least one parameter descriptor
206
+
// to improve readability and maintainability.
207
+
208
+
// When the source is unsorted we still must anticipate the possibility of parameter position information being
209
+
// randomly provided in the descriptor to find the corresponding parameter for comparison.
210
+
// If the position information is provided but does not match the current parameter index, we skip this parameter
211
+
// and continue searching for the corresponding parameter in the method signature.
// Parameter is valid if it matches position in method signature, parameter type and modifier.
448
481
// Since parameter collections are always ordered by parameter position in ascending order, we don't have to check the order explicitly (only count - see above).
0 commit comments