Skip to content

Commit

Permalink
Deprecate TinyJSON and SharpZipLib
Browse files Browse the repository at this point in the history
  • Loading branch information
slxdy committed Jan 22, 2025
1 parent 056c2fb commit a9478dd
Show file tree
Hide file tree
Showing 107 changed files with 298 additions and 92 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ dotnet_diagnostic.CA1845.severity = warning
csharp_preserve_single_line_statements = false
csharp_preserve_single_line_blocks = true

# IDE0079: Remove unnecessary suppression
dotnet_diagnostic.IDE0079.severity = none

[*.{cs,vb}]
#### Naming styles ####

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
<PackageReference Include="Il2CppInterop.Runtime" Version="$(Il2CppInteropVersion)" ExcludeAssets="Runtime" />
<PackageReference Include="Mono.Cecil" Version="0.11.6" ExcludeAssets="Runtime" />
<PackageReference Include="AssetRipper.VersionUtilities" Version="1.5.0" ExcludeAssets="Runtime" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
</Project>
34 changes: 10 additions & 24 deletions Dependencies/Il2CppAssemblyGenerator/RemoteAPI.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Semver;
using Newtonsoft.Json;
using Semver;
using System;
using System.Collections.Generic;
using System.Net.Http;
Expand All @@ -12,9 +13,16 @@ internal static class RemoteAPI
{
internal class InfoStruct
{
[JsonProperty("forceCpp2IlVersion")]
internal string ForceDumperVersion = null;

[JsonProperty("obfuscationRegex")]
internal string ObfuscationRegex = null;

[JsonProperty("mappingUrl")]
internal string MappingURL = null;

[JsonProperty("mappingFileSHA512")]
internal string MappingFileSHA512 = null;
}
internal static InfoStruct Info = new();
Expand Down Expand Up @@ -122,29 +130,7 @@ internal static class Melon

internal static InfoStruct Contact(string response_str)
{
var responseobj = MelonUtils.ParseJSONStringtoStruct<ResponseStruct>(response_str);
if (responseobj == null)
return null;

var returninfo = new InfoStruct
{
ForceDumperVersion = responseobj.forceCpp2IlVersion,
ObfuscationRegex = responseobj.obfuscationRegex,
MappingURL = responseobj.mappingUrl,
MappingFileSHA512 = responseobj.mappingFileSHA512
};
return returninfo;
}

internal class ResponseStruct
{
public string gameSlug = null;
public string gameName = null;
public string mappingUrl = null;
public string mappingFileSHA512 = null;
public string forceCpp2IlVersion = null;
public string forceUnhollowerVersion = null; //TODO: Remove this from the API
public string obfuscationRegex = null;
return JsonConvert.DeserializeObject<InfoStruct>(response_str);
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions Dependencies/SupportModules/Component.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using UnityEngine;
using System.Diagnostics.CodeAnalysis;


#if SM_Il2Cpp
using Il2CppInterop.Runtime;
#endif
Expand All @@ -12,7 +11,6 @@ namespace MelonLoader.Support;

[SuppressMessage("CodeQuality", "IDE0051:Remove unused private members", Justification = "Used by Unity through reflection")]
[SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "Used by Unity through reflection")]
[SuppressMessage("CodeQuality", "IDE0079:Remove unnecessary suppression", Justification = "It is necessary")]
internal class SM_Component : MonoBehaviour
{
private bool isQuitting;
Expand Down
5 changes: 3 additions & 2 deletions Dependencies/SupportModules/Il2Cpp/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.Startup;
using MelonLoader.CoreClrUtils;
using MelonLoader.Modules;
using MelonLoader.Support.Preferences;
using MelonLoader.Utils;
using Microsoft.Extensions.Logging;
Expand All @@ -20,15 +21,15 @@ namespace MelonLoader.Support;

internal static class Main
{
internal static ISupportModule_From Interface;
internal static ISupportModuleFrom Interface;
internal static InteropInterface Interop;
internal static GameObject obj = null;
internal static SM_Component component = null;

private static Assembly Il2Cppmscorlib = null;
private static Type streamType = null;

private static ISupportModule_To Initialize(ISupportModule_From interface_from)
private static ISupportModuleTo Initialize(ISupportModuleFrom interface_from)
{
Interface = interface_from;

Expand Down
7 changes: 4 additions & 3 deletions Dependencies/SupportModules/Mono/Main.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using MelonLoader.Support.Preferences;
using MelonLoader.Modules;
using MelonLoader.Support.Preferences;
using System.Reflection;
using UnityEngine;

Expand All @@ -8,11 +9,11 @@ namespace MelonLoader.Support;

internal static class Main
{
internal static ISupportModule_From Interface = null;
internal static ISupportModuleFrom Interface = null;
internal static GameObject obj = null;
internal static SM_Component component = null;

private static ISupportModule_To Initialize(ISupportModule_From interface_from)
private static ISupportModuleTo Initialize(ISupportModuleFrom interface_from)
{
Interface = interface_from;
UnityMappers.RegisterMappers();
Expand Down
5 changes: 3 additions & 2 deletions Dependencies/SupportModules/SupportModule_To.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System.Collections;
using MelonLoader.Modules;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace MelonLoader.Support;

internal class SupportModule_To : ISupportModule_To
internal class SupportModule_To : ISupportModuleTo
{
internal static readonly List<IEnumerator> QueuedCoroutines = [];
public object StartCoroutine(IEnumerator coroutine)
Expand Down
27 changes: 22 additions & 5 deletions MelonLoader/Assertions/LemonAssertMapping.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;

namespace MelonLoader.Assertions;

Expand All @@ -10,15 +11,17 @@ public static class LemonAssertMapping

internal static void Setup()
{
Register_IsNull<object>(IsNull_object);
Register_IsNull<string>(IsNull_string);
Register_IsEqual<object>(IsEqual_object);
RegisterIsNull<object>(IsNull_object);
RegisterIsNull<string>(IsNull_string);
RegisterIsEqual<object>(IsEqual_object);
}

public static void Register_IsNull<T>(Func<T, bool> method)
public static void RegisterIsNull<T>(Func<T, bool> method)
=> Register<T>(method, ref IsNull);
public static void Register_IsEqual<T>(Func<T, T, bool> method)

public static void RegisterIsEqual<T>(Func<T, T, bool> method)
=> Register<T>(method, ref IsEqual);

private static void Register<T>(Delegate method, ref Dictionary<Type, Delegate> tbl)
{
if (method == null)
Expand All @@ -38,4 +41,18 @@ private static bool IsEqual_object(object obj, object obj2)
{
return obj == null ? obj2 == null : obj2 == null ? obj == null : obj.Equals(obj2);
}

#region Obsolete

[Obsolete("Use RegisterIsNull instead.", true)]
[SuppressMessage("Naming", "CA1707: Identifiers should not contain underscores", Justification = "Reason for deprecation")]
public static void Register_IsNull<T>(Func<T, bool> method)
=> Register<T>(method, ref IsNull);

[Obsolete("Use RegisterIsNull instead.", true)]
[SuppressMessage("Naming", "CA1707: Identifiers should not contain underscores", Justification = "Reason for deprecation")]
public static void Register_IsEqual<T>(Func<T, T, bool> method)
=> Register<T>(method, ref IsEqual);

#endregion
}
3 changes: 2 additions & 1 deletion MelonLoader/BackwardsCompatibility/.editorconfig
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[*.cs]
dotnet_style_namespace_match_folder = false
dotnet_style_namespace_match_folder = false
dotnet_diagnostic.CA1707.severity = none
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace MelonLoader.ICSharpCode.SharpZipLib.BZip2;
/// <summary>
/// An example class to demonstrate compression and decompression of BZip2 streams.
/// </summary>
[Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)]
public static class BZip2
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
using System;

namespace MelonLoader.ICSharpCode.SharpZipLib.BZip2;

/// <summary>
/// Defines internal values for both compression and decompression
/// </summary>
[Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)]
internal static class BZip2Constants
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ namespace MelonLoader.ICSharpCode.SharpZipLib.BZip2;
/// <summary>
/// BZip2Exception represents exceptions specific to BZip2 classes and code.
/// </summary>
[Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)]
[Serializable]
public class BZip2Exception : SharpZipBaseException
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace MelonLoader.ICSharpCode.SharpZipLib.BZip2;
/// <summary>
/// An input stream that decompresses files in the BZip2 format
/// </summary>
[Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)]
public class BZip2InputStream : Stream
{
#region Constants
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace MelonLoader.ICSharpCode.SharpZipLib.BZip2;
/// An output stream that compresses into the BZip2 format
/// including file header chars into another stream.
/// </summary>
[Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)]
public class BZip2OutputStream : Stream
{
#region Constants
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ namespace MelonLoader.ICSharpCode.SharpZipLib.Checksum;
/// </summary>
/// <see cref="ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream"/>
/// <see cref="ICSharpCode.SharpZipLib.Zip.Compression.Streams.DeflaterOutputStream"/>
[Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)]
public sealed class Adler32 : IChecksum
{
#region Instance Fields
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ namespace MelonLoader.ICSharpCode.SharpZipLib.Checksum;
/// memory consumed by the lookup tables. (Slicing-by-16 requires a 16KB table,
/// which is still small enough to fit in most processors' L1 cache.)
/// </remarks>
[Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)]
public sealed class BZip2Crc : IChecksum
{
#region Instance Fields
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ namespace MelonLoader.ICSharpCode.SharpZipLib.Checksum;
/// memory consumed by the lookup tables. (Slicing-by-16 requires a 16KB table,
/// which is still small enough to fit in most processors' L1 cache.)
/// </remarks>
[Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)]
public sealed class Crc32 : IChecksum
{
#region Instance Fields
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
namespace MelonLoader.ICSharpCode.SharpZipLib.Checksum;
using System;

namespace MelonLoader.ICSharpCode.SharpZipLib.Checksum;

[Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)]
internal static class CrcUtilities
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace MelonLoader.ICSharpCode.SharpZipLib.Checksum;
/// <code>getValue</code>. The complete checksum object can also be reset
/// so it can be used again with new data.
/// </summary>
[Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)]
public interface IChecksum
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
namespace MelonLoader.ICSharpCode.SharpZipLib.Core;
using System;

namespace MelonLoader.ICSharpCode.SharpZipLib.Core;

[Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)]
internal static class Empty
{
internal static class EmptyArray<T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace MelonLoader.ICSharpCode.SharpZipLib.Core;
/// <summary>
/// Event arguments for scanning.
/// </summary>
[Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)]
public class ScanEventArgs : EventArgs
{
#region Constructors
Expand Down Expand Up @@ -50,6 +51,7 @@ public bool ContinueRunning
/// <summary>
/// Event arguments during processing of a single file or directory.
/// </summary>
[Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)]
public class ProgressEventArgs : EventArgs
{
#region Constructors
Expand Down Expand Up @@ -129,6 +131,7 @@ public long Target
/// <summary>
/// Event arguments for directories.
/// </summary>
[Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)]
public class DirectoryEventArgs : ScanEventArgs
{
#region Constructors
Expand Down Expand Up @@ -166,6 +169,7 @@ private readonly
/// <summary>
/// Arguments passed when scan failures are detected.
/// </summary>
[Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)]
public class ScanFailureEventArgs : EventArgs
{
#region Constructors
Expand Down Expand Up @@ -227,41 +231,47 @@ public bool ContinueRunning
/// </summary>
/// <param name="sender">The source of the event</param>
/// <param name="e">The event arguments.</param>
[Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)]
public delegate void ProcessFileHandler(object sender, ScanEventArgs e);

/// <summary>
/// Delegate invoked during processing of a file or directory
/// </summary>
/// <param name="sender">The source of the event</param>
/// <param name="e">The event arguments.</param>
[Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)]
public delegate void ProgressHandler(object sender, ProgressEventArgs e);

