Skip to content

Commit

Permalink
rem - brk|doc - Removed all obsolete functions and classes
Browse files Browse the repository at this point in the history
---

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
  • Loading branch information
AptiviCEO committed Feb 10, 2024
1 parent 6ae5259 commit 1e86f95
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 291 deletions.
113 changes: 0 additions & 113 deletions public/Nitrocid.Addons/Nitrocid.Extras.JsonShell/Tools/JsonTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -412,119 +412,6 @@ public static void Remove(string parent)
parentToken.Remove();
}

/// <summary>
/// Adds a new object to the current JSON file
/// </summary>
/// <param name="ParentProperty">Where is the target array found?</param>
/// <param name="Key">Name of property containing the array</param>
/// <param name="Value">The new value</param>
[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());
}

/// <summary>
/// Adds a new object to the current JSON file by index
/// </summary>
/// <param name="ParentProperty">Where is the target array found?</param>
/// <param name="Index">Index number of an array to add the value to</param>
/// <param name="Value">The new value</param>
[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());
}

/// <summary>
/// Adds a new property to the current JSON file
/// </summary>
/// <param name="ParentProperty">Where to place the new property?</param>
/// <param name="Key">New property</param>
/// <param name="Value">The value for the new property</param>
[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());
}

/// <summary>
/// Adds a new array to the current JSON file
/// </summary>
/// <param name="ParentProperty">Where to place the new array?</param>
/// <param name="Key">New array</param>
/// <param name="Values">The values for the new array</param>
[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());
}

/// <summary>
/// Removes a property from the current JSON file
/// </summary>
/// <param name="Property">The property. You can use JSONPath.</param>
[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());
}

/// <summary>
/// Removes an object from the current JSON file
/// </summary>
/// <param name="ParentProperty">Where is the target object found?</param>
/// <param name="ObjectName">The object name. You can use JSONPath.</param>
[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());
}

/// <summary>
/// Removes an object from the current JSON file
/// </summary>
/// <param name="ParentProperty">Where is the target object found?</param>
/// <param name="Index">Index number of an array to add the value to</param>
[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());
}

/// <summary>
/// Serializes the property to the string
/// </summary>
Expand Down
7 changes: 0 additions & 7 deletions public/Nitrocid/Kernel/Threading/KernelThread.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,6 @@ public class KernelThread
/// </summary>
public int ThreadId => BaseThread.ManagedThreadId;

/// <summary>
/// Native Thread ID for this kernel thread (unstable, don't use unless necessary)
/// </summary>
[Obsolete("This ID is unstable and is inaccurate.")]
public ulong NativeThreadId =>
(ulong)BaseThread.GetType().GetProperty("CurrentOSThreadId", BindingFlags.Static | BindingFlags.GetProperty | BindingFlags.NonPublic).GetValue(null);

/// <summary>
/// Makes a new kernel thread
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion public/Nitrocid/Nitrocid.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<NitrocidModAPIVersionMajor>3.0.25</NitrocidModAPIVersionMajor>

<!-- Increment NitrocidModAPIVersionChangeset every time there is a breaking change or an API addition in the N-KS API. -->
<NitrocidModAPIVersionChangeset>419</NitrocidModAPIVersionChangeset>
<NitrocidModAPIVersionChangeset>420</NitrocidModAPIVersionChangeset>

<!-- To be installed to the file version -->
<NitrocidModAPIVersion>$(NitrocidModAPIVersionMajor).$(NitrocidModAPIVersionChangeset)</NitrocidModAPIVersion>
Expand Down
71 changes: 0 additions & 71 deletions public/Nitrocid/Shell/ShellBase/Aliases/AliasManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,77 +69,6 @@ public static void SaveAliases()
Writing.WriteContentsText(PathsManagement.GetKernelPath(KernelPathType.Aliases), serialized);
}

/// <summary>
/// Manages the alias
/// </summary>
/// <param name="mode">Either add or rem</param>
/// <param name="Type">Alias type (Shell or Remote Debug)</param>
/// <param name="AliasCmd">A specified alias</param>
/// <param name="DestCmd">A destination command (target)</param>
[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);

/// <summary>
/// Manages the alias
/// </summary>
/// <param name="mode">Either add or rem</param>
/// <param name="Type">Alias type (Shell or Remote Debug)</param>
/// <param name="AliasCmd">A specified alias</param>
/// <param name="DestCmd">A destination command (target)</param>
[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);
}
}

/// <summary>
/// Adds alias to kernel
/// </summary>
Expand Down

This file was deleted.

0 comments on commit 1e86f95

Please sign in to comment.