diff --git a/BepInEx.Core/Bootstrap/BaseChainloader.cs b/BepInEx.Core/Bootstrap/BaseChainloader.cs index 9dc1ca5..ead5e38 100644 --- a/BepInEx.Core/Bootstrap/BaseChainloader.cs +++ b/BepInEx.Core/Bootstrap/BaseChainloader.cs @@ -312,8 +312,8 @@ namespace BepInEx.Bootstrap if (missingDependencies.Count != 0) { var message = $@"Could not load [{plugin}] because it has missing dependencies: { - string.Join(", ", missingDependencies.Select(s => s.VersionRange == null ? s.DependencyGUID : $"{s.DependencyGUID} ({s.VersionRange})").ToArray()) - }"; + string.Join(", ", missingDependencies.Select(s => s.VersionRange == null ? s.DependencyGUID : $"{s.DependencyGUID} ({s.VersionRange})").ToArray()) + }"; DependencyErrors.Add(message); Logger.LogError(message); diff --git a/BepInEx.Core/Configuration/AcceptableValueBase.cs b/BepInEx.Core/Configuration/AcceptableValueBase.cs index 6ff96bc..810d892 100644 --- a/BepInEx.Core/Configuration/AcceptableValueBase.cs +++ b/BepInEx.Core/Configuration/AcceptableValueBase.cs @@ -8,7 +8,10 @@ namespace BepInEx.Configuration public abstract class AcceptableValueBase { /// Type of values that this class can Clamp. - protected AcceptableValueBase(Type valueType) => ValueType = valueType; + protected AcceptableValueBase(Type valueType) + { + ValueType = valueType; + } /// /// Type of the supported values. diff --git a/BepInEx.Core/Configuration/ConfigEntryBase.cs b/BepInEx.Core/Configuration/ConfigEntryBase.cs index 74fa1a4..a5b822f 100644 --- a/BepInEx.Core/Configuration/ConfigEntryBase.cs +++ b/BepInEx.Core/Configuration/ConfigEntryBase.cs @@ -17,11 +17,13 @@ namespace BepInEx.Configuration ConfigDefinition definition, T defaultValue, ConfigDescription configDescription) : base(configFile, definition, typeof(T), - defaultValue, configDescription) => + defaultValue, configDescription) + { configFile.SettingChanged += (sender, args) => { if (args.ChangedSetting == this) SettingChanged?.Invoke(sender, args); }; + } /// /// Value of this setting. diff --git a/BepInEx.Core/Configuration/ConfigFile.cs b/BepInEx.Core/Configuration/ConfigFile.cs index d26a642..5f1a711 100644 --- a/BepInEx.Core/Configuration/ConfigFile.cs +++ b/BepInEx.Core/Configuration/ConfigFile.cs @@ -55,7 +55,10 @@ namespace BepInEx.Configuration { get { - lock (_ioLock) return Entries.Keys.ToList().AsReadOnly(); + lock (_ioLock) + { + return Entries.Keys.ToList().AsReadOnly(); + } } } @@ -77,7 +80,9 @@ namespace BepInEx.Configuration get { lock (_ioLock) + { return Entries[key]; + } } } @@ -98,14 +103,18 @@ namespace BepInEx.Configuration KeyValuePair item) { lock (_ioLock) + { Entries.Add(item.Key, item.Value); + } } /// public bool Contains(KeyValuePair item) { lock (_ioLock) + { return ((ICollection>) Entries).Contains(item); + } } void ICollection>.CopyTo( @@ -113,14 +122,18 @@ namespace BepInEx.Configuration int arrayIndex) { lock (_ioLock) + { ((ICollection>) Entries).CopyTo(array, arrayIndex); + } } bool ICollection>.Remove( KeyValuePair item) { lock (_ioLock) + { return Entries.Remove(item.Key); + } } /// @@ -129,7 +142,9 @@ namespace BepInEx.Configuration get { lock (_ioLock) + { return Entries.Count; + } } } @@ -140,7 +155,9 @@ namespace BepInEx.Configuration public bool ContainsKey(ConfigDefinition key) { lock (_ioLock) + { return Entries.ContainsKey(key); + } } /// @@ -151,20 +168,26 @@ namespace BepInEx.Configuration public bool Remove(ConfigDefinition key) { lock (_ioLock) + { return Entries.Remove(key); + } } /// public void Clear() { lock (_ioLock) + { Entries.Clear(); + } } bool IDictionary.TryGetValue(ConfigDefinition key, out ConfigEntryBase value) { lock (_ioLock) + { return Entries.TryGetValue(key, out value); + } } /// @@ -173,7 +196,9 @@ namespace BepInEx.Configuration get { lock (_ioLock) + { return Entries[key]; + } } set => throw new InvalidOperationException("Directly setting a config entry is not supported"); } @@ -187,7 +212,9 @@ namespace BepInEx.Configuration get { lock (_ioLock) + { return Entries.Keys.ToArray(); + } } } @@ -200,7 +227,9 @@ namespace BepInEx.Configuration get { lock (_ioLock) + { return Entries.Values.ToArray(); + } } } @@ -214,7 +243,9 @@ namespace BepInEx.Configuration public ConfigEntryBase[] GetConfigEntries() { lock (_ioLock) + { return Entries.Values.ToArray(); + } } #region Save/Load diff --git a/BepInEx.Core/Configuration/SettingChangedEventArgs.cs b/BepInEx.Core/Configuration/SettingChangedEventArgs.cs index 4dfa06f..9beffa0 100644 --- a/BepInEx.Core/Configuration/SettingChangedEventArgs.cs +++ b/BepInEx.Core/Configuration/SettingChangedEventArgs.cs @@ -9,7 +9,10 @@ namespace BepInEx.Configuration public sealed class SettingChangedEventArgs : EventArgs { /// - public SettingChangedEventArgs(ConfigEntryBase changedSetting) => ChangedSetting = changedSetting; + public SettingChangedEventArgs(ConfigEntryBase changedSetting) + { + ChangedSetting = changedSetting; + } /// /// Setting that was changed diff --git a/BepInEx.Core/Console/ConsoleManager.cs b/BepInEx.Core/Console/ConsoleManager.cs index 79f909d..60dce5a 100644 --- a/BepInEx.Core/Console/ConsoleManager.cs +++ b/BepInEx.Core/Console/ConsoleManager.cs @@ -23,14 +23,14 @@ namespace BepInEx } private const uint SHIFT_JIS_CP = 932; - + public static bool ConsoleEnabled => EnableConsoleArgOverride ?? ConfigConsoleEnabled.Value; public static readonly ConfigEntry ConfigConsoleEnabled = ConfigFile.CoreConfig.Bind( "Logging.Console", "Enabled", false, "Enables showing a console for log output."); - + public static readonly ConfigEntry ConfigPreventClose = ConfigFile.CoreConfig.Bind( "Logging.Console", "PreventClose", false, @@ -69,11 +69,11 @@ namespace BepInEx /// The stream that writes to an external console. Null if no such console exists /// public static TextWriter ConsoleStream => Driver?.ConsoleOut; - + private static readonly bool? EnableConsoleArgOverride; private const string ENABLE_CONSOLE_ARG = "--enable-console"; - + static ConsoleManager() { // Ensure GetCommandLineArgs failing (e.g. on unix) does not kill bepin @@ -127,7 +127,7 @@ namespace BepInEx Driver.CreateConsole(codepage); // Console.SetOut(ConsoleStream); - + if (ConfigPreventClose.Value) Driver.PreventClose(); } diff --git a/BepInEx.Core/Console/IConsoleDriver.cs b/BepInEx.Core/Console/IConsoleDriver.cs index 3631995..a9561d5 100644 --- a/BepInEx.Core/Console/IConsoleDriver.cs +++ b/BepInEx.Core/Console/IConsoleDriver.cs @@ -10,7 +10,7 @@ namespace BepInEx bool ConsoleActive { get; } bool ConsoleIsExternal { get; } - + void PreventClose(); void Initialize(bool alreadyActive); diff --git a/BepInEx.Core/Console/Unix/LinuxConsoleDriver.cs b/BepInEx.Core/Console/Unix/LinuxConsoleDriver.cs index 6446379..1ab4a87 100644 --- a/BepInEx.Core/Console/Unix/LinuxConsoleDriver.cs +++ b/BepInEx.Core/Console/Unix/LinuxConsoleDriver.cs @@ -15,11 +15,11 @@ namespace BepInEx.Unix "ForceBepInExTTYDriver", false, "If enabled, forces to use custom BepInEx TTY driver for handling terminal output on unix."); - + static LinuxConsoleDriver() { UseMonoTtyDriver = false; - + if (ForceCustomTtyDriverConfig.Value) return; diff --git a/BepInEx.Core/Console/Unix/UnixStream.cs b/BepInEx.Core/Console/Unix/UnixStream.cs index 9db012d..8de1aff 100644 --- a/BepInEx.Core/Console/Unix/UnixStream.cs +++ b/BepInEx.Core/Console/Unix/UnixStream.cs @@ -67,6 +67,9 @@ namespace BepInEx.Unix base.Dispose(disposing); } - ~UnixStream() => Dispose(false); + ~UnixStream() + { + Dispose(false); + } } } diff --git a/BepInEx.Core/Console/Windows/ConsoleEncoding/ConsoleEncoding.PInvoke.cs b/BepInEx.Core/Console/Windows/ConsoleEncoding/ConsoleEncoding.PInvoke.cs index 1e4f0d3..f8d098e 100644 --- a/BepInEx.Core/Console/Windows/ConsoleEncoding/ConsoleEncoding.PInvoke.cs +++ b/BepInEx.Core/Console/Windows/ConsoleEncoding/ConsoleEncoding.PInvoke.cs @@ -26,9 +26,11 @@ namespace UnityInjector.ConsoleUtil [DllImport("kernel32.dll", SetLastError = true)] private static extern int MultiByteToWideChar(uint codePage, uint dwFlags, - [In] [MarshalAs(UnmanagedType.LPArray)] byte[] lpMultiByteStr, + [In] [MarshalAs(UnmanagedType.LPArray)] + byte[] lpMultiByteStr, int cbMultiByte, - [Out] [MarshalAs(UnmanagedType.LPWStr)] char[] lpWideCharStr, + [Out] [MarshalAs(UnmanagedType.LPWStr)] + char[] lpWideCharStr, int cchWideChar); [DllImport("kernel32.dll")] @@ -39,7 +41,8 @@ namespace UnityInjector.ConsoleUtil uint dwFlags, [In] [MarshalAs(UnmanagedType.LPWStr)] char[] lpWideCharStr, int cchWideChar, - [Out] [MarshalAs(UnmanagedType.LPArray)] byte[] lpMultiByteStr, + [Out] [MarshalAs(UnmanagedType.LPArray)] + byte[] lpMultiByteStr, int cbMultiByte, IntPtr lpDefaultChar, IntPtr lpUsedDefaultChar); diff --git a/BepInEx.Core/Console/Windows/ConsoleEncoding/ConsoleEncoding.cs b/BepInEx.Core/Console/Windows/ConsoleEncoding/ConsoleEncoding.cs index 209d51e..7b4294f 100644 --- a/BepInEx.Core/Console/Windows/ConsoleEncoding/ConsoleEncoding.cs +++ b/BepInEx.Core/Console/Windows/ConsoleEncoding/ConsoleEncoding.cs @@ -19,7 +19,10 @@ namespace UnityInjector.ConsoleUtil { private readonly uint _codePage; - private ConsoleEncoding(uint codePage) => _codePage = codePage; + private ConsoleEncoding(uint codePage) + { + _codePage = codePage; + } public override int CodePage => (int) _codePage; diff --git a/BepInEx.Core/Console/Windows/ConsoleWindow.cs b/BepInEx.Core/Console/Windows/ConsoleWindow.cs index 721bdf7..67ef4fe 100644 --- a/BepInEx.Core/Console/Windows/ConsoleWindow.cs +++ b/BepInEx.Core/Console/Windows/ConsoleWindow.cs @@ -30,7 +30,7 @@ namespace UnityInjector.ConsoleUtil if (!SetConsoleTitle(value)) throw new InvalidOperationException("Console title invalid"); } } - + public static void PreventClose() { if (!IsAttached) @@ -129,14 +129,14 @@ namespace UnityInjector.ConsoleUtil [DllImport("kernel32.dll", BestFitMapping = true, CharSet = CharSet.Auto, SetLastError = true)] private static extern bool SetConsoleTitle(string title); - + [DllImport("user32.dll")] private static extern IntPtr GetSystemMenu(IntPtr hwnd, bool bRevert); - const uint SC_CLOSE = 0xF060; - const uint MF_BYCOMMAND = 0x00000000; + private const uint SC_CLOSE = 0xF060; + private const uint MF_BYCOMMAND = 0x00000000; [DllImport("user32.dll")] - static extern bool DeleteMenu(IntPtr hMenu, uint uPosition, uint uFlags); + private static extern bool DeleteMenu(IntPtr hMenu, uint uPosition, uint uFlags); } } diff --git a/BepInEx.Core/Console/Windows/Kon.cs b/BepInEx.Core/Console/Windows/Kon.cs index 52fcb0e..f2ea9a1 100644 --- a/BepInEx.Core/Console/Windows/Kon.cs +++ b/BepInEx.Core/Console/Windows/Kon.cs @@ -1,6 +1,5 @@ using System; using System.Runtime.InteropServices; - #if NET35 using System.Security.Permissions; diff --git a/BepInEx.Core/Console/Windows/WindowsConsoleDriver.cs b/BepInEx.Core/Console/Windows/WindowsConsoleDriver.cs index 6411194..46fc856 100644 --- a/BepInEx.Core/Console/Windows/WindowsConsoleDriver.cs +++ b/BepInEx.Core/Console/Windows/WindowsConsoleDriver.cs @@ -68,11 +68,8 @@ namespace BepInEx }; ConsoleActive = true; } - - public void PreventClose() - { - ConsoleWindow.PreventClose(); - } + + public void PreventClose() => ConsoleWindow.PreventClose(); public void DetachConsole() { diff --git a/BepInEx.Core/Contract/Attributes.cs b/BepInEx.Core/Contract/Attributes.cs index cd6438c..93402b5 100644 --- a/BepInEx.Core/Contract/Attributes.cs +++ b/BepInEx.Core/Contract/Attributes.cs @@ -122,7 +122,10 @@ namespace BepInEx /// The GUID of the referenced plugin. /// The version range of the referenced plugin. /// When version is supplied the dependency is always treated as HardDependency - public BepInDependency(string guid, string version) : this(guid) => VersionRange = Range.Parse(version); + public BepInDependency(string guid, string version) : this(guid) + { + VersionRange = Range.Parse(version); + } /// /// The GUID of the referenced plugin. @@ -179,7 +182,10 @@ namespace BepInEx /// If the other plugin exists, this plugin will not be loaded and a warning will be shown. /// /// The GUID of the referenced plugin. - public BepInIncompatibility(string IncompatibilityGUID) => this.IncompatibilityGUID = IncompatibilityGUID; + public BepInIncompatibility(string IncompatibilityGUID) + { + this.IncompatibilityGUID = IncompatibilityGUID; + } /// /// The GUID of the referenced plugin. @@ -209,7 +215,10 @@ namespace BepInEx public class BepInProcess : Attribute { /// The name of the process that this plugin will run under. - public BepInProcess(string ProcessName) => this.ProcessName = ProcessName; + public BepInProcess(string ProcessName) + { + this.ProcessName = ProcessName; + } /// /// The name of the process that this plugin will run under. diff --git a/BepInEx.Core/Logging/DiskLogListener.cs b/BepInEx.Core/Logging/DiskLogListener.cs index f6fb35d..b5b8beb 100644 --- a/BepInEx.Core/Logging/DiskLogListener.cs +++ b/BepInEx.Core/Logging/DiskLogListener.cs @@ -108,6 +108,9 @@ namespace BepInEx.Logging catch (ObjectDisposedException) { } } - ~DiskLogListener() => Dispose(); + ~DiskLogListener() + { + Dispose(); + } } } diff --git a/BepInEx.Core/Logging/ManualLogSource.cs b/BepInEx.Core/Logging/ManualLogSource.cs index 4e45a11..40eac75 100644 --- a/BepInEx.Core/Logging/ManualLogSource.cs +++ b/BepInEx.Core/Logging/ManualLogSource.cs @@ -11,7 +11,10 @@ namespace BepInEx.Logging /// Creates a manual log source. /// /// Name of the log source. - public ManualLogSource(string sourceName) => SourceName = sourceName; + public ManualLogSource(string sourceName) + { + SourceName = sourceName; + } /// public string SourceName { get; } diff --git a/BepInEx.Core/Logging/TraceLogSource.cs b/BepInEx.Core/Logging/TraceLogSource.cs index 8c60a78..6a3779f 100644 --- a/BepInEx.Core/Logging/TraceLogSource.cs +++ b/BepInEx.Core/Logging/TraceLogSource.cs @@ -13,7 +13,10 @@ namespace BepInEx.Logging /// /// Creates a new trace log source. /// - protected TraceLogSource() => LogSource = new ManualLogSource("Trace"); + protected TraceLogSource() + { + LogSource = new ManualLogSource("Trace"); + } /// /// Whether Trace logs are currently being rerouted. diff --git a/BepInEx.Core/Paths.cs b/BepInEx.Core/Paths.cs index b0f2cb1..58f8d6b 100644 --- a/BepInEx.Core/Paths.cs +++ b/BepInEx.Core/Paths.cs @@ -78,7 +78,7 @@ namespace BepInEx /// The name of the currently executing process. /// public static string ProcessName { get; private set; } - + /// /// List of directories from where Mono will search assemblies before assembly resolving is invoked. /// diff --git a/BepInEx.Core/Utility.cs b/BepInEx.Core/Utility.cs index acd4ff7..844a885 100644 --- a/BepInEx.Core/Utility.cs +++ b/BepInEx.Core/Utility.cs @@ -22,7 +22,7 @@ namespace BepInEx /// namespace. /// public static bool CLRSupportsDynamicAssemblies => CheckSRE(); - + /// /// An encoding for UTF-8 which does not emit a byte order mark (BOM). /// @@ -345,7 +345,7 @@ namespace BepInEx var newTrusted = curTrusted == null ? addTrusted : $"{curTrusted}{Path.PathSeparator}{addTrusted}"; appDomain.SetData(TRUSTED_PLATFORM_ASSEMBLIES, newTrusted); } - + /// /// Gets unique files in all given directories. If the file with the same name exists in multiple directories, /// only the first occurrence is returned. @@ -353,7 +353,8 @@ namespace BepInEx /// Directories to search from. /// File pattern to search. /// Collection of all files in the directories. - public static IEnumerable GetUniqueFilesInDirectories(IEnumerable directories, string pattern = "*") + public static IEnumerable GetUniqueFilesInDirectories(IEnumerable directories, + string pattern = "*") { var result = new Dictionary(StringComparer.InvariantCultureIgnoreCase); foreach (var directory in directories) @@ -363,6 +364,7 @@ namespace BepInEx if (!result.ContainsKey(fileName)) result[fileName] = file; } + return result.Values; } } diff --git a/BepInEx.IL2CPP/Hook/Allocator/UnixPageAllocator.cs b/BepInEx.IL2CPP/Hook/Allocator/UnixPageAllocator.cs index c4f73bd..faacaa0 100644 --- a/BepInEx.IL2CPP/Hook/Allocator/UnixPageAllocator.cs +++ b/BepInEx.IL2CPP/Hook/Allocator/UnixPageAllocator.cs @@ -117,7 +117,8 @@ namespace BepInEx.IL2CPP.Hook.Allocator public static readonly nint MAP_FAILED = -1; - static Unix() => + static Unix() + { typeof(Unix).ResolveDynDllImports(new Dictionary> { ["libc"] = new() @@ -127,6 +128,7 @@ namespace BepInEx.IL2CPP.Hook.Allocator "/usr/lib/libSystem.dylib" // OSX POSIX } }); + } #pragma warning disable 649 // Set by MonoMod [DynDllImport("mmap")] diff --git a/BepInEx.IL2CPP/Hook/IL2CPPDetourMethodPatcher.cs b/BepInEx.IL2CPP/Hook/IL2CPPDetourMethodPatcher.cs index 24004d0..c9a62e9 100644 --- a/BepInEx.IL2CPP/Hook/IL2CPPDetourMethodPatcher.cs +++ b/BepInEx.IL2CPP/Hook/IL2CPPDetourMethodPatcher.cs @@ -69,7 +69,10 @@ namespace BepInEx.IL2CPP.Hook /// Constructs a new instance of method patcher. /// /// - public IL2CPPDetourMethodPatcher(MethodBase original) : base(original) => Init(); + public IL2CPPDetourMethodPatcher(MethodBase original) : base(original) + { + Init(); + } private void Init() { @@ -91,15 +94,20 @@ namespace BepInEx.IL2CPP.Hook } // Get the native MethodInfo struct for the target method - originalNativeMethodInfo = UnityVersionHandler.Wrap((Il2CppMethodInfo*) (IntPtr) methodField.GetValue(null)); + originalNativeMethodInfo = + UnityVersionHandler.Wrap((Il2CppMethodInfo*) (IntPtr) methodField.GetValue(null)); // Create a trampoline from the original target method var trampolinePtr = DetourGenerator.CreateTrampolineFromFunction(originalNativeMethodInfo.MethodPointer, out _, out _); // Create a modified native MethodInfo struct to point towards the trampoline - modifiedNativeMethodInfo = UnityVersionHandler.NewMethod(); //(Il2CppMethodInfo*) Marshal.AllocHGlobal(Marshal.SizeOf()); - Buffer.MemoryCopy(originalNativeMethodInfo.Pointer.ToPointer(), modifiedNativeMethodInfo.Pointer.ToPointer(), modifiedNativeMethodInfo.StructSize, originalNativeMethodInfo.StructSize); + modifiedNativeMethodInfo = + UnityVersionHandler + .NewMethod(); //(Il2CppMethodInfo*) Marshal.AllocHGlobal(Marshal.SizeOf()); + Buffer.MemoryCopy(originalNativeMethodInfo.Pointer.ToPointer(), + modifiedNativeMethodInfo.Pointer.ToPointer(), modifiedNativeMethodInfo.StructSize, + originalNativeMethodInfo.StructSize); modifiedNativeMethodInfo.MethodPointer = trampolinePtr; isValid = true; } diff --git a/BepInEx.IL2CPP/Logging/IL2CPPUnityLogSource.cs b/BepInEx.IL2CPP/Logging/IL2CPPUnityLogSource.cs index 9e67ee7..8c224ab 100644 --- a/BepInEx.IL2CPP/Logging/IL2CPPUnityLogSource.cs +++ b/BepInEx.IL2CPP/Logging/IL2CPPUnityLogSource.cs @@ -6,8 +6,10 @@ namespace BepInEx.IL2CPP.Logging { public class IL2CPPUnityLogSource : ILogSource { - public IL2CPPUnityLogSource() => + public IL2CPPUnityLogSource() + { Application.s_LogCallbackHandler = new Action(UnityLogCallback); + } public string SourceName { get; } = "Unity"; diff --git a/BepInEx.NetLauncher/NetPreloader.cs b/BepInEx.NetLauncher/NetPreloader.cs index 07d688a..997b4e2 100644 --- a/BepInEx.NetLauncher/NetPreloader.cs +++ b/BepInEx.NetLauncher/NetPreloader.cs @@ -72,7 +72,7 @@ namespace BepInEx.NetLauncher Log.LogInfo($"{assemblyPatcher.PatcherPlugins.Count} patcher plugin(s) loaded"); - assemblyPatcher.LoadAssemblyDirectories(new []{ Paths.GameRootPath }, new []{ "dll", "exe" }); + assemblyPatcher.LoadAssemblyDirectories(new[] { Paths.GameRootPath }, new[] { "dll", "exe" }); Log.LogInfo($"{assemblyPatcher.AssembliesToPatch.Count} assemblies discovered"); diff --git a/BepInEx.NetLauncher/Program.cs b/BepInEx.NetLauncher/Program.cs index 85a350a..77fedf7 100644 --- a/BepInEx.NetLauncher/Program.cs +++ b/BepInEx.NetLauncher/Program.cs @@ -79,7 +79,8 @@ namespace BepInEx.NetLauncher #if DEBUG filename = - Path.Combine(Directory.GetCurrentDirectory(), Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName)); + Path.Combine(Directory.GetCurrentDirectory(), + Path.GetFileName(Process.GetCurrentProcess().MainModule.FileName)); ResolveDirectories.Add(Path.GetDirectoryName(filename)); // for debugging within VS diff --git a/BepInEx.Preloader.Core/EnvVars.cs b/BepInEx.Preloader.Core/EnvVars.cs index 1f28f6d..c150d8d 100644 --- a/BepInEx.Preloader.Core/EnvVars.cs +++ b/BepInEx.Preloader.Core/EnvVars.cs @@ -24,7 +24,7 @@ namespace BepInEx.Preloader.Core /// Full path to the game executable currently running. /// public static string DOORSTOP_PROCESS_PATH { get; private set; } - + /// /// Array of paths where Mono searches DLLs from before assembly resolvers are invoked. /// @@ -35,7 +35,9 @@ namespace BepInEx.Preloader.Core DOORSTOP_INVOKE_DLL_PATH = Environment.GetEnvironmentVariable("DOORSTOP_INVOKE_DLL_PATH"); DOORSTOP_MANAGED_FOLDER_DIR = Environment.GetEnvironmentVariable("DOORSTOP_MANAGED_FOLDER_DIR"); DOORSTOP_PROCESS_PATH = Environment.GetEnvironmentVariable("DOORSTOP_PROCESS_PATH"); - DOORSTOP_DLL_SEARCH_DIRS = Environment.GetEnvironmentVariable("DOORSTOP_DLL_SEARCH_DIRS")?.Split(Path.PathSeparator) ?? new string[0]; + DOORSTOP_DLL_SEARCH_DIRS = + Environment.GetEnvironmentVariable("DOORSTOP_DLL_SEARCH_DIRS")?.Split(Path.PathSeparator) ?? + new string[0]; } } } diff --git a/BepInEx.Preloader.Core/Patching/AssemblyPatcher.cs b/BepInEx.Preloader.Core/Patching/AssemblyPatcher.cs index 28da948..df6650b 100644 --- a/BepInEx.Preloader.Core/Patching/AssemblyPatcher.cs +++ b/BepInEx.Preloader.Core/Patching/AssemblyPatcher.cs @@ -214,7 +214,8 @@ namespace BepInEx.Preloader.Core /// are skipped. /// /// The directories to search. - public void LoadAssemblyDirectories(params string[] directories) => LoadAssemblyDirectories(directories, new []{ "dll" }); + public void LoadAssemblyDirectories(params string[] directories) => + LoadAssemblyDirectories(directories, new[] { "dll" }); /// /// Adds all assemblies in given directories to be patched and loaded by this patcher instance. Non-managed assemblies are diff --git a/BepInEx.Preloader.Unity/DoorstopEntrypoint.cs b/BepInEx.Preloader.Unity/DoorstopEntrypoint.cs index 8f0ab59..270f90e 100644 --- a/BepInEx.Preloader.Unity/DoorstopEntrypoint.cs +++ b/BepInEx.Preloader.Unity/DoorstopEntrypoint.cs @@ -42,11 +42,11 @@ namespace BepInEx.Preloader.Unity PlatformUtils.SetPlatform(); var bepinPath = Utility.ParentDirectory(Path.GetFullPath(EnvVars.DOORSTOP_INVOKE_DLL_PATH), 2); - + Paths.SetExecutablePath(EnvVars.DOORSTOP_PROCESS_PATH, bepinPath, EnvVars.DOORSTOP_MANAGED_FOLDER_DIR, EnvVars.DOORSTOP_DLL_SEARCH_DIRS); - + LoadCriticalAssemblies(); AppDomain.CurrentDomain.AssemblyResolve += LocalResolve; // Remove temporary resolver early so it won't override local resolver diff --git a/BepInEx.Preloader.Unity/RuntimeFixes/TraceFix.cs b/BepInEx.Preloader.Unity/RuntimeFixes/TraceFix.cs index 220ad01..6cfc343 100644 --- a/BepInEx.Preloader.Unity/RuntimeFixes/TraceFix.cs +++ b/BepInEx.Preloader.Unity/RuntimeFixes/TraceFix.cs @@ -58,6 +58,7 @@ namespace BepInEx.Preloader.RuntimeFixes var type = (TraceEventType) Enum.Parse(typeof(TraceEventType), kind); lock (ListenersSyncRoot) + { foreach (var obj in Listeners) { var traceListener = (TraceListener) obj; @@ -65,6 +66,7 @@ namespace BepInEx.Preloader.RuntimeFixes if (AutoFlush) traceListener.Flush(); } + } return false; } diff --git a/BepInEx.Shared/BuildInfoAttribute.cs b/BepInEx.Shared/BuildInfoAttribute.cs index c008b26..9f0f251 100644 --- a/BepInEx.Shared/BuildInfoAttribute.cs +++ b/BepInEx.Shared/BuildInfoAttribute.cs @@ -10,7 +10,10 @@ namespace BepInEx.Shared [AttributeUsage(AttributeTargets.Assembly)] public class BuildInfoAttribute : Attribute { - public BuildInfoAttribute(string info) => Info = info; + public BuildInfoAttribute(string info) + { + Info = info; + } public string Info { get; } } diff --git a/BepInEx.Unity/Bootstrap/UnityChainloader.cs b/BepInEx.Unity/Bootstrap/UnityChainloader.cs index 14480f6..15ad83c 100644 --- a/BepInEx.Unity/Bootstrap/UnityChainloader.cs +++ b/BepInEx.Unity/Bootstrap/UnityChainloader.cs @@ -46,7 +46,8 @@ namespace BepInEx.Unity.Bootstrap // TODO: Figure out better version obtaining mechanism (e.g. from globalmanagers) private static string UnityVersion { - [MethodImpl(MethodImplOptions.NoInlining)] get => Application.unityVersion; + [MethodImpl(MethodImplOptions.NoInlining)] + get => Application.unityVersion; } private static void StaticStart(string gameExePath = null) diff --git a/BepInEx.Unity/Configuration/KeyboardShortcut.cs b/BepInEx.Unity/Configuration/KeyboardShortcut.cs index c3e368b..596b043 100644 --- a/BepInEx.Unity/Configuration/KeyboardShortcut.cs +++ b/BepInEx.Unity/Configuration/KeyboardShortcut.cs @@ -18,7 +18,8 @@ namespace BepInEx.Configuration /// public struct KeyboardShortcut { - static KeyboardShortcut() => + static KeyboardShortcut() + { TomlTypeConverter.AddConverter( typeof(KeyboardShortcut), new TypeConverter @@ -26,6 +27,7 @@ namespace BepInEx.Configuration ConvertToString = (o, type) => ((KeyboardShortcut) o).Serialize(), ConvertToObject = (s, type) => Deserialize(s) }); + } /// /// Shortcut that never triggers. @@ -59,7 +61,10 @@ namespace BepInEx.Configuration ArgumentException($"Can't set {nameof(mainKey)} to KeyCode.None if there are any {nameof(modifiers)}"); } - private KeyboardShortcut(KeyCode[] keys) => _allKeys = SanitizeKeys(keys); + private KeyboardShortcut(KeyCode[] keys) + { + _allKeys = SanitizeKeys(keys); + } private static KeyCode[] SanitizeKeys(params KeyCode[] keys) { diff --git a/BepInEx.Unity/Logging/UnityLogSource.cs b/BepInEx.Unity/Logging/UnityLogSource.cs index c571dce..da39f75 100644 --- a/BepInEx.Unity/Logging/UnityLogSource.cs +++ b/BepInEx.Unity/Logging/UnityLogSource.cs @@ -15,7 +15,10 @@ namespace BepInEx.Unity.Logging /// /// Creates a new Unity log source. /// - public UnityLogSource() => InternalUnityLogMessage += UnityLogMessageHandler; + public UnityLogSource() + { + InternalUnityLogMessage += UnityLogMessageHandler; + } /// public string SourceName { get; } = "Unity Log"; diff --git a/BepInEx.Unity/ThreadingHelper.cs b/BepInEx.Unity/ThreadingHelper.cs index 3cec182..ae3cdaa 100644 --- a/BepInEx.Unity/ThreadingHelper.cs +++ b/BepInEx.Unity/ThreadingHelper.cs @@ -75,7 +75,10 @@ namespace BepInEx { if (action == null) throw new ArgumentNullException(nameof(action)); - lock (_invokeLock) _invokeList += action; + lock (_invokeLock) + { + _invokeList += action; + } } /// @@ -167,7 +170,10 @@ namespace BepInEx { internal bool ExceptionThrown; - public InvokeResult() => AsyncWaitHandle = new EventWaitHandle(false, EventResetMode.ManualReset); + public InvokeResult() + { + AsyncWaitHandle = new EventWaitHandle(false, EventResetMode.ManualReset); + } public bool IsCompleted { get; private set; } public WaitHandle AsyncWaitHandle { get; }