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/Framework/Events/ManagedEvent.cs | 8 +++----- src/SMAPI/Framework/Events/ManagedEventHandler.cs | 4 +--- 2 files changed, 4 insertions(+), 8 deletions(-) (limited to 'src/SMAPI/Framework/Events') diff --git a/src/SMAPI/Framework/Events/ManagedEvent.cs b/src/SMAPI/Framework/Events/ManagedEvent.cs index 8fa31165..4b8a770d 100644 --- a/src/SMAPI/Framework/Events/ManagedEvent.cs +++ b/src/SMAPI/Framework/Events/ManagedEvent.cs @@ -1,5 +1,3 @@ -#nullable disable - using System; using System.Collections.Generic; using System.Linq; @@ -23,7 +21,7 @@ namespace StardewModdingAPI.Framework.Events private readonly List> Handlers = new(); /// A cached snapshot of , or null to rebuild it next raise. - private ManagedEventHandler[] CachedHandlers = Array.Empty>(); + private ManagedEventHandler[]? CachedHandlers = Array.Empty>(); /// The total number of event handlers registered for this events, regardless of whether they're still registered. private int RegistrationIndex; @@ -100,7 +98,7 @@ namespace StardewModdingAPI.Framework.Events /// Raise the event and notify all handlers. /// The event arguments to pass. /// A lambda which returns true if the event should be raised for the given mod. - public void Raise(TEventArgs args, Func match = null) + public void Raise(TEventArgs args, Func? match = null) { this.Raise((_, invoke) => invoke(args), match); } @@ -108,7 +106,7 @@ namespace StardewModdingAPI.Framework.Events /// Raise the event and notify all handlers. /// Invoke an event handler. This receives the mod which registered the handler, and should invoke the callback with the event arguments to pass it. /// A lambda which returns true if the event should be raised for the given mod. - public void Raise(Action> invoke, Func match = null) + public void Raise(Action> invoke, Func? match = null) { // skip if no handlers if (this.Handlers.Count == 0) diff --git a/src/SMAPI/Framework/Events/ManagedEventHandler.cs b/src/SMAPI/Framework/Events/ManagedEventHandler.cs index f31bc04d..d32acdb9 100644 --- a/src/SMAPI/Framework/Events/ManagedEventHandler.cs +++ b/src/SMAPI/Framework/Events/ManagedEventHandler.cs @@ -1,5 +1,3 @@ -#nullable disable - using System; using StardewModdingAPI.Events; @@ -42,7 +40,7 @@ namespace StardewModdingAPI.Framework.Events } /// - public int CompareTo(object obj) + public int CompareTo(object? obj) { if (obj is not ManagedEventHandler other) throw new ArgumentException("Can't compare to an unrelated object type."); -- cgit