Fix SYSLIB1045: Use 'GeneratedRegexAttribute' to generate the regular expression implementation at compile-time.

This commit is contained in:
Haselnussbomber 2025-10-24 04:10:07 +02:00
parent d38aa63370
commit 28f63ad83e
No known key found for this signature in database
GPG key ID: BB905BB49E7295D1
2 changed files with 9 additions and 5 deletions

View file

@ -8,11 +8,12 @@ namespace Dalamud.Interface.ImGuiFileDialog;
/// </summary>
public partial class FileDialog
{
private static Regex filterRegex = new(@"[^,{}]+(\{([^{}]*?)\})?", RegexOptions.Compiled);
private List<FilterStruct> filters = [];
private FilterStruct selectedFilter;
[GeneratedRegex(@"[^,{}]+(\{([^{}]*?)\})?", RegexOptions.Compiled)]
private static partial Regex FilterRegex();
private void ParseFilters(string filters)
{
// ".*,.cpp,.h,.hpp"
@ -22,7 +23,7 @@ public partial class FileDialog
if (filters.Length == 0) return;
var currentFilterFound = false;
var matches = filterRegex.Matches(filters);
var matches = FilterRegex().Matches(filters);
foreach (Match m in matches)
{
var match = m.Value;

View file

@ -15,7 +15,7 @@ namespace Dalamud.Plugin.Internal.Profiles;
/// Class responsible for managing plugin profiles.
/// </summary>
[ServiceManager.BlockingEarlyLoadedService($"Data provider for {nameof(PluginManager)}.")]
internal class ProfileManager : IServiceType
internal partial class ProfileManager : IServiceType
{
private static readonly ModuleLog Log = new("PROFMAN");
private readonly DalamudConfiguration config;
@ -334,12 +334,15 @@ internal class ProfileManager : IServiceType
}
}
[GeneratedRegex(@" \(.* Mix\)")]
private static partial Regex MixRegex();
private string GenerateUniqueProfileName(string startingWith)
{
if (this.profiles.All(x => x.Name != startingWith))
return startingWith;
startingWith = Regex.Replace(startingWith, @" \(.* Mix\)", string.Empty);
startingWith = MixRegex().Replace(startingWith, string.Empty);
while (true)
{