diff --git a/Dalamud/Configuration/PluginConfigurations.cs b/Dalamud/Configuration/PluginConfigurations.cs index 95f25b04a..6c7143ee2 100644 --- a/Dalamud/Configuration/PluginConfigurations.cs +++ b/Dalamud/Configuration/PluginConfigurations.cs @@ -45,8 +45,7 @@ namespace Dalamud.Configuration /// /// Plugin name. /// Plugin configuration. - [CanBeNull] - public IPluginConfiguration Load(string pluginName) + public IPluginConfiguration? Load(string pluginName) { var path = this.GetConfigFile(pluginName); diff --git a/Dalamud/Game/ClientState/Buddy/BuddyList.cs b/Dalamud/Game/ClientState/Buddy/BuddyList.cs index eda592d6b..715a5ce30 100644 --- a/Dalamud/Game/ClientState/Buddy/BuddyList.cs +++ b/Dalamud/Game/ClientState/Buddy/BuddyList.cs @@ -66,8 +66,7 @@ namespace Dalamud.Game.ClientState.Buddy /// /// Gets the active companion buddy. /// - [CanBeNull] - public BuddyMember CompanionBuddy + public BuddyMember? CompanionBuddy { get { @@ -79,8 +78,7 @@ namespace Dalamud.Game.ClientState.Buddy /// /// Gets the active pet buddy. /// - [CanBeNull] - public BuddyMember PetBuddy + public BuddyMember? PetBuddy { get { @@ -103,8 +101,7 @@ namespace Dalamud.Game.ClientState.Buddy /// /// Spawn index. /// A at the specified spawn index. - [CanBeNull] - public BuddyMember this[int index] + public BuddyMember? this[int index] { get { @@ -149,8 +146,7 @@ namespace Dalamud.Game.ClientState.Buddy /// /// The address of the buddy in memory. /// object containing the requested data. - [CanBeNull] - public BuddyMember CreateBuddyMemberReference(IntPtr address) + public BuddyMember? CreateBuddyMemberReference(IntPtr address) { var clientState = Service.Get(); diff --git a/Dalamud/Game/ClientState/Buddy/BuddyMember.cs b/Dalamud/Game/ClientState/Buddy/BuddyMember.cs index 4c4fbc013..ad81874ba 100644 --- a/Dalamud/Game/ClientState/Buddy/BuddyMember.cs +++ b/Dalamud/Game/ClientState/Buddy/BuddyMember.cs @@ -37,8 +37,7 @@ namespace Dalamud.Game.ClientState.Buddy /// /// This iterates the actor table, it should be used with care. /// - [CanBeNull] - public GameObject GameObject => Service.Get().SearchByID(this.ObjectId); + public GameObject? GameObject => Service.Get().SearchByID(this.ObjectId); /// /// Gets the current health of this buddy. diff --git a/Dalamud/Game/ClientState/ClientState.cs b/Dalamud/Game/ClientState/ClientState.cs index 5ed9443ab..8c53a69c0 100644 --- a/Dalamud/Game/ClientState/ClientState.cs +++ b/Dalamud/Game/ClientState/ClientState.cs @@ -109,8 +109,7 @@ namespace Dalamud.Game.ClientState /// /// Gets the local player character, if one is present. /// - [CanBeNull] - public PlayerCharacter LocalPlayer => Service.Get()[0] as PlayerCharacter; + public PlayerCharacter? LocalPlayer => Service.Get()[0] as PlayerCharacter; /// /// Gets the content ID of the local character. diff --git a/Dalamud/Game/ClientState/Fates/FateTable.cs b/Dalamud/Game/ClientState/Fates/FateTable.cs index d57d3f4bd..65926f54c 100644 --- a/Dalamud/Game/ClientState/Fates/FateTable.cs +++ b/Dalamud/Game/ClientState/Fates/FateTable.cs @@ -75,8 +75,7 @@ namespace Dalamud.Game.ClientState.Fates /// /// Spawn index. /// A at the specified spawn index. - [CanBeNull] - public Fate this[int index] + public Fate? this[int index] { get { @@ -108,8 +107,7 @@ namespace Dalamud.Game.ClientState.Fates /// /// The offset of the actor in memory. /// object containing requested data. - [CanBeNull] - internal unsafe Fate CreateFateReference(IntPtr offset) + internal Fate? CreateFateReference(IntPtr offset) { var clientState = Service.Get(); diff --git a/Dalamud/Game/ClientState/Objects/ObjectTable.cs b/Dalamud/Game/ClientState/Objects/ObjectTable.cs index d2c0e6eaa..957ef7c68 100644 --- a/Dalamud/Game/ClientState/Objects/ObjectTable.cs +++ b/Dalamud/Game/ClientState/Objects/ObjectTable.cs @@ -49,8 +49,7 @@ namespace Dalamud.Game.ClientState.Objects /// /// Spawn index. /// An at the specified spawn index. - [CanBeNull] - public GameObject this[int index] + public GameObject? this[int index] { get { @@ -64,8 +63,7 @@ namespace Dalamud.Game.ClientState.Objects /// /// Object ID to find. /// A game object or null. - [CanBeNull] - public GameObject SearchByID(uint objectID) + public GameObject? SearchByID(uint objectID) { foreach (var obj in this) { @@ -97,8 +95,7 @@ namespace Dalamud.Game.ClientState.Objects /// /// The address of the object in memory. /// object or inheritor containing the requested data. - [CanBeNull] - public unsafe GameObject CreateObjectReference(IntPtr address) + public unsafe GameObject? CreateObjectReference(IntPtr address) { var clientState = Service.Get(); diff --git a/Dalamud/Game/ClientState/Objects/TargetManager.cs b/Dalamud/Game/ClientState/Objects/TargetManager.cs index 7d7f08121..91a7ef1c2 100644 --- a/Dalamud/Game/ClientState/Objects/TargetManager.cs +++ b/Dalamud/Game/ClientState/Objects/TargetManager.cs @@ -33,8 +33,7 @@ namespace Dalamud.Game.ClientState.Objects /// /// Gets or sets the current target. /// - [CanBeNull] - public GameObject Target + public GameObject? Target { get => Service.Get().CreateObjectReference((IntPtr)Struct->Target); set => this.SetTarget(value); @@ -43,8 +42,7 @@ namespace Dalamud.Game.ClientState.Objects /// /// Gets or sets the mouseover target. /// - [CanBeNull] - public GameObject MouseOverTarget + public GameObject? MouseOverTarget { get => Service.Get().CreateObjectReference((IntPtr)Struct->MouseOverTarget); set => this.SetMouseOverTarget(value); @@ -53,8 +51,7 @@ namespace Dalamud.Game.ClientState.Objects /// /// Gets or sets the focus target. /// - [CanBeNull] - public GameObject FocusTarget + public GameObject? FocusTarget { get => Service.Get().CreateObjectReference((IntPtr)Struct->FocusTarget); set => this.SetFocusTarget(value); @@ -63,8 +60,7 @@ namespace Dalamud.Game.ClientState.Objects /// /// Gets or sets the previous target. /// - [CanBeNull] - public GameObject PreviousTarget + public GameObject? PreviousTarget { get => Service.Get().CreateObjectReference((IntPtr)Struct->PreviousTarget); set => this.SetPreviousTarget(value); @@ -73,8 +69,7 @@ namespace Dalamud.Game.ClientState.Objects /// /// Gets or sets the soft target. /// - [CanBeNull] - public GameObject SoftTarget + public GameObject? SoftTarget { get => Service.Get().CreateObjectReference((IntPtr)Struct->SoftTarget); set => this.SetSoftTarget(value); @@ -86,31 +81,31 @@ namespace Dalamud.Game.ClientState.Objects /// Sets the current target. /// /// Actor to target. - public void SetTarget(GameObject actor) => this.SetTarget(actor?.Address ?? IntPtr.Zero); + public void SetTarget(GameObject? actor) => this.SetTarget(actor?.Address ?? IntPtr.Zero); /// /// Sets the mouseover target. /// /// Actor to target. - public void SetMouseOverTarget(GameObject actor) => this.SetTarget(actor?.Address ?? IntPtr.Zero); + public void SetMouseOverTarget(GameObject? actor) => this.SetTarget(actor?.Address ?? IntPtr.Zero); /// /// Sets the focus target. /// /// Actor to target. - public void SetFocusTarget(GameObject actor) => this.SetTarget(actor?.Address ?? IntPtr.Zero); + public void SetFocusTarget(GameObject? actor) => this.SetTarget(actor?.Address ?? IntPtr.Zero); /// /// Sets the previous target. /// /// Actor to target. - public void SetPreviousTarget(GameObject actor) => this.SetTarget(actor?.Address ?? IntPtr.Zero); + public void SetPreviousTarget(GameObject? actor) => this.SetTarget(actor?.Address ?? IntPtr.Zero); /// /// Sets the soft target. /// /// Actor to target. - public void SetSoftTarget(GameObject actor) => this.SetTarget(actor?.Address ?? IntPtr.Zero); + public void SetSoftTarget(GameObject? actor) => this.SetTarget(actor?.Address ?? IntPtr.Zero); /// /// Sets the current target. diff --git a/Dalamud/Game/ClientState/Objects/Types/GameObject.cs b/Dalamud/Game/ClientState/Objects/Types/GameObject.cs index 138dc43e2..837c08911 100644 --- a/Dalamud/Game/ClientState/Objects/Types/GameObject.cs +++ b/Dalamud/Game/ClientState/Objects/Types/GameObject.cs @@ -157,8 +157,7 @@ namespace Dalamud.Game.ClientState.Objects.Types /// /// This iterates the actor table, it should be used with care. /// - [CanBeNull] - public virtual GameObject TargetObject => Service.Get().SearchByID(this.TargetObjectId); + public virtual GameObject? TargetObject => Service.Get().SearchByID(this.TargetObjectId); /// /// Gets the underlying structure. diff --git a/Dalamud/Game/ClientState/Party/PartyList.cs b/Dalamud/Game/ClientState/Party/PartyList.cs index 60432c710..3ec936d44 100644 --- a/Dalamud/Game/ClientState/Party/PartyList.cs +++ b/Dalamud/Game/ClientState/Party/PartyList.cs @@ -72,8 +72,7 @@ namespace Dalamud.Game.ClientState.Party /// /// Spawn index. /// A at the specified spawn index. - [CanBeNull] - public PartyMember this[int index] + public PartyMember? this[int index] { get { @@ -112,8 +111,7 @@ namespace Dalamud.Game.ClientState.Party /// /// The address of the party member in memory. /// The party member object containing the requested data. - [CanBeNull] - public PartyMember CreatePartyMemberReference(IntPtr address) + public PartyMember? CreatePartyMemberReference(IntPtr address) { var clientState = Service.Get(); @@ -144,8 +142,7 @@ namespace Dalamud.Game.ClientState.Party /// /// The address of the alliance member in memory. /// The party member object containing the requested data. - [CanBeNull] - public PartyMember CreateAllianceMemberReference(IntPtr address) + public PartyMember? CreateAllianceMemberReference(IntPtr address) { var clientState = Service.Get(); diff --git a/Dalamud/Game/ClientState/Party/PartyMember.cs b/Dalamud/Game/ClientState/Party/PartyMember.cs index 8a74977cf..2f7422c5d 100644 --- a/Dalamud/Game/ClientState/Party/PartyMember.cs +++ b/Dalamud/Game/ClientState/Party/PartyMember.cs @@ -56,8 +56,7 @@ namespace Dalamud.Game.ClientState.Party /// /// This iterates the actor table, it should be used with care. /// - [CanBeNull] - public GameObject GameObject => Service.Get().SearchByID(this.ObjectId); + public GameObject? GameObject => Service.Get().SearchByID(this.ObjectId); /// /// Gets the current HP of this party member. diff --git a/Dalamud/Game/ClientState/Statuses/Status.cs b/Dalamud/Game/ClientState/Statuses/Status.cs index 9d159e25c..6abd2a048 100644 --- a/Dalamud/Game/ClientState/Statuses/Status.cs +++ b/Dalamud/Game/ClientState/Statuses/Status.cs @@ -62,8 +62,7 @@ namespace Dalamud.Game.ClientState.Statuses /// /// This iterates the actor table, it should be used with care. /// - [CanBeNull] - public GameObject SourceObject => Service.Get().SearchByID(this.SourceID); + public GameObject? SourceObject => Service.Get().SearchByID(this.SourceID); private FFXIVClientStructs.FFXIV.Client.Game.Status* Struct => (FFXIVClientStructs.FFXIV.Client.Game.Status*)this.Address; } diff --git a/Dalamud/Game/ClientState/Statuses/StatusList.cs b/Dalamud/Game/ClientState/Statuses/StatusList.cs index 800d6077b..10304eec3 100644 --- a/Dalamud/Game/ClientState/Statuses/StatusList.cs +++ b/Dalamud/Game/ClientState/Statuses/StatusList.cs @@ -65,8 +65,7 @@ namespace Dalamud.Game.ClientState.Statuses /// /// Status Index. /// The status at the specified index. - [CanBeNull] - public Status this[int index] + public Status? this[int index] { get { @@ -96,8 +95,7 @@ namespace Dalamud.Game.ClientState.Statuses /// /// The address of the status effect in memory. /// The status object containing the requested data. - [CanBeNull] - public Status CreateStatusReference(IntPtr address) + public Status? CreateStatusReference(IntPtr address) { var clientState = Service.Get(); diff --git a/Dalamud/Plugin/Internal/PluginManager.cs b/Dalamud/Plugin/Internal/PluginManager.cs index 5b386de1a..4e1471861 100644 --- a/Dalamud/Plugin/Internal/PluginManager.cs +++ b/Dalamud/Plugin/Internal/PluginManager.cs @@ -702,7 +702,6 @@ namespace Dalamud.Plugin.Internal /// Whether to notify that installed plugins have changed afterwards. /// Whether or not to actually perform the update, or just indicate success. /// The status of the update. - [CanBeNull] public async Task UpdateSinglePluginAsync(AvailablePluginUpdate metadata, bool notify, bool dryRun) { var plugin = metadata.InstalledPlugin; diff --git a/Dalamud/SafeMemory.cs b/Dalamud/SafeMemory.cs index 362291506..efd2fed04 100644 --- a/Dalamud/SafeMemory.cs +++ b/Dalamud/SafeMemory.cs @@ -75,8 +75,7 @@ namespace Dalamud /// The address to read from. /// The length of the array. /// An array of the read objects, or null if any entry of the array failed to read. - [CanBeNull] - public static T[] Read(IntPtr address, int count) where T : struct + public static T[]? Read(IntPtr address, int count) where T : struct { var size = SizeOf(); if (!ReadBytes(address, count * size, out var buffer)) @@ -132,8 +131,7 @@ namespace Dalamud /// The address to read from. /// The maximum length of the string. /// The read string, or null in case the read was not successful. - [CanBeNull] - public static string ReadString(IntPtr address, int maxLength = 256) + public static string? ReadString(IntPtr address, int maxLength = 256) { return ReadString(address, Encoding.UTF8, maxLength); } @@ -150,8 +148,7 @@ namespace Dalamud /// The encoding to use to decode the string. /// The maximum length of the string. /// The read string, or null in case the read was not successful. - [CanBeNull] - public static string ReadString(IntPtr address, Encoding encoding, int maxLength = 256) + public static string? ReadString(IntPtr address, Encoding encoding, int maxLength = 256) { if (!ReadBytes(address, maxLength, out var buffer)) return null;