/// <summary>
/// Delegate invoked when a file has been completely processed.
/// </summary>
/// <param name="sender">The source of the event</param>
/// <param name="e">The event arguments.</param>
[Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)]
public delegate void CompletedFileHandler(object sender, ScanEventArgs e);

/// <summary>
/// Delegate invoked when a directory failure is detected.
/// </summary>
/// <param name="sender">The source of the event</param>
/// <param name="e">The event arguments.</param>
[Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)]
public delegate void DirectoryFailureHandler(object sender, ScanFailureEventArgs e);

/// <summary>
/// Delegate invoked when a file failure is detected.
/// </summary>
/// <param name="sender">The source of the event</param>
/// <param name="e">The event arguments.</param>
[Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)]
public delegate void FileFailureHandler(object sender, ScanFailureEventArgs e);

#endregion Delegates

/// <summary>
/// FileSystemScanner provides facilities scanning of files and directories.
/// </summary>
[Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)]
public class FileSystemScanner
{
#region Constructors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
using System;

namespace MelonLoader.ICSharpCode.SharpZipLib.Core;

/// <summary>
/// INameTransform defines how file system names are transformed for use with archives, or vice versa.
/// </summary>
[Obsolete("Please use an alternative library instead. This will be removed in a future version.", true)]
public interface INameTransform
{
/// <summary>
Expand Down
Loading

0 comments on commit a9478dd

Please sign in to comment.