Skip to content

Commit 2ce90d6

Browse files
committed
Updated parameter names to be more consistent
Some of the objects to work against were named `target` when they should have been `source` (e.g., when calling `GetPropertyValue()`). The member names were inconsistently named either `name` or `memberName`; updated these to use `memberName`, `propertyName`, or `methodName`. This makes the parameter names more intuitive.
1 parent d8a236c commit 2ce90d6

1 file changed

Lines changed: 44 additions & 42 deletions

File tree

OnTopic/Internal/Reflection/TypeAccessor.cs

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,11 @@ internal IEnumerable<T> GetMembers<T>() where T : MemberInfo
125125
| GET MEMBER
126126
\-------------------------------------------------------------------------------------------------------------------------*/
127127
/// <summary>
128-
/// Retrieves a property or method supported by the <see cref="TypeAccessor"/> by <paramref name="name"/>.
128+
/// Retrieves a property or method supported by the <see cref="TypeAccessor"/> by <paramref name="memberName"/>.
129129
/// </summary>
130-
/// <param name="name">The name of the <see cref="MemberAccessor"/>, derived from <see cref="MemberInfo.Name"/>.</param>
130+
/// <param name="memberName">The name of the member to retrieve, derived from <see cref="MemberAccessor.Name"/>.</param>
131131
/// <returns>A <see cref="MemberAccessor"/> instance for getting or setting values on a given member.</returns>
132-
internal MemberAccessor? GetMember(string name) => _members.GetValueOrDefault(name);
132+
internal MemberAccessor? GetMember(string memberName) => _members.GetValueOrDefault(memberName);
133133

134134
/*==========================================================================================================================
135135
| METHOD: GET PRIMARY CONSTRUCTOR
@@ -145,11 +145,12 @@ internal ConstructorInfo GetPrimaryConstructor() =>
145145
| HAS GETTER?
146146
\-------------------------------------------------------------------------------------------------------------------------*/
147147
/// <summary>
148-
/// Determines if a <see cref="MemberAccessor"/> with a getter exists for a member with the given <paramref name="name"/>.
148+
/// Determines if a <see cref="MemberAccessor"/> with a getter exists for a member with the given <paramref name="
149+
/// memberName"/>.
149150
/// </summary>
150-
/// <param name="name">The name of the <see cref="MemberAccessor"/>, derived from <see cref="MemberInfo.Name"/>.</param>
151+
/// <param name="memberName">The name of the member to assess, derived from <see cref="MemberAccessor.Name"/>.</param>
151152
/// <returns>True if a gettable member exists; otherwise false.</returns>
152-
internal bool HasGetter(string name) => GetMember(name)?.CanRead ?? false;
153+
internal bool HasGetter(string memberName) => GetMember(memberName)?.CanRead ?? false;
153154

