mirror of
https://github.com/0x7c13/Pal3.Unity.git
synced 2026-11-26 17:38:10 +08:00
Cover SCE command contracts, binary readers, resource layouts and full local CPK decompression for PAL3 and PAL3A. Fix CVD time rebasing, binary read bounds and short reads, and CPK/NAV validation. Standardize first-party copyright headers, preserve correct creation years, and update console source generation. Validate both variants in Unity and verify all live CPK entries.
72 lines
2.1 KiB
C#
72 lines
2.1 KiB
C#
// ------------------------------------------------------------------------
|
|
// Copyright (c) 2021-2026, Jiaqi (0x7c13) Liu. All rights reserved.
|
|
// See LICENSE file in the project root for license information.
|
|
// ------------------------------------------------------------------------
|
|
|
|
namespace Pal3.Core.Utilities
|
|
{
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
|
|
/// <summary>
|
|
/// Checks method arguments for both dotnet objects and Unity objects.
|
|
/// </summary>
|
|
public static class Requires
|
|
{
|
|
public static T IsNotNull<T>([NotNull] T instance, string paramName)
|
|
where T : class
|
|
{
|
|
if (typeof(T) == typeof(object) ||
|
|
typeof(T).IsSubclassOf(typeof(object)))
|
|
{
|
|
if (ReferenceEquals(null, instance))
|
|
{
|
|
throw new ArgumentNullException(paramName);
|
|
}
|
|
}
|
|
else if (instance == null)
|
|
{
|
|
throw new ArgumentNullException(paramName);
|
|
}
|
|
|
|
return instance;
|
|
}
|
|
|
|
public static string IsNotNullOrEmpty([NotNull] string value, string paramName)
|
|
{
|
|
IsNotNull(value, paramName);
|
|
|
|
if (value == string.Empty)
|
|
{
|
|
throw new ArgumentException(paramName);
|
|
}
|
|
|
|
return value;
|
|
}
|
|
|
|
public static ICollection<T> IsNotNullOrEmpty<T>([NotNull] ICollection<T> value, string paramName)
|
|
{
|
|
IsNotNull(value, paramName);
|
|
|
|
if (value.Count == 0)
|
|
{
|
|
throw new ArgumentException("Collection is empty", paramName);
|
|
}
|
|
|
|
return value;
|
|
}
|
|
|
|
public static T[] IsNotNullOrEmpty<T>([NotNull] T[] instances, string paramName)
|
|
{
|
|
IsNotNull(instances, paramName);
|
|
|
|
if (instances.Length == 0)
|
|
{
|
|
throw new ArgumentException("Array is empty", paramName);
|
|
}
|
|
|
|
return instances;
|
|
}
|
|
}
|
|
} |