diff options
Diffstat (limited to 'src/SMAPI/Framework/Reflection/ReflectedMethod.cs')
-rw-r--r-- | src/SMAPI/Framework/Reflection/ReflectedMethod.cs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/SMAPI/Framework/Reflection/ReflectedMethod.cs b/src/SMAPI/Framework/Reflection/ReflectedMethod.cs index 26112806..a607141e 100644 --- a/src/SMAPI/Framework/Reflection/ReflectedMethod.cs +++ b/src/SMAPI/Framework/Reflection/ReflectedMethod.cs @@ -12,8 +12,8 @@ namespace StardewModdingAPI.Framework.Reflection /// <summary>The type that has the method.</summary> private readonly Type ParentType; - /// <summary>The object that has the instance method (if applicable).</summary> - private readonly object Parent; + /// <summary>The object that has the instance method, or <c>null</c> for a static method.</summary> + private readonly object? Parent; /// <summary>The display name shown in error messages.</summary> private string DisplayName => $"{this.ParentType.FullName}::{this.MethodInfo.Name}"; @@ -31,12 +31,12 @@ namespace StardewModdingAPI.Framework.Reflection *********/ /// <summary>Construct an instance.</summary> /// <param name="parentType">The type that has the method.</param> - /// <param name="obj">The object that has the instance method(if applicable).</param> + /// <param name="obj">The object that has the instance method, or <c>null</c> for a static method.</param> /// <param name="method">The reflection metadata.</param> /// <param name="isStatic">Whether the method is static.</param> /// <exception cref="ArgumentNullException">The <paramref name="parentType"/> or <paramref name="method"/> is null.</exception> /// <exception cref="ArgumentException">The <paramref name="obj"/> is null for a non-static method, or not null for a static method.</exception> - public ReflectedMethod(Type parentType, object obj, MethodInfo method, bool isStatic) + public ReflectedMethod(Type parentType, object? obj, MethodInfo method, bool isStatic) { // validate if (parentType == null) @@ -55,10 +55,10 @@ namespace StardewModdingAPI.Framework.Reflection } /// <inheritdoc /> - public TValue Invoke<TValue>(params object[] arguments) + public TValue Invoke<TValue>(params object?[] arguments) { // invoke method - object result; + object? result; try { result = this.MethodInfo.Invoke(this.Parent, arguments); @@ -75,7 +75,7 @@ namespace StardewModdingAPI.Framework.Reflection // cast return value try { - return (TValue)result; + return (TValue)result!; } catch (InvalidCastException) { @@ -84,7 +84,7 @@ namespace StardewModdingAPI.Framework.Reflection } /// <inheritdoc /> - public void Invoke(params object[] arguments) + public void Invoke(params object?[] arguments) { // invoke method try |