mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-15 05:04:15 +01:00
refactor: use nullable annotations instead of CanBeNullAttribute
This commit is contained in:
parent
3c5c7fbc80
commit
010a4972cd
14 changed files with 33 additions and 62 deletions
|
|
@ -45,8 +45,7 @@ namespace Dalamud.Configuration
|
|||
/// </summary>
|
||||
/// <param name="pluginName">Plugin name.</param>
|
||||
/// <returns>Plugin configuration.</returns>
|
||||
[CanBeNull]
|
||||
public IPluginConfiguration Load(string pluginName)
|
||||
public IPluginConfiguration? Load(string pluginName)
|
||||
{
|
||||
var path = this.GetConfigFile(pluginName);
|
||||
|
||||
|
|
|
|||
|
|
@ -66,8 +66,7 @@ namespace Dalamud.Game.ClientState.Buddy
|
|||
/// <summary>
|
||||
/// Gets the active companion buddy.
|
||||
/// </summary>
|
||||
[CanBeNull]
|
||||
public BuddyMember CompanionBuddy
|
||||
public BuddyMember? CompanionBuddy
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
@ -79,8 +78,7 @@ namespace Dalamud.Game.ClientState.Buddy
|
|||
/// <summary>
|
||||
/// Gets the active pet buddy.
|
||||
/// </summary>
|
||||
[CanBeNull]
|
||||
public BuddyMember PetBuddy
|
||||
public BuddyMember? PetBuddy
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
@ -103,8 +101,7 @@ namespace Dalamud.Game.ClientState.Buddy
|
|||
/// </summary>
|
||||
/// <param name="index">Spawn index.</param>
|
||||
/// <returns>A <see cref="BuddyMember"/> at the specified spawn index.</returns>
|
||||
[CanBeNull]
|
||||
public BuddyMember this[int index]
|
||||
public BuddyMember? this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
@ -149,8 +146,7 @@ namespace Dalamud.Game.ClientState.Buddy
|
|||
/// </summary>
|
||||
/// <param name="address">The address of the buddy in memory.</param>
|
||||
/// <returns><see cref="BuddyMember"/> object containing the requested data.</returns>
|
||||
[CanBeNull]
|
||||
public BuddyMember CreateBuddyMemberReference(IntPtr address)
|
||||
public BuddyMember? CreateBuddyMemberReference(IntPtr address)
|
||||
{
|
||||
var clientState = Service<ClientState>.Get();
|
||||
|
||||
|
|
|
|||
|
|
@ -37,8 +37,7 @@ namespace Dalamud.Game.ClientState.Buddy
|
|||
/// <remarks>
|
||||
/// This iterates the actor table, it should be used with care.
|
||||
/// </remarks>
|
||||
[CanBeNull]
|
||||
public GameObject GameObject => Service<ObjectTable>.Get().SearchByID(this.ObjectId);
|
||||
public GameObject? GameObject => Service<ObjectTable>.Get().SearchByID(this.ObjectId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current health of this buddy.
|
||||
|
|
|
|||
|
|
@ -109,8 +109,7 @@ namespace Dalamud.Game.ClientState
|
|||
/// <summary>
|
||||
/// Gets the local player character, if one is present.
|
||||
/// </summary>
|
||||
[CanBeNull]
|
||||
public PlayerCharacter LocalPlayer => Service<ObjectTable>.Get()[0] as PlayerCharacter;
|
||||
public PlayerCharacter? LocalPlayer => Service<ObjectTable>.Get()[0] as PlayerCharacter;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the content ID of the local character.
|
||||
|
|
|
|||
|
|
@ -75,8 +75,7 @@ namespace Dalamud.Game.ClientState.Fates
|
|||
/// </summary>
|
||||
/// <param name="index">Spawn index.</param>
|
||||
/// <returns>A <see cref="Fate"/> at the specified spawn index.</returns>
|
||||
[CanBeNull]
|
||||
public Fate this[int index]
|
||||
public Fate? this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
@ -108,8 +107,7 @@ namespace Dalamud.Game.ClientState.Fates
|
|||
/// </summary>
|
||||
/// <param name="offset">The offset of the actor in memory.</param>
|
||||
/// <returns><see cref="Fate"/> object containing requested data.</returns>
|
||||
[CanBeNull]
|
||||
internal unsafe Fate CreateFateReference(IntPtr offset)
|
||||
internal Fate? CreateFateReference(IntPtr offset)
|
||||
{
|
||||
var clientState = Service<ClientState>.Get();
|
||||
|
||||
|
|
|
|||
|
|
@ -49,8 +49,7 @@ namespace Dalamud.Game.ClientState.Objects
|
|||
/// </summary>
|
||||
/// <param name="index">Spawn index.</param>
|
||||
/// <returns>An <see cref="GameObject"/> at the specified spawn index.</returns>
|
||||
[CanBeNull]
|
||||
public GameObject this[int index]
|
||||
public GameObject? this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
@ -64,8 +63,7 @@ namespace Dalamud.Game.ClientState.Objects
|
|||
/// </summary>
|
||||
/// <param name="objectID">Object ID to find.</param>
|
||||
/// <returns>A game object or null.</returns>
|
||||
[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
|
|||
/// </summary>
|
||||
/// <param name="address">The address of the object in memory.</param>
|
||||
/// <returns><see cref="GameObject"/> object or inheritor containing the requested data.</returns>
|
||||
[CanBeNull]
|
||||
public unsafe GameObject CreateObjectReference(IntPtr address)
|
||||
public unsafe GameObject? CreateObjectReference(IntPtr address)
|
||||
{
|
||||
var clientState = Service<ClientState>.Get();
|
||||
|
||||
|
|
|
|||
|
|
@ -33,8 +33,7 @@ namespace Dalamud.Game.ClientState.Objects
|
|||
/// <summary>
|
||||
/// Gets or sets the current target.
|
||||
/// </summary>
|
||||
[CanBeNull]
|
||||
public GameObject Target
|
||||
public GameObject? Target
|
||||
{
|
||||
get => Service<ObjectTable>.Get().CreateObjectReference((IntPtr)Struct->Target);
|
||||
set => this.SetTarget(value);
|
||||
|
|
@ -43,8 +42,7 @@ namespace Dalamud.Game.ClientState.Objects
|
|||
/// <summary>
|
||||
/// Gets or sets the mouseover target.
|
||||
/// </summary>
|
||||
[CanBeNull]
|
||||
public GameObject MouseOverTarget
|
||||
public GameObject? MouseOverTarget
|
||||
{
|
||||
get => Service<ObjectTable>.Get().CreateObjectReference((IntPtr)Struct->MouseOverTarget);
|
||||
set => this.SetMouseOverTarget(value);
|
||||
|
|
@ -53,8 +51,7 @@ namespace Dalamud.Game.ClientState.Objects
|
|||
/// <summary>
|
||||
/// Gets or sets the focus target.
|
||||
/// </summary>
|
||||
[CanBeNull]
|
||||
public GameObject FocusTarget
|
||||
public GameObject? FocusTarget
|
||||
{
|
||||
get => Service<ObjectTable>.Get().CreateObjectReference((IntPtr)Struct->FocusTarget);
|
||||
set => this.SetFocusTarget(value);
|
||||
|
|
@ -63,8 +60,7 @@ namespace Dalamud.Game.ClientState.Objects
|
|||
/// <summary>
|
||||
/// Gets or sets the previous target.
|
||||
/// </summary>
|
||||
[CanBeNull]
|
||||
public GameObject PreviousTarget
|
||||
public GameObject? PreviousTarget
|
||||
{
|
||||
get => Service<ObjectTable>.Get().CreateObjectReference((IntPtr)Struct->PreviousTarget);
|
||||
set => this.SetPreviousTarget(value);
|
||||
|
|
@ -73,8 +69,7 @@ namespace Dalamud.Game.ClientState.Objects
|
|||
/// <summary>
|
||||
/// Gets or sets the soft target.
|
||||
/// </summary>
|
||||
[CanBeNull]
|
||||
public GameObject SoftTarget
|
||||
public GameObject? SoftTarget
|
||||
{
|
||||
get => Service<ObjectTable>.Get().CreateObjectReference((IntPtr)Struct->SoftTarget);
|
||||
set => this.SetSoftTarget(value);
|
||||
|
|
@ -86,31 +81,31 @@ namespace Dalamud.Game.ClientState.Objects
|
|||
/// Sets the current target.
|
||||
/// </summary>
|
||||
/// <param name="actor">Actor to target.</param>
|
||||
public void SetTarget(GameObject actor) => this.SetTarget(actor?.Address ?? IntPtr.Zero);
|
||||
public void SetTarget(GameObject? actor) => this.SetTarget(actor?.Address ?? IntPtr.Zero);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the mouseover target.
|
||||
/// </summary>
|
||||
/// <param name="actor">Actor to target.</param>
|
||||
public void SetMouseOverTarget(GameObject actor) => this.SetTarget(actor?.Address ?? IntPtr.Zero);
|
||||
public void SetMouseOverTarget(GameObject? actor) => this.SetTarget(actor?.Address ?? IntPtr.Zero);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the focus target.
|
||||
/// </summary>
|
||||
/// <param name="actor">Actor to target.</param>
|
||||
public void SetFocusTarget(GameObject actor) => this.SetTarget(actor?.Address ?? IntPtr.Zero);
|
||||
public void SetFocusTarget(GameObject? actor) => this.SetTarget(actor?.Address ?? IntPtr.Zero);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the previous target.
|
||||
/// </summary>
|
||||
/// <param name="actor">Actor to target.</param>
|
||||
public void SetPreviousTarget(GameObject actor) => this.SetTarget(actor?.Address ?? IntPtr.Zero);
|
||||
public void SetPreviousTarget(GameObject? actor) => this.SetTarget(actor?.Address ?? IntPtr.Zero);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the soft target.
|
||||
/// </summary>
|
||||
/// <param name="actor">Actor to target.</param>
|
||||
public void SetSoftTarget(GameObject actor) => this.SetTarget(actor?.Address ?? IntPtr.Zero);
|
||||
public void SetSoftTarget(GameObject? actor) => this.SetTarget(actor?.Address ?? IntPtr.Zero);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the current target.
|
||||
|
|
|
|||
|
|
@ -157,8 +157,7 @@ namespace Dalamud.Game.ClientState.Objects.Types
|
|||
/// <remarks>
|
||||
/// This iterates the actor table, it should be used with care.
|
||||
/// </remarks>
|
||||
[CanBeNull]
|
||||
public virtual GameObject TargetObject => Service<ObjectTable>.Get().SearchByID(this.TargetObjectId);
|
||||
public virtual GameObject? TargetObject => Service<ObjectTable>.Get().SearchByID(this.TargetObjectId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the underlying structure.
|
||||
|
|
|
|||
|
|
@ -72,8 +72,7 @@ namespace Dalamud.Game.ClientState.Party
|
|||
/// </summary>
|
||||
/// <param name="index">Spawn index.</param>
|
||||
/// <returns>A <see cref="PartyMember"/> at the specified spawn index.</returns>
|
||||
[CanBeNull]
|
||||
public PartyMember this[int index]
|
||||
public PartyMember? this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
@ -112,8 +111,7 @@ namespace Dalamud.Game.ClientState.Party
|
|||
/// </summary>
|
||||
/// <param name="address">The address of the party member in memory.</param>
|
||||
/// <returns>The party member object containing the requested data.</returns>
|
||||
[CanBeNull]
|
||||
public PartyMember CreatePartyMemberReference(IntPtr address)
|
||||
public PartyMember? CreatePartyMemberReference(IntPtr address)
|
||||
{
|
||||
var clientState = Service<ClientState>.Get();
|
||||
|
||||
|
|
@ -144,8 +142,7 @@ namespace Dalamud.Game.ClientState.Party
|
|||
/// </summary>
|
||||
/// <param name="address">The address of the alliance member in memory.</param>
|
||||
/// <returns>The party member object containing the requested data.</returns>
|
||||
[CanBeNull]
|
||||
public PartyMember CreateAllianceMemberReference(IntPtr address)
|
||||
public PartyMember? CreateAllianceMemberReference(IntPtr address)
|
||||
{
|
||||
var clientState = Service<ClientState>.Get();
|
||||
|
||||
|
|
|
|||
|
|
@ -56,8 +56,7 @@ namespace Dalamud.Game.ClientState.Party
|
|||
/// <remarks>
|
||||
/// This iterates the actor table, it should be used with care.
|
||||
/// </remarks>
|
||||
[CanBeNull]
|
||||
public GameObject GameObject => Service<ObjectTable>.Get().SearchByID(this.ObjectId);
|
||||
public GameObject? GameObject => Service<ObjectTable>.Get().SearchByID(this.ObjectId);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current HP of this party member.
|
||||
|
|
|
|||
|
|
@ -62,8 +62,7 @@ namespace Dalamud.Game.ClientState.Statuses
|
|||
/// <remarks>
|
||||
/// This iterates the actor table, it should be used with care.
|
||||
/// </remarks>
|
||||
[CanBeNull]
|
||||
public GameObject SourceObject => Service<ObjectTable>.Get().SearchByID(this.SourceID);
|
||||
public GameObject? SourceObject => Service<ObjectTable>.Get().SearchByID(this.SourceID);
|
||||
|
||||
private FFXIVClientStructs.FFXIV.Client.Game.Status* Struct => (FFXIVClientStructs.FFXIV.Client.Game.Status*)this.Address;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,8 +65,7 @@ namespace Dalamud.Game.ClientState.Statuses
|
|||
/// </summary>
|
||||
/// <param name="index">Status Index.</param>
|
||||
/// <returns>The status at the specified index.</returns>
|
||||
[CanBeNull]
|
||||
public Status this[int index]
|
||||
public Status? this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
@ -96,8 +95,7 @@ namespace Dalamud.Game.ClientState.Statuses
|
|||
/// </summary>
|
||||
/// <param name="address">The address of the status effect in memory.</param>
|
||||
/// <returns>The status object containing the requested data.</returns>
|
||||
[CanBeNull]
|
||||
public Status CreateStatusReference(IntPtr address)
|
||||
public Status? CreateStatusReference(IntPtr address)
|
||||
{
|
||||
var clientState = Service<ClientState>.Get();
|
||||
|
||||
|
|
|
|||
|
|
@ -702,7 +702,6 @@ namespace Dalamud.Plugin.Internal
|
|||
/// <param name="notify">Whether to notify that installed plugins have changed afterwards.</param>
|
||||
/// <param name="dryRun">Whether or not to actually perform the update, or just indicate success.</param>
|
||||
/// <returns>The status of the update.</returns>
|
||||
[CanBeNull]
|
||||
public async Task<PluginUpdateStatus?> UpdateSinglePluginAsync(AvailablePluginUpdate metadata, bool notify, bool dryRun)
|
||||
{
|
||||
var plugin = metadata.InstalledPlugin;
|
||||
|
|
|
|||
|
|
@ -75,8 +75,7 @@ namespace Dalamud
|
|||
/// <param name="address">The address to read from.</param>
|
||||
/// <param name="count">The length of the array.</param>
|
||||
/// <returns>An array of the read objects, or null if any entry of the array failed to read.</returns>
|
||||
[CanBeNull]
|
||||
public static T[] Read<T>(IntPtr address, int count) where T : struct
|
||||
public static T[]? Read<T>(IntPtr address, int count) where T : struct
|
||||
{
|
||||
var size = SizeOf<T>();
|
||||
if (!ReadBytes(address, count * size, out var buffer))
|
||||
|
|
@ -132,8 +131,7 @@ namespace Dalamud
|
|||
/// <param name="address">The address to read from.</param>
|
||||
/// <param name="maxLength">The maximum length of the string.</param>
|
||||
/// <returns>The read string, or null in case the read was not successful.</returns>
|
||||
[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
|
|||
/// <param name="encoding">The encoding to use to decode the string.</param>
|
||||
/// <param name="maxLength">The maximum length of the string.</param>
|
||||
/// <returns>The read string, or null in case the read was not successful.</returns>
|
||||
[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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue