From 1e86f958841eb8cf6fcb01b8fc1223d12dadaebf Mon Sep 17 00:00:00 2001 From: Aptivi CEO Date: Sat, 10 Feb 2024 10:15:03 +0300 Subject: [PATCH] rem - brk|doc - Removed all obsolete functions and classes --- This breaking change is made to clean things up as we remove obsolete functions and classes. This is mandatory for the final release of 0.1.0. --- Type: rem Breaking: True Doc Required: True Part: 1/1 --- .../Tools/JsonTools.cs | 113 ------------------ .../Nitrocid/Kernel/Threading/KernelThread.cs | 7 -- public/Nitrocid/Nitrocid.csproj | 2 +- .../Shell/ShellBase/Aliases/AliasManager.cs | 71 ----------- .../Scripting/Interaction/UESHCommands.cs | 99 --------------- 5 files changed, 1 insertion(+), 291 deletions(-) delete mode 100644 public/Nitrocid/Shell/ShellBase/Scripting/Interaction/UESHCommands.cs diff --git a/public/Nitrocid.Addons/Nitrocid.Extras.JsonShell/Tools/JsonTools.cs b/public/Nitrocid.Addons/Nitrocid.Extras.JsonShell/Tools/JsonTools.cs index 7dc9f71228..741b7bcbaa 100644 --- a/public/Nitrocid.Addons/Nitrocid.Extras.JsonShell/Tools/JsonTools.cs +++ b/public/Nitrocid.Addons/Nitrocid.Extras.JsonShell/Tools/JsonTools.cs @@ -412,119 +412,6 @@ public static void Remove(string parent) parentToken.Remove(); } - /// - /// Adds a new object to the current JSON file - /// - /// Where is the target array found? - /// Name of property containing the array - /// The new value - [Obsolete($"Use {nameof(Add)}() instead.")] - public static void AddNewObject(string ParentProperty, string Key, JToken Value) - { - DebugWriter.WriteDebug(DebugLevel.I, "Old file lines: {0}", JsonShellCommon.FileToken.Count()); - var TargetToken = GetToken(ParentProperty); - JToken PropertyToken = TargetToken[Key]; - - // Check to see if we're dealing with the array - if (PropertyToken.Type == JTokenType.Array) - ((JArray)PropertyToken).Add(Value); - DebugWriter.WriteDebug(DebugLevel.I, "New file lines: {0}", JsonShellCommon.FileToken.Count()); - } - - /// - /// Adds a new object to the current JSON file by index - /// - /// Where is the target array found? - /// Index number of an array to add the value to - /// The new value - [Obsolete($"Use {nameof(Add)}() instead.")] - public static void AddNewObjectIndexed(string ParentProperty, int Index, JToken Value) - { - DebugWriter.WriteDebug(DebugLevel.I, "Old file lines: {0}", JsonShellCommon.FileToken.Count()); - var TargetToken = GetToken(ParentProperty); - JToken PropertyToken = TargetToken.ElementAt(Index); - - // Check to see if we're dealing with the array - if (PropertyToken.Type == JTokenType.Array) - ((JArray)PropertyToken).Add(Value); - DebugWriter.WriteDebug(DebugLevel.I, "New file lines: {0}", JsonShellCommon.FileToken.Count()); - } - - /// - /// Adds a new property to the current JSON file - /// - /// Where to place the new property? - /// New property - /// The value for the new property - [Obsolete($"Use {nameof(Add)}() instead.")] - public static void AddNewProperty(string ParentProperty, string Key, JToken Value) - { - DebugWriter.WriteDebug(DebugLevel.I, "Old file lines: {0}", JsonShellCommon.FileToken.Count()); - var TargetToken = GetToken(ParentProperty); - JObject TokenObject = (JObject)TargetToken; - TokenObject.Add(Key, Value); - DebugWriter.WriteDebug(DebugLevel.I, "New file lines: {0}", JsonShellCommon.FileToken.Count()); - } - - /// - /// Adds a new array to the current JSON file - /// - /// Where to place the new array? - /// New array - /// The values for the new array - [Obsolete($"Use {nameof(Add)}() instead.")] - public static void AddNewArray(string ParentProperty, string Key, JArray Values) - { - DebugWriter.WriteDebug(DebugLevel.I, "Old file lines: {0}", JsonShellCommon.FileToken.Count()); - var TargetToken = GetToken(ParentProperty); - JObject TokenObject = (JObject)TargetToken; - TokenObject.Add(Key, Values); - DebugWriter.WriteDebug(DebugLevel.I, "New file lines: {0}", JsonShellCommon.FileToken.Count()); - } - - /// - /// Removes a property from the current JSON file - /// - /// The property. You can use JSONPath. - [Obsolete($"Use {nameof(Remove)}() instead.")] - public static void RemoveProperty(string Property) - { - DebugWriter.WriteDebug(DebugLevel.I, "Old file lines: {0}", JsonShellCommon.FileToken.Count()); - var TargetToken = GetToken(Property); - TargetToken.Parent.Remove(); - DebugWriter.WriteDebug(DebugLevel.I, "New file lines: {0}", JsonShellCommon.FileToken.Count()); - } - - /// - /// Removes an object from the current JSON file - /// - /// Where is the target object found? - /// The object name. You can use JSONPath. - [Obsolete($"Use {nameof(Remove)}() instead.")] - public static void RemoveObject(string ParentProperty, string ObjectName) - { - DebugWriter.WriteDebug(DebugLevel.I, "Old file lines: {0}", JsonShellCommon.FileToken.Count()); - var TargetToken = GetToken(ParentProperty); - JToken PropertyToken = TargetToken[ObjectName]; - PropertyToken.Remove(); - DebugWriter.WriteDebug(DebugLevel.I, "New file lines: {0}", JsonShellCommon.FileToken.Count()); - } - - /// - /// Removes an object from the current JSON file - /// - /// Where is the target object found? - /// Index number of an array to add the value to - [Obsolete($"Use {nameof(Remove)}() instead.")] - public static void RemoveObjectIndexed(string ParentProperty, int Index) - { - DebugWriter.WriteDebug(DebugLevel.I, "Old file lines: {0}", JsonShellCommon.FileToken.Count()); - var TargetToken = GetToken(ParentProperty); - JToken PropertyToken = TargetToken.ElementAt(Index); - PropertyToken.Remove(); - DebugWriter.WriteDebug(DebugLevel.I, "New file lines: {0}", JsonShellCommon.FileToken.Count()); - } - /// /// Serializes the property to the string /// diff --git a/public/Nitrocid/Kernel/Threading/KernelThread.cs b/public/Nitrocid/Kernel/Threading/KernelThread.cs index 17af41f098..a1f005540b 100644 --- a/public/Nitrocid/Kernel/Threading/KernelThread.cs +++ b/public/Nitrocid/Kernel/Threading/KernelThread.cs @@ -86,13 +86,6 @@ public class KernelThread /// public int ThreadId => BaseThread.ManagedThreadId; - /// - /// Native Thread ID for this kernel thread (unstable, don't use unless necessary) - /// - [Obsolete("This ID is unstable and is inaccurate.")] - public ulong NativeThreadId => - (ulong)BaseThread.GetType().GetProperty("CurrentOSThreadId", BindingFlags.Static | BindingFlags.GetProperty | BindingFlags.NonPublic).GetValue(null); - /// /// Makes a new kernel thread /// diff --git a/public/Nitrocid/Nitrocid.csproj b/public/Nitrocid/Nitrocid.csproj index cb99965b07..7b11c0f8a5 100644 --- a/public/Nitrocid/Nitrocid.csproj +++ b/public/Nitrocid/Nitrocid.csproj @@ -56,7 +56,7 @@ 3.0.25 - 419 + 420 $(NitrocidModAPIVersionMajor).$(NitrocidModAPIVersionChangeset) diff --git a/public/Nitrocid/Shell/ShellBase/Aliases/AliasManager.cs b/public/Nitrocid/Shell/ShellBase/Aliases/AliasManager.cs index aca67f519a..ee41296e2c 100644 --- a/public/Nitrocid/Shell/ShellBase/Aliases/AliasManager.cs +++ b/public/Nitrocid/Shell/ShellBase/Aliases/AliasManager.cs @@ -69,77 +69,6 @@ public static void SaveAliases() Writing.WriteContentsText(PathsManagement.GetKernelPath(KernelPathType.Aliases), serialized); } - /// - /// Manages the alias - /// - /// Either add or rem - /// Alias type (Shell or Remote Debug) - /// A specified alias - /// A destination command (target) - [Obsolete("This function was used for the \"alias\" command. However, it was designed as a wrapper. " + - $"Use {nameof(AddAlias)} or {nameof(RemoveAlias)} instead.")] - public static void ManageAlias(string mode, ShellType Type, string AliasCmd, string DestCmd = "") => - ManageAlias(mode, ShellManager.GetShellTypeName(Type), AliasCmd, DestCmd); - - /// - /// Manages the alias - /// - /// Either add or rem - /// Alias type (Shell or Remote Debug) - /// A specified alias - /// A destination command (target) - [Obsolete("This function was used for the \"alias\" command. However, it was designed as a wrapper. " + - $"Use {nameof(AddAlias)} or {nameof(RemoveAlias)} instead.")] - public static void ManageAlias(string mode, string Type, string AliasCmd, string DestCmd = "") - { - if (Enum.IsDefined(typeof(ShellType), Type)) - { - if (mode == "add") - { - // User tries to add an alias. - try - { - AddAlias(DestCmd, AliasCmd, Type); - TextWriterColor.Write(Translate.DoTranslation("You can now run \"{0}\" as a command: \"{1}\"."), AliasCmd, DestCmd); - } - catch (Exception ex) - { - DebugWriter.WriteDebug(DebugLevel.E, "Failed to add alias. Stack trace written using WStkTrc(). {0}", ex.Message); - DebugWriter.WriteDebugStackTrace(ex); - TextWriters.Write(ex.Message, true, KernelColorType.Error); - } - } - else if (mode == "rem") - { - // User tries to remove an alias - try - { - RemoveAlias(AliasCmd, Type); - TextWriterColor.Write(Translate.DoTranslation("Removed alias {0} successfully."), AliasCmd); - } - catch (Exception ex) - { - DebugWriter.WriteDebug(DebugLevel.E, "Failed to remove alias. Stack trace written using WStkTrc(). {0}", ex.Message); - DebugWriter.WriteDebugStackTrace(ex); - TextWriters.Write(ex.Message, true, KernelColorType.Error); - } - } - else - { - DebugWriter.WriteDebug(DebugLevel.E, "Mode {0} was neither add nor rem.", mode); - TextWriters.Write(Translate.DoTranslation("Invalid mode {0}."), true, KernelColorType.Error, mode); - } - - // Save all aliases - SaveAliases(); - } - else - { - DebugWriter.WriteDebug(DebugLevel.E, "Type {0} not found.", Type); - TextWriters.Write(Translate.DoTranslation("Invalid type {0}."), true, KernelColorType.Error, Type); - } - } - /// /// Adds alias to kernel /// diff --git a/public/Nitrocid/Shell/ShellBase/Scripting/Interaction/UESHCommands.cs b/public/Nitrocid/Shell/ShellBase/Scripting/Interaction/UESHCommands.cs deleted file mode 100644 index 5068d3b9e2..0000000000 --- a/public/Nitrocid/Shell/ShellBase/Scripting/Interaction/UESHCommands.cs +++ /dev/null @@ -1,99 +0,0 @@ -// -// Nitrocid KS Copyright (C) 2018-2024 Aptivi -// -// This file is part of Nitrocid KS -// -// Nitrocid KS is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Nitrocid KS is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY, without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - -using System; -using Terminaux.Inputs.Styles; -using Terminaux.Inputs.Styles.Choice; -using Terminaux.Inputs.Styles.Selection; -using Nitrocid.Kernel.Debugging; - -namespace Nitrocid.Shell.ShellBase.Scripting.Interaction -{ - /// - /// UESH scripting command functions - /// - [Obsolete("Already made obsolete by the -set switch. Consider using that.")] - public static class UESHCommands - { - - /// - /// Prompts user for choice - /// - /// A question - /// A $variable - /// Set of answers. They can be written like this: Y/N/C. - /// Output type of choices - /// When enabled, allows the input to consist of multiple characters - public static void PromptChoiceAndSet(string Question, string ScriptVariable, string AnswersStr, ChoiceOutputType OutputType = ChoiceOutputType.OneLine, bool PressEnter = false) => PromptChoiceAndSet(Question, ScriptVariable, AnswersStr, [], OutputType, PressEnter); - - /// - /// Prompts user for choice - /// - /// A question - /// A $variable - /// Set of answers. They can be written like this: Y/N/C. - /// Working titles for each answer. It must be the same amount as the answers. - /// Output type of choices - /// When enabled, allows the input to consist of multiple characters - public static void PromptChoiceAndSet(string Question, string ScriptVariable, string AnswersStr, string[] AnswersTitles, ChoiceOutputType OutputType = ChoiceOutputType.OneLine, bool PressEnter = false) - { - string Answer = ChoiceStyle.PromptChoice(Question, AnswersStr, AnswersTitles, OutputType, PressEnter); - UESHVariables.SetVariable(ScriptVariable, Answer); - } - - /// - /// Prompts user for selection - /// - /// A question - /// A $variable - /// Set of answers. They can be written like this: Y/N/C. - public static void PromptSelectionAndSet(string Question, string ScriptVariable, string AnswersStr) => PromptSelectionAndSet(Question, ScriptVariable, AnswersStr, []); - - /// - /// Prompts user for Selection - /// - /// A question - /// A $variable - /// Set of answers. They can be written like this: Y/N/C. - /// Working titles for each answer. It must be the same amount as the answers. - public static void PromptSelectionAndSet(string Question, string ScriptVariable, string AnswersStr, string[] AnswersTitles) - { - int SelectedAnswer = SelectionStyle.PromptSelection(Question, AnswersStr, AnswersTitles); - - // Set the value - if (SelectedAnswer != -1) - UESHVariables.SetVariable(ScriptVariable, SelectedAnswer.ToString()); - } - - /// - /// Prompts user for input (answer the question with your own answers) - /// - /// The question to ask - /// An $variable - public static void PromptInputAndSet(string Question, string ScriptVariable) - { - // Variables - string Answer = InputStyle.PromptInput(Question); - DebugWriter.WriteDebug(DebugLevel.I, "Script var: {0} ({1})", ScriptVariable, UESHVariables.ShellVariables.ContainsKey(ScriptVariable)); - DebugWriter.WriteDebug(DebugLevel.I, "Setting to {0}...", Answer); - UESHVariables.SetVariable(ScriptVariable, Answer); - } - - } -}