diff --git a/Installer/Compiler.cs b/Installer/Compiler.cs index 6230b7c..749612f 100644 --- a/Installer/Compiler.cs +++ b/Installer/Compiler.cs @@ -13,7 +13,7 @@ namespace Installer; -internal class Compiler +internal partial class Compiler { private ZipArchive ProjectArchive { get; } private Installation Installation { get; } @@ -42,9 +42,9 @@ public Compiler(ZipArchive projectArchive, CompilationContext context) private IEnumerable GetSourceFiles() { - var matches = Regex.Matches(ProjectContent, ".*)\"\\s*/>"); + var matches = CompileFileRegex().Matches(ProjectContent); - foreach (Match match in matches) + foreach (var match in matches.Cast()) { if (!match.Success) continue; @@ -116,9 +116,9 @@ private IEnumerable GetReferences() { yield return MetadataReference.CreateFromFile(Path.Combine(Installation.Managed, "mscorlib.dll")); - var matches = Regex.Matches(ProjectContent, "<(Project)?Reference\\s+Include=\"(?.*)\"\\s*/?>"); + var matches = ProjectReferenceRegex().Matches(ProjectContent); - foreach (Match match in matches) + foreach (var match in matches.Cast()) { if (!match.Success) continue; @@ -166,4 +166,10 @@ public CSharpCompilation Compile(string assemblyName) return CSharpCompilation.Create(assemblyName, syntaxTrees, references, CompilationOptions); } + + [GeneratedRegex(".*)\"\\s*/>")] + private static partial Regex CompileFileRegex(); + + [GeneratedRegex("<(Project)?Reference\\s+Include=\"(?.*)\"\\s*/?>")] + private static partial Regex ProjectReferenceRegex(); } diff --git a/Installer/InstallCommand.cs b/Installer/InstallCommand.cs index 6a270d0..352e7e2 100644 --- a/Installer/InstallCommand.cs +++ b/Installer/InstallCommand.cs @@ -154,7 +154,7 @@ public override async Task ExecuteAsync(CommandContext commandContext, Sett } } - if (compilation == null && files.Any() && files.All(f => f!.StartsWith(features))) + if (compilation == null && files.Length != 0 && files.All(f => f!.StartsWith(features))) { // Failure, retry by removing faulting features if possible AnsiConsole.MarkupLine($"[yellow]Trying to disable faulting feature(s): [red]{GetFaultingFeatures(files)}[/].[/]"); @@ -163,7 +163,7 @@ public override async Task ExecuteAsync(CommandContext commandContext, Sett (compilation, archive, errors) = await GetCompilationAsync(context); - if (!errors.Any()) + if (errors.Length == 0) AnsiConsole.MarkupLine("[yellow]We found a fallback! But please file an issue here : https://github.com/sailro/EscapeFromTarkov-Trainer/issues [/]"); } @@ -241,7 +241,7 @@ private static void TryCreateGameDocumentFolder() AnsiConsole.MarkupLine($"[grey]>> {error.Id} [[{error.Location.SourceTree?.FilePath.EscapeMarkup()}]]: {error.GetMessage().EscapeMarkup()}.[/]"); #endif - if (errors.Any()) + if (errors.Length != 0) { AnsiConsole.MarkupLine($">> [blue]Try #{context.Try}[/] [yellow]Compilation failed for {context.Branch.EscapeMarkup()} branch.[/]"); compilation = null; diff --git a/Installer/Installation.cs b/Installer/Installation.cs index e56a44e..0dfe4e4 100644 --- a/Installer/Installation.cs +++ b/Installer/Installation.cs @@ -25,7 +25,7 @@ internal class Installation private Installation(string location, Version version) { if (string.IsNullOrEmpty(location)) - throw new ArgumentException(nameof(location)); + throw new ArgumentException("empty location"); Location = location; Version = version; diff --git a/Installer/Installer.csproj b/Installer/Installer.csproj index bcb68ff..2b9d064 100644 --- a/Installer/Installer.csproj +++ b/Installer/Installer.csproj @@ -17,6 +17,8 @@ https://github.com/sailro/EscapeFromTarkov-Trainer 2.6.0.0 Sebastien Lebreton + true + en-US diff --git a/Installer/ParentProcessHelper.cs b/Installer/ParentProcessHelper.cs index 47c55b8..0d1b6ac 100644 --- a/Installer/ParentProcessHelper.cs +++ b/Installer/ParentProcessHelper.cs @@ -5,8 +5,8 @@ namespace Installer; -[StructLayout(LayoutKind.Sequential)] -public struct ParentProcessHelper +[StructLayout(LayoutKind.Sequential), System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006")] +public partial struct ParentProcessHelper { // These members must match PROCESS_BASIC_INFORMATION internal IntPtr Reserved1; @@ -16,8 +16,8 @@ public struct ParentProcessHelper internal IntPtr UniqueProcessId; internal IntPtr InheritedFromUniqueProcessId; - [DllImport("ntdll.dll")] - private static extern int NtQueryInformationProcess(IntPtr processHandle, int processInformationClass, ref ParentProcessHelper processInformation, int processInformationLength, out int returnLength); + [LibraryImport("ntdll.dll")] + private static partial int NtQueryInformationProcess(IntPtr processHandle, int processInformationClass, ref ParentProcessHelper processInformation, int processInformationLength, out int returnLength); public static Process? GetParentProcess() { diff --git a/UI/ColorPicker.cs b/UI/ColorPicker.cs index 2b4619d..f00ac30 100644 --- a/UI/ColorPicker.cs +++ b/UI/ColorPicker.cs @@ -24,7 +24,7 @@ public class ColorPicker : Picker private readonly Texture2D _rightArrow; private readonly Texture2D _leftArrow; - const int HsvPickerSize = 120, HuePickerWidth = 16; + private const int HsvPickerSize = 120, HuePickerWidth = 16; public ColorPicker(Color color) : base(color) { diff --git a/UI/Picker.cs b/UI/Picker.cs index c1665ed..8b9f093 100644 --- a/UI/Picker.cs +++ b/UI/Picker.cs @@ -6,6 +6,7 @@ public abstract class Picker public T Value => _value; public abstract bool IsSelected { get; protected set; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0290")] protected Picker(T value) { _value = value;