From 46ee2b61a5b57f3edadf3a98e4c26926d30a5748 Mon Sep 17 00:00:00 2001 From: zznty <94796179+zznty@users.noreply.github.com> Date: Wed, 15 May 2024 20:59:30 +0700 Subject: [PATCH] refactoring and proper game state destruction --- Torch.API/IPlayer.cs | 9 +- Torch.API/ITorchBase.cs | 4 - Torch.API/Managers/IChatManagerClient.cs | 8 - Torch.API/Managers/IChatManagerServer.cs | 5 - Torch.API/Managers/IDependencyManager.cs | 3 - Torch.API/Managers/IDependencyProvider.cs | 4 - Torch.API/Managers/IManager.cs | 8 +- Torch.API/Managers/IMultiplayerManagerBase.cs | 3 - .../Managers/IMultiplayerManagerClient.cs | 8 +- .../Managers/IMultiplayerManagerServer.cs | 3 - Torch.API/Managers/INetworkManager.cs | 7 +- Torch.API/Managers/IPackageManager.cs | 1 - Torch.API/Managers/IPluginManager.cs | 2 - Torch.API/ModAPI/Ingame/GridExtensions.cs | 12 +- Torch.API/ModAPI/TorchAPI.cs | 7 +- Torch.API/Plugins/ITorchPlugin.cs | 5 - Torch.API/Plugins/IWpfPlugin.cs | 7 +- Torch.API/Plugins/PluginAttribute.cs | 5 - Torch.API/ServerState.cs | 8 +- Torch.API/Session/GameSaveResult.cs | 8 +- Torch.API/Session/ITorchSession.cs | 7 +- Torch.API/Session/ITorchSessionManager.cs | 3 - Torch.API/Session/TorchSessionState.cs | 8 +- Torch.API/Torch.API.csproj | 1 + Torch.API/TorchGameState.cs | 7 +- Torch.API/Utils/StringUtils.cs | 1 - Torch.API/WebAPI/Plugins/IPackageReader.cs | 2 - Torch.API/packages.lock.json | 6 + Torch.Mod/Messages/DialogMessage.cs | 4 - Torch.Mod/Messages/JoinServerMessage.cs | 5 +- Torch.Mod/Messages/NotificationMessage.cs | 2 - Torch.Mod/Messages/VoxelResetMessage.cs | 2 - .../TorchServerSessionSettingsTest.cs | 2 - Torch.Server.Tests/packages.lock.json | 6 + Torch.Server/Commands/WhitelistCommands.cs | 7 +- Torch.Server/Initializer.cs | 11 - Torch.Server/LogViewerTarget.cs | 1 - Torch.Server/Managers/EntityControlManager.cs | 6 - Torch.Server/Managers/InstanceManager.cs | 12 - .../Managers/MultiplayerManagerDedicated.cs | 5 - .../MultiplayerManagerDedicatedEventShim.cs | 8 +- .../MultiplayerManagerDedicatedPatchShim.cs | 8 +- Torch.Server/NativeMethods.cs | 7 +- Torch.Server/Patches/PromotePatch.cs | 4 - Torch.Server/Patches/ServerResponsePatch.cs | 5 - .../Patches/WorldLoadExceptionPatch.cs | 1 - Torch.Server/Program.cs | 2 - Torch.Server/Properties/Annotations.cs | 1065 ----------------- Torch.Server/TorchServer.cs | 18 +- .../ViewModels/BlockLimitViewModel.cs | 10 +- .../ViewModels/CheckpointViewModel.cs | 4 - .../ViewModels/ConfigDedicatedViewModel.cs | 6 +- .../Entities/Blocks/BlockViewModel.cs | 5 - .../Entities/Blocks/PropertyViewModel.cs | 5 - .../Entities/EntityControlViewModel.cs | 7 +- .../ViewModels/Entities/EntityViewModel.cs | 5 - .../ViewModels/Entities/GridViewModel.cs | 3 - .../ViewModels/Entities/VoxelMapViewModel.cs | 6 +- .../ViewModels/EntityTreeViewModel.cs | 7 - Torch.Server/ViewModels/ILazyLoad.cs | 8 +- Torch.Server/ViewModels/ModItemInfo.cs | 5 +- .../ViewModels/PluginManagerViewModel.cs | 6 +- Torch.Server/ViewModels/PluginViewModel.cs | 5 - .../ViewModels/SessionSettingsViewModel.cs | 9 +- .../Views/AddWorkshopItemsDialog.xaml.cs | 14 +- Torch.Server/Views/ChatControl.xaml.cs | 15 - Torch.Server/Views/ConfigControl.xaml.cs | 5 +- .../Views/Converters/BooleanAndConverter.cs | 4 - .../Converters/DefinitionToIdConverter.cs | 1 - .../Views/Converters/ListConverter.cs | 3 - .../Converters/ListConverterWorkshopId.cs | 4 - .../Views/Converters/Vector3DConverter.cs | 4 - .../Views/Entities/Blocks/BlockView.xaml.cs | 19 +- .../Entities/Blocks/PropertyView.xaml.cs | 12 +- .../Views/Entities/CharacterView.xaml.cs | 14 +- Torch.Server/Views/Entities/GridView.xaml.cs | 14 +- .../Views/Entities/VoxelMapView.xaml.cs | 13 +- Torch.Server/Views/EntitiesControl.xaml.cs | 12 - Torch.Server/Views/Extensions.cs | 7 +- Torch.Server/Views/LogViewerControl.xaml.cs | 6 +- Torch.Server/Views/ModsControl.xaml.cs | 16 +- Torch.Server/Views/PlayerListControl.xaml.cs | 19 - Torch.Server/Views/PluginBrowser.xaml.cs | 12 +- Torch.Server/Views/PluginDownloader.xaml.cs | 12 - Torch.Server/Views/PluginsControl.xaml.cs | 16 +- Torch.Server/Views/RoleEditor.xaml.cs | 11 - .../Views/SessionSettingsView.xaml.cs | 14 +- Torch.Server/Views/ThemeControl.xaml.cs | 8 - Torch.Server/Views/TorchUI.xaml.cs | 21 +- .../ValidationRules/NumberValidationRule.cs | 7 +- .../Views/WorldGeneratorDialog.xaml.cs | 11 - Torch.Server/packages.lock.json | 6 + Torch.Tests/ReflectionTestManager.cs | 1 - Torch.Tests/TestUtils.cs | 6 - Torch.Tests/packages.lock.json | 6 + Torch/Collections/BinaryMinHeap.cs | 2 - Torch/Collections/KeyTree.cs | 6 +- Torch/Collections/MTObservableCollection.cs | 6 - .../Collections/MtObservableCollectionBase.cs | 3 - Torch/Collections/MtObservableList.cs | 3 - Torch/Collections/RollingAverage.cs | 7 +- Torch/Collections/SortedView.cs | 5 - Torch/Collections/SystemSortedView.cs | 3 - Torch/Collections/TransformComparer.cs | 3 - Torch/Collections/TransformEnumerator.cs | 3 - Torch/Commands/CategoryAttribute.cs | 2 - Torch/Commands/Command.cs | 1 - Torch/Commands/CommandAttribute.cs | 3 + Torch/Commands/CommandContext.cs | 4 - Torch/Commands/CommandManager.cs | 3 - Torch/Commands/CommandModule.cs | 4 +- Torch/Commands/CommandTree.cs | 3 - Torch/Commands/ConsoleCommandContext.cs | 1 - .../Permissions/PermissionAttribute.cs | 4 - .../Commands/Permissions/PermissonsSystem.cs | 3 - Torch/Commands/TorchCommands.cs | 21 +- Torch/Event/EventShimAttribute.cs | 4 - Torch/Extensions/DispatcherExtensions.cs | 4 - Torch/Extensions/ICollectionExtensions.cs | 1 - .../MyPlayerCollectionExtensions.cs | 7 +- Torch/Extensions/StringExtensions.cs | 4 - .../Managers/ChatManager/ChatManagerClient.cs | 15 +- .../Managers/ChatManager/ChatManagerServer.cs | 6 - Torch/Managers/DependencyManager.cs | 1 - Torch/Managers/EntityManager.cs | 24 +- Torch/Managers/FilesystemManager.cs | 5 - Torch/Managers/Manager.cs | 4 - Torch/Managers/MultiplayerManagerBase.cs | 22 - .../Managers/NetworkManager/NetworkManager.cs | 2 - Torch/Managers/PatchManager/EmitExtensions.cs | 1 - .../PatchManager/MSIL/MsilArgument.cs | 5 - .../PatchManager/MSIL/MsilInstruction.cs | 4 - .../MSIL/MsilInstructionExtensions.cs | 5 - Torch/Managers/PatchManager/MSIL/MsilLocal.cs | 5 - .../PatchManager/MSIL/MsilOperandInline.cs | 2 - .../MSIL/MsilTryCatchOperation.cs | 5 - Torch/Managers/PatchManager/PatchManager.cs | 1 - .../PatchManager/PatchShimAttribute.cs | 6 +- Torch/Managers/PatchManager/PatchUtilities.cs | 5 - .../Transpile/LoggingILGenerator.cs | 2 - .../PatchManager/Transpile/MethodContext.cs | 2 - .../Transpile/MethodTranspiler.cs | 1 - Torch/Managers/UpdateManager.cs | 7 - Torch/Patches/AutoSavePatch.cs | 54 + Torch/Patches/EntityIdentifierPatch.cs | 6 +- Torch/Patches/GameAnalyticsPatch.cs | 2 - Torch/Patches/GameStatePatchShim.cs | 2 - Torch/Patches/KeenLogPatch.cs | 9 +- Torch/Patches/LoaderHook.cs | 5 +- Torch/Patches/ModsDownloadingPatch.cs | 8 +- Torch/Patches/PhysicsMemoryPatch.cs | 3 - Torch/Patches/ProgramableBlockPatch.cs | 5 +- Torch/Patches/ScriptCompilerPatch.cs | 11 +- Torch/Patches/SessionDownloadPatch.cs | 9 +- Torch/Patches/TorchAsyncSaving.cs | 5 - Torch/Patches/XmlRootWriterPatch.cs | 4 +- Torch/Persistent.cs | 3 - Torch/Plugins/PluginManager.cs | 4 - Torch/Plugins/PluginManifest.cs | 3 - Torch/Session/TorchSession.cs | 7 +- Torch/Session/TorchSessionManager.cs | 5 - Torch/TorchBase.cs | 3 +- Torch/TorchPluginBase.cs | 9 - Torch/Utils/MiscExtensions.cs | 3 - Torch/Utils/ModItemUtils.cs | 3 - .../ReflectedEventReplaceAttribute.cs | 2 + .../Reflected/ReflectedFieldInfoAttribute.cs | 2 + .../Reflected/ReflectedGetterAttribute.cs | 2 + .../Utils/Reflected/ReflectedLazyAttribute.cs | 4 - Torch/Utils/Reflected/ReflectedManager.cs | 6 - .../Reflected/ReflectedMemberAttribute.cs | 2 + .../Reflected/ReflectedMethodInfoAttribute.cs | 2 + .../ReflectedPropertyInfoAttribute.cs | 2 + Torch/Utils/Reflection.cs | 3 - Torch/Utils/SynchronizationExtensions.cs | 4 - Torch/Utils/TorchAssemblyResolver.cs | 3 - Torch/Utils/TorchLogManager.cs | 3 +- Torch/VRageGame.cs | 8 - Torch/ViewModels/ModViewModel.cs | 7 +- Torch/ViewModels/PlayerViewModel.cs | 7 +- Torch/ViewModels/PluginViewModel.cs | 8 +- Torch/ViewModels/ViewModel.cs | 4 - Torch/Views/CollectionEditor.xaml.cs | 9 - Torch/Views/DictionaryEditor.xaml.cs | 14 - Torch/Views/DisplayAttribute.cs | 4 - Torch/Views/EmbeddedCollectionEditor.xaml.cs | 11 - Torch/Views/FlagsEditor.xaml.cs | 14 - Torch/Views/ObjectCollectionEditor.xaml.cs | 19 +- Torch/Views/ObjectEditor.xaml.cs | 15 +- Torch/Views/PropertyGrid.xaml.cs | 11 - Torch/packages.lock.json | 6 + 191 files changed, 204 insertions(+), 2108 deletions(-) delete mode 100644 Torch.Server/Properties/Annotations.cs create mode 100644 Torch/Patches/AutoSavePatch.cs diff --git a/Torch.API/IPlayer.cs b/Torch.API/IPlayer.cs index e2357a4..8c25849 100644 --- a/Torch.API/IPlayer.cs +++ b/Torch.API/IPlayer.cs @@ -1,11 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using VRage.Game.ModAPI; - -namespace Torch.API +namespace Torch.API { /// /// Represents a player on the server. diff --git a/Torch.API/ITorchBase.cs b/Torch.API/ITorchBase.cs index 06c4ae0..52e9428 100644 --- a/Torch.API/ITorchBase.cs +++ b/Torch.API/ITorchBase.cs @@ -1,13 +1,9 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Runtime.CompilerServices; -using System.Text; using System.Threading.Tasks; using Microsoft.Extensions.Configuration; using Torch.API.Managers; using Torch.API.Session; -using VRage.Game.ModAPI; using Version = SemanticVersioning.Version; namespace Torch.API diff --git a/Torch.API/Managers/IChatManagerClient.cs b/Torch.API/Managers/IChatManagerClient.cs index 19bc3b9..a5a209b 100644 --- a/Torch.API/Managers/IChatManagerClient.cs +++ b/Torch.API/Managers/IChatManagerClient.cs @@ -1,17 +1,9 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Sandbox.Engine.Multiplayer; using Sandbox.Game.Gui; -using Sandbox.Game.Multiplayer; using Torch.Utils; using VRage.Game; -using VRage.Network; -using VRage.Replication; using VRageMath; -using VRageRender; namespace Torch.API.Managers { diff --git a/Torch.API/Managers/IChatManagerServer.cs b/Torch.API/Managers/IChatManagerServer.cs index df488d9..dbc2507 100644 --- a/Torch.API/Managers/IChatManagerServer.cs +++ b/Torch.API/Managers/IChatManagerServer.cs @@ -1,11 +1,6 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using VRage.Collections; using VRage.Game; -using VRage.Network; using VRageMath; namespace Torch.API.Managers diff --git a/Torch.API/Managers/IDependencyManager.cs b/Torch.API/Managers/IDependencyManager.cs index 36ceec7..84b0ba9 100644 --- a/Torch.API/Managers/IDependencyManager.cs +++ b/Torch.API/Managers/IDependencyManager.cs @@ -1,8 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Torch.API.Managers { diff --git a/Torch.API/Managers/IDependencyProvider.cs b/Torch.API/Managers/IDependencyProvider.cs index 37bcb9c..f71a4c9 100644 --- a/Torch.API/Managers/IDependencyProvider.cs +++ b/Torch.API/Managers/IDependencyProvider.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Torch.API.Managers { diff --git a/Torch.API/Managers/IManager.cs b/Torch.API/Managers/IManager.cs index 3e1a951..d127606 100644 --- a/Torch.API/Managers/IManager.cs +++ b/Torch.API/Managers/IManager.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Torch.API.Managers +namespace Torch.API.Managers { /// /// Base interface for Torch managers. diff --git a/Torch.API/Managers/IMultiplayerManagerBase.cs b/Torch.API/Managers/IMultiplayerManagerBase.cs index 09b76c9..b67d98f 100644 --- a/Torch.API/Managers/IMultiplayerManagerBase.cs +++ b/Torch.API/Managers/IMultiplayerManagerBase.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using VRage.Game; using VRage.Game.ModAPI; namespace Torch.API.Managers diff --git a/Torch.API/Managers/IMultiplayerManagerClient.cs b/Torch.API/Managers/IMultiplayerManagerClient.cs index f4e6a32..805dd46 100644 --- a/Torch.API/Managers/IMultiplayerManagerClient.cs +++ b/Torch.API/Managers/IMultiplayerManagerClient.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Torch.API.Managers +namespace Torch.API.Managers { public interface IMultiplayerManagerClient : IMultiplayerManagerBase { diff --git a/Torch.API/Managers/IMultiplayerManagerServer.cs b/Torch.API/Managers/IMultiplayerManagerServer.cs index 3571918..9b3d1aa 100644 --- a/Torch.API/Managers/IMultiplayerManagerServer.cs +++ b/Torch.API/Managers/IMultiplayerManagerServer.cs @@ -1,8 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using VRage.Game.ModAPI; namespace Torch.API.Managers diff --git a/Torch.API/Managers/INetworkManager.cs b/Torch.API/Managers/INetworkManager.cs index acbea3b..19cbfb4 100644 --- a/Torch.API/Managers/INetworkManager.cs +++ b/Torch.API/Managers/INetworkManager.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using VRage; +using VRage; using VRage.Library.Collections; using VRage.Network; diff --git a/Torch.API/Managers/IPackageManager.cs b/Torch.API/Managers/IPackageManager.cs index 8338e4b..8d02ba5 100644 --- a/Torch.API/Managers/IPackageManager.cs +++ b/Torch.API/Managers/IPackageManager.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Reflection; -using System.Runtime.Loader; using Torch.API.WebAPI.Plugins; namespace Torch.API.Managers; diff --git a/Torch.API/Managers/IPluginManager.cs b/Torch.API/Managers/IPluginManager.cs index 46cf0f6..7f22eef 100644 --- a/Torch.API/Managers/IPluginManager.cs +++ b/Torch.API/Managers/IPluginManager.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; using Torch.API.Plugins; -using VRage.Collections; -using VRage.Plugins; namespace Torch.API.Managers { diff --git a/Torch.API/ModAPI/Ingame/GridExtensions.cs b/Torch.API/ModAPI/Ingame/GridExtensions.cs index a7ccd74..8e026ca 100644 --- a/Torch.API/ModAPI/Ingame/GridExtensions.cs +++ b/Torch.API/ModAPI/Ingame/GridExtensions.cs @@ -1,14 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Sandbox.Game.Entities.Blocks; -using Sandbox.ModAPI.Ingame; -using VRage.Game.ModAPI.Ingame; - -namespace Torch.API.ModAPI.Ingame +namespace Torch.API.ModAPI.Ingame { public static class GridExtensions { diff --git a/Torch.API/ModAPI/TorchAPI.cs b/Torch.API/ModAPI/TorchAPI.cs index 40a2822..a1f1e88 100644 --- a/Torch.API/ModAPI/TorchAPI.cs +++ b/Torch.API/ModAPI/TorchAPI.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Text; -using System.Threading.Tasks; +using System.Runtime.CompilerServices; //Needed so Torch can set the instance here without exposing anything bad to mods or creating a circular dependency. [assembly: InternalsVisibleTo("Torch")] diff --git a/Torch.API/Plugins/ITorchPlugin.cs b/Torch.API/Plugins/ITorchPlugin.cs index fd7c83f..3dba517 100644 --- a/Torch.API/Plugins/ITorchPlugin.cs +++ b/Torch.API/Plugins/ITorchPlugin.cs @@ -1,9 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography.X509Certificates; -using System.Text; -using System.Threading.Tasks; namespace Torch.API.Plugins { diff --git a/Torch.API/Plugins/IWpfPlugin.cs b/Torch.API/Plugins/IWpfPlugin.cs index 0fcc91d..f1f81e4 100644 --- a/Torch.API/Plugins/IWpfPlugin.cs +++ b/Torch.API/Plugins/IWpfPlugin.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Controls; +using System.Windows.Controls; namespace Torch.API.Plugins { diff --git a/Torch.API/Plugins/PluginAttribute.cs b/Torch.API/Plugins/PluginAttribute.cs index d8c1297..ee494fc 100644 --- a/Torch.API/Plugins/PluginAttribute.cs +++ b/Torch.API/Plugins/PluginAttribute.cs @@ -1,9 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; namespace Torch.API.Plugins { diff --git a/Torch.API/ServerState.cs b/Torch.API/ServerState.cs index 7409680..1a0c099 100644 --- a/Torch.API/ServerState.cs +++ b/Torch.API/ServerState.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Torch.API +namespace Torch.API { /// /// Used to indicate the state of the dedicated server. diff --git a/Torch.API/Session/GameSaveResult.cs b/Torch.API/Session/GameSaveResult.cs index 51d16b8..836f884 100644 --- a/Torch.API/Session/GameSaveResult.cs +++ b/Torch.API/Session/GameSaveResult.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Torch.API.Session +namespace Torch.API.Session { /// /// The result of a save operation diff --git a/Torch.API/Session/ITorchSession.cs b/Torch.API/Session/ITorchSession.cs index 0648fcb..e35bf40 100644 --- a/Torch.API/Session/ITorchSession.cs +++ b/Torch.API/Session/ITorchSession.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Sandbox.Game.World; +using Sandbox.Game.World; using Torch.API.Managers; namespace Torch.API.Session diff --git a/Torch.API/Session/ITorchSessionManager.cs b/Torch.API/Session/ITorchSessionManager.cs index 1b13e95..7c5e3b8 100644 --- a/Torch.API/Session/ITorchSessionManager.cs +++ b/Torch.API/Session/ITorchSessionManager.cs @@ -1,9 +1,6 @@ using System; using System.Collections.Generic; using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Torch.API.Managers; using VRage.Game; diff --git a/Torch.API/Session/TorchSessionState.cs b/Torch.API/Session/TorchSessionState.cs index 6d02da3..4eec387 100644 --- a/Torch.API/Session/TorchSessionState.cs +++ b/Torch.API/Session/TorchSessionState.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Torch.API.Session +namespace Torch.API.Session { /// /// Represents the state of a diff --git a/Torch.API/Torch.API.csproj b/Torch.API/Torch.API.csproj index 1d437df..64d2d07 100644 --- a/Torch.API/Torch.API.csproj +++ b/Torch.API/Torch.API.csproj @@ -12,6 +12,7 @@ + diff --git a/Torch.API/TorchGameState.cs b/Torch.API/TorchGameState.cs index 5c81393..7f497aa 100644 --- a/Torch.API/TorchGameState.cs +++ b/Torch.API/TorchGameState.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Sandbox; +using Sandbox; namespace Torch.API { diff --git a/Torch.API/Utils/StringUtils.cs b/Torch.API/Utils/StringUtils.cs index 2177009..a09f4b7 100644 --- a/Torch.API/Utils/StringUtils.cs +++ b/Torch.API/Utils/StringUtils.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; -using System.Threading.Tasks; namespace Torch.Utils { diff --git a/Torch.API/WebAPI/Plugins/IPackageReader.cs b/Torch.API/WebAPI/Plugins/IPackageReader.cs index 494a8c1..08b6923 100644 --- a/Torch.API/WebAPI/Plugins/IPackageReader.cs +++ b/Torch.API/WebAPI/Plugins/IPackageReader.cs @@ -1,7 +1,5 @@ #nullable enable using System.Collections.Generic; -using System.IO; -using System.Linq; using System.Threading.Tasks; namespace Torch.API.WebAPI.Plugins; diff --git a/Torch.API/packages.lock.json b/Torch.API/packages.lock.json index fb7345f..e77c42c 100644 --- a/Torch.API/packages.lock.json +++ b/Torch.API/packages.lock.json @@ -2,6 +2,12 @@ "version": 1, "dependencies": { "net8.0-windows7.0": { + "JetBrains.Annotations": { + "type": "Direct", + "requested": "[2023.3.0, )", + "resolved": "2023.3.0", + "contentHash": "PHfnvdBUdGaTVG9bR/GEfxgTwWM0Z97Y6X3710wiljELBISipSfF5okn/vz+C2gfO+ihoEyVPjaJwn8ZalVukA==" + }, "Microsoft.Extensions.Configuration.Binder": { "type": "Direct", "requested": "[8.0.1, )", diff --git a/Torch.Mod/Messages/DialogMessage.cs b/Torch.Mod/Messages/DialogMessage.cs index ae54317..88d7f84 100644 --- a/Torch.Mod/Messages/DialogMessage.cs +++ b/Torch.Mod/Messages/DialogMessage.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using ProtoBuf; using Sandbox.ModAPI; diff --git a/Torch.Mod/Messages/JoinServerMessage.cs b/Torch.Mod/Messages/JoinServerMessage.cs index c13cc35..408e83b 100644 --- a/Torch.Mod/Messages/JoinServerMessage.cs +++ b/Torch.Mod/Messages/JoinServerMessage.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; -using ProtoBuf; +using ProtoBuf; using Sandbox.ModAPI; namespace Torch.Mod.Messages diff --git a/Torch.Mod/Messages/NotificationMessage.cs b/Torch.Mod/Messages/NotificationMessage.cs index 951f053..8d4ddc8 100644 --- a/Torch.Mod/Messages/NotificationMessage.cs +++ b/Torch.Mod/Messages/NotificationMessage.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using ProtoBuf; using Sandbox.ModAPI; diff --git a/Torch.Mod/Messages/VoxelResetMessage.cs b/Torch.Mod/Messages/VoxelResetMessage.cs index 1b6f1df..ecbca37 100644 --- a/Torch.Mod/Messages/VoxelResetMessage.cs +++ b/Torch.Mod/Messages/VoxelResetMessage.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using ProtoBuf; using Sandbox.ModAPI; using VRage.ModAPI; diff --git a/Torch.Server.Tests/TorchServerSessionSettingsTest.cs b/Torch.Server.Tests/TorchServerSessionSettingsTest.cs index 3efe9b1..7a68e88 100644 --- a/Torch.Server.Tests/TorchServerSessionSettingsTest.cs +++ b/Torch.Server.Tests/TorchServerSessionSettingsTest.cs @@ -2,8 +2,6 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; using Torch.Server.ViewModels; using VRage.Game; using Xunit; diff --git a/Torch.Server.Tests/packages.lock.json b/Torch.Server.Tests/packages.lock.json index f0a1d73..6a5947f 100644 --- a/Torch.Server.Tests/packages.lock.json +++ b/Torch.Server.Tests/packages.lock.json @@ -64,6 +64,11 @@ "MonoMod.RuntimeDetour": "25.1.0-prerelease.1" } }, + "JetBrains.Annotations": { + "type": "Transitive", + "resolved": "2023.3.0", + "contentHash": "PHfnvdBUdGaTVG9bR/GEfxgTwWM0Z97Y6X3710wiljELBISipSfF5okn/vz+C2gfO+ihoEyVPjaJwn8ZalVukA==" + }, "MahApps.Metro": { "type": "Transitive", "resolved": "2.4.10", @@ -641,6 +646,7 @@ "torch.api": { "type": "Project", "dependencies": { + "JetBrains.Annotations": "[2023.3.0, )", "Microsoft.Extensions.Configuration.Binder": "[8.0.1, )", "NLog": "[5.3.2, )", "NuGet.Commands": "[6.9.1, )", diff --git a/Torch.Server/Commands/WhitelistCommands.cs b/Torch.Server/Commands/WhitelistCommands.cs index 729c6cc..3ad1b19 100644 --- a/Torch.Server/Commands/WhitelistCommands.cs +++ b/Torch.Server/Commands/WhitelistCommands.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Torch.Commands; +using Torch.Commands; namespace Torch.Server.Commands { diff --git a/Torch.Server/Initializer.cs b/Torch.Server/Initializer.cs index e43cff2..dff1a4a 100644 --- a/Torch.Server/Initializer.cs +++ b/Torch.Server/Initializer.cs @@ -1,24 +1,13 @@ using System; -using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.IO.Compression; -using System.Linq; -using System.Net; using System.Net.Http; -using System.Reflection; -using System.Text; using System.Threading; using System.Threading.Tasks; -using System.Windows; using System.Windows.Threading; using Microsoft.Extensions.Configuration; using NLog; -using NLog.Targets; -using Sandbox.Engine.Utils; -using SpaceEngineers.Game; -using Torch.Utils; -using VRage.FileSystem; namespace Torch.Server { diff --git a/Torch.Server/LogViewerTarget.cs b/Torch.Server/LogViewerTarget.cs index 7ea6723..f3c401e 100644 --- a/Torch.Server/LogViewerTarget.cs +++ b/Torch.Server/LogViewerTarget.cs @@ -1,7 +1,6 @@ using System.Collections.Generic; using System.Threading; using System.Windows.Media; -using System.Windows.Threading; using NLog; using NLog.Targets; using Torch.Server.ViewModels; diff --git a/Torch.Server/Managers/EntityControlManager.cs b/Torch.Server/Managers/EntityControlManager.cs index b121fdf..679a633 100644 --- a/Torch.Server/Managers/EntityControlManager.cs +++ b/Torch.Server/Managers/EntityControlManager.cs @@ -1,19 +1,13 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Reflection; using System.Runtime.CompilerServices; -using System.Text; -using System.Threading; -using System.Threading.Tasks; using System.Windows.Controls; using NLog; -using NLog.Fluent; using Torch.API; using Torch.Collections; using Torch.Managers; using Torch.Server.ViewModels.Entities; -using Torch.Utils; namespace Torch.Server.Managers { diff --git a/Torch.Server/Managers/InstanceManager.cs b/Torch.Server/Managers/InstanceManager.cs index c00cd7c..d6141c6 100644 --- a/Torch.Server/Managers/InstanceManager.cs +++ b/Torch.Server/Managers/InstanceManager.cs @@ -1,21 +1,12 @@ using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.ComponentModel; using System.IO; using System.Linq; -using System.Reflection; using System.Runtime.Serialization; -using System.Text; using System.Threading; using System.Threading.Tasks; -using Havok; using NLog; using Sandbox; -using Sandbox.Engine.Networking; using Sandbox.Engine.Utils; -using Sandbox.Game; -using Sandbox.Game.Gui; using Torch.API; using Torch.API.Managers; using Torch.Collections; @@ -23,13 +14,10 @@ using Torch.Managers; using Torch.Mod; using Torch.Server.ViewModels; using Torch.Utils; -using VRage; using VRage.FileSystem; using VRage.Game; -using VRage.Game.ObjectBuilder; using VRage.ObjectBuilders; using VRage.ObjectBuilders.Private; -using VRage.Plugins; namespace Torch.Server.Managers { diff --git a/Torch.Server/Managers/MultiplayerManagerDedicated.cs b/Torch.Server/Managers/MultiplayerManagerDedicated.cs index aadd2ce..ac7ceb8 100644 --- a/Torch.Server/Managers/MultiplayerManagerDedicated.cs +++ b/Torch.Server/Managers/MultiplayerManagerDedicated.cs @@ -2,11 +2,8 @@ using System.Collections.Generic; using System.Linq; using System.Net; -using System.Reflection; -using System.Text; using System.Threading.Tasks; using NLog; -using NLog.Fluent; using Sandbox; using Sandbox.Engine.Multiplayer; using Sandbox.Engine.Networking; @@ -16,12 +13,10 @@ using Torch.API; using Torch.API.Managers; using Torch.Managers; using Torch.Utils; -using Torch.ViewModels; using VRage.Game; using VRage.Game.ModAPI; using VRage.GameServices; using VRage.Network; -using VRage.Steam; namespace Torch.Server.Managers { diff --git a/Torch.Server/Managers/MultiplayerManagerDedicatedEventShim.cs b/Torch.Server/Managers/MultiplayerManagerDedicatedEventShim.cs index c9a302d..418ddaa 100644 --- a/Torch.Server/Managers/MultiplayerManagerDedicatedEventShim.cs +++ b/Torch.Server/Managers/MultiplayerManagerDedicatedEventShim.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using NLog; -using Sandbox; +using System.Threading.Tasks; using Torch.API.Event; using Torch.Event; using VRage.Network; diff --git a/Torch.Server/Managers/MultiplayerManagerDedicatedPatchShim.cs b/Torch.Server/Managers/MultiplayerManagerDedicatedPatchShim.cs index d6ddded..686a325 100644 --- a/Torch.Server/Managers/MultiplayerManagerDedicatedPatchShim.cs +++ b/Torch.Server/Managers/MultiplayerManagerDedicatedPatchShim.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using NLog; -using Sandbox.Engine.Multiplayer; +using Sandbox.Engine.Multiplayer; using Torch.Managers.PatchManager; using Torch.API.Managers; diff --git a/Torch.Server/NativeMethods.cs b/Torch.Server/NativeMethods.cs index 564fd13..1013fd2 100644 --- a/Torch.Server/NativeMethods.cs +++ b/Torch.Server/NativeMethods.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; +using System.Runtime.InteropServices; namespace Torch.Server { diff --git a/Torch.Server/Patches/PromotePatch.cs b/Torch.Server/Patches/PromotePatch.cs index 7de35bf..810946e 100644 --- a/Torch.Server/Patches/PromotePatch.cs +++ b/Torch.Server/Patches/PromotePatch.cs @@ -1,9 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; using NLog; using Sandbox.Game.World; using Torch.Managers.PatchManager; diff --git a/Torch.Server/Patches/ServerResponsePatch.cs b/Torch.Server/Patches/ServerResponsePatch.cs index 21ecb14..9e56416 100644 --- a/Torch.Server/Patches/ServerResponsePatch.cs +++ b/Torch.Server/Patches/ServerResponsePatch.cs @@ -1,15 +1,10 @@ -using System; using System.Collections.Generic; using System.Reflection; using System.Reflection.Emit; using NLog; using Sandbox.Engine.Multiplayer; -using Sandbox.Game.World; -using Torch.API.Managers; using Torch.Managers.PatchManager; using Torch.Managers.PatchManager.MSIL; -using Torch.Server.Managers; -using VRage.Game.ModAPI; namespace Torch.Patches { diff --git a/Torch.Server/Patches/WorldLoadExceptionPatch.cs b/Torch.Server/Patches/WorldLoadExceptionPatch.cs index c90a1e2..72b053c 100644 --- a/Torch.Server/Patches/WorldLoadExceptionPatch.cs +++ b/Torch.Server/Patches/WorldLoadExceptionPatch.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; diff --git a/Torch.Server/Program.cs b/Torch.Server/Program.cs index f0e701d..19cb068 100644 --- a/Torch.Server/Program.cs +++ b/Torch.Server/Program.cs @@ -1,8 +1,6 @@ using System; using System.IO; using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Configuration.Xml; -using NLog; using NLog.Config; using NLog.Targets; using Torch.API; diff --git a/Torch.Server/Properties/Annotations.cs b/Torch.Server/Properties/Annotations.cs deleted file mode 100644 index c00e554..0000000 --- a/Torch.Server/Properties/Annotations.cs +++ /dev/null @@ -1,1065 +0,0 @@ -/* MIT License - -Copyright (c) 2016 JetBrains http://www.jetbrains.com - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. */ - -using System; - -#pragma warning disable 1591 -// ReSharper disable UnusedMember.Global -// ReSharper disable MemberCanBePrivate.Global -// ReSharper disable UnusedAutoPropertyAccessor.Global -// ReSharper disable IntroduceOptionalParameters.Global -// ReSharper disable MemberCanBeProtected.Global -// ReSharper disable InconsistentNaming - -namespace Torch.Server.Annotations -{ - /// - /// Indicates that the value of the marked element could be null sometimes, - /// so the check for null is necessary before its usage. - /// - /// - /// [CanBeNull] object Test() => null; - /// - /// void UseTest() { - /// var p = Test(); - /// var s = p.ToString(); // Warning: Possible 'System.NullReferenceException' - /// } - /// - [AttributeUsage( - AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | - AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event | - AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter)] - public sealed class CanBeNullAttribute : Attribute { } - - /// - /// Indicates that the value of the marked element could never be null. - /// - /// - /// [NotNull] object Foo() { - /// return null; // Warning: Possible 'null' assignment - /// } - /// - [AttributeUsage( - AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | - AttributeTargets.Delegate | AttributeTargets.Field | AttributeTargets.Event | - AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.GenericParameter)] - public sealed class NotNullAttribute : Attribute { } - - /// - /// Can be appplied to symbols of types derived from IEnumerable as well as to symbols of Task - /// and Lazy classes to indicate that the value of a collection item, of the Task.Result property - /// or of the Lazy.Value property can never be null. - /// - [AttributeUsage( - AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | - AttributeTargets.Delegate | AttributeTargets.Field)] - public sealed class ItemNotNullAttribute : Attribute { } - - /// - /// Can be appplied to symbols of types derived from IEnumerable as well as to symbols of Task - /// and Lazy classes to indicate that the value of a collection item, of the Task.Result property - /// or of the Lazy.Value property can be null. - /// - [AttributeUsage( - AttributeTargets.Method | AttributeTargets.Parameter | AttributeTargets.Property | - AttributeTargets.Delegate | AttributeTargets.Field)] - public sealed class ItemCanBeNullAttribute : Attribute { } - - /// - /// Indicates that the marked method builds string by format pattern and (optional) arguments. - /// Parameter, which contains format string, should be given in constructor. The format string - /// should be in -like form. - /// - /// - /// [StringFormatMethod("message")] - /// void ShowError(string message, params object[] args) { /* do something */ } - /// - /// void Foo() { - /// ShowError("Failed: {0}"); // Warning: Non-existing argument in format string - /// } - /// - [AttributeUsage( - AttributeTargets.Constructor | AttributeTargets.Method | - AttributeTargets.Property | AttributeTargets.Delegate)] - public sealed class StringFormatMethodAttribute : Attribute - { - /// - /// Specifies which parameter of an annotated method should be treated as format-string - /// - public StringFormatMethodAttribute([NotNull] string formatParameterName) - { - FormatParameterName = formatParameterName; - } - - [NotNull] public string FormatParameterName { get; private set; } - } - - /// - /// For a parameter that is expected to be one of the limited set of values. - /// Specify fields of which type should be used as values for this parameter. - /// - [AttributeUsage( - AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field, - AllowMultiple = true)] - public sealed class ValueProviderAttribute : Attribute - { - public ValueProviderAttribute([NotNull] string name) - { - Name = name; - } - - [NotNull] public string Name { get; private set; } - } - - /// - /// Indicates that the function argument should be string literal and match one - /// of the parameters of the caller function. For example, ReSharper annotates - /// the parameter of . - /// - /// - /// void Foo(string param) { - /// if (param == null) - /// throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol - /// } - /// - [AttributeUsage(AttributeTargets.Parameter)] - public sealed class InvokerParameterNameAttribute : Attribute { } - - /// - /// Indicates that the method is contained in a type that implements - /// System.ComponentModel.INotifyPropertyChanged interface and this method - /// is used to notify that some property value changed. - /// - /// - /// The method should be non-static and conform to one of the supported signatures: - /// - /// NotifyChanged(string) - /// NotifyChanged(params string[]) - /// NotifyChanged{T}(Expression{Func{T}}) - /// NotifyChanged{T,U}(Expression{Func{T,U}}) - /// SetProperty{T}(ref T, T, string) - /// - /// - /// - /// public class Foo : INotifyPropertyChanged { - /// public event PropertyChangedEventHandler PropertyChanged; - /// - /// [NotifyPropertyChangedInvocator] - /// protected virtual void NotifyChanged(string propertyName) { ... } - /// - /// string _name; - /// - /// public string Name { - /// get { return _name; } - /// set { _name = value; NotifyChanged("LastName"); /* Warning */ } - /// } - /// } - /// - /// Examples of generated notifications: - /// - /// NotifyChanged("Property") - /// NotifyChanged(() => Property) - /// NotifyChanged((VM x) => x.Property) - /// SetProperty(ref myField, value, "Property") - /// - /// - [AttributeUsage(AttributeTargets.Method)] - public sealed class NotifyPropertyChangedInvocatorAttribute : Attribute - { - public NotifyPropertyChangedInvocatorAttribute() { } - public NotifyPropertyChangedInvocatorAttribute([NotNull] string parameterName) - { - ParameterName = parameterName; - } - - [CanBeNull] public string ParameterName { get; private set; } - } - - /// - /// Describes dependency between method input and output. - /// - /// - ///

Function Definition Table syntax:

- /// - /// FDT ::= FDTRow [;FDTRow]* - /// FDTRow ::= Input => Output | Output <= Input - /// Input ::= ParameterName: Value [, Input]* - /// Output ::= [ParameterName: Value]* {halt|stop|void|nothing|Value} - /// Value ::= true | false | null | notnull | canbenull - /// - /// If method has single input parameter, it's name could be omitted.
- /// Using halt (or void/nothing, which is the same) for method output - /// means that the methos doesn't return normally (throws or terminates the process).
- /// Value canbenull is only applicable for output parameters.
- /// You can use multiple [ContractAnnotation] for each FDT row, or use single attribute - /// with rows separated by semicolon. There is no notion of order rows, all rows are checked - /// for applicability and applied per each program state tracked by R# analysis.
- ///
- /// - /// - /// [ContractAnnotation("=> halt")] - /// public void TerminationMethod() - /// - /// - /// [ContractAnnotation("halt <= condition: false")] - /// public void Assert(bool condition, string text) // regular assertion method - /// - /// - /// [ContractAnnotation("s:null => true")] - /// public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty() - /// - /// - /// // A method that returns null if the parameter is null, - /// // and not null if the parameter is not null - /// [ContractAnnotation("null => null; notnull => notnull")] - /// public object Transform(object data) - /// - /// - /// [ContractAnnotation("=> true, result: notnull; => false, result: null")] - /// public bool TryParse(string s, out Person result) - /// - /// - [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] - public sealed class ContractAnnotationAttribute : Attribute - { - public ContractAnnotationAttribute([NotNull] string contract) - : this(contract, false) { } - - public ContractAnnotationAttribute([NotNull] string contract, bool forceFullStates) - { - Contract = contract; - ForceFullStates = forceFullStates; - } - - [NotNull] public string Contract { get; private set; } - - public bool ForceFullStates { get; private set; } - } - - /// - /// Indicates that marked element should be localized or not. - /// - /// - /// [LocalizationRequiredAttribute(true)] - /// class Foo { - /// string str = "my string"; // Warning: Localizable string - /// } - /// - [AttributeUsage(AttributeTargets.All)] - public sealed class LocalizationRequiredAttribute : Attribute - { - public LocalizationRequiredAttribute() : this(true) { } - - public LocalizationRequiredAttribute(bool required) - { - Required = required; - } - - public bool Required { get; private set; } - } - - /// - /// Indicates that the value of the marked type (or its derivatives) - /// cannot be compared using '==' or '!=' operators and Equals() - /// should be used instead. However, using '==' or '!=' for comparison - /// with null is always permitted. - /// - /// - /// [CannotApplyEqualityOperator] - /// class NoEquality { } - /// - /// class UsesNoEquality { - /// void Test() { - /// var ca1 = new NoEquality(); - /// var ca2 = new NoEquality(); - /// if (ca1 != null) { // OK - /// bool condition = ca1 == ca2; // Warning - /// } - /// } - /// } - /// - [AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class | AttributeTargets.Struct)] - public sealed class CannotApplyEqualityOperatorAttribute : Attribute { } - - /// - /// When applied to a target attribute, specifies a requirement for any type marked - /// with the target attribute to implement or inherit specific type or types. - /// - /// - /// [BaseTypeRequired(typeof(IComponent)] // Specify requirement - /// class ComponentAttribute : Attribute { } - /// - /// [Component] // ComponentAttribute requires implementing IComponent interface - /// class MyComponent : IComponent { } - /// - [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] - [BaseTypeRequired(typeof(Attribute))] - public sealed class BaseTypeRequiredAttribute : Attribute - { - public BaseTypeRequiredAttribute([NotNull] Type baseType) - { - BaseType = baseType; - } - - [NotNull] public Type BaseType { get; private set; } - } - - /// - /// Indicates that the marked symbol is used implicitly (e.g. via reflection, in external library), - /// so this symbol will not be marked as unused (as well as by other usage inspections). - /// - [AttributeUsage(AttributeTargets.All)] - public sealed class UsedImplicitlyAttribute : Attribute - { - public UsedImplicitlyAttribute() - : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) { } - - public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags) - : this(useKindFlags, ImplicitUseTargetFlags.Default) { } - - public UsedImplicitlyAttribute(ImplicitUseTargetFlags targetFlags) - : this(ImplicitUseKindFlags.Default, targetFlags) { } - - public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags) - { - UseKindFlags = useKindFlags; - TargetFlags = targetFlags; - } - - public ImplicitUseKindFlags UseKindFlags { get; private set; } - - public ImplicitUseTargetFlags TargetFlags { get; private set; } - } - - /// - /// Should be used on attributes and causes ReSharper to not mark symbols marked with such attributes - /// as unused (as well as by other usage inspections) - /// - [AttributeUsage(AttributeTargets.Class | AttributeTargets.GenericParameter)] - public sealed class MeansImplicitUseAttribute : Attribute - { - public MeansImplicitUseAttribute() - : this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) { } - - public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags) - : this(useKindFlags, ImplicitUseTargetFlags.Default) { } - - public MeansImplicitUseAttribute(ImplicitUseTargetFlags targetFlags) - : this(ImplicitUseKindFlags.Default, targetFlags) { } - - public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags) - { - UseKindFlags = useKindFlags; - TargetFlags = targetFlags; - } - - [UsedImplicitly] public ImplicitUseKindFlags UseKindFlags { get; private set; } - - [UsedImplicitly] public ImplicitUseTargetFlags TargetFlags { get; private set; } - } - - [Flags] - public enum ImplicitUseKindFlags - { - Default = Access | Assign | InstantiatedWithFixedConstructorSignature, - /// Only entity marked with attribute considered used. - Access = 1, - /// Indicates implicit assignment to a member. - Assign = 2, - /// - /// Indicates implicit instantiation of a type with fixed constructor signature. - /// That means any unused constructor parameters won't be reported as such. - /// - InstantiatedWithFixedConstructorSignature = 4, - /// Indicates implicit instantiation of a type. - InstantiatedNoFixedConstructorSignature = 8, - } - - /// - /// Specify what is considered used implicitly when marked - /// with or . - /// - [Flags] - public enum ImplicitUseTargetFlags - { - Default = Itself, - Itself = 1, - /// Members of entity marked with attribute are considered used. - Members = 2, - /// Entity marked with attribute and all its members considered used. - WithMembers = Itself | Members - } - - /// - /// This attribute is intended to mark publicly available API - /// which should not be removed and so is treated as used. - /// - [MeansImplicitUse(ImplicitUseTargetFlags.WithMembers)] - public sealed class PublicAPIAttribute : Attribute - { - public PublicAPIAttribute() { } - - public PublicAPIAttribute([NotNull] string comment) - { - Comment = comment; - } - - [CanBeNull] public string Comment { get; private set; } - } - - /// - /// Tells code analysis engine if the parameter is completely handled when the invoked method is on stack. - /// If the parameter is a delegate, indicates that delegate is executed while the method is executed. - /// If the parameter is an enumerable, indicates that it is enumerated while the method is executed. - /// - [AttributeUsage(AttributeTargets.Parameter)] - public sealed class InstantHandleAttribute : Attribute { } - - /// - /// Indicates that a method does not make any observable state changes. - /// The same as System.Diagnostics.Contracts.PureAttribute. - /// - /// - /// [Pure] int Multiply(int x, int y) => x * y; - /// - /// void M() { - /// Multiply(123, 42); // Waring: Return value of pure method is not used - /// } - /// - [AttributeUsage(AttributeTargets.Method)] - public sealed class PureAttribute : Attribute { } - - /// - /// Indicates that the return value of method invocation must be used. - /// - [AttributeUsage(AttributeTargets.Method)] - public sealed class MustUseReturnValueAttribute : Attribute - { - public MustUseReturnValueAttribute() { } - - public MustUseReturnValueAttribute([NotNull] string justification) - { - Justification = justification; - } - - [CanBeNull] public string Justification { get; private set; } - } - - /// - /// Indicates the type member or parameter of some type, that should be used instead of all other ways - /// to get the value that type. This annotation is useful when you have some "context" value evaluated - /// and stored somewhere, meaning that all other ways to get this value must be consolidated with existing one. - /// - /// - /// class Foo { - /// [ProvidesContext] IBarService _barService = ...; - /// - /// void ProcessNode(INode node) { - /// DoSomething(node, node.GetGlobalServices().Bar); - /// // ^ Warning: use value of '_barService' field - /// } - /// } - /// - [AttributeUsage( - AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.Method | - AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct | AttributeTargets.GenericParameter)] - public sealed class ProvidesContextAttribute : Attribute { } - - /// - /// Indicates that a parameter is a path to a file or a folder within a web project. - /// Path can be relative or absolute, starting from web root (~). - /// - [AttributeUsage(AttributeTargets.Parameter)] - public sealed class PathReferenceAttribute : Attribute - { - public PathReferenceAttribute() { } - - public PathReferenceAttribute([NotNull, PathReference] string basePath) - { - BasePath = basePath; - } - - [CanBeNull] public string BasePath { get; private set; } - } - - /// - /// An extension method marked with this attribute is processed by ReSharper code completion - /// as a 'Source Template'. When extension method is completed over some expression, it's source code - /// is automatically expanded like a template at call site. - /// - /// - /// Template method body can contain valid source code and/or special comments starting with '$'. - /// Text inside these comments is added as source code when the template is applied. Template parameters - /// can be used either as additional method parameters or as identifiers wrapped in two '$' signs. - /// Use the attribute to specify macros for parameters. - /// - /// - /// In this example, the 'forEach' method is a source template available over all values - /// of enumerable types, producing ordinary C# 'foreach' statement and placing caret inside block: - /// - /// [SourceTemplate] - /// public static void forEach<T>(this IEnumerable<T> xs) { - /// foreach (var x in xs) { - /// //$ $END$ - /// } - /// } - /// - /// - [AttributeUsage(AttributeTargets.Method)] - public sealed class SourceTemplateAttribute : Attribute { } - - /// - /// Allows specifying a macro for a parameter of a source template. - /// - /// - /// You can apply the attribute on the whole method or on any of its additional parameters. The macro expression - /// is defined in the property. When applied on a method, the target - /// template parameter is defined in the property. To apply the macro silently - /// for the parameter, set the property value = -1. - /// - /// - /// Applying the attribute on a source template method: - /// - /// [SourceTemplate, Macro(Target = "item", Expression = "suggestVariableName()")] - /// public static void forEach<T>(this IEnumerable<T> collection) { - /// foreach (var item in collection) { - /// //$ $END$ - /// } - /// } - /// - /// Applying the attribute on a template method parameter: - /// - /// [SourceTemplate] - /// public static void something(this Entity x, [Macro(Expression = "guid()", Editable = -1)] string newguid) { - /// /*$ var $x$Id = "$newguid$" + x.ToString(); - /// x.DoSomething($x$Id); */ - /// } - /// - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method, AllowMultiple = true)] - public sealed class MacroAttribute : Attribute - { - /// - /// Allows specifying a macro that will be executed for a source template - /// parameter when the template is expanded. - /// - [CanBeNull] public string Expression { get; set; } - - /// - /// Allows specifying which occurrence of the target parameter becomes editable when the template is deployed. - /// - /// - /// If the target parameter is used several times in the template, only one occurrence becomes editable; - /// other occurrences are changed synchronously. To specify the zero-based index of the editable occurrence, - /// use values >= 0. To make the parameter non-editable when the template is expanded, use -1. - /// > - public int Editable { get; set; } - - /// - /// Identifies the target parameter of a source template if the - /// is applied on a template method. - /// - [CanBeNull] public string Target { get; set; } - } - - [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)] - public sealed class AspMvcAreaMasterLocationFormatAttribute : Attribute - { - public AspMvcAreaMasterLocationFormatAttribute([NotNull] string format) - { - Format = format; - } - - [NotNull] public string Format { get; private set; } - } - - [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)] - public sealed class AspMvcAreaPartialViewLocationFormatAttribute : Attribute - { - public AspMvcAreaPartialViewLocationFormatAttribute([NotNull] string format) - { - Format = format; - } - - [NotNull] public string Format { get; private set; } - } - - [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)] - public sealed class AspMvcAreaViewLocationFormatAttribute : Attribute - { - public AspMvcAreaViewLocationFormatAttribute([NotNull] string format) - { - Format = format; - } - - [NotNull] public string Format { get; private set; } - } - - [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)] - public sealed class AspMvcMasterLocationFormatAttribute : Attribute - { - public AspMvcMasterLocationFormatAttribute([NotNull] string format) - { - Format = format; - } - - [NotNull] public string Format { get; private set; } - } - - [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)] - public sealed class AspMvcPartialViewLocationFormatAttribute : Attribute - { - public AspMvcPartialViewLocationFormatAttribute([NotNull] string format) - { - Format = format; - } - - [NotNull] public string Format { get; private set; } - } - - [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = true)] - public sealed class AspMvcViewLocationFormatAttribute : Attribute - { - public AspMvcViewLocationFormatAttribute([NotNull] string format) - { - Format = format; - } - - [NotNull] public string Format { get; private set; } - } - - /// - /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter - /// is an MVC action. If applied to a method, the MVC action name is calculated - /// implicitly from the context. Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String). - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] - public sealed class AspMvcActionAttribute : Attribute - { - public AspMvcActionAttribute() { } - - public AspMvcActionAttribute([NotNull] string anonymousProperty) - { - AnonymousProperty = anonymousProperty; - } - - [CanBeNull] public string AnonymousProperty { get; private set; } - } - - /// - /// ASP.NET MVC attribute. Indicates that a parameter is an MVC area. - /// Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String). - /// - [AttributeUsage(AttributeTargets.Parameter)] - public sealed class AspMvcAreaAttribute : Attribute - { - public AspMvcAreaAttribute() { } - - public AspMvcAreaAttribute([NotNull] string anonymousProperty) - { - AnonymousProperty = anonymousProperty; - } - - [CanBeNull] public string AnonymousProperty { get; private set; } - } - - /// - /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is - /// an MVC controller. If applied to a method, the MVC controller name is calculated - /// implicitly from the context. Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String, String). - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] - public sealed class AspMvcControllerAttribute : Attribute - { - public AspMvcControllerAttribute() { } - - public AspMvcControllerAttribute([NotNull] string anonymousProperty) - { - AnonymousProperty = anonymousProperty; - } - - [CanBeNull] public string AnonymousProperty { get; private set; } - } - - /// - /// ASP.NET MVC attribute. Indicates that a parameter is an MVC Master. Use this attribute - /// for custom wrappers similar to System.Web.Mvc.Controller.View(String, String). - /// - [AttributeUsage(AttributeTargets.Parameter)] - public sealed class AspMvcMasterAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. Indicates that a parameter is an MVC model type. Use this attribute - /// for custom wrappers similar to System.Web.Mvc.Controller.View(String, Object). - /// - [AttributeUsage(AttributeTargets.Parameter)] - public sealed class AspMvcModelTypeAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter is an MVC - /// partial view. If applied to a method, the MVC partial view name is calculated implicitly - /// from the context. Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper, String). - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] - public sealed class AspMvcPartialViewAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. Allows disabling inspections for MVC views within a class or a method. - /// - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)] - public sealed class AspMvcSuppressViewErrorAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. Indicates that a parameter is an MVC display template. - /// Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Html.DisplayExtensions.DisplayForModel(HtmlHelper, String). - /// - [AttributeUsage(AttributeTargets.Parameter)] - public sealed class AspMvcDisplayTemplateAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. Indicates that a parameter is an MVC editor template. - /// Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Html.EditorExtensions.EditorForModel(HtmlHelper, String). - /// - [AttributeUsage(AttributeTargets.Parameter)] - public sealed class AspMvcEditorTemplateAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. Indicates that a parameter is an MVC template. - /// Use this attribute for custom wrappers similar to - /// System.ComponentModel.DataAnnotations.UIHintAttribute(System.String). - /// - [AttributeUsage(AttributeTargets.Parameter)] - public sealed class AspMvcTemplateAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter - /// is an MVC view component. If applied to a method, the MVC view name is calculated implicitly - /// from the context. Use this attribute for custom wrappers similar to - /// System.Web.Mvc.Controller.View(Object). - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] - public sealed class AspMvcViewAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter - /// is an MVC view component name. - /// - [AttributeUsage(AttributeTargets.Parameter)] - public sealed class AspMvcViewComponentAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter - /// is an MVC view component view. If applied to a method, the MVC view component view name is default. - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] - public sealed class AspMvcViewComponentViewAttribute : Attribute { } - - /// - /// ASP.NET MVC attribute. When applied to a parameter of an attribute, - /// indicates that this parameter is an MVC action name. - /// - /// - /// [ActionName("Foo")] - /// public ActionResult Login(string returnUrl) { - /// ViewBag.ReturnUrl = Url.Action("Foo"); // OK - /// return RedirectToAction("Bar"); // Error: Cannot resolve action - /// } - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property)] - public sealed class AspMvcActionSelectorAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.Field)] - public sealed class HtmlElementAttributesAttribute : Attribute - { - public HtmlElementAttributesAttribute() { } - - public HtmlElementAttributesAttribute([NotNull] string name) - { - Name = name; - } - - [CanBeNull] public string Name { get; private set; } - } - - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Field | AttributeTargets.Property)] - public sealed class HtmlAttributeValueAttribute : Attribute - { - public HtmlAttributeValueAttribute([NotNull] string name) - { - Name = name; - } - - [NotNull] public string Name { get; private set; } - } - - /// - /// Razor attribute. Indicates that a parameter or a method is a Razor section. - /// Use this attribute for custom wrappers similar to - /// System.Web.WebPages.WebPageBase.RenderSection(String). - /// - [AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)] - public sealed class RazorSectionAttribute : Attribute { } - - /// - /// Indicates how method, constructor invocation or property access - /// over collection type affects content of the collection. - /// - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Property)] - public sealed class CollectionAccessAttribute : Attribute - { - public CollectionAccessAttribute(CollectionAccessType collectionAccessType) - { - CollectionAccessType = collectionAccessType; - } - - public CollectionAccessType CollectionAccessType { get; private set; } - } - - [Flags] - public enum CollectionAccessType - { - /// Method does not use or modify content of the collection. - None = 0, - /// Method only reads content of the collection but does not modify it. - Read = 1, - /// Method can change content of the collection but does not add new elements. - ModifyExistingContent = 2, - /// Method can add new elements to the collection. - UpdatedContent = ModifyExistingContent | 4 - } - - /// - /// Indicates that the marked method is assertion method, i.e. it halts control flow if - /// one of the conditions is satisfied. To set the condition, mark one of the parameters with - /// attribute. - /// - [AttributeUsage(AttributeTargets.Method)] - public sealed class AssertionMethodAttribute : Attribute { } - - /// - /// Indicates the condition parameter of the assertion method. The method itself should be - /// marked by attribute. The mandatory argument of - /// the attribute is the assertion type. - /// - [AttributeUsage(AttributeTargets.Parameter)] - public sealed class AssertionConditionAttribute : Attribute - { - public AssertionConditionAttribute(AssertionConditionType conditionType) - { - ConditionType = conditionType; - } - - public AssertionConditionType ConditionType { get; private set; } - } - - /// - /// Specifies assertion type. If the assertion method argument satisfies the condition, - /// then the execution continues. Otherwise, execution is assumed to be halted. - /// - public enum AssertionConditionType - { - /// Marked parameter should be evaluated to true. - IS_TRUE = 0, - /// Marked parameter should be evaluated to false. - IS_FALSE = 1, - /// Marked parameter should be evaluated to null value. - IS_NULL = 2, - /// Marked parameter should be evaluated to not null value. - IS_NOT_NULL = 3, - } - - /// - /// Indicates that the marked method unconditionally terminates control flow execution. - /// For example, it could unconditionally throw exception. - /// - [Obsolete("Use [ContractAnnotation('=> halt')] instead")] - [AttributeUsage(AttributeTargets.Method)] - public sealed class TerminatesProgramAttribute : Attribute { } - - /// - /// Indicates that method is pure LINQ method, with postponed enumeration (like Enumerable.Select, - /// .Where). This annotation allows inference of [InstantHandle] annotation for parameters - /// of delegate type by analyzing LINQ method chains. - /// - [AttributeUsage(AttributeTargets.Method)] - public sealed class LinqTunnelAttribute : Attribute { } - - /// - /// Indicates that IEnumerable, passed as parameter, is not enumerated. - /// - [AttributeUsage(AttributeTargets.Parameter)] - public sealed class NoEnumerationAttribute : Attribute { } - - /// - /// Indicates that parameter is regular expression pattern. - /// - [AttributeUsage(AttributeTargets.Parameter)] - public sealed class RegexPatternAttribute : Attribute { } - - /// - /// Prevents the Member Reordering feature from tossing members of the marked class. - /// - /// - /// The attribute must be mentioned in your member reordering patterns - /// - [AttributeUsage( - AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct | AttributeTargets.Enum)] - public sealed class NoReorderAttribute : Attribute { } - - /// - /// XAML attribute. Indicates the type that has ItemsSource property and should be treated - /// as ItemsControl-derived type, to enable inner items DataContext type resolve. - /// - [AttributeUsage(AttributeTargets.Class)] - public sealed class XamlItemsControlAttribute : Attribute { } - - /// - /// XAML attribute. Indicates the property of some BindingBase-derived type, that - /// is used to bind some item of ItemsControl-derived type. This annotation will - /// enable the DataContext type resolve for XAML bindings for such properties. - /// - /// - /// Property should have the tree ancestor of the ItemsControl type or - /// marked with the attribute. - /// - [AttributeUsage(AttributeTargets.Property)] - public sealed class XamlItemBindingOfItemsControlAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] - public sealed class AspChildControlTypeAttribute : Attribute - { - public AspChildControlTypeAttribute([NotNull] string tagName, [NotNull] Type controlType) - { - TagName = tagName; - ControlType = controlType; - } - - [NotNull] public string TagName { get; private set; } - - [NotNull] public Type ControlType { get; private set; } - } - - [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)] - public sealed class AspDataFieldAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Property | AttributeTargets.Method)] - public sealed class AspDataFieldsAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Property)] - public sealed class AspMethodPropertyAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)] - public sealed class AspRequiredAttributeAttribute : Attribute - { - public AspRequiredAttributeAttribute([NotNull] string attribute) - { - Attribute = attribute; - } - - [NotNull] public string Attribute { get; private set; } - } - - [AttributeUsage(AttributeTargets.Property)] - public sealed class AspTypePropertyAttribute : Attribute - { - public bool CreateConstructorReferences { get; private set; } - - public AspTypePropertyAttribute(bool createConstructorReferences) - { - CreateConstructorReferences = createConstructorReferences; - } - } - - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - public sealed class RazorImportNamespaceAttribute : Attribute - { - public RazorImportNamespaceAttribute([NotNull] string name) - { - Name = name; - } - - [NotNull] public string Name { get; private set; } - } - - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - public sealed class RazorInjectionAttribute : Attribute - { - public RazorInjectionAttribute([NotNull] string type, [NotNull] string fieldName) - { - Type = type; - FieldName = fieldName; - } - - [NotNull] public string Type { get; private set; } - - [NotNull] public string FieldName { get; private set; } - } - - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - public sealed class RazorDirectiveAttribute : Attribute - { - public RazorDirectiveAttribute([NotNull] string directive) - { - Directive = directive; - } - - [NotNull] public string Directive { get; private set; } - } - - [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] - public sealed class RazorPageBaseTypeAttribute : Attribute - { - public RazorPageBaseTypeAttribute([NotNull] string baseType) - { - BaseType = baseType; - } - public RazorPageBaseTypeAttribute([NotNull] string baseType, string pageName) - { - BaseType = baseType; - PageName = pageName; - } - - [NotNull] public string BaseType { get; private set; } - [CanBeNull] public string PageName { get; private set; } - } - - [AttributeUsage(AttributeTargets.Method)] - public sealed class RazorHelperCommonAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Property)] - public sealed class RazorLayoutAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Method)] - public sealed class RazorWriteLiteralMethodAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Method)] - public sealed class RazorWriteMethodAttribute : Attribute { } - - [AttributeUsage(AttributeTargets.Parameter)] - public sealed class RazorWriteMethodParameterAttribute : Attribute { } -} \ No newline at end of file diff --git a/Torch.Server/TorchServer.cs b/Torch.Server/TorchServer.cs index 0f0e83e..22f4aa9 100644 --- a/Torch.Server/TorchServer.cs +++ b/Torch.Server/TorchServer.cs @@ -20,7 +20,6 @@ using Torch.API.Managers; using Torch.API.Session; using Torch.Commands; using Torch.Managers.PatchManager; -using Torch.Mod; using Torch.Server.Commands; using Torch.Server.Managers; using Torch.Utils; @@ -75,7 +74,7 @@ namespace Torch.Server if (State == ServerState.Running) Stop(); - Environment.Exit(0); + Destroy(); }; } @@ -244,7 +243,18 @@ namespace Torch.Server new Thread(() => { + if (save) + { + var saveResult = Save().Result; + if (saveResult is not (GameSaveResult.Success or GameSaveResult.TimedOut)) + { + Log.Error("Save failed due to {Reason}. Restart aborted!", saveResult); + return; + } + } + StopInternal(); + Destroy(); LogManager.Flush(); if ( @@ -254,7 +264,7 @@ namespace Torch.Server #endif ApplicationContext.Current.IsService ) - Environment.Exit(0); + return; var exe = Path.Combine(AppContext.BaseDirectory, "Torch.Server.exe"); @@ -274,8 +284,6 @@ namespace Torch.Server } Process.Start(exe, $"--waitForPid {Environment.ProcessId} --tempAutostart true {string.Join(" ", args)}"); - - Environment.Exit(0); }) { Name = "Restart thread" diff --git a/Torch.Server/ViewModels/BlockLimitViewModel.cs b/Torch.Server/ViewModels/BlockLimitViewModel.cs index 87117e4..025e99a 100644 --- a/Torch.Server/ViewModels/BlockLimitViewModel.cs +++ b/Torch.Server/ViewModels/BlockLimitViewModel.cs @@ -1,12 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Input; -using VRage.Game; - -namespace Torch.Server.ViewModels +namespace Torch.Server.ViewModels { public class BlockLimitViewModel : ViewModel { diff --git a/Torch.Server/ViewModels/CheckpointViewModel.cs b/Torch.Server/ViewModels/CheckpointViewModel.cs index 0ac571a..8179f87 100644 --- a/Torch.Server/ViewModels/CheckpointViewModel.cs +++ b/Torch.Server/ViewModels/CheckpointViewModel.cs @@ -1,9 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Torch.Collections; using VRage; using VRage.Game; using VRage.Game.ModAPI; diff --git a/Torch.Server/ViewModels/ConfigDedicatedViewModel.cs b/Torch.Server/ViewModels/ConfigDedicatedViewModel.cs index ca24e9b..5db7cb5 100644 --- a/Torch.Server/ViewModels/ConfigDedicatedViewModel.cs +++ b/Torch.Server/ViewModels/ConfigDedicatedViewModel.cs @@ -1,14 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Linq; +using System.Collections.Generic; using System.Threading.Tasks; using NLog; using Sandbox.Engine.Utils; using Torch.Collections; using Torch.Server.Managers; -using Torch.Utils; using VRage.Game; -using VRage.GameServices; namespace Torch.Server.ViewModels { diff --git a/Torch.Server/ViewModels/Entities/Blocks/BlockViewModel.cs b/Torch.Server/ViewModels/Entities/Blocks/BlockViewModel.cs index 4358274..f5d15dc 100644 --- a/Torch.Server/ViewModels/Entities/Blocks/BlockViewModel.cs +++ b/Torch.Server/ViewModels/Entities/Blocks/BlockViewModel.cs @@ -1,10 +1,5 @@ using System; using System.Collections.Generic; -using System.Drawing.Text; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; using Sandbox.Game.Entities.Cube; using Sandbox.ModAPI; using Sandbox.ModAPI.Interfaces; diff --git a/Torch.Server/ViewModels/Entities/Blocks/PropertyViewModel.cs b/Torch.Server/ViewModels/Entities/Blocks/PropertyViewModel.cs index 2bb26a2..620a4c4 100644 --- a/Torch.Server/ViewModels/Entities/Blocks/PropertyViewModel.cs +++ b/Torch.Server/ViewModels/Entities/Blocks/PropertyViewModel.cs @@ -1,9 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Sandbox.ModAPI; using Sandbox.ModAPI.Interfaces; namespace Torch.Server.ViewModels.Blocks diff --git a/Torch.Server/ViewModels/Entities/EntityControlViewModel.cs b/Torch.Server/ViewModels/Entities/EntityControlViewModel.cs index e963d29..3d8a352 100644 --- a/Torch.Server/ViewModels/Entities/EntityControlViewModel.cs +++ b/Torch.Server/ViewModels/Entities/EntityControlViewModel.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; +using System.Windows; namespace Torch.Server.ViewModels.Entities { diff --git a/Torch.Server/ViewModels/Entities/EntityViewModel.cs b/Torch.Server/ViewModels/Entities/EntityViewModel.cs index 50e22cd..2772582 100644 --- a/Torch.Server/ViewModels/Entities/EntityViewModel.cs +++ b/Torch.Server/ViewModels/Entities/EntityViewModel.cs @@ -1,16 +1,11 @@ using System; -using System.Collections; using System.Collections.Generic; -using System.Windows.Controls; using NLog; using Sandbox.Game.Entities; -using Sandbox.Game.World; using Torch.API.Managers; using Torch.Collections; using Torch.Server.Managers; using Torch.Utils; -using VRage.Game.Entity; -using VRage.Game.ModAPI; using VRage.ModAPI; using VRageMath; diff --git a/Torch.Server/ViewModels/Entities/GridViewModel.cs b/Torch.Server/ViewModels/Entities/GridViewModel.cs index 041bc16..f4ed6fd 100644 --- a/Torch.Server/ViewModels/Entities/GridViewModel.cs +++ b/Torch.Server/ViewModels/Entities/GridViewModel.cs @@ -1,12 +1,9 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Runtime.CompilerServices; using Sandbox.Definitions; using Sandbox.Game.Entities; using Sandbox.Game.Entities.Cube; -using Sandbox.ModAPI; -using Torch.API.Managers; using Torch.Collections; using Torch.Server.ViewModels.Blocks; using VRage.Game; diff --git a/Torch.Server/ViewModels/Entities/VoxelMapViewModel.cs b/Torch.Server/ViewModels/Entities/VoxelMapViewModel.cs index 6a2d4dc..6ca5228 100644 --- a/Torch.Server/ViewModels/Entities/VoxelMapViewModel.cs +++ b/Torch.Server/ViewModels/Entities/VoxelMapViewModel.cs @@ -1,8 +1,4 @@ -using System.Collections.Generic; -using System.Linq; -using Sandbox.Game.Entities; -using VRage.Game.Entity; -using VRage.Game.ModAPI; +using Sandbox.Game.Entities; using System.Threading.Tasks; using Torch.Collections; diff --git a/Torch.Server/ViewModels/EntityTreeViewModel.cs b/Torch.Server/ViewModels/EntityTreeViewModel.cs index bf940e4..a10fc07 100644 --- a/Torch.Server/ViewModels/EntityTreeViewModel.cs +++ b/Torch.Server/ViewModels/EntityTreeViewModel.cs @@ -1,18 +1,11 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Controls; using Sandbox.Game.Entities; using Sandbox.Game.Entities.Character; using Torch.Server.ViewModels.Entities; -using VRage.Game.ModAPI; -using VRage.ModAPI; using System.Windows.Threading; using NLog; using Torch.Collections; -using Torch.Server.Views.Entities; namespace Torch.Server.ViewModels { diff --git a/Torch.Server/ViewModels/ILazyLoad.cs b/Torch.Server/ViewModels/ILazyLoad.cs index 526b03d..a773c16 100644 --- a/Torch.Server/ViewModels/ILazyLoad.cs +++ b/Torch.Server/ViewModels/ILazyLoad.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Torch.Server.ViewModels +namespace Torch.Server.ViewModels { public interface ILazyLoad { diff --git a/Torch.Server/ViewModels/ModItemInfo.cs b/Torch.Server/ViewModels/ModItemInfo.cs index 5848c55..46ce0a8 100644 --- a/Torch.Server/ViewModels/ModItemInfo.cs +++ b/Torch.Server/ViewModels/ModItemInfo.cs @@ -1,9 +1,6 @@ -using System; -using System.Threading.Tasks; +using System.Threading.Tasks; using NLog; using VRage.Game; -using Torch.Utils; -using VRage.GameServices; namespace Torch.Server.ViewModels { diff --git a/Torch.Server/ViewModels/PluginManagerViewModel.cs b/Torch.Server/ViewModels/PluginManagerViewModel.cs index 4a6e97e..1f58732 100644 --- a/Torch.Server/ViewModels/PluginManagerViewModel.cs +++ b/Torch.Server/ViewModels/PluginManagerViewModel.cs @@ -1,9 +1,5 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Torch.API; using Torch.API.Managers; using Torch.API.Plugins; using Torch.Collections; diff --git a/Torch.Server/ViewModels/PluginViewModel.cs b/Torch.Server/ViewModels/PluginViewModel.cs index de30e2f..c5d71c5 100644 --- a/Torch.Server/ViewModels/PluginViewModel.cs +++ b/Torch.Server/ViewModels/PluginViewModel.cs @@ -1,13 +1,8 @@ using System; -using System.Collections.Generic; using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using NLog; -using Torch.API; using Torch.API.Plugins; using Torch.Server.Views; diff --git a/Torch.Server/ViewModels/SessionSettingsViewModel.cs b/Torch.Server/ViewModels/SessionSettingsViewModel.cs index 4498ae0..332a480 100644 --- a/Torch.Server/ViewModels/SessionSettingsViewModel.cs +++ b/Torch.Server/ViewModels/SessionSettingsViewModel.cs @@ -1,14 +1,7 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.ComponentModel; -using System.ComponentModel.DataAnnotations; -using System.Linq; -using Torch; -using Torch.Collections; -using Torch.Views; using VRage.Game; using VRage.Library.Utils; -using VRage.Serialization; namespace Torch.Server.ViewModels { diff --git a/Torch.Server/Views/AddWorkshopItemsDialog.xaml.cs b/Torch.Server/Views/AddWorkshopItemsDialog.xaml.cs index 18b00c8..fef7adb 100644 --- a/Torch.Server/Views/AddWorkshopItemsDialog.xaml.cs +++ b/Torch.Server/Views/AddWorkshopItemsDialog.xaml.cs @@ -1,17 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading.Tasks; +using System.Text.RegularExpressions; using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; namespace Torch.Server { diff --git a/Torch.Server/Views/ChatControl.xaml.cs b/Torch.Server/Views/ChatControl.xaml.cs index a9dcc1f..5e6817e 100644 --- a/Torch.Server/Views/ChatControl.xaml.cs +++ b/Torch.Server/Views/ChatControl.xaml.cs @@ -1,35 +1,20 @@ using System; using System.Collections.Generic; -using System.Collections.Specialized; -using System.Linq; using System.Reflection; -using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; -using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; -using System.Windows.Threading; using NLog; -using Torch; -using Sandbox; -using Sandbox.Engine.Multiplayer; using Sandbox.Game.Gui; -using Sandbox.Game.Multiplayer; using Sandbox.Game.World; using Torch.API; using Torch.API.Managers; using Torch.API.Session; -using Torch.Managers; -using Torch.Server.Managers; using Torch.Server.Views; -using VRage.Game; using Color = VRageMath.Color; namespace Torch.Server diff --git a/Torch.Server/Views/ConfigControl.xaml.cs b/Torch.Server/Views/ConfigControl.xaml.cs index fd1cb59..c57c3cb 100644 --- a/Torch.Server/Views/ConfigControl.xaml.cs +++ b/Torch.Server/Views/ConfigControl.xaml.cs @@ -6,17 +6,14 @@ using System.Runtime.CompilerServices; using System.Windows; using System.Windows.Controls; using System.Windows.Data; -using System.Windows.Media; using System.Windows.Threading; +using JetBrains.Annotations; using Sandbox; using Torch.API; using Torch.API.Managers; -using Torch.Server.Annotations; using Torch.Server.Managers; using Torch.Server.ViewModels; -using Torch.Views; using VRage.Game.ModAPI; -using VRage.Serialization; namespace Torch.Server.Views { diff --git a/Torch.Server/Views/Converters/BooleanAndConverter.cs b/Torch.Server/Views/Converters/BooleanAndConverter.cs index 2c88b1f..75355d9 100644 --- a/Torch.Server/Views/Converters/BooleanAndConverter.cs +++ b/Torch.Server/Views/Converters/BooleanAndConverter.cs @@ -1,9 +1,5 @@ using System; -using System.Collections.Generic; using System.Globalization; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Data; namespace Torch.Server.Views.Converters diff --git a/Torch.Server/Views/Converters/DefinitionToIdConverter.cs b/Torch.Server/Views/Converters/DefinitionToIdConverter.cs index 883ad67..ee11009 100644 --- a/Torch.Server/Views/Converters/DefinitionToIdConverter.cs +++ b/Torch.Server/Views/Converters/DefinitionToIdConverter.cs @@ -1,6 +1,5 @@ using System; using System.Globalization; -using System.Windows; using System.Windows.Data; using Sandbox.Definitions; using VRage.Game; diff --git a/Torch.Server/Views/Converters/ListConverter.cs b/Torch.Server/Views/Converters/ListConverter.cs index bc0e982..ce6f164 100644 --- a/Torch.Server/Views/Converters/ListConverter.cs +++ b/Torch.Server/Views/Converters/ListConverter.cs @@ -3,11 +3,8 @@ using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Globalization; -using System.Linq; using System.Text; -using System.Threading.Tasks; using System.Windows.Data; -using System.Windows.Navigation; namespace Torch.Server.Views.Converters { diff --git a/Torch.Server/Views/Converters/ListConverterWorkshopId.cs b/Torch.Server/Views/Converters/ListConverterWorkshopId.cs index 1771884..8451069 100644 --- a/Torch.Server/Views/Converters/ListConverterWorkshopId.cs +++ b/Torch.Server/Views/Converters/ListConverterWorkshopId.cs @@ -1,16 +1,12 @@ using System; using System.Collections; using System.Collections.Generic; -using System.ComponentModel; using System.Globalization; using System.Linq; using System.Text; -using System.Threading.Tasks; using System.Windows.Data; -using Sandbox.Engine.Networking; using Torch.Server.ViewModels; using Torch.Utils; -using VRage.Game; namespace Torch.Server.Views.Converters { diff --git a/Torch.Server/Views/Converters/Vector3DConverter.cs b/Torch.Server/Views/Converters/Vector3DConverter.cs index 0047c42..fd458d4 100644 --- a/Torch.Server/Views/Converters/Vector3DConverter.cs +++ b/Torch.Server/Views/Converters/Vector3DConverter.cs @@ -1,9 +1,5 @@ using System; -using System.Collections.Generic; using System.Globalization; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Data; using VRageMath; diff --git a/Torch.Server/Views/Entities/Blocks/BlockView.xaml.cs b/Torch.Server/Views/Entities/Blocks/BlockView.xaml.cs index 425283c..b1ce683 100644 --- a/Torch.Server/Views/Entities/Blocks/BlockView.xaml.cs +++ b/Torch.Server/Views/Entities/Blocks/BlockView.xaml.cs @@ -1,22 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using System.Windows; +using System.Windows; using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; -using Sandbox.ModAPI; -using Sandbox.ModAPI.Interfaces; -using Torch.Server.ViewModels.Blocks; -using VRage.Game.ModAPI; namespace Torch.Server.Views.Blocks { diff --git a/Torch.Server/Views/Entities/Blocks/PropertyView.xaml.cs b/Torch.Server/Views/Entities/Blocks/PropertyView.xaml.cs index 29a7c5d..73e9b23 100644 --- a/Torch.Server/Views/Entities/Blocks/PropertyView.xaml.cs +++ b/Torch.Server/Views/Entities/Blocks/PropertyView.xaml.cs @@ -1,17 +1,7 @@ -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Text; using System.Windows; using System.Windows.Controls; -using System.Windows.Controls.Primitives; using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; using Torch.Server.ViewModels.Blocks; using Torch.Server.Views.Converters; diff --git a/Torch.Server/Views/Entities/CharacterView.xaml.cs b/Torch.Server/Views/Entities/CharacterView.xaml.cs index b054887..1726927 100644 --- a/Torch.Server/Views/Entities/CharacterView.xaml.cs +++ b/Torch.Server/Views/Entities/CharacterView.xaml.cs @@ -1,17 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; +using System.Windows; using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; namespace Torch.Server.Views.Entities { diff --git a/Torch.Server/Views/Entities/GridView.xaml.cs b/Torch.Server/Views/Entities/GridView.xaml.cs index 36aa877..70a931e 100644 --- a/Torch.Server/Views/Entities/GridView.xaml.cs +++ b/Torch.Server/Views/Entities/GridView.xaml.cs @@ -1,17 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; +using System.Windows; using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; namespace Torch.Server.Views.Entities { diff --git a/Torch.Server/Views/Entities/VoxelMapView.xaml.cs b/Torch.Server/Views/Entities/VoxelMapView.xaml.cs index da1fdbc..e53d710 100644 --- a/Torch.Server/Views/Entities/VoxelMapView.xaml.cs +++ b/Torch.Server/Views/Entities/VoxelMapView.xaml.cs @@ -1,17 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; using Torch.Server.ViewModels.Entities; namespace Torch.Server.Views.Entities diff --git a/Torch.Server/Views/EntitiesControl.xaml.cs b/Torch.Server/Views/EntitiesControl.xaml.cs index 4cdfa45..cf15584 100644 --- a/Torch.Server/Views/EntitiesControl.xaml.cs +++ b/Torch.Server/Views/EntitiesControl.xaml.cs @@ -1,20 +1,8 @@ using System; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.Linq; -using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; using NLog; -using Torch.Collections; using Torch.Server.ViewModels; using Torch.Server.ViewModels.Blocks; using Torch.Server.ViewModels.Entities; diff --git a/Torch.Server/Views/Extensions.cs b/Torch.Server/Views/Extensions.cs index 47aeb5c..6b841f3 100644 --- a/Torch.Server/Views/Extensions.cs +++ b/Torch.Server/Views/Extensions.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; +using System.Windows; namespace Torch.Server.Views { diff --git a/Torch.Server/Views/LogViewerControl.xaml.cs b/Torch.Server/Views/LogViewerControl.xaml.cs index 2aa47d7..90f16a9 100644 --- a/Torch.Server/Views/LogViewerControl.xaml.cs +++ b/Torch.Server/Views/LogViewerControl.xaml.cs @@ -1,11 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; +using System.Collections.Generic; using System.Collections.Specialized; using System.Windows; using System.Windows.Controls; -using System.Windows.Media; -using Torch.Collections; using Torch.Server.ViewModels; namespace Torch.Server.Views; diff --git a/Torch.Server/Views/ModsControl.xaml.cs b/Torch.Server/Views/ModsControl.xaml.cs index 3fc7ec2..5c0e6c4 100644 --- a/Torch.Server/Views/ModsControl.xaml.cs +++ b/Torch.Server/Views/ModsControl.xaml.cs @@ -1,21 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; +using System.Diagnostics; using System.Windows; using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; -using Sandbox.Engine.Networking; -using VRage.Game; namespace Torch.Server { diff --git a/Torch.Server/Views/PlayerListControl.xaml.cs b/Torch.Server/Views/PlayerListControl.xaml.cs index 17268d6..4cc10b3 100644 --- a/Torch.Server/Views/PlayerListControl.xaml.cs +++ b/Torch.Server/Views/PlayerListControl.xaml.cs @@ -1,31 +1,12 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; using NLog; -using Torch; -using Sandbox; -using Sandbox.Engine.Multiplayer; -using Sandbox.Game.Gui; -using Sandbox.Game.Multiplayer; -using Sandbox.Game.World; -using Sandbox.ModAPI; using Torch.API; using Torch.API.Managers; using Torch.API.Session; -using Torch.Managers; using Torch.Server.Managers; -using Torch.Utils; using Torch.ViewModels; using VRage.Game.ModAPI; diff --git a/Torch.Server/Views/PluginBrowser.xaml.cs b/Torch.Server/Views/PluginBrowser.xaml.cs index 894e970..fb48ffe 100644 --- a/Torch.Server/Views/PluginBrowser.xaml.cs +++ b/Torch.Server/Views/PluginBrowser.xaml.cs @@ -3,24 +3,14 @@ using System.Collections.Generic; using System.ComponentModel; using System.IO; using System.Linq; -using System.Net; -using System.Net.Http; using System.Runtime.CompilerServices; -using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; +using JetBrains.Annotations; using NLog; -using Torch.API.WebAPI; using Torch.Collections; -using Torch.Server.Annotations; -using Torch.Managers; using Torch.API.Managers; using Torch.API.Plugins; using Torch.API.WebAPI.Plugin; diff --git a/Torch.Server/Views/PluginDownloader.xaml.cs b/Torch.Server/Views/PluginDownloader.xaml.cs index a4614d3..1cfdeae 100644 --- a/Torch.Server/Views/PluginDownloader.xaml.cs +++ b/Torch.Server/Views/PluginDownloader.xaml.cs @@ -1,18 +1,6 @@ using System; using System.Collections; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; -using Torch.API.WebAPI; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; using System.ComponentModel; using Torch.API.WebAPI.Plugin; diff --git a/Torch.Server/Views/PluginsControl.xaml.cs b/Torch.Server/Views/PluginsControl.xaml.cs index d4f291a..975a087 100644 --- a/Torch.Server/Views/PluginsControl.xaml.cs +++ b/Torch.Server/Views/PluginsControl.xaml.cs @@ -1,21 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.ComponentModel; +using System.ComponentModel; using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; -using NLog; using Torch.API; using Torch.API.Managers; using Torch.Managers; diff --git a/Torch.Server/Views/RoleEditor.xaml.cs b/Torch.Server/Views/RoleEditor.xaml.cs index b8c32ff..d574ee9 100644 --- a/Torch.Server/Views/RoleEditor.xaml.cs +++ b/Torch.Server/Views/RoleEditor.xaml.cs @@ -3,18 +3,7 @@ using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; -using Torch.Server.Managers; using Torch.Views; using VRage.Game.ModAPI; diff --git a/Torch.Server/Views/SessionSettingsView.xaml.cs b/Torch.Server/Views/SessionSettingsView.xaml.cs index b19821f..0b6a877 100644 --- a/Torch.Server/Views/SessionSettingsView.xaml.cs +++ b/Torch.Server/Views/SessionSettingsView.xaml.cs @@ -1,17 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; +using System.Windows; using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; using Torch.Server.ViewModels; namespace Torch.Server.Views diff --git a/Torch.Server/Views/ThemeControl.xaml.cs b/Torch.Server/Views/ThemeControl.xaml.cs index 88fec7f..66c984a 100644 --- a/Torch.Server/Views/ThemeControl.xaml.cs +++ b/Torch.Server/Views/ThemeControl.xaml.cs @@ -2,19 +2,11 @@ using System.Collections.Generic; using System.ComponentModel; using System.Linq; -using System.Runtime.CompilerServices; using System.Diagnostics; using System.Windows.Navigation; using System.Windows; using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Media; -using System.Windows.Threading; -using Torch.API.Managers; using Torch.API.Plugins; -using Torch.Server.Annotations; -using Torch.Server.Managers; -using Torch.Server.ViewModels; namespace Torch.Server.Views { diff --git a/Torch.Server/Views/TorchUI.xaml.cs b/Torch.Server/Views/TorchUI.xaml.cs index 880c4e3..bb3babd 100644 --- a/Torch.Server/Views/TorchUI.xaml.cs +++ b/Torch.Server/Views/TorchUI.xaml.cs @@ -1,26 +1,11 @@ using System; using System.ComponentModel; -using System.Diagnostics; -using System.IO; using System.Threading; using System.Threading.Tasks; -using System.Timers; using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; -using System.Windows.Threading; using NLog; using NLog.Targets.Wrappers; -using Sandbox; using Torch.API; -using Torch.API.Managers; -using Torch.Server.Managers; using Torch.Server.ViewModels; using Torch.Server.Views; using MessageBoxResult = System.Windows.MessageBoxResult; @@ -113,10 +98,10 @@ namespace Torch.Server //_config.Save(); //you idiot - if (_server?.State == ServerState.Running) + if (_server.CurrentSession is not null) _server.Stop(); - - Environment.Exit(0); + + _server.Destroy(); } } } diff --git a/Torch.Server/Views/ValidationRules/NumberValidationRule.cs b/Torch.Server/Views/ValidationRules/NumberValidationRule.cs index 6cff1d1..e6e873e 100644 --- a/Torch.Server/Views/ValidationRules/NumberValidationRule.cs +++ b/Torch.Server/Views/ValidationRules/NumberValidationRule.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Globalization; using System.Windows.Controls; namespace Torch.Server.Views.ValidationRules diff --git a/Torch.Server/Views/WorldGeneratorDialog.xaml.cs b/Torch.Server/Views/WorldGeneratorDialog.xaml.cs index 6034bae..d6f00bb 100644 --- a/Torch.Server/Views/WorldGeneratorDialog.xaml.cs +++ b/Torch.Server/Views/WorldGeneratorDialog.xaml.cs @@ -1,18 +1,8 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using NLog; -using Sandbox.Definitions; using Sandbox.Engine.Networking; using Sandbox.Game.World; using Torch.Server.Managers; @@ -22,7 +12,6 @@ using VRage; using VRage.Dedicated; using VRage.FileSystem; using VRage.Game; -using VRage.Game.Localization; using VRage.Utils; namespace Torch.Server diff --git a/Torch.Server/packages.lock.json b/Torch.Server/packages.lock.json index 08ff824..af7a6c4 100644 --- a/Torch.Server/packages.lock.json +++ b/Torch.Server/packages.lock.json @@ -165,6 +165,11 @@ "MonoMod.RuntimeDetour": "25.1.0-prerelease.1" } }, + "JetBrains.Annotations": { + "type": "Transitive", + "resolved": "2023.3.0", + "contentHash": "PHfnvdBUdGaTVG9bR/GEfxgTwWM0Z97Y6X3710wiljELBISipSfF5okn/vz+C2gfO+ihoEyVPjaJwn8ZalVukA==" + }, "MdXaml.Plugins": { "type": "Transitive", "resolved": "1.27.0", @@ -592,6 +597,7 @@ "torch.api": { "type": "Project", "dependencies": { + "JetBrains.Annotations": "[2023.3.0, )", "Microsoft.Extensions.Configuration.Binder": "[8.0.1, )", "NLog": "[5.3.2, )", "NuGet.Commands": "[6.9.1, )", diff --git a/Torch.Tests/ReflectionTestManager.cs b/Torch.Tests/ReflectionTestManager.cs index 61494a9..f094313 100644 --- a/Torch.Tests/ReflectionTestManager.cs +++ b/Torch.Tests/ReflectionTestManager.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Reflection; using Torch.Utils; diff --git a/Torch.Tests/TestUtils.cs b/Torch.Tests/TestUtils.cs index 286fc66..a03a673 100644 --- a/Torch.Tests/TestUtils.cs +++ b/Torch.Tests/TestUtils.cs @@ -1,11 +1,5 @@ using System; -using System.Collections.Generic; -using System.Diagnostics; using System.IO; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; using Torch.Utils; namespace Torch.Tests diff --git a/Torch.Tests/packages.lock.json b/Torch.Tests/packages.lock.json index 3d91802..29de19a 100644 --- a/Torch.Tests/packages.lock.json +++ b/Torch.Tests/packages.lock.json @@ -46,6 +46,11 @@ "MonoMod.RuntimeDetour": "25.1.0-prerelease.1" } }, + "JetBrains.Annotations": { + "type": "Transitive", + "resolved": "2023.3.0", + "contentHash": "PHfnvdBUdGaTVG9bR/GEfxgTwWM0Z97Y6X3710wiljELBISipSfF5okn/vz+C2gfO+ihoEyVPjaJwn8ZalVukA==" + }, "MahApps.Metro": { "type": "Transitive", "resolved": "2.4.10", @@ -465,6 +470,7 @@ "torch.api": { "type": "Project", "dependencies": { + "JetBrains.Annotations": "[2023.3.0, )", "Microsoft.Extensions.Configuration.Binder": "[8.0.1, )", "NLog": "[5.3.2, )", "NuGet.Commands": "[6.9.1, )", diff --git a/Torch/Collections/BinaryMinHeap.cs b/Torch/Collections/BinaryMinHeap.cs index 78f0294..067056f 100644 --- a/Torch/Collections/BinaryMinHeap.cs +++ b/Torch/Collections/BinaryMinHeap.cs @@ -1,8 +1,6 @@ using System; -using System.Collections; using System.Collections.Generic; using System.Diagnostics; -using System.Linq; namespace Torch.Collections { diff --git a/Torch/Collections/KeyTree.cs b/Torch/Collections/KeyTree.cs index 4026488..676397d 100644 --- a/Torch/Collections/KeyTree.cs +++ b/Torch/Collections/KeyTree.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; namespace Torch.Collections { diff --git a/Torch/Collections/MTObservableCollection.cs b/Torch/Collections/MTObservableCollection.cs index 4973117..7189d47 100644 --- a/Torch/Collections/MTObservableCollection.cs +++ b/Torch/Collections/MTObservableCollection.cs @@ -1,13 +1,7 @@ using System; -using System.Collections; -using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.Specialized; -using System.ComponentModel; -using System.Linq; -using System.Text; using System.Threading; -using System.Threading.Tasks; using Torch.Utils; namespace Torch.Collections diff --git a/Torch/Collections/MtObservableCollectionBase.cs b/Torch/Collections/MtObservableCollectionBase.cs index ce612f0..f7ae0b0 100644 --- a/Torch/Collections/MtObservableCollectionBase.cs +++ b/Torch/Collections/MtObservableCollectionBase.cs @@ -4,10 +4,7 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel; -using System.Linq; -using System.Text; using System.Threading; -using System.Threading.Tasks; using PropertyChanged; using Torch.Utils; diff --git a/Torch/Collections/MtObservableList.cs b/Torch/Collections/MtObservableList.cs index d8ba646..3921bc3 100644 --- a/Torch/Collections/MtObservableList.cs +++ b/Torch/Collections/MtObservableList.cs @@ -2,9 +2,6 @@ using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using PropertyChanged; using Torch.Utils; diff --git a/Torch/Collections/RollingAverage.cs b/Torch/Collections/RollingAverage.cs index 3254657..7f4fc39 100644 --- a/Torch/Collections/RollingAverage.cs +++ b/Torch/Collections/RollingAverage.cs @@ -1,9 +1,4 @@ -using System; -using System.CodeDom; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Linq; namespace Torch.Collections { diff --git a/Torch/Collections/SortedView.cs b/Torch/Collections/SortedView.cs index 392e0dc..40eb2bb 100644 --- a/Torch/Collections/SortedView.cs +++ b/Torch/Collections/SortedView.cs @@ -3,12 +3,7 @@ using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel; -using System.Linq; using System.Runtime.CompilerServices; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using Havok; using NLog; namespace Torch.Collections diff --git a/Torch/Collections/SystemSortedView.cs b/Torch/Collections/SystemSortedView.cs index d1e3f14..5364819 100644 --- a/Torch/Collections/SystemSortedView.cs +++ b/Torch/Collections/SystemSortedView.cs @@ -4,10 +4,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; using System.ComponentModel; -using System.Linq; using System.Runtime.CompilerServices; -using System.Text; -using System.Threading.Tasks; namespace Torch.Collections { diff --git a/Torch/Collections/TransformComparer.cs b/Torch/Collections/TransformComparer.cs index 893fa17..48ac549 100644 --- a/Torch/Collections/TransformComparer.cs +++ b/Torch/Collections/TransformComparer.cs @@ -1,8 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Torch.Collections { diff --git a/Torch/Collections/TransformEnumerator.cs b/Torch/Collections/TransformEnumerator.cs index 5a3a431..22400a4 100644 --- a/Torch/Collections/TransformEnumerator.cs +++ b/Torch/Collections/TransformEnumerator.cs @@ -1,9 +1,6 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Torch.Collections { diff --git a/Torch/Commands/CategoryAttribute.cs b/Torch/Commands/CategoryAttribute.cs index 409dce9..1652c44 100644 --- a/Torch/Commands/CategoryAttribute.cs +++ b/Torch/Commands/CategoryAttribute.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Torch.Commands { diff --git a/Torch/Commands/Command.cs b/Torch/Commands/Command.cs index ffc303c..1efd467 100644 --- a/Torch/Commands/Command.cs +++ b/Torch/Commands/Command.cs @@ -5,7 +5,6 @@ using System.Linq; using System.Reflection; using System.Text; using NLog; -using Torch.API; using Torch.API.Plugins; using Torch.Commands.Permissions; using VRage.Game; diff --git a/Torch/Commands/CommandAttribute.cs b/Torch/Commands/CommandAttribute.cs index 9da06d0..a92a7ea 100644 --- a/Torch/Commands/CommandAttribute.cs +++ b/Torch/Commands/CommandAttribute.cs @@ -1,9 +1,12 @@ using System; using System.Collections.Generic; using System.Linq; +using JetBrains.Annotations; namespace Torch.Commands { + [MeansImplicitUse] + [AttributeUsage(AttributeTargets.Method)] public class CommandAttribute : Attribute { public string Name { get; } diff --git a/Torch/Commands/CommandContext.cs b/Torch/Commands/CommandContext.cs index 2f916f7..e524856 100644 --- a/Torch/Commands/CommandContext.cs +++ b/Torch/Commands/CommandContext.cs @@ -1,8 +1,4 @@ using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Text.RegularExpressions; -using Sandbox.Engine.Networking; using Sandbox.Game.Multiplayer; using Torch.API; using Torch.API.Managers; diff --git a/Torch/Commands/CommandManager.cs b/Torch/Commands/CommandManager.cs index 87a25b4..5827047 100644 --- a/Torch/Commands/CommandManager.cs +++ b/Torch/Commands/CommandManager.cs @@ -10,10 +10,7 @@ using Torch.API; using Torch.API.Managers; using Torch.API.Plugins; using Torch.Managers; -using Torch.Utils; -using VRage.Game; using VRage.Game.ModAPI; -using VRage.Network; namespace Torch.Commands { diff --git a/Torch/Commands/CommandModule.cs b/Torch/Commands/CommandModule.cs index 74a7ad6..23d5c05 100644 --- a/Torch/Commands/CommandModule.cs +++ b/Torch/Commands/CommandModule.cs @@ -1,6 +1,4 @@ -using Torch.API; - -namespace Torch.Commands +namespace Torch.Commands { public class CommandModule { diff --git a/Torch/Commands/CommandTree.cs b/Torch/Commands/CommandTree.cs index d67a177..eb943e2 100644 --- a/Torch/Commands/CommandTree.cs +++ b/Torch/Commands/CommandTree.cs @@ -2,10 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using System.Threading.Tasks; -using Torch.API; using VRage.Collections; -using VRage.Library.Collections; namespace Torch.Commands { diff --git a/Torch/Commands/ConsoleCommandContext.cs b/Torch/Commands/ConsoleCommandContext.cs index 9a1cc08..364e39c 100644 --- a/Torch/Commands/ConsoleCommandContext.cs +++ b/Torch/Commands/ConsoleCommandContext.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Text; using Torch.API; using Torch.API.Managers; using Torch.API.Plugins; diff --git a/Torch/Commands/Permissions/PermissionAttribute.cs b/Torch/Commands/Permissions/PermissionAttribute.cs index 570ce5b..402a76c 100644 --- a/Torch/Commands/Permissions/PermissionAttribute.cs +++ b/Torch/Commands/Permissions/PermissionAttribute.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using VRage.Game.ModAPI; namespace Torch.Commands.Permissions diff --git a/Torch/Commands/Permissions/PermissonsSystem.cs b/Torch/Commands/Permissions/PermissonsSystem.cs index ab0267b..4491a21 100644 --- a/Torch/Commands/Permissions/PermissonsSystem.cs +++ b/Torch/Commands/Permissions/PermissonsSystem.cs @@ -1,8 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Sandbox.Game.World; using VRage.Game.ModAPI; diff --git a/Torch/Commands/TorchCommands.cs b/Torch/Commands/TorchCommands.cs index fc3616b..90fe69b 100644 --- a/Torch/Commands/TorchCommands.cs +++ b/Torch/Commands/TorchCommands.cs @@ -1,17 +1,12 @@ using System; using System.Collections; -using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Net; using System.Text; using System.Threading; using System.Threading.Tasks; -using System.Timers; using NLog; -using Sandbox.Game.Multiplayer; -using Sandbox.ModAPI; -using Torch; using Torch.API; using Torch.API.Managers; using Torch.API.Session; @@ -206,9 +201,6 @@ namespace Torch.Commands _restartPending = true; - if (!save) - Log.Warn("Restart without save is not possible. Feature is deprecated"); - Task.Run(() => { var countdown = RestartCountdown(countdownSeconds, save).GetEnumerator(); @@ -281,8 +273,13 @@ namespace Torch.Commands } + if (save) + DoSave().Wait(); + Log.Info("Stopping server."); - Context.Torch.Invoke(() => Context.Torch.Stop()); + + Context.Torch.Stop(); + Context.Torch.Destroy(); yield break; } } @@ -323,9 +320,13 @@ namespace Torch.Commands Context.Torch.CurrentSession.Managers.GetManager() .SendMessageAsSelf($"Saving game before restart."); } + + if (save) + DoSave().Wait(); Log.Info("Restarting server."); - Context.Torch.Invoke(() => Context.Torch.Restart(save)); + + Context.Torch.Restart(false); yield break; } diff --git a/Torch/Event/EventShimAttribute.cs b/Torch/Event/EventShimAttribute.cs index 8b2d25e..17ef7be 100644 --- a/Torch/Event/EventShimAttribute.cs +++ b/Torch/Event/EventShimAttribute.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Torch.Event { diff --git a/Torch/Extensions/DispatcherExtensions.cs b/Torch/Extensions/DispatcherExtensions.cs index 7d4ea60..8c550f8 100644 --- a/Torch/Extensions/DispatcherExtensions.cs +++ b/Torch/Extensions/DispatcherExtensions.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Threading; namespace Torch diff --git a/Torch/Extensions/ICollectionExtensions.cs b/Torch/Extensions/ICollectionExtensions.cs index a80fbfe..6ac2a9e 100644 --- a/Torch/Extensions/ICollectionExtensions.cs +++ b/Torch/Extensions/ICollectionExtensions.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; using System.ComponentModel; -using System.Windows.Threading; using PropertyChanged; namespace Torch diff --git a/Torch/Extensions/MyPlayerCollectionExtensions.cs b/Torch/Extensions/MyPlayerCollectionExtensions.cs index aa9bf39..b4e3551 100644 --- a/Torch/Extensions/MyPlayerCollectionExtensions.cs +++ b/Torch/Extensions/MyPlayerCollectionExtensions.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Sandbox.Game.Multiplayer; +using Sandbox.Game.Multiplayer; using Sandbox.Game.World; namespace Torch diff --git a/Torch/Extensions/StringExtensions.cs b/Torch/Extensions/StringExtensions.cs index 204c87e..e9d6ff7 100644 --- a/Torch/Extensions/StringExtensions.cs +++ b/Torch/Extensions/StringExtensions.cs @@ -1,9 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Text.RegularExpressions; -using System.Threading.Tasks; namespace Torch { diff --git a/Torch/Managers/ChatManager/ChatManagerClient.cs b/Torch/Managers/ChatManager/ChatManagerClient.cs index 2cfcf63..cb0d65d 100644 --- a/Torch/Managers/ChatManager/ChatManagerClient.cs +++ b/Torch/Managers/ChatManager/ChatManagerClient.cs @@ -1,13 +1,7 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Media; using NLog; using Sandbox.Engine.Multiplayer; using Sandbox.Engine.Networking; -using Sandbox.Game.Entities.Character; using Sandbox.Game.Gui; using Sandbox.Game.Multiplayer; using Sandbox.Game.World; @@ -16,7 +10,6 @@ using Torch.API; using Torch.API.Managers; using Torch.Utils; using VRage.Game; -using VRageMath; using Color = VRageMath.Color; namespace Torch.Managers.ChatManager @@ -82,8 +75,12 @@ namespace Torch.Managers.ChatManager { _chatMessageRecievedReplacer = _chatMessageReceivedFactory.Invoke(); _scriptedChatMessageRecievedReplacer = _scriptedChatMessageReceivedFactory.Invoke(); - _chatMessageRecievedReplacer.Replace(Multiplayer_ChatMessageReceived, MyMultiplayer.Static); - _scriptedChatMessageRecievedReplacer.Replace(Multiplayer_ScriptedChatMessageReceived, MyMultiplayer.Static); + _chatMessageRecievedReplacer.Replace( + new Action(Multiplayer_ChatMessageReceived), + MyMultiplayer.Static); + _scriptedChatMessageRecievedReplacer.Replace( + new Action(Multiplayer_ScriptedChatMessageReceived), + MyMultiplayer.Static); } else { diff --git a/Torch/Managers/ChatManager/ChatManagerServer.cs b/Torch/Managers/ChatManager/ChatManagerServer.cs index bb61234..05410d0 100644 --- a/Torch/Managers/ChatManager/ChatManagerServer.cs +++ b/Torch/Managers/ChatManager/ChatManagerServer.cs @@ -1,10 +1,6 @@ using System; using System.Collections.Generic; -using System.Data; -using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; using NLog; using Sandbox.Engine.Multiplayer; using Sandbox.Engine.Networking; @@ -15,10 +11,8 @@ using Torch.API; using Torch.API.Managers; using Torch.Managers.PatchManager; using Torch.Utils; -using VRage; using VRage.Collections; using VRage.Game; -using VRage.Library.Collections; using VRage.Network; using VRageMath; diff --git a/Torch/Managers/DependencyManager.cs b/Torch/Managers/DependencyManager.cs index a334ece..32dfc2a 100644 --- a/Torch/Managers/DependencyManager.cs +++ b/Torch/Managers/DependencyManager.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Generic; using System.Linq; using System.Reflection; diff --git a/Torch/Managers/EntityManager.cs b/Torch/Managers/EntityManager.cs index ff6a591..3b57fa1 100644 --- a/Torch/Managers/EntityManager.cs +++ b/Torch/Managers/EntityManager.cs @@ -1,34 +1,12 @@ -using System; -using System.Collections.Generic; -using System.IO; +using System.IO; using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using System.Timers; using NLog; -using Sandbox; -using Sandbox.Engine.Multiplayer; using Sandbox.Game.Entities; -using Sandbox.Game.Entities.Blocks; -using Sandbox.Game.Multiplayer; -using Sandbox.Game.World; -using Sandbox.ModAPI; -using SpaceEngineers.Game.Entities.Blocks; -using SpaceEngineers.Game.ModAPI; using Torch.API; -using Torch.API.Managers; -using Torch.API.Plugins; -using VRage; -using VRage.Collections; -using VRage.Game; -using VRage.Game.Entity; using VRage.Game.ModAPI; using VRage.Groups; -using VRage.ModAPI; using VRage.ObjectBuilders; using VRage.ObjectBuilders.Private; -using VRage.Sync; using VRageMath; namespace Torch.Managers diff --git a/Torch/Managers/FilesystemManager.cs b/Torch/Managers/FilesystemManager.cs index 7cc8c45..76c45a7 100644 --- a/Torch/Managers/FilesystemManager.cs +++ b/Torch/Managers/FilesystemManager.cs @@ -1,10 +1,5 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; using NLog; using Torch.API; diff --git a/Torch/Managers/Manager.cs b/Torch/Managers/Manager.cs index 73c6ae3..0942ed4 100644 --- a/Torch/Managers/Manager.cs +++ b/Torch/Managers/Manager.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Torch.API; using Torch.API.Managers; diff --git a/Torch/Managers/MultiplayerManagerBase.cs b/Torch/Managers/MultiplayerManagerBase.cs index 30bf775..cd01791 100644 --- a/Torch/Managers/MultiplayerManagerBase.cs +++ b/Torch/Managers/MultiplayerManagerBase.cs @@ -1,40 +1,18 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.ComponentModel; -using System.Diagnostics; using System.Linq; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Data; -using System.Windows.Threading; using NLog; -using Torch; -using Sandbox; using Sandbox.Engine.Multiplayer; -using Sandbox.Engine.Networking; -using Sandbox.Game.Entities.Character; using Sandbox.Game.Multiplayer; using Sandbox.Game.World; -using Sandbox.ModAPI; using Torch.API; using Torch.API.Managers; using Torch.Collections; -using Torch.Commands; using Torch.Utils; using Torch.ViewModels; -using VRage.Game; using VRage.Game.ModAPI; using VRage.GameServices; -using VRage.Library.Collections; -using VRage.Network; -using VRage.Steam; -using VRage.Utils; namespace Torch.Managers { diff --git a/Torch/Managers/NetworkManager/NetworkManager.cs b/Torch/Managers/NetworkManager/NetworkManager.cs index 1bb9a95..e24e930 100644 --- a/Torch/Managers/NetworkManager/NetworkManager.cs +++ b/Torch/Managers/NetworkManager/NetworkManager.cs @@ -3,8 +3,6 @@ using System.Collections.Generic; using System.Reflection; using NLog; using Sandbox.Engine.Multiplayer; -using Torch.API; -using Torch.API.Managers; using VRage.Network; using VRageMath; diff --git a/Torch/Managers/PatchManager/EmitExtensions.cs b/Torch/Managers/PatchManager/EmitExtensions.cs index dad1a1a..614eab8 100644 --- a/Torch/Managers/PatchManager/EmitExtensions.cs +++ b/Torch/Managers/PatchManager/EmitExtensions.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.Reflection.Emit; using Torch.Managers.PatchManager.MSIL; -using Torch.Managers.PatchManager.Transpile; namespace Torch.Managers.PatchManager { diff --git a/Torch/Managers/PatchManager/MSIL/MsilArgument.cs b/Torch/Managers/PatchManager/MSIL/MsilArgument.cs index cb2e081..3dfa197 100644 --- a/Torch/Managers/PatchManager/MSIL/MsilArgument.cs +++ b/Torch/Managers/PatchManager/MSIL/MsilArgument.cs @@ -1,10 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Reflection.Emit; -using System.Text; -using System.Threading.Tasks; namespace Torch.Managers.PatchManager.MSIL { diff --git a/Torch/Managers/PatchManager/MSIL/MsilInstruction.cs b/Torch/Managers/PatchManager/MSIL/MsilInstruction.cs index c0fadd6..fce1a1a 100644 --- a/Torch/Managers/PatchManager/MSIL/MsilInstruction.cs +++ b/Torch/Managers/PatchManager/MSIL/MsilInstruction.cs @@ -6,11 +6,7 @@ using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Text; -using System.Windows.Documents; using HarmonyLib; -using Mono.Cecil; -using Mono.Cecil.Cil; -using MonoMod.Utils; using Torch.Managers.PatchManager.Transpile; using Torch.Utils; using VRage.Game.VisualScripting; diff --git a/Torch/Managers/PatchManager/MSIL/MsilInstructionExtensions.cs b/Torch/Managers/PatchManager/MSIL/MsilInstructionExtensions.cs index b0b8532..f775ce0 100644 --- a/Torch/Managers/PatchManager/MSIL/MsilInstructionExtensions.cs +++ b/Torch/Managers/PatchManager/MSIL/MsilInstructionExtensions.cs @@ -1,10 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; using System.Reflection.Emit; -using System.Text; -using System.Threading.Tasks; namespace Torch.Managers.PatchManager.MSIL { diff --git a/Torch/Managers/PatchManager/MSIL/MsilLocal.cs b/Torch/Managers/PatchManager/MSIL/MsilLocal.cs index 4b9c4a1..1c3d48d 100644 --- a/Torch/Managers/PatchManager/MSIL/MsilLocal.cs +++ b/Torch/Managers/PatchManager/MSIL/MsilLocal.cs @@ -1,11 +1,6 @@ using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; using System.Reflection; using System.Reflection.Emit; -using System.Text; -using System.Threading.Tasks; namespace Torch.Managers.PatchManager.MSIL { diff --git a/Torch/Managers/PatchManager/MSIL/MsilOperandInline.cs b/Torch/Managers/PatchManager/MSIL/MsilOperandInline.cs index 9a13d67..9e9b36e 100644 --- a/Torch/Managers/PatchManager/MSIL/MsilOperandInline.cs +++ b/Torch/Managers/PatchManager/MSIL/MsilOperandInline.cs @@ -1,11 +1,9 @@ using System; using System.Diagnostics; using System.IO; -using System.Linq; using System.Reflection; using System.Reflection.Emit; using Torch.Managers.PatchManager.Transpile; -using Torch.Utils; namespace Torch.Managers.PatchManager.MSIL { diff --git a/Torch/Managers/PatchManager/MSIL/MsilTryCatchOperation.cs b/Torch/Managers/PatchManager/MSIL/MsilTryCatchOperation.cs index 7f555f4..66e9656 100644 --- a/Torch/Managers/PatchManager/MSIL/MsilTryCatchOperation.cs +++ b/Torch/Managers/PatchManager/MSIL/MsilTryCatchOperation.cs @@ -1,9 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; namespace Torch.Managers.PatchManager.MSIL { diff --git a/Torch/Managers/PatchManager/PatchManager.cs b/Torch/Managers/PatchManager/PatchManager.cs index b968381..a168602 100644 --- a/Torch/Managers/PatchManager/PatchManager.cs +++ b/Torch/Managers/PatchManager/PatchManager.cs @@ -7,7 +7,6 @@ using System.Threading; using HarmonyLib; using NLog; using Torch.API; -using Torch.Managers.PatchManager.Transpile; namespace Torch.Managers.PatchManager { diff --git a/Torch/Managers/PatchManager/PatchShimAttribute.cs b/Torch/Managers/PatchManager/PatchShimAttribute.cs index fcac873..6ff4079 100644 --- a/Torch/Managers/PatchManager/PatchShimAttribute.cs +++ b/Torch/Managers/PatchManager/PatchShimAttribute.cs @@ -1,8 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using JetBrains.Annotations; namespace Torch.Managers.PatchManager { @@ -14,6 +11,7 @@ namespace Torch.Managers.PatchManager /// Patch shims should be singleton, and have one method of signature void Patch(PatchContext) /// [AttributeUsage(AttributeTargets.Class)] + [MeansImplicitUse] public class PatchShimAttribute : Attribute { } diff --git a/Torch/Managers/PatchManager/PatchUtilities.cs b/Torch/Managers/PatchManager/PatchUtilities.cs index 10cc4b0..5ca92bb 100644 --- a/Torch/Managers/PatchManager/PatchUtilities.cs +++ b/Torch/Managers/PatchManager/PatchUtilities.cs @@ -3,13 +3,8 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Reflection.Emit; -using System.Runtime.CompilerServices; -using System.Text; -using System.Threading.Tasks; -using NLog; using Torch.Managers.PatchManager.MSIL; using Torch.Managers.PatchManager.Transpile; -using Torch.Utils; namespace Torch.Managers.PatchManager { diff --git a/Torch/Managers/PatchManager/Transpile/LoggingILGenerator.cs b/Torch/Managers/PatchManager/Transpile/LoggingILGenerator.cs index a9ae5d5..f4e1c18 100644 --- a/Torch/Managers/PatchManager/Transpile/LoggingILGenerator.cs +++ b/Torch/Managers/PatchManager/Transpile/LoggingILGenerator.cs @@ -3,8 +3,6 @@ using System.Diagnostics; using System.Linq; using System.Reflection; using System.Reflection.Emit; -using Mono.Cecil.Cil; -using MonoMod.Utils.Cil; using NLog; using Torch.Utils; using OpCode = System.Reflection.Emit.OpCode; diff --git a/Torch/Managers/PatchManager/Transpile/MethodContext.cs b/Torch/Managers/PatchManager/Transpile/MethodContext.cs index 9062e00..c8b003e 100644 --- a/Torch/Managers/PatchManager/Transpile/MethodContext.cs +++ b/Torch/Managers/PatchManager/Transpile/MethodContext.cs @@ -7,8 +7,6 @@ using System.Reflection; using System.Reflection.Emit; using NLog; using Torch.Managers.PatchManager.MSIL; -using Torch.Utils; -using VRage.Game.VisualScripting.Utils; namespace Torch.Managers.PatchManager.Transpile { diff --git a/Torch/Managers/PatchManager/Transpile/MethodTranspiler.cs b/Torch/Managers/PatchManager/Transpile/MethodTranspiler.cs index 6806642..b171a96 100644 --- a/Torch/Managers/PatchManager/Transpile/MethodTranspiler.cs +++ b/Torch/Managers/PatchManager/Transpile/MethodTranspiler.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Text; -using System.Windows.Documents; using NLog; using Torch.Managers.PatchManager.MSIL; diff --git a/Torch/Managers/UpdateManager.cs b/Torch/Managers/UpdateManager.cs index c19ed31..9b3774f 100644 --- a/Torch/Managers/UpdateManager.cs +++ b/Torch/Managers/UpdateManager.cs @@ -1,18 +1,11 @@ using System; -using System.Collections.Generic; using System.IO; using System.IO.Compression; -using System.IO.Packaging; -using System.Linq; -using System.Net; using System.Net.Http; -using System.Text; -using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using NLog; using Torch.API; -using Torch.API.WebAPI; using Torch.API.WebAPI.Update; namespace Torch.Managers diff --git a/Torch/Patches/AutoSavePatch.cs b/Torch/Patches/AutoSavePatch.cs new file mode 100644 index 0000000..d1d668d --- /dev/null +++ b/Torch/Patches/AutoSavePatch.cs @@ -0,0 +1,54 @@ +using NLog; +using Sandbox.Game.World; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Reflection.Emit; +using Torch.Managers.PatchManager; +using Torch.Managers.PatchManager.MSIL; +using Torch.Utils; + +namespace Torch.Patches +{ + /* + The purpose of this patch is to prevent an autosave from occurring unintentionally during world unloading initiated by the !stop or !restart command. + Due to the user using the command(s) potentially performing an autosave or an opting out of an autosave, Keen's autosave code during unloading has to be disabled. + Setting MySandboxGame.ConfigDedicated.RestartSave to false can resolve this issue, but this method (patch method) prevents us from changing the config file to prevent confusion. + */ + [PatchShim] + public static class AutoSavePatch + { + private static readonly Logger Log = LogManager.GetCurrentClassLogger(); + + public static void Patch(PatchContext ctx) + { + ctx.GetPattern(Info.OfMethod(nameof(MySession.Unload))).AddTranspiler(nameof(Transpile)); + Log.Info("Patching autosave on unload."); + } + + private static IEnumerable Transpile(IEnumerable instructions) + { + var msil = instructions.ToList(); + + for (var i = 0; i < msil.Count; i++) + { + var instruction = msil[i]; + + if (instruction.OpCode != OpCodes.Ldsfld || instruction.Operand is not + MsilOperandInline.MsilOperandReflected + operandReflected + || operandReflected.Value.FieldType != typeof(bool) || + operandReflected.Value.Name != "IsDedicated") continue; + + for (var c = 0; c < 13; c++) + { + msil.RemoveAt(i); + } + + break; + } + + return msil; + } + } +} diff --git a/Torch/Patches/EntityIdentifierPatch.cs b/Torch/Patches/EntityIdentifierPatch.cs index 4a6229d..0229c5c 100644 --- a/Torch/Patches/EntityIdentifierPatch.cs +++ b/Torch/Patches/EntityIdentifierPatch.cs @@ -11,13 +11,13 @@ namespace Torch.Patches; internal static class EntityIdentifierPatch { [ReflectedGetter(Type = typeof(MyEntityIdentifier), Name = "m_perThreadData")] - private static Func _perThreadGetter = null!; + private static Func _perThreadGetter; [ReflectedGetter(TypeName = "VRage.MyEntityIdentifier+PerThreadData, VRage.Game", Name = "EntityList")] - private static Func> _entityDataGetter = null; + private static Func> _entityDataGetter; [ReflectedMethodInfo(typeof(MyEntityIdentifier), "GetPerThreadEntities")] - private static MethodInfo _getPerThreadMethod = null!; + private static MethodInfo _getPerThreadMethod; public static void Patch(PatchContext context) { diff --git a/Torch/Patches/GameAnalyticsPatch.cs b/Torch/Patches/GameAnalyticsPatch.cs index e3f66ab..86ed15e 100644 --- a/Torch/Patches/GameAnalyticsPatch.cs +++ b/Torch/Patches/GameAnalyticsPatch.cs @@ -1,9 +1,7 @@ using System; -using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using NLog; -using NLog.Config; using Torch.Managers.PatchManager; using Torch.Utils; diff --git a/Torch/Patches/GameStatePatchShim.cs b/Torch/Patches/GameStatePatchShim.cs index 3505cab..176edcd 100644 --- a/Torch/Patches/GameStatePatchShim.cs +++ b/Torch/Patches/GameStatePatchShim.cs @@ -11,12 +11,10 @@ namespace Torch.Patches [PatchShim] internal static class GameStatePatchShim { -#pragma warning disable 649 [ReflectedMethodInfo(typeof(MySandboxGame), nameof(MySandboxGame.Dispose))] private static MethodInfo _sandboxGameDispose; [ReflectedMethodInfo(typeof(MySandboxGame), "Initialize")] private static MethodInfo _sandboxGameInit; -#pragma warning restore 649 internal static void Patch(PatchContext target) { diff --git a/Torch/Patches/KeenLogPatch.cs b/Torch/Patches/KeenLogPatch.cs index b38ffca..05bf75c 100644 --- a/Torch/Patches/KeenLogPatch.cs +++ b/Torch/Patches/KeenLogPatch.cs @@ -1,12 +1,7 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; using System.Text; -using System.Threading; -using System.Threading.Tasks; using NLog; -using Torch.API; using Torch.Managers.PatchManager; using Torch.Utils; using VRage; @@ -18,8 +13,7 @@ namespace Torch.Patches internal static class KeenLogPatch { private static readonly Logger _log = LogManager.GetLogger("Keen"); - -#pragma warning disable 649 + [ReflectedMethodInfo(typeof(MyLog), nameof(MyLog.Log), Parameters = new[] { typeof(MyLogSeverity), typeof(StringBuilder) })] private static MethodInfo _logStringBuilder; @@ -49,7 +43,6 @@ namespace Torch.Patches [ReflectedMethodInfo(typeof(MyLog), nameof(MyLog.Close))] private static MethodInfo _logClose; -#pragma warning restore 649 public static void Patch(PatchContext context) diff --git a/Torch/Patches/LoaderHook.cs b/Torch/Patches/LoaderHook.cs index 71ea5b1..26cd161 100644 --- a/Torch/Patches/LoaderHook.cs +++ b/Torch/Patches/LoaderHook.cs @@ -1,5 +1,4 @@ -using System.Collections; -using System.Diagnostics; +using System.Diagnostics; using System.Linq; using System.Reflection; using NLog; @@ -17,7 +16,7 @@ internal static class LoaderHook private static Stopwatch _stopwatch; [ReflectedMethodInfo(typeof(MyScriptManager), nameof(MyScriptManager.LoadData))] - private static MethodInfo _compilerLoadData = null!; + private static MethodInfo _compilerLoadData; public static void Patch(PatchContext context) { diff --git a/Torch/Patches/ModsDownloadingPatch.cs b/Torch/Patches/ModsDownloadingPatch.cs index d2ef647..89eb115 100644 --- a/Torch/Patches/ModsDownloadingPatch.cs +++ b/Torch/Patches/ModsDownloadingPatch.cs @@ -1,13 +1,9 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.Linq; using System.Reflection; using NLog; -using Sandbox; using Sandbox.Engine.Networking; -using Torch.API; using Torch.Managers.PatchManager; -using Torch.Managers.PatchManager.MSIL; using Torch.Utils; using VRage.Game; using VRage.GameServices; @@ -18,10 +14,8 @@ namespace Torch.Patches internal static class ModsDownloadingPatch { private static readonly Logger _log = LogManager.GetCurrentClassLogger(); -#pragma warning disable 649 [ReflectedMethodInfo(typeof(MyWorkshop), nameof(MyWorkshop.DownloadWorldModsBlocking))] private static MethodInfo _downloadWorldModsBlockingMethod; -#pragma warning restore 649 public static void Patch(PatchContext ctx) { diff --git a/Torch/Patches/PhysicsMemoryPatch.cs b/Torch/Patches/PhysicsMemoryPatch.cs index da5efee..bb13517 100644 --- a/Torch/Patches/PhysicsMemoryPatch.cs +++ b/Torch/Patches/PhysicsMemoryPatch.cs @@ -1,8 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Text; using System.Threading; using System.Threading.Tasks; using Havok; diff --git a/Torch/Patches/ProgramableBlockPatch.cs b/Torch/Patches/ProgramableBlockPatch.cs index ab551f4..f6cbfae 100644 --- a/Torch/Patches/ProgramableBlockPatch.cs +++ b/Torch/Patches/ProgramableBlockPatch.cs @@ -1,4 +1,3 @@ -using System; using System.Reflection; using Sandbox.Game.Entities.Blocks; using Sandbox.Game.World; @@ -13,11 +12,11 @@ namespace Torch.Patches; public static class ProgramableBlockPatch { [ReflectedMethodInfo(typeof(MyProgrammableBlock), "Compile")] - private static MethodInfo CompileMethod = null!; + private static MethodInfo _compileMethod; public static void Patch(PatchContext context) { - context.GetPattern(CompileMethod).AddPrefix(); + context.GetPattern(_compileMethod).AddPrefix(); } private static bool Prefix(MyProgrammableBlock __instance, string program, string storage, bool instantiate) diff --git a/Torch/Patches/ScriptCompilerPatch.cs b/Torch/Patches/ScriptCompilerPatch.cs index 706847c..6ab2a13 100644 --- a/Torch/Patches/ScriptCompilerPatch.cs +++ b/Torch/Patches/ScriptCompilerPatch.cs @@ -1,5 +1,4 @@ using System; -using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.Immutable; @@ -12,8 +11,6 @@ using System.Reflection.Emit; using System.Text.RegularExpressions; using System.Threading; using Microsoft.CodeAnalysis; -using ParallelTasks; -using ProtoBuf; using Torch.Managers.PatchManager; using Torch.Managers.PatchManager.MSIL; using Torch.Utils; @@ -26,10 +23,10 @@ namespace Torch.Patches public static class ScriptCompilerPatch { [ReflectedMethodInfo(typeof(MyScriptWhitelist), "Register", Parameters = new[] {typeof(MyWhitelistTarget), typeof(INamespaceSymbol), typeof(Type)})] - private static MethodInfo Register1Method = null!; + private static MethodInfo _register1Method; [ReflectedMethodInfo(typeof(MyScriptWhitelist), "Register", Parameters = new[] {typeof(MyWhitelistTarget), typeof(ITypeSymbol), typeof(Type)})] - private static MethodInfo Register2Method = null!; + private static MethodInfo _register2Method; public static void Patch(PatchContext context) { @@ -39,8 +36,8 @@ namespace Torch.Patches .AddPrefix(nameof(InitializePrefix)); context.GetPattern(typeof(MyScriptWhitelist).GetNestedType("MyWhitelistBatch", BindingFlags.NonPublic)! .GetMethod("AllowMembers")).AddPrefix(nameof(AllowMembersPrefix)); - context.GetPattern(Register1Method).AddTranspiler(nameof(RegisterTranspiler)); - context.GetPattern(Register2Method).AddTranspiler(nameof(RegisterTranspiler)); + context.GetPattern(_register1Method).AddTranspiler(nameof(RegisterTranspiler)); + context.GetPattern(_register2Method).AddTranspiler(nameof(RegisterTranspiler)); } private static void WhitelistCtorPrefix(MyScriptCompiler scriptCompiler) diff --git a/Torch/Patches/SessionDownloadPatch.cs b/Torch/Patches/SessionDownloadPatch.cs index 418de8a..6621ffc 100644 --- a/Torch/Patches/SessionDownloadPatch.cs +++ b/Torch/Patches/SessionDownloadPatch.cs @@ -1,16 +1,9 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; +using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using NLog; using Sandbox.Game.World; using Torch.API.Session; using Torch.API.Managers; using Torch.Managers.PatchManager; -using Torch.Mod; using VRage.Game; namespace Torch.Patches diff --git a/Torch/Patches/TorchAsyncSaving.cs b/Torch/Patches/TorchAsyncSaving.cs index 0b3a33d..c659416 100644 --- a/Torch/Patches/TorchAsyncSaving.cs +++ b/Torch/Patches/TorchAsyncSaving.cs @@ -1,9 +1,6 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; using System.Text; -using System.Threading; using System.Threading.Tasks; using Sandbox; using Sandbox.Engine.Platform; @@ -14,8 +11,6 @@ using Sandbox.Graphics.GUI; using Torch.API; using Torch.API.Session; using VRage; -using VRage.Audio; -using VRage.Utils; namespace Torch.Patches { diff --git a/Torch/Patches/XmlRootWriterPatch.cs b/Torch/Patches/XmlRootWriterPatch.cs index 5b04152..af5e405 100644 --- a/Torch/Patches/XmlRootWriterPatch.cs +++ b/Torch/Patches/XmlRootWriterPatch.cs @@ -13,11 +13,11 @@ namespace Torch.Patches; internal static class XmlRootWriterPatch { [ReflectedMethodInfo(typeof(CustomRootWriter), "Init")] - private static MethodInfo InitMethod = null!; + private static MethodInfo _initMethod; public static void Patch(PatchContext context) { - context.GetPattern(InitMethod).AddTranspiler(); + context.GetPattern(_initMethod).AddTranspiler(); } private static IEnumerable Transpiler(IEnumerable instructions) diff --git a/Torch/Persistent.cs b/Torch/Persistent.cs index 91a4bf0..df212c0 100644 --- a/Torch/Persistent.cs +++ b/Torch/Persistent.cs @@ -1,11 +1,8 @@ using System; -using System.Collections.Generic; using System.ComponentModel; using System.IO; -using System.Linq; using System.Text; using System.Threading; -using System.Threading.Tasks; using System.Xml; using System.Xml.Serialization; using NLog; diff --git a/Torch/Plugins/PluginManager.cs b/Torch/Plugins/PluginManager.cs index d90e6cd..cf523a1 100644 --- a/Torch/Plugins/PluginManager.cs +++ b/Torch/Plugins/PluginManager.cs @@ -1,21 +1,17 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Collections.ObjectModel; using System.IO; using System.IO.Compression; using System.Linq; -using System.Net; using System.Reflection; using System.Threading; using System.Threading.Tasks; -using System.Xml.Serialization; using NLog; using Torch.API; using Torch.API.Managers; using Torch.API.Plugins; using Torch.API.Session; -using Torch.API.WebAPI; using Torch.API.WebAPI.Plugin; using Torch.Collections; using Torch.Commands; diff --git a/Torch/Plugins/PluginManifest.cs b/Torch/Plugins/PluginManifest.cs index 59ec853..34eadc6 100644 --- a/Torch/Plugins/PluginManifest.cs +++ b/Torch/Plugins/PluginManifest.cs @@ -1,9 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Xml.Serialization; namespace Torch diff --git a/Torch/Session/TorchSession.cs b/Torch/Session/TorchSession.cs index c8b04f4..1fd7cff 100644 --- a/Torch/Session/TorchSession.cs +++ b/Torch/Session/TorchSession.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using NLog; +using NLog; using Sandbox.Game.World; using Torch.API; using Torch.API.Managers; diff --git a/Torch/Session/TorchSessionManager.cs b/Torch/Session/TorchSessionManager.cs index 7ec202f..60d2b23 100644 --- a/Torch/Session/TorchSessionManager.cs +++ b/Torch/Session/TorchSessionManager.cs @@ -1,18 +1,13 @@ using System; using System.Collections.Generic; using System.ComponentModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using NLog; -using Sandbox.Engine.Networking; using Sandbox.Game.World; using Torch.API; using Torch.API.Managers; using Torch.API.Session; using Torch.Managers; using Torch.Mod; -using Torch.Session; using Torch.Utils; using VRage.Game; diff --git a/Torch/TorchBase.cs b/Torch/TorchBase.cs index 400c3c7..363677c 100644 --- a/Torch/TorchBase.cs +++ b/Torch/TorchBase.cs @@ -310,11 +310,12 @@ namespace Torch /// public virtual void Destroy() { - Managers.Detach(); Game.SignalDestroy(); if (!Game.WaitFor(VRageGame.GameState.Destroyed)) Log.Warn("Failed to wait for the game to be destroyed"); Game = null; + + Managers.Detach(); } #endregion diff --git a/Torch/TorchPluginBase.cs b/Torch/TorchPluginBase.cs index 04c9a72..463b34f 100644 --- a/Torch/TorchPluginBase.cs +++ b/Torch/TorchPluginBase.cs @@ -1,13 +1,4 @@ using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Reflection; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using NLog; using Torch.API; using Torch.API.Plugins; diff --git a/Torch/Utils/MiscExtensions.cs b/Torch/Utils/MiscExtensions.cs index fcb5a08..977365e 100644 --- a/Torch/Utils/MiscExtensions.cs +++ b/Torch/Utils/MiscExtensions.cs @@ -1,9 +1,6 @@ using System; using System.IO; -using System.Linq; -using System.Net; using System.Threading; -using Sandbox.Engine.Multiplayer; using Sandbox.Game.Entities; using Sandbox.Game.World; diff --git a/Torch/Utils/ModItemUtils.cs b/Torch/Utils/ModItemUtils.cs index 4022094..dc3c465 100644 --- a/Torch/Utils/ModItemUtils.cs +++ b/Torch/Utils/ModItemUtils.cs @@ -1,8 +1,5 @@ using System; -using System.Collections.Generic; -using System.Threading.Tasks; using Sandbox.Engine.Networking; -using Torch.API; using VRage.Game; namespace Torch.Utils diff --git a/Torch/Utils/Reflected/ReflectedEventReplaceAttribute.cs b/Torch/Utils/Reflected/ReflectedEventReplaceAttribute.cs index 2eca09f..0cdc7a9 100644 --- a/Torch/Utils/Reflected/ReflectedEventReplaceAttribute.cs +++ b/Torch/Utils/Reflected/ReflectedEventReplaceAttribute.cs @@ -1,4 +1,5 @@ using System; +using JetBrains.Annotations; namespace Torch.Utils { @@ -7,6 +8,7 @@ namespace Torch.Utils /// a function used to create a new event replacer. /// [AttributeUsage(AttributeTargets.Field)] + [MeansImplicitUse] public class ReflectedEventReplaceAttribute : Attribute { /// diff --git a/Torch/Utils/Reflected/ReflectedFieldInfoAttribute.cs b/Torch/Utils/Reflected/ReflectedFieldInfoAttribute.cs index 9553085..6f76a01 100644 --- a/Torch/Utils/Reflected/ReflectedFieldInfoAttribute.cs +++ b/Torch/Utils/Reflected/ReflectedFieldInfoAttribute.cs @@ -1,4 +1,5 @@ using System; +using JetBrains.Annotations; namespace Torch.Utils { @@ -6,6 +7,7 @@ namespace Torch.Utils /// Indicates that this field should contain the instance for the given field. /// [AttributeUsage(AttributeTargets.Field)] + [MeansImplicitUse] public class ReflectedFieldInfoAttribute : ReflectedMemberAttribute { /// diff --git a/Torch/Utils/Reflected/ReflectedGetterAttribute.cs b/Torch/Utils/Reflected/ReflectedGetterAttribute.cs index 738cda5..3059332 100644 --- a/Torch/Utils/Reflected/ReflectedGetterAttribute.cs +++ b/Torch/Utils/Reflected/ReflectedGetterAttribute.cs @@ -1,4 +1,5 @@ using System; +using JetBrains.Annotations; namespace Torch.Utils { @@ -22,6 +23,7 @@ namespace Torch.Utils /// /// [AttributeUsage(AttributeTargets.Field)] + [MeansImplicitUse] public class ReflectedGetterAttribute : ReflectedMemberAttribute { } diff --git a/Torch/Utils/Reflected/ReflectedLazyAttribute.cs b/Torch/Utils/Reflected/ReflectedLazyAttribute.cs index 28d3896..15f558a 100644 --- a/Torch/Utils/Reflected/ReflectedLazyAttribute.cs +++ b/Torch/Utils/Reflected/ReflectedLazyAttribute.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Torch.Utils.Reflected { diff --git a/Torch/Utils/Reflected/ReflectedManager.cs b/Torch/Utils/Reflected/ReflectedManager.cs index 1097423..055605c 100644 --- a/Torch/Utils/Reflected/ReflectedManager.cs +++ b/Torch/Utils/Reflected/ReflectedManager.cs @@ -6,14 +6,8 @@ using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Reflection.Emit; -using System.Text; -using System.Threading.Tasks; using NLog; -using Sandbox.Engine.Multiplayer; -using Torch.API; -using Torch.Managers.PatchManager; using Torch.Utils.Reflected; -using PropertyAttributes = System.Reflection.PropertyAttributes; namespace Torch.Utils { diff --git a/Torch/Utils/Reflected/ReflectedMemberAttribute.cs b/Torch/Utils/Reflected/ReflectedMemberAttribute.cs index a8c6fbd..cd3be2b 100644 --- a/Torch/Utils/Reflected/ReflectedMemberAttribute.cs +++ b/Torch/Utils/Reflected/ReflectedMemberAttribute.cs @@ -1,7 +1,9 @@ using System; +using JetBrains.Annotations; namespace Torch.Utils { + [MeansImplicitUse] public abstract class ReflectedMemberAttribute : Attribute { /// diff --git a/Torch/Utils/Reflected/ReflectedMethodInfoAttribute.cs b/Torch/Utils/Reflected/ReflectedMethodInfoAttribute.cs index 65be9e7..3d7287b 100644 --- a/Torch/Utils/Reflected/ReflectedMethodInfoAttribute.cs +++ b/Torch/Utils/Reflected/ReflectedMethodInfoAttribute.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using JetBrains.Annotations; namespace Torch.Utils { @@ -7,6 +8,7 @@ namespace Torch.Utils /// Indicates that this field should contain the instance for the given method. /// [AttributeUsage(AttributeTargets.Field)] + [MeansImplicitUse] public class ReflectedMethodInfoAttribute : ReflectedMemberAttribute { /// diff --git a/Torch/Utils/Reflected/ReflectedPropertyInfoAttribute.cs b/Torch/Utils/Reflected/ReflectedPropertyInfoAttribute.cs index 4964f8a..d3fa2d5 100644 --- a/Torch/Utils/Reflected/ReflectedPropertyInfoAttribute.cs +++ b/Torch/Utils/Reflected/ReflectedPropertyInfoAttribute.cs @@ -1,4 +1,5 @@ using System; +using JetBrains.Annotations; namespace Torch.Utils { @@ -6,6 +7,7 @@ namespace Torch.Utils /// Indicates that this field should contain the instance for the given property. /// [AttributeUsage(AttributeTargets.Field)] + [MeansImplicitUse] public class ReflectedPropertyInfoAttribute : ReflectedMemberAttribute { /// diff --git a/Torch/Utils/Reflection.cs b/Torch/Utils/Reflection.cs index fbbbb46..9e9526f 100644 --- a/Torch/Utils/Reflection.cs +++ b/Torch/Utils/Reflection.cs @@ -1,9 +1,6 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; using NLog; namespace Torch.Utils diff --git a/Torch/Utils/SynchronizationExtensions.cs b/Torch/Utils/SynchronizationExtensions.cs index 0364cab..25ed326 100644 --- a/Torch/Utils/SynchronizationExtensions.cs +++ b/Torch/Utils/SynchronizationExtensions.cs @@ -1,9 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Threading; -using System.Threading.Tasks; namespace Torch.Utils { diff --git a/Torch/Utils/TorchAssemblyResolver.cs b/Torch/Utils/TorchAssemblyResolver.cs index dab28c5..65d83f9 100644 --- a/Torch/Utils/TorchAssemblyResolver.cs +++ b/Torch/Utils/TorchAssemblyResolver.cs @@ -1,10 +1,7 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; using NLog; namespace Torch.Utils diff --git a/Torch/Utils/TorchLogManager.cs b/Torch/Utils/TorchLogManager.cs index 963e1cf..e1d8b25 100644 --- a/Torch/Utils/TorchLogManager.cs +++ b/Torch/Utils/TorchLogManager.cs @@ -1,5 +1,4 @@ -using System; -using System.IO; +using System.IO; using System.Linq; using System.Reflection; #if !NETFRAMEWORK diff --git a/Torch/VRageGame.cs b/Torch/VRageGame.cs index e7c9af9..f98eea5 100644 --- a/Torch/VRageGame.cs +++ b/Torch/VRageGame.cs @@ -1,18 +1,12 @@ using System; -using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; using System.Linq; -using System.Reflection; -using System.Text; using System.Threading; using System.Threading.Tasks; -using Havok; using Microsoft.Extensions.Configuration; using NLog; -using NLog.Fluent; using Sandbox; -using Sandbox.Engine.Analytics; using Sandbox.Engine.Multiplayer; using Sandbox.Engine.Networking; using Sandbox.Engine.Platform.VideoMode; @@ -27,7 +21,6 @@ using Torch.API; using Torch.Utils; using VRage; using VRage.Audio; -using VRage.Dedicated; using VRage.EOS; using VRage.FileSystem; using VRage.Game; @@ -38,7 +31,6 @@ using VRage.GameServices; using VRage.Mod.Io; using VRage.Platform.Windows; using VRage.Plugins; -using VRage.Scripting; using VRage.Steam; using VRage.Utils; using VRageRender; diff --git a/Torch/ViewModels/ModViewModel.cs b/Torch/ViewModels/ModViewModel.cs index 8596638..75d0398 100644 --- a/Torch/ViewModels/ModViewModel.cs +++ b/Torch/ViewModels/ModViewModel.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using VRage.Game; +using VRage.Game; namespace Torch { diff --git a/Torch/ViewModels/PlayerViewModel.cs b/Torch/ViewModels/PlayerViewModel.cs index 619ad34..2f0b917 100644 --- a/Torch/ViewModels/PlayerViewModel.cs +++ b/Torch/ViewModels/PlayerViewModel.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Sandbox.Engine.Multiplayer; +using Sandbox.Engine.Multiplayer; using Sandbox.Game.World; using Torch.API; using VRage.Game.ModAPI; diff --git a/Torch/ViewModels/PluginViewModel.cs b/Torch/ViewModels/PluginViewModel.cs index dfa1120..1b224be 100644 --- a/Torch/ViewModels/PluginViewModel.cs +++ b/Torch/ViewModels/PluginViewModel.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Torch.ViewModels +namespace Torch.ViewModels { public class PluginViewModel : ViewModel { diff --git a/Torch/ViewModels/ViewModel.cs b/Torch/ViewModels/ViewModel.cs index 1de99be..9ae0451 100644 --- a/Torch/ViewModels/ViewModel.cs +++ b/Torch/ViewModels/ViewModel.cs @@ -2,11 +2,7 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel; -using System.Linq; -using System.Reflection; using System.Runtime.CompilerServices; -using System.Text; -using System.Threading.Tasks; using System.Windows.Threading; using PropertyChanged; diff --git a/Torch/Views/CollectionEditor.xaml.cs b/Torch/Views/CollectionEditor.xaml.cs index d2e3bac..8771557 100644 --- a/Torch/Views/CollectionEditor.xaml.cs +++ b/Torch/Views/CollectionEditor.xaml.cs @@ -4,16 +4,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; namespace Torch.Views { diff --git a/Torch/Views/DictionaryEditor.xaml.cs b/Torch/Views/DictionaryEditor.xaml.cs index 7d2e8c6..7e453ff 100644 --- a/Torch/Views/DictionaryEditor.xaml.cs +++ b/Torch/Views/DictionaryEditor.xaml.cs @@ -1,21 +1,7 @@ using System; using System.Collections; -using System.Collections.Generic; using System.Collections.ObjectModel; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; -using NLog; -using Torch.Collections; namespace Torch.Views { diff --git a/Torch/Views/DisplayAttribute.cs b/Torch/Views/DisplayAttribute.cs index ba9c043..720e6ec 100644 --- a/Torch/Views/DisplayAttribute.cs +++ b/Torch/Views/DisplayAttribute.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Torch.Views { diff --git a/Torch/Views/EmbeddedCollectionEditor.xaml.cs b/Torch/Views/EmbeddedCollectionEditor.xaml.cs index ff5a859..2de4ab7 100644 --- a/Torch/Views/EmbeddedCollectionEditor.xaml.cs +++ b/Torch/Views/EmbeddedCollectionEditor.xaml.cs @@ -4,19 +4,8 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; -using NLog; -using NLog.Fluent; namespace Torch.Views { diff --git a/Torch/Views/FlagsEditor.xaml.cs b/Torch/Views/FlagsEditor.xaml.cs index bfae80d..d605ab1 100644 --- a/Torch/Views/FlagsEditor.xaml.cs +++ b/Torch/Views/FlagsEditor.xaml.cs @@ -1,21 +1,7 @@ using System; -using System.Collections; using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; -using NLog; -using Torch.Collections; namespace Torch.Views { diff --git a/Torch/Views/ObjectCollectionEditor.xaml.cs b/Torch/Views/ObjectCollectionEditor.xaml.cs index f32c315..4422af8 100644 --- a/Torch/Views/ObjectCollectionEditor.xaml.cs +++ b/Torch/Views/ObjectCollectionEditor.xaml.cs @@ -1,22 +1,5 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; +using System.Collections; using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; -using NLog; -using NLog.Fluent; namespace Torch.Views { diff --git a/Torch/Views/ObjectEditor.xaml.cs b/Torch/Views/ObjectEditor.xaml.cs index 456924e..1507cab 100644 --- a/Torch/Views/ObjectEditor.xaml.cs +++ b/Torch/Views/ObjectEditor.xaml.cs @@ -1,17 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; +using System.Windows; namespace Torch.Views { diff --git a/Torch/Views/PropertyGrid.xaml.cs b/Torch/Views/PropertyGrid.xaml.cs index 05b1a40..7ef6fda 100644 --- a/Torch/Views/PropertyGrid.xaml.cs +++ b/Torch/Views/PropertyGrid.xaml.cs @@ -1,24 +1,13 @@ using System; using System.Collections; using System.Collections.Generic; -using System.ComponentModel; -using System.ComponentModel.DataAnnotations; using System.Linq; using System.Reflection; -using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; -using NLog; -using NLog.Fluent; -using VRage.Game; using VRage.Serialization; namespace Torch.Views diff --git a/Torch/packages.lock.json b/Torch/packages.lock.json index e83eacc..dc77415 100644 --- a/Torch/packages.lock.json +++ b/Torch/packages.lock.json @@ -118,6 +118,11 @@ "resolved": "6.8.0", "contentHash": "hfZ/f8Mezt8aTkgv9nsvFdYoQ809/AqwsJlOGOPYIfBcG2aAIG3v3ex9d8ZqQuFYyMoucjRg4eKy3VleeGodKQ==" }, + "JetBrains.Annotations": { + "type": "Transitive", + "resolved": "2023.3.0", + "contentHash": "PHfnvdBUdGaTVG9bR/GEfxgTwWM0Z97Y6X3710wiljELBISipSfF5okn/vz+C2gfO+ihoEyVPjaJwn8ZalVukA==" + }, "Microsoft.Bcl.AsyncInterfaces": { "type": "Transitive", "resolved": "6.0.0", @@ -398,6 +403,7 @@ "torch.api": { "type": "Project", "dependencies": { + "JetBrains.Annotations": "[2023.3.0, )", "Microsoft.Extensions.Configuration.Binder": "[8.0.1, )", "NLog": "[5.3.2, )", "NuGet.Commands": "[6.9.1, )",