154155
/*==========================================================================================================================
155156
| METHOD: HAS GETTABLE PROPERTY
@@ -160,11 +161,11 @@ internal ConstructorInfo GetPrimaryConstructor() =>
160161
/// <remarks>
161162
/// Will return false if the property is not available.
162163
/// </remarks>
163-
/// <param name="name">The name of the property to assess.</param>
164+
/// <param name="propertyName">The name of the property to assess, derived from <see cref="MemberAccessor.Name"/>.</param>
164165
/// <param name="targetType">Optional, the <see cref="Type"/> expected.</param>
165166
/// <param name="attributeFlag">Optional, the <see cref="Attribute"/> expected on the property.</param>
166-
internal bool HasGettableProperty(string name, Type? targetType = null, Type? attributeFlag = null) {
167-
var property = GetMember(name);
167+
internal bool HasGettableProperty(string propertyName, Type? targetType = null, Type? attributeFlag = null) {
168+
var property = GetMember(propertyName);
168169
return (
169170
property is not null and { CanRead: true, MemberType: MemberTypes.Property } &&
170171
property.IsSettable(targetType, true) &&
@@ -174,8 +175,8 @@ internal bool HasGettableProperty(string name, Type? targetType = null, Type? at
174175

175176
/// <inheritdoc cref="HasGettableProperty(string, Type?, Type?)"/>
176177
/// <typeparam name="T">The <see cref="Attribute"/> expected on the property.</typeparam>
177-
internal bool HasGettableProperty<T>(string name, Type? targetType = null) where T : Attribute
178-
=> HasGettableProperty(name, targetType, typeof(T));
178+
internal bool HasGettableProperty<T>(string propertyName, Type? targetType = null) where T : Attribute
179+
=> HasGettableProperty(propertyName, targetType, typeof(T));
179180

180181
/*==========================================================================================================================
181182
| METHOD: HAS GETTABLE METHOD
@@ -187,11 +188,11 @@ internal bool HasGettableProperty<T>(string name, Type? targetType = null) where
187188
/// Will return false if the method is not available. Methods are only considered gettable if they have no parameters and
188189
/// their return value is a settable type.
189190
/// </remarks>
190-
/// <param name="name">The name of the method to assess.</param>
191+
/// <param name="methodName">The name of the method to assess, derived from <see cref="MemberAccessor.Name"/>.</param>
191192
/// <param name="targetType">Optional, the <see cref="Type"/> expected.</param>
192193
/// <param name="attributeFlag">Optional, the <see cref="Attribute"/> expected on the property.</param>
193-
internal bool HasGettableMethod(string name, Type? targetType = null, Type? attributeFlag = null) {
194-
var method = GetMember(name);
194+
internal bool HasGettableMethod(string methodName, Type? targetType = null, Type? attributeFlag = null) {
195+
var method = GetMember(methodName);
195196
return (
196197
method is not null and { CanRead: true, MemberType: MemberTypes.Method } &&
197198
method.IsSettable(targetType, true) &&
@@ -212,7 +213,7 @@ internal bool HasGettableMethod<T>(string name, Type? targetType = null) where T
212213
/// object.
213214
/// </summary>
214215
/// <param name="source">The <see cref="Object"/> instance from which the value should be retrieved.</param>
215-
/// <param name="memberName">The name of the method or property from which the value should be retrieved.</param>
216+
/// <param name="memberName">The name of the member to retrieve, derived from <see cref="MemberAccessor.Name"/>.</param>
216217
/// <returns>The value returned from the member.</returns>
217218
internal object? GetValue(object source, string memberName) {
218219

@@ -245,29 +246,30 @@ internal bool HasGettableMethod<T>(string name, Type? targetType = null) where T
245246
/// Uses reflection to call a property, assuming that it is a) readable, and b) of type <see cref="String"/>,
246247
/// <see cref="Int32"/>, or <see cref="Boolean"/>.
247248
/// </summary>
248-
/// <param name="target">The object instance on which the property is defined.</param>
249-
/// <param name="name">The name of the property to assess.</param>
250-
internal object? GetPropertyValue(object target, string name) => GetValue(target, name);
249+
/// <param name="source">The object instance on which the property is defined.</param>
250+
/// <param name="propertyName">The name of the property to retrieve, derived from <see cref="MemberAccessor.Name"/>.</param>
251+
internal object? GetPropertyValue(object source, string propertyName) => GetValue(source, propertyName);
251252

252253
/*==========================================================================================================================
253254
| METHOD: GET METHOD VALUE
254255
\-------------------------------------------------------------------------------------------------------------------------*/
255256
/// <summary>
256257
/// Uses reflection to call a method, assuming that it has no parameters.
257258
/// </summary>
258-
/// <param name="target">The object instance on which the method is defined.</param>
259-
/// <param name="name">The name of the method to assess.</param>
260-
internal object? GetMethodValue(object target, string name) => GetValue(target, name);
259+
/// <param name="source">The object instance on which the method is defined.</param>
260+
/// <param name="methodName">The name of the method to retrieve, derived from <see cref="MemberAccessor.Name"/>.</param>
261+
internal object? GetMethodValue(object source, string methodName) => GetValue(source, methodName);
261262

