refactor: Update Unity to 2022.3.62

This commit is contained in:
2025-06-21 01:22:02 +08:00
parent d71bf7d4a5
commit 283783954f
112 changed files with 778 additions and 907 deletions

View File

@@ -65,7 +65,7 @@ namespace Cryville.Common.Pdt {
/// </summary>
public int Position { get; protected set; }
readonly StringBuilder _sb = new StringBuilder();
readonly StringBuilder _sb = new();
#pragma warning disable IDE1006
/// <summary>
/// The character at the current position.
@@ -86,7 +86,7 @@ namespace Cryville.Common.Pdt {
protected string tokenb(CharCategory flag) {
int sp = Position;
while ((ct & flag) == 0) Position++;
return Source.Substring(sp, Position - sp);
return Source[sp..Position];
}
/// <summary>
/// Reads a token until a character that is not of type <paramref name="flag" /> is met.
@@ -97,7 +97,7 @@ namespace Cryville.Common.Pdt {
protected string tokenw(CharCategory flag) {
int sp = Position;
while ((ct & flag) != 0) Position++;
return Source.Substring(sp, Position - sp);
return Source[sp..Position];
}
/// <summary>
/// Skips over whitespaces.
@@ -163,7 +163,7 @@ namespace Cryville.Common.Pdt {
return new PdtExpression(ins);
}
readonly Dictionary<string, PdtExpression> defs = new Dictionary<string, PdtExpression>();
readonly Dictionary<string, PdtExpression> defs = new();
/// <summary>
/// Creates an instance of the <see cref="PdtInterpreter" /> class.
/// </summary>
@@ -186,8 +186,7 @@ namespace Cryville.Common.Pdt {
public object Interpret(Type type) {
try {
if (m_formatVersion == null) InterpretDirectives();
if (_binder == null)
_binder = BinderAttribute.CreateBinderOfType(type);
_binder ??= BinderAttribute.CreateBinderOfType(type);
return InterpretObject(type);
}
catch (Exception ex) {
@@ -256,18 +255,17 @@ namespace Cryville.Common.Pdt {
}
void InterpretObjectInternal<T>(bool pcflag, Type type, object pkey, object result, Func<Type, object> vfunc) where T : Attribute {
if (pcflag) {
using (var collection = new PairCollection(result)) {
var ktype = type.GetGenericArguments()[0];
var ptype = type.GetGenericArguments()[1];
object key = _binder.ChangeType(pkey, ktype, null);
object value = vfunc(ptype);
collection.Add(key, value);
}
using var collection = new PairCollection(result);
var ktype = type.GetGenericArguments()[0];
var ptype = type.GetGenericArguments()[1];
object key = _binder.ChangeType(pkey, ktype, null);
object value = vfunc(ptype);
collection.Add(key, value);
}
else {
MemberInfo prop = null;
bool flag = false;
if (pkey is string) prop = FieldLikeHelper.GetMember(type, (string)pkey);
if (pkey is string pname) prop = FieldLikeHelper.GetMember(type, pname);
if (prop == null) {
prop = FieldLikeHelper.FindMemberWithAttribute<T>(type);
flag = true;
@@ -279,13 +277,12 @@ namespace Cryville.Common.Pdt {
if (origCollection == null) {
FieldLikeHelper.SetValue(prop, result, origCollection = Activator.CreateInstance(ptype));
}
using (var collection = new PairCollection(origCollection)) {
var ktype = ptype.GetGenericArguments()[0];
var vtype = ptype.GetGenericArguments()[1];
object key = _binder.ChangeType(pkey, ktype, null);
object value = vfunc(vtype);
collection.Add(key, value);
}
using var collection = new PairCollection(origCollection);
var ktype = ptype.GetGenericArguments()[0];
var vtype = ptype.GetGenericArguments()[1];
object key = _binder.ChangeType(pkey, ktype, null);
object value = vfunc(vtype);
collection.Add(key, value);
}
else FieldLikeHelper.SetValue(prop, result, vfunc(ptype), _binder);
}
@@ -326,7 +323,7 @@ namespace Cryville.Common.Pdt {
src.Take(interpreter.Position).Count(c => c == '\n') + 1,
pos - lineStartPos + 1,
innerException == null ? "Unknown error" : innerException.Message,
src.Substring(previewStartPos, previewEndPos - previewStartPos)
src[previewStartPos..previewEndPos]
);
}
}