From 4fc29e556200ade675c9e9cc81012e472e53af49 Mon Sep 17 00:00:00 2001 From: Anairkoen Schno Date: Thu, 27 Feb 2020 18:11:46 -0600 Subject: [PATCH] Did some warning cleanup --- .../Config/Stores/GeneratedStoreImpl.cs | 20 +- IPA.Loader/IPA.Loader.csproj | 12 + IPA.Loader/Loader/PluginManager.cs | 3 +- IPA.Loader/Logging/StdoutInterceptor.cs | 2 +- IPA/IPA.csproj | 268 +++++++++--------- IPA/Program.cs | 59 +--- 6 files changed, 166 insertions(+), 198 deletions(-) diff --git a/IPA.Loader/Config/Stores/GeneratedStoreImpl.cs b/IPA.Loader/Config/Stores/GeneratedStoreImpl.cs index c0bcbed6..b43f0aaf 100644 --- a/IPA.Loader/Config/Stores/GeneratedStoreImpl.cs +++ b/IPA.Loader/Config/Stores/GeneratedStoreImpl.cs @@ -148,7 +148,7 @@ namespace IPA.Config.Stores { private readonly IGeneratedStore generated; private bool inChangeTransaction = false; - private bool changedInTransaction = false; + //private bool changedInTransaction = false; internal static ConstructorInfo Ctor = typeof(Impl).GetConstructor(new[] { typeof(IGeneratedStore) }); public Impl(IGeneratedStore store) => generated = store; @@ -1405,16 +1405,16 @@ namespace IPA.Config.Stores il.Emit(OpCodes.Call, Type_GetTypeFromHandle); } - private static Type IDisposable_t = typeof(IDisposable); - private static MethodInfo IDisposable_Dispose = IDisposable_t.GetMethod(nameof(IDisposable.Dispose)); + private static readonly Type IDisposable_t = typeof(IDisposable); + private static readonly MethodInfo IDisposable_Dispose = IDisposable_t.GetMethod(nameof(IDisposable.Dispose)); - private static Type Decimal_t = typeof(decimal); - private static ConstructorInfo Decimal_FromFloat = Decimal_t.GetConstructor(new[] { typeof(float) }); - private static ConstructorInfo Decimal_FromDouble = Decimal_t.GetConstructor(new[] { typeof(double) }); - private static ConstructorInfo Decimal_FromInt = Decimal_t.GetConstructor(new[] { typeof(int) }); - private static ConstructorInfo Decimal_FromUInt = Decimal_t.GetConstructor(new[] { typeof(uint) }); - private static ConstructorInfo Decimal_FromLong = Decimal_t.GetConstructor(new[] { typeof(long) }); - private static ConstructorInfo Decimal_FromULong = Decimal_t.GetConstructor(new[] { typeof(ulong) }); + private static readonly Type Decimal_t = typeof(decimal); + private static readonly ConstructorInfo Decimal_FromFloat = Decimal_t.GetConstructor(new[] { typeof(float) }); + private static readonly ConstructorInfo Decimal_FromDouble = Decimal_t.GetConstructor(new[] { typeof(double) }); + private static readonly ConstructorInfo Decimal_FromInt = Decimal_t.GetConstructor(new[] { typeof(int) }); + private static readonly ConstructorInfo Decimal_FromUInt = Decimal_t.GetConstructor(new[] { typeof(uint) }); + private static readonly ConstructorInfo Decimal_FromLong = Decimal_t.GetConstructor(new[] { typeof(long) }); + private static readonly ConstructorInfo Decimal_FromULong = Decimal_t.GetConstructor(new[] { typeof(ulong) }); private static void EmitNumberConvertTo(ILGenerator il, Type to, Type from) { // WARNING: THIS USES THE NO-OVERFLOW OPCODES if (to == from) return; diff --git a/IPA.Loader/IPA.Loader.csproj b/IPA.Loader/IPA.Loader.csproj index 81dd44ab..d79de0d8 100644 --- a/IPA.Loader/IPA.Loader.csproj +++ b/IPA.Loader/IPA.Loader.csproj @@ -51,6 +51,18 @@ $(OutputPath)IPA.Loader.xml + + CA1031 + + + CA1031 + + + CA1031 + + + CA1031 + diff --git a/IPA.Loader/Loader/PluginManager.cs b/IPA.Loader/Loader/PluginManager.cs index 16c23879..d872892a 100644 --- a/IPA.Loader/Loader/PluginManager.cs +++ b/IPA.Loader/Loader/PluginManager.cs @@ -24,6 +24,7 @@ using Net3_Proxy; using Path = Net3_Proxy.Path; using File = Net3_Proxy.File; using Directory = Net3_Proxy.Directory; +using Array = Net3_Proxy.Array; #endif namespace IPA.Loader @@ -421,7 +422,7 @@ namespace IPA.Loader catch (ReflectionTypeLoadException e) { Logger.loader.Error($"Could not load the following types from {Path.GetFileName(file)}:"); - Logger.loader.Error($" {string.Join("\n ", e.LoaderExceptions?.Select(e1 => e1?.Message).StrJP() ?? new string[0])}"); + Logger.loader.Error($" {string.Join("\n ", e.LoaderExceptions?.Select(e1 => e1?.Message).StrJP() ?? Array.Empty())}"); } catch (Exception e) { diff --git a/IPA.Loader/Logging/StdoutInterceptor.cs b/IPA.Loader/Logging/StdoutInterceptor.cs index aeac0be7..fca129b0 100644 --- a/IPA.Loader/Logging/StdoutInterceptor.cs +++ b/IPA.Loader/Logging/StdoutInterceptor.cs @@ -19,7 +19,7 @@ namespace IPA.Logging } private string lineBuffer = ""; - private object bufferLock = new object(); + private readonly object bufferLock = new object(); public override void Write(string value) { diff --git a/IPA/IPA.csproj b/IPA/IPA.csproj index 98e852c3..bd05c219 100644 --- a/IPA/IPA.csproj +++ b/IPA/IPA.csproj @@ -1,133 +1,137 @@ - - - - - Debug - AnyCPU - {14092533-98BB-40A4-9AFC-27BB75672A70} - Exe - Properties - IPA - IPA - v4.6.1 - 512 - - - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - true - $(SolutionDir)=C:\ - $(Configuration) - - - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - false - Debug - Release - - - AnyCPU - none - true - bin\Release\ - TRACE - prompt - 4 - false - true - Release - Release - - - favicon.ico - - - IPA.Program - - - false - - - true - bin\Verbose\ - DEBUG;TRACE - full - AnyCPU - prompt - MinimumRecommendedRules.ruleset - Debug - Verbose_Release - - - bin\Verbose_Release\ - Release - Verbose_Release - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0.11.1 - - - - - False - Microsoft .NET Framework 4.6.2 %28x86 and x64%29 - true - - - False - .NET Framework 3.5 SP1 - false - - - + + + + + Debug + AnyCPU + {14092533-98BB-40A4-9AFC-27BB75672A70} + Exe + Properties + IPA + IPA + v4.6.1 + 512 + + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + true + $(SolutionDir)=C:\ + $(Configuration) + + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + Debug + Release + CA1031 + + + AnyCPU + none + true + bin\Release\ + TRACE + prompt + 4 + false + true + Release + Release + CA1031 + + + favicon.ico + + + IPA.Program + + + false + + + true + bin\Verbose\ + DEBUG;TRACE + full + AnyCPU + prompt + MinimumRecommendedRules.ruleset + Debug + Verbose_Release + CA1031 + + + bin\Verbose_Release\ + Release + Verbose_Release + CA1031 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0.11.1 + + + + + False + Microsoft .NET Framework 4.6.2 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + + \ No newline at end of file diff --git a/IPA/Program.cs b/IPA/Program.cs index 03927c69..2452dd3f 100644 --- a/IPA/Program.cs +++ b/IPA/Program.cs @@ -13,7 +13,7 @@ using IPA.Patcher; namespace IPA { [SuppressMessage("ReSharper", "ClassNeverInstantiated.Global")] - public class Program + public static class Program { [SuppressMessage("ReSharper", "InconsistentNaming")] public enum Architecture @@ -37,7 +37,7 @@ namespace IPA public static readonly ArgumentFlag ArgLaunch = new ArgumentFlag("--launch", "-l") { DocString = "uses positional parameters as arguments to start the game after patch/unpatch" }; [STAThread] - public static void Main(string[] args) + public static void Main() { Arguments.CmdLine.Flags(ArgHelp, ArgWaitFor, ArgForce, ArgRevert, ArgNoWait, ArgStart, ArgLaunch, ArgNoRevert).Process(); @@ -177,13 +177,9 @@ namespace IPA Console.WriteLine("Installing files... "); CopyAll(new DirectoryInfo(context.DataPathSrc), new DirectoryInfo(context.DataPathDst), force, - backup, - (from, to) => NativePluginInterceptor(from, to, new DirectoryInfo(nativePluginFolder), isFlat, - architecture)); + backup); CopyAll(new DirectoryInfo(context.LibsPathSrc), new DirectoryInfo(context.LibsPathDst), force, - backup, - (from, to) => NativePluginInterceptor(from, to, new DirectoryInfo(nativePluginFolder), isFlat, - architecture)); + backup); CopyAll(new DirectoryInfo(context.IPARoot), new DirectoryInfo(context.ProjectRoot), force, backup, null, false); @@ -261,51 +257,6 @@ namespace IPA } } - public static IEnumerable NativePluginInterceptor(FileInfo from, FileInfo to, - DirectoryInfo nativePluginFolder, bool isFlat, Architecture preferredArchitecture) - { - if (to.FullName.StartsWith(nativePluginFolder.FullName)) - { - var relevantBit = to.FullName.Substring(nativePluginFolder.FullName.Length + 1); - // Goes into the plugin folder! - bool isFileFlat = !relevantBit.StartsWith("x86"); - if (isFlat && !isFileFlat) - { - // Flatten structure - bool is64Bit = relevantBit.StartsWith("x86_64"); - if (!is64Bit && preferredArchitecture == Architecture.x86) - { - // 32 bit - yield return new FileInfo(Path.Combine(nativePluginFolder.FullName, - relevantBit.Substring("x86".Length + 1))); - } - else if (is64Bit && (preferredArchitecture == Architecture.x64 || - preferredArchitecture == Architecture.Unknown)) - { - // 64 bit - yield return new FileInfo(Path.Combine(nativePluginFolder.FullName, - relevantBit.Substring("x86_64".Length + 1))); - } - } - else if (!isFlat && isFileFlat) - { - // Deepen structure - yield return new FileInfo(Path.Combine(Path.Combine(nativePluginFolder.FullName, "x86"), - relevantBit)); - yield return new FileInfo(Path.Combine(Path.Combine(nativePluginFolder.FullName, "x86_64"), - relevantBit)); - } - else - { - yield return to; - } - } - else - { - yield return to; - } - } - public static void ClearLine() { if (IsConsole) @@ -445,7 +396,7 @@ namespace IPA } } - public abstract class Keyboard + internal static class Keyboard { [Flags] private enum KeyStates