[Build][CmdPal] Use GeneratedRegexAttribute for InternetShortcutURLPrefix

This commit is contained in:
Jeremy Sinclair
2025-07-30 22:13:54 -04:00
parent ad5954eb65
commit ccd3ce7147

View File

@@ -29,7 +29,7 @@ using Windows.System;
namespace Microsoft.CmdPal.Ext.Apps.Programs;
[Serializable]
public class Win32Program : IProgram
public partial class Win32Program : IProgram
{
public static readonly Win32Program InvalidProgram = new Win32Program { Valid = false, Enabled = false };
@@ -278,7 +278,8 @@ public class Win32Program : IProgram
}
}
private static readonly Regex InternetShortcutURLPrefixes = new Regex(@"^steam:\/\/(rungameid|run|open)\/|^com\.epicgames\.launcher:\/\/apps\/", RegexOptions.Compiled);
[GeneratedRegex(@"^steam:\/\/(rungameid|run|open)\/|^com\.epicgames\.launcher:\/\/apps\/", RegexOptions.Compiled)]
private static partial Regex InternetShortcutURLPrefixes();
// This function filters Internet Shortcut programs
private static Win32Program InternetShortcutProgram(string path)
@@ -307,7 +308,7 @@ public class Win32Program : IProgram
}
// To filter out only those steam shortcuts which have 'run' or 'rungameid' as the hostname
if (InternetShortcutURLPrefixes.Match(urlPath).Success)
if (InternetShortcutURLPrefixes().IsMatch(urlPath))
{
validApp = true;
}