fix: Mark remaining as obsolete

This commit is contained in:
Kaz Wolfe 2025-09-11 10:20:29 -07:00
parent 77a15a533d
commit a1cc4fa91b
No known key found for this signature in database
GPG key ID: 258813F53A16EBB4
3 changed files with 57 additions and 18 deletions

View file

@ -14,6 +14,11 @@ namespace Dalamud.Test.Compliance;
public class PublicApiTests
{
private static List<Type> IgnoredTypes { get; } =
[
typeof(Utility.CStringExtensions),
];
private static List<Assembly> PermittedAssemblies { get; } =
[
typeof(object).Assembly,
@ -38,7 +43,7 @@ public class PublicApiTests
[Fact]
public void NoRestrictedTypes()
{
foreach (var type in typeof(Dalamud).Assembly.GetTypes().Where(t => t.IsPublic))
foreach (var type in typeof(Dalamud).Assembly.GetTypes().Where(t => t.IsPublic).Except(IgnoredTypes))
{
if (type.GetCustomAttribute<ObsoleteAttribute>() != null) continue;
@ -48,14 +53,14 @@ public class PublicApiTests
if (!this.IsPermittedType(m.ReturnType))
{
Assert.Fail($"Method {type.FullName}.{m.Name} returns invalid type: {m.ReturnType.FullName}");
Assert.Fail($"Method {type.FullName}.{m.Name} returns unapproved type: {m.ReturnType.FullName}");
}
foreach (var param in m.GetParameters())
{
if (!this.IsPermittedType(param.ParameterType))
{
Assert.Fail($"Method {type.FullName}.{m.Name} uses invalid type: {param.ParameterType.FullName}");
Assert.Fail($"Method {type.FullName}.{m.Name} uses unapproved type: {param.ParameterType.FullName}");
}
}
}
@ -68,7 +73,7 @@ public class PublicApiTests
if (!this.IsPermittedType(p.PropertyType))
{
Assert.Fail(
$"Property {type.FullName}.{p.Name} is invalid type: {p.PropertyType.FullName}");
$"Property {type.FullName}.{p.Name} is unapproved type: {p.PropertyType.FullName}");
}
}
@ -79,7 +84,7 @@ public class PublicApiTests
if (!this.IsPermittedType(f.FieldType))
{
Assert.Fail(
$"Field {type.FullName}.{f.Name} is invalid type: {f.FieldType.FullName}");
$"Field {type.FullName}.{f.Name} is unapproved type: {f.FieldType.FullName}");
}
}
}

View file

@ -72,37 +72,38 @@ public unsafe class SMNGauge : JobGaugeBase<SummonerGauge>
/// Use the summon accessors instead.
/// </summary>
[Api14ToDo("Declare our own enum for this to avoid CS type.")]
[Obsolete("Use specific accessors instead until API14.")]
public AetherFlags AetherFlags => this.Struct->AetherFlags;
/// <summary>
/// Gets a value indicating whether Bahamut is ready to be summoned.
/// </summary>
/// <returns><c>true</c> or <c>false</c>.</returns>
public bool IsBahamutReady => !this.AetherFlags.HasFlag(AetherFlags.PhoenixReady);
public bool IsBahamutReady => !this.Struct->AetherFlags.HasFlag(AetherFlags.PhoenixReady);
/// <summary>
/// Gets a value indicating whether if Phoenix is ready to be summoned.
/// </summary>
/// <returns><c>true</c> or <c>false</c>.</returns>
public bool IsPhoenixReady => this.AetherFlags.HasFlag(AetherFlags.PhoenixReady);
public bool IsPhoenixReady => this.Struct->AetherFlags.HasFlag(AetherFlags.PhoenixReady);
/// <summary>
/// Gets a value indicating whether if Ifrit is ready to be summoned.
/// </summary>
/// <returns><c>true</c> or <c>false</c>.</returns>
public bool IsIfritReady => this.AetherFlags.HasFlag(AetherFlags.IfritReady);
public bool IsIfritReady => this.Struct->AetherFlags.HasFlag(AetherFlags.IfritReady);
/// <summary>
/// Gets a value indicating whether if Titan is ready to be summoned.
/// </summary>
/// <returns><c>true</c> or <c>false</c>.</returns>
public bool IsTitanReady => this.AetherFlags.HasFlag(AetherFlags.TitanReady);
public bool IsTitanReady => this.Struct->AetherFlags.HasFlag(AetherFlags.TitanReady);
/// <summary>
/// Gets a value indicating whether if Garuda is ready to be summoned.
/// </summary>
/// <returns><c>true</c> or <c>false</c>.</returns>
public bool IsGarudaReady => this.AetherFlags.HasFlag(AetherFlags.GarudaReady);
public bool IsGarudaReady => this.Struct->AetherFlags.HasFlag(AetherFlags.GarudaReady);
/// <summary>
/// Gets a value indicating whether if Ifrit is currently attuned.
@ -131,5 +132,5 @@ public unsafe class SMNGauge : JobGaugeBase<SummonerGauge>
/// <summary>
/// Gets the amount of Aetherflow available.
/// </summary>
public byte AetherflowStacks => (byte)(this.AetherFlags & AetherFlags.Aetherflow);
public byte AetherflowStacks => (byte)(this.Struct->AetherFlags & AetherFlags.Aetherflow);
}

View file

@ -4,6 +4,8 @@ using Dalamud.Utility;
using FFXIVClientStructs.FFXIV.Common.Math;
#pragma warning disable CS0618 // Type or member is obsolete. To be fixed with API14.
namespace Dalamud.Interface.Components;
/// <summary>
@ -23,15 +25,10 @@ public static partial class ImGuiComponents
/// <param name="helpText">The text to display on hover.</param>
/// <param name="icon">The icon to use.</param>
/// <param name="color">The color of the icon.</param>
[Api14ToDo("Replace CS Vector4 with System.Numerics.Vector4")]
public static void HelpMarker(string helpText, FontAwesomeIcon icon, Vector4? color = null)
public static void HelpMarker(string helpText, FontAwesomeIcon icon, System.Numerics.Vector4 color)
{
using var col = new ImRaii.Color();
if (color.HasValue)
{
col.Push(ImGuiCol.TextDisabled, color.Value);
}
col.Push(ImGuiCol.TextDisabled, color);
ImGui.SameLine();
@ -51,4 +48,40 @@ public static partial class ImGuiComponents
}
}
}
/// <summary>
/// HelpMarker component to add a custom icon with text on hover.
/// </summary>
/// <param name="helpText">The text to display on hover.</param>
/// <param name="icon">The icon to use.</param>
/// <param name="color">The color of the icon.</param>
[Api14ToDo(Api14ToDoAttribute.Remove)]
[Obsolete("CS type is deprecated. Use System.Numerics.Vector4 instead.")]
public static void HelpMarker(string helpText, FontAwesomeIcon icon, Vector4? color = null)
{
if (color.HasValue)
{
HelpMarker(helpText, icon, color.Value);
return;
}
// FIXME: Code duplication is easier than splitting up the Nullable in a way that doesn't break the API.
ImGui.SameLine();
using (ImRaii.PushFont(UiBuilder.IconFont))
{
ImGui.TextDisabled(icon.ToIconString());
}
if (ImGui.IsItemHovered())
{
using (ImRaii.Tooltip())
{
using (ImRaii.TextWrapPos(ImGui.GetFontSize() * 35.0f))
{
ImGui.Text(helpText);
}
}
}
}
}