Fix a lot of the analyzer warnings too

This commit is contained in:
Loporrit
2025-06-30 17:50:31 +00:00
parent dd42bf0913
commit aa377439ce
46 changed files with 160 additions and 210 deletions

View File

@@ -39,7 +39,6 @@ public class CompactUi : WindowMediatorSubscriberBase
private readonly GroupPanel _groupPanel;
private readonly PairGroupsUi _pairGroupsUi;
private readonly PairManager _pairManager;
private readonly ChatService _chatService;
private readonly SelectGroupForPairUi _selectGroupForPairUi;
private readonly SelectPairForGroupUi _selectPairsForGroupUi;
private readonly ServerConfigurationManager _serverManager;
@@ -68,14 +67,13 @@ public class CompactUi : WindowMediatorSubscriberBase
_configService = configService;
_apiController = apiController;
_pairManager = pairManager;
_chatService = chatService;
_serverManager = serverManager;
_fileTransferManager = fileTransferManager;
_uidDisplayHandler = uidDisplayHandler;
_charaDataManager = charaDataManager;
var tagHandler = new TagHandler(_serverManager);
_groupPanel = new(this, uiShared, _pairManager, _chatService, uidDisplayHandler, _configService, _serverManager, _charaDataManager);
_groupPanel = new(this, uiShared, _pairManager, chatService, uidDisplayHandler, _configService, _serverManager, _charaDataManager);
_selectGroupForPairUi = new(tagHandler, uidDisplayHandler, _uiSharedService);
_selectPairsForGroupUi = new(tagHandler, uidDisplayHandler);
_pairGroupsUi = new(configService, tagHandler, uidDisplayHandler, apiController, _selectPairsForGroupUi, _uiSharedService);
@@ -107,17 +105,10 @@ public class CompactUi : WindowMediatorSubscriberBase
protected override void DrawInternal()
{
/*if (_apiController.ServerInfo.AccentColor.HasValue)
{
UiSharedService.AccentColor = _apiController.ServerInfo.AccentColor.Value;
}
else*/
{
if (_serverManager.CurrentApiUrl == ApiController.LoporritServiceUri)
UiSharedService.AccentColor = new Vector4(1.0f, 0.8666f, 0.06666f, 1.0f);
else
UiSharedService.AccentColor = ImGuiColors.ParsedGreen;
}
if (_serverManager.CurrentApiUrl.Equals(ApiController.LoporritServiceUri, StringComparison.Ordinal))
UiSharedService.AccentColor = new Vector4(1.0f, 0.8666f, 0.06666f, 1.0f);
else
UiSharedService.AccentColor = ImGuiColors.ParsedGreen;
ImGui.SetCursorPosY(ImGui.GetCursorPosY() - ImGui.GetStyle().WindowPadding.Y - 1f * ImGuiHelpers.GlobalScale + ImGui.GetStyle().ItemSpacing.Y);
WindowContentWidth = UiSharedService.GetWindowContentRegionWidth();
if (!_apiController.IsCurrentVersion)
@@ -292,7 +283,6 @@ public class CompactUi : WindowMediatorSubscriberBase
private void DrawFilter()
{
var buttonSize = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.ArrowUp);
var playButtonSize = _uiSharedService.GetIconButtonSize(FontAwesomeIcon.Play);
var users = GetFilteredUsers();
@@ -371,7 +361,7 @@ public class CompactUi : WindowMediatorSubscriberBase
var ySize = TransferPartHeight == 0
? 1
: (ImGui.GetWindowContentRegionMax().Y - ImGui.GetWindowContentRegionMin().Y) - TransferPartHeight - ImGui.GetCursorPosY();
var users = GetFilteredUsers().OrderBy(u => u.GetPairSortKey());
var users = GetFilteredUsers().OrderBy(u => u.GetPairSortKey(), StringComparer.Ordinal);
var onlineUsers = users.Where(u => u.UserPair!.OtherPermissions.IsPaired() && (u.IsOnline || u.UserPair!.OwnPermissions.IsPaused())).Select(c => new DrawUserPair("Online" + c.UserData.UID, c, _uidDisplayHandler, _apiController, Mediator, _selectGroupForPairUi, _uiSharedService, _charaDataManager)).ToList();
var visibleUsers = users.Where(u => u.IsVisible).Select(c => new DrawUserPair("Visible" + c.UserData.UID, c, _uidDisplayHandler, _apiController, Mediator, _selectGroupForPairUi, _uiSharedService, _charaDataManager)).ToList();

View File

@@ -460,8 +460,8 @@ public class DataAnalysisUi : WindowMediatorSubscriberBase
if (_enableBc7ConversionMode)
{
ImGui.TableNextColumn();
if (item.Format.Value.StartsWith("BC") || item.Format.Value.StartsWith("DXT")
|| item.Format.Value.StartsWith("24864")) // BC4
if (item.Format.Value.StartsWith("BC", StringComparison.Ordinal) || item.Format.Value.StartsWith("DXT", StringComparison.Ordinal)
|| item.Format.Value.StartsWith("24864", StringComparison.Ordinal)) // BC4
{
ImGui.TextUnformatted("");
continue;

View File

@@ -123,7 +123,7 @@ public class EditProfileUi : WindowMediatorSubscriberBase
ImGui.Checkbox("Is NSFW", ref nsfw);
ImGui.EndDisabled();
if (_serverConfigurationManager.CurrentApiUrl == ApiController.MainServiceUri)
if (_serverConfigurationManager.CurrentApiUrl.Equals(ApiController.MainServiceUri, StringComparison.Ordinal))
{
ImGui.Separator();
_uiSharedService.BigText("Notes and Rules for Profiles");

View File

@@ -374,6 +374,8 @@ This service is provided as-is.
}
}
#pragma warning disable MA0009
[GeneratedRegex("^([A-F0-9]{2})+")]
private static partial Regex HexRegex();
#pragma warning restore MA0009
}

View File

@@ -377,7 +377,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
}
private static readonly List<(XivChatType, string)> _syncshellChatTypes = [
(0, "(use global setting)"),
(XivChatType.None, "(use global setting)"),
(XivChatType.Debug, "Debug"),
(XivChatType.Echo, "Echo"),
(XivChatType.StandardEmote, "Standard Emote"),
@@ -448,20 +448,6 @@ public class SettingsUi : WindowMediatorSubscriberBase
_uiShared.BigText("\"Chat 2\" Plugin Integration");
ImGui.SetWindowFontScale(1.0f);
// TODO: ExtraChat API impersonation
/*
var extraChatAPI = _configService.Current.ExtraChatAPI;
if (ImGui.Checkbox("ExtraChat replacement mode", ref extraChatAPI))
{
_configService.Current.ExtraChatAPI = extraChatAPI;
if (extraChatAPI)
_configService.Current.ExtraChatTags = true;
_configService.Save();
}
ImGui.EndDisabled();
UiSharedService.DrawHelpText("Enable ExtraChat APIs for full Chat 2 plugin integration.\n\nDo not enable this if ExtraChat is also installed and running.");
*/
var extraChatTags = _configService.Current.ExtraChatTags;
if (ImGui.Checkbox("Tag messages as ExtraChat", ref extraChatTags))
{
@@ -488,7 +474,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
return;
}
foreach (var group in _pairManager.Groups.OrderBy(k => k.Key.GID))
foreach (var group in _pairManager.Groups.OrderBy(k => k.Key.GID, StringComparer.Ordinal))
{
var gid = group.Key.GID;
using var pushId = ImRaii.PushId(gid);
@@ -514,11 +500,11 @@ public class SettingsUi : WindowMediatorSubscriberBase
bool conflict = false;
foreach (var otherGroup in _pairManager.Groups)
{
if (gid == otherGroup.Key.GID) continue;
if (gid.Equals(otherGroup.Key.GID, StringComparison.Ordinal)) continue;
var otherShellConfig = _serverConfigurationManager.GetShellConfigForGid(otherGroup.Key.GID);
if (otherShellConfig.Enabled && otherShellConfig.ShellNumber == shellNumber)
conflict = true;
nextNumber = System.Math.Max(nextNumber, otherShellConfig.ShellNumber) + 1;
nextNumber = Math.Max(nextNumber, otherShellConfig.ShellNumber) + 1;
}
if (conflict)
shellConfig.ShellNumber = nextNumber;
@@ -530,24 +516,6 @@ public class SettingsUi : WindowMediatorSubscriberBase
ImGui.SetNextItemWidth(50 * ImGuiHelpers.GlobalScale);
var setSyncshellNumberFn = (int i) => {
// Find an active group with the same syncshell number as selected, and swap it
// This logic can leave duplicate IDs present in the config but its not critical
foreach (var otherGroup in _pairManager.Groups)
{
if (gid == otherGroup.Key.GID) continue;
var otherShellConfig = _serverConfigurationManager.GetShellConfigForGid(otherGroup.Key.GID);
if (otherShellConfig.Enabled && otherShellConfig.ShellNumber == i)
{
otherShellConfig.ShellNumber = shellNumber;
_serverConfigurationManager.SaveShellConfigForGid(otherGroup.Key.GID, otherShellConfig);
break;
}
}
shellConfig.ShellNumber = i;
_serverConfigurationManager.SaveShellConfigForGid(gid, shellConfig);
};
// _uiShared.DrawCombo() remembers the selected option -- we don't want that, because the value can change
if (ImGui.BeginCombo("Syncshell number##{gid}", $"{shellNumber}"))
{
@@ -560,7 +528,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
// This logic can leave duplicate IDs present in the config but its not critical
foreach (var otherGroup in _pairManager.Groups)
{
if (gid == otherGroup.Key.GID) continue;
if (gid.Equals(otherGroup.Key.GID, StringComparison.Ordinal)) continue;
var otherShellConfig = _serverConfigurationManager.GetShellConfigForGid(otherGroup.Key.GID);
if (otherShellConfig.Enabled && otherShellConfig.ShellNumber == i)
{
@@ -945,8 +913,6 @@ public class SettingsUi : WindowMediatorSubscriberBase
}
_lastTab = "General";
//UiSharedService.FontText("Experimental", _uiShared.UidFont);
//ImGui.Separator();
_uiShared.BigText("Notes");
if (_uiShared.IconTextButton(FontAwesomeIcon.StickyNote, "Export all your user notes to clipboard"))
@@ -1785,13 +1751,13 @@ public class SettingsUi : WindowMediatorSubscriberBase
var postUri = MareAuth.AuthRegisterFullPath(new Uri(selectedServer.ServerUri
.Replace("wss://", "https://", StringComparison.OrdinalIgnoreCase)
.Replace("ws://", "http://", StringComparison.OrdinalIgnoreCase)));
_logger.LogInformation("Registering new account: " + postUri.ToString());
_logger.LogInformation("Registering new account: {uri}", postUri.ToString());
var result = await httpClient.PostAsync(postUri, null).ConfigureAwait(false);
result.EnsureSuccessStatusCode();
var reply = await result.Content.ReadFromJsonAsync<RegisterReplyDto>().ConfigureAwait(false) ?? new();
if (!reply.Success)
{
_logger.LogWarning("Registration failed: " + reply.ErrorMessage);
_logger.LogWarning("Registration failed: {err}", reply.ErrorMessage);
_registrationMessage = reply.ErrorMessage;
if (_registrationMessage.IsNullOrEmpty())
_registrationMessage = "An unknown error occured. Please try again later.";
@@ -1816,7 +1782,7 @@ public class SettingsUi : WindowMediatorSubscriberBase
{
_registrationInProgress = false;
}
});
}, CancellationToken.None);
}
if (_registrationInProgress)
{

View File

@@ -351,7 +351,7 @@ public class SyncshellAdminUI : WindowMediatorSubscriberBase
using var pushId = ImRaii.PushId(bannedUser.UID);
if (_uiSharedService.IconTextButton(FontAwesomeIcon.Check, "Unban"))
{
Task.Run(async () => await _apiController.GroupUnbanUser(bannedUser));
_ = Task.Run(async () => await _apiController.GroupUnbanUser(bannedUser).ConfigureAwait(false));
_bannedUsers.RemoveAll(b => string.Equals(b.UID, bannedUser.UID, StringComparison.Ordinal));
}
}

View File

@@ -35,7 +35,8 @@ public partial class UiSharedService : DisposableMediatorSubscriberBase
public static readonly ImGuiWindowFlags PopupWindowFlags = ImGuiWindowFlags.NoResize |
ImGuiWindowFlags.NoScrollbar |
ImGuiWindowFlags.NoScrollWithMouse;
public static Vector4 AccentColor = ImGuiColors.DalamudYellow;
public static Vector4 AccentColor { get; set; } = ImGuiColors.DalamudYellow;
public readonly FileDialogManager FileDialogManager;