262263
/*==========================================================================================================================
263264
| HAS SETTER?
264265
\-------------------------------------------------------------------------------------------------------------------------*/
265266
/// <summary>
266-
/// Determines if a <see cref="MemberAccessor"/> with a setter exists for a member with the given <paramref name="name"/>.
267+
/// Determines if a <see cref="MemberAccessor"/> with a setter exists for a member with the given <paramref name="
268+
/// memberName"/>.
267269
/// </summary>
268-
/// <param name="name">The name of the <see cref="MemberAccessor"/>, derived from <see cref="MemberInfo.Name"/>.</param>
270+
/// <param name="memberName">The name of the member to assess, derived from <see cref="MemberAccessor.Name"/>.</param>
269271
/// <returns>True if a settable member exists; otherwise false.</returns>
270-
internal bool HasSetter(string name) => GetMember(name)?.CanWrite ?? false;
272+
internal bool HasSetter(string memberName) => GetMember(memberName)?.CanWrite ?? false;
271273

272274
/*==========================================================================================================================
273275
| METHOD: HAS SETTABLE PROPERTY
@@ -278,11 +280,11 @@ internal bool HasGettableMethod<T>(string name, Type? targetType = null) where T
278280
/// <remarks>
279281
/// Will return false if the property is not available.
280282
/// </remarks>
281-
/// <param name="name">The name of the property to assess.</param>
283+
/// <param name="propertyName">The name of the property to assess, derived from <see cref="MemberAccessor.Name"/>.</param>
282284
/// <param name="targetType">Optional, the <see cref="Type"/> expected.</param>
283285
/// <param name="attributeFlag">Optional, the <see cref="Attribute"/> expected on the property.</param>
284-
internal bool HasSettableProperty(string name, Type? targetType = null, Type? attributeFlag = null) {
285-
var property = GetMember(name);
286+
internal bool HasSettableProperty(string propertyName, Type? targetType = null, Type? attributeFlag = null) {
287+
var property = GetMember(propertyName);
286288
return (
287289
property is not null and { CanWrite: true, MemberType: MemberTypes.Property } &&
288290
property.IsSettable(targetType, true) &&
@@ -292,8 +294,8 @@ internal bool HasSettableProperty(string name, Type? targetType = null, Type? at
292294

293295
/// <inheritdoc cref="HasSettableProperty(string, Type?, Type?)"/>
294296
/// <typeparam name="T">The <see cref="Attribute"/> expected on the property.</typeparam>
295-
internal bool HasSettableProperty<T>(string name, Type? targetType = null) where T : Attribute
296-
=> HasSettableProperty(name, targetType, typeof(T));
297+
internal bool HasSettableProperty<T>(string propertyName, Type? targetType = null) where T : Attribute
298+
=> HasSettableProperty(propertyName, targetType, typeof(T));
297299

298300
/*==========================================================================================================================
299301
| METHOD: HAS SETTABLE METHOD
@@ -306,11 +308,11 @@ internal bool HasSettableProperty<T>(string name, Type? targetType = null) where
306308
/// a settable type. Be aware that this will return <c>false</c> if the method has additional parameters, even if those
307309
/// additional parameters are optional.
308310
/// </remarks>
309-
/// <param name="name">The name of the method to assess.</param>
311+
/// <param name="methodName">The name of the method to assess, derived from <see cref="MemberAccessor.Name"/>.</param>
310312
/// <param name="targetType">Optional, the <see cref="Type"/> expected.</param>
311313
/// <param name="attributeFlag">Optional, the <see cref="Attribute"/> expected on the property.</param>
312-
internal bool HasSettableMethod(string name, Type? targetType = null, Type? attributeFlag = null) {
313-
var method = GetMember(name);
314+
internal bool HasSettableMethod(string methodName, Type? targetType = null, Type? attributeFlag = null) {
315+
var method = GetMember(methodName);
314316
return (
315317
method is not null and { CanWrite: true, MemberType: MemberTypes.Method } &&
316318
method.IsSettable(targetType, true) &&
@@ -320,8 +322,8 @@ internal bool HasSettableMethod(string name, Type? targetType = null, Type? attr
320322

321323
/// <inheritdoc cref="HasSettableMethod(String, Type?, Type?)"/>
322324
/// <typeparam name="T">The <see cref="Attribute"/> expected on the property.</typeparam>
323-
internal bool HasSettableMethod<T>(string name, Type? targetType = null) where T : Attribute
324-
=> HasSettableMethod(name, targetType, typeof(T));
325+
internal bool HasSettableMethod<T>(string methodName, Type? targetType = null) where T : Attribute
326+
=> HasSettableMethod(methodName, targetType, typeof(T));
325327

326328
/*==========================================================================================================================
327329
| SET VALUE
@@ -330,7 +332,7 @@ internal bool HasSettableMethod<T>(string name, Type? targetType = null) where T
330332
/// Sets the value of a member named <paramref name="memberName"/> on the supplied <paramref name="target"/> object.
331333
/// </summary>
332334
/// <param name="target">The <see cref="Object"/> instance on which the value should be set.</param>
333-
/// <param name="memberName">The name of the method or property on which the value should be set.</param>
335+
/// <param name="memberName">The name of the member to set, derived from <see cref="MemberAccessor.Name"/>.</param>
334336
/// <param name="value">The <see cref="Object"/> value to set the member to.</param>
335337
/// <param name="allowConversion">
336338
/// Determines whether a fallback to <see cref="AttributeValueConverter.Convert(String?, Type)"/> is permitted.
@@ -365,13 +367,13 @@ internal void SetValue(object target, string memberName, object? value, bool all
365367
/// Int32"/>, or <see cref="Boolean"/>, or is otherwise compatible with the <paramref name="value"/> type.
366368
/// </summary>
367369
/// <param name="target">The object on which the property is defined.</param>
368-
/// <param name="name">The name of the property to assess.</param>
370+
/// <param name="propertyName">The name of the property to set, derived from <see cref="MemberAccessor.Name"/>.</param>
369371
/// <param name="value">The value to set on the property.</param>
370372
/// <param name="allowConversion">
371373
/// Determines whether a fallback to <see cref="AttributeValueConverter.Convert(String?, Type)"/> is permitted.
372374
/// </param>
373-
internal void SetPropertyValue(object target, string name, object? value, bool allowConversion = false)
374-
=> SetValue(target, name, value, allowConversion);
375+
internal void SetPropertyValue(object target, string propertyName, object? value, bool allowConversion = false)
376+
=> SetValue(target, propertyName, value, allowConversion);
375377

376378
/*==========================================================================================================================
377379
| METHOD: SET METHOD VALUE
@@ -385,13 +387,13 @@ internal void SetPropertyValue(object target, string name, object? value, bool a
385387
/// are present it will return <c>false</c>, even if those additional parameters are optional.
386388
/// </remarks>
387389
/// <param name="target">The object instance on which the method is defined.</param>
388-
/// <param name="name">The name of the method to assess.</param>
390+
/// <param name="methodName">The name of the method to set, derived from <see cref="MemberAccessor.Name"/>.</param>
389391
/// <param name="value">The value to set the method to.</param>
390392
/// <param name="allowConversion">
391393
/// Determines whether a fallback to <see cref="AttributeValueConverter.Convert(String?, Type)"/> is permitted.
392394
/// </param>
393-
internal void SetMethodValue(object target, string name, object? value, bool allowConversion = false)
394-
=> SetValue(target, name, value, allowConversion);
395+
internal void SetMethodValue(object target, string methodName, object? value, bool allowConversion = false)
396+
=> SetValue(target, methodName, value, allowConversion);
395397

396398
} //Class
397-
} //Namespace
399+
} //Namespace

0 commit comments

Comments
 (0)