From f39da383a17b368e92fd243cf155b27ba42671f3 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 13 Apr 2022 20:24:14 -0400 Subject: enable nullable annotations in SMAPI where no logic changes are needed (#837) --- src/SMAPI/IReflectionHelper.cs | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'src/SMAPI/IReflectionHelper.cs') diff --git a/src/SMAPI/IReflectionHelper.cs b/src/SMAPI/IReflectionHelper.cs index bf7270cf..b8fb877f 100644 --- a/src/SMAPI/IReflectionHelper.cs +++ b/src/SMAPI/IReflectionHelper.cs @@ -1,5 +1,3 @@ -#nullable disable - using System; namespace StardewModdingAPI @@ -14,40 +12,52 @@ namespace StardewModdingAPI /// The field type. /// The object which has the field. /// The field name. - /// Whether to throw an exception if the field is not found. + /// Whether to throw an exception if the field isn't found. Due to limitations with nullable reference types, setting this to false will still mark the return value non-nullable. + /// Returns the method wrapper, or null if is false and the field doesn't exist. + /// The target field doesn't exist, and is true. IReflectedField GetField(object obj, string name, bool required = true); /// Get a static field. /// The field type. /// The type which has the field. /// The field name. - /// Whether to throw an exception if the field is not found. + /// Whether to throw an exception if the field isn't found. Due to limitations with nullable reference types, setting this to false will still mark the return value non-nullable. + /// Returns the method wrapper, or null if is false and the field doesn't exist. + /// The target field doesn't exist, and is true. IReflectedField GetField(Type type, string name, bool required = true); /// Get an instance property. /// The property type. /// The object which has the property. /// The property name. - /// Whether to throw an exception if the property is not found. + /// Whether to throw an exception if the property isn't found. Due to limitations with nullable reference types, setting this to false will still mark the return value non-nullable. + /// Returns the method wrapper, or null if is false and the property doesn't exist. + /// The target property doesn't exist, and is true. IReflectedProperty GetProperty(object obj, string name, bool required = true); /// Get a static property. /// The property type. /// The type which has the property. /// The property name. - /// Whether to throw an exception if the property is not found. + /// Whether to throw an exception if the property isn't found. Due to limitations with nullable reference types, setting this to false will still mark the return value non-nullable. + /// Returns the method wrapper, or null if is false and the property doesn't exist. + /// The target property doesn't exist, and is true. IReflectedProperty GetProperty(Type type, string name, bool required = true); /// Get an instance method. /// The object which has the method. - /// The field name. - /// Whether to throw an exception if the field is not found. + /// The method name. + /// Whether to throw an exception if the method isn't found. Due to limitations with nullable reference types, setting this to false will still mark the return value non-nullable. + /// Returns the method wrapper, or null if is false and the method doesn't exist. + /// The target method doesn't exist, and is true. IReflectedMethod GetMethod(object obj, string name, bool required = true); /// Get a static method. /// The type which has the method. - /// The field name. - /// Whether to throw an exception if the field is not found. + /// The method name. + /// Whether to throw an exception if the method isn't found. Due to limitations with nullable reference types, setting this to false will still mark the return value non-nullable. + /// Returns the method wrapper, or null if is false and the method doesn't exist. + /// The target method doesn't exist, and is true. IReflectedMethod GetMethod(Type type, string name, bool required = true); } } -- cgit