fix: Updates serialization to use v2.0 (#998)

- [X] Deletes serialization annotations
- [X] Updates to ModernUO.Serialization.Annotations nuget
- [X] Updates serializer to v2.0
- [X] Changes all `Serializable()` to `SerializationGenerator()`
- [X] Updates to schema generator v2.0
This commit is contained in:
Kamron Batman 2022-04-17 08:02:15 -07:00 • committed by GitHub
parent 5d972caa9c
commit 54d728a322
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
740 changed files with 2552 additions and 1743 deletions

View file

@ -1,38 +0,0 @@
/*************************************************************************
* ModernUO *
* Copyright 2019-2021 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: AfterDeserializationAttribute.cs *
* *
* This program 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. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using System;
namespace Server
{
/// <summary>
/// Hints to the source generator that this method should be executed after deserializing the object.
/// Method must have no parameters and return void.
/// </summary>
[AttributeUsage(AttributeTargets.Method)]
public class AfterDeserializationAttribute : Attribute
{
/// <summary>
/// Indicates whether the source generator should execute the method this is attached to immediately, or when
/// this is set to false, execute it using a Timer Delay.
///
/// Note: Use false when the after deserialization involves deleting objects. This is to prevent corrupted
/// deserialization by removing an object before it has finished deserializing.
/// </summary>
public bool Synchronous { get; set; }
public AfterDeserializationAttribute(bool synchronous = true) => Synchronous = true;
}
}

View file

@ -1,27 +0,0 @@
/*************************************************************************
* ModernUO *
* Copyright 2019-2021 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: DeltaDateTimeAttribute.cs *
* *
* This program 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. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using System;
namespace Server
{
/// <summary>
/// Hints to the source generator that a serializable DateTime field or property is for delta time (duration)
/// </summary>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public class DeltaDateTimeAttribute : Attribute
{
}
}

View file

@ -1,34 +0,0 @@
/*************************************************************************
* ModernUO *
* Copyright 2019-2021 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: DeserializeTimerFieldAttribute.cs *
* *
* This program 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. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using System;
namespace Server
{
/// <summary>
/// Hints to the source generator that the specified serializable field, which must be a timer,
/// can be deserialized by this method. The method signature should look like this:
///
/// [DeserializeTimerField(0)]
/// private void DeserializeTimer(TimeSpan delay)
/// </summary>
[AttributeUsage(AttributeTargets.Method)]
public sealed class DeserializeTimerFieldAttribute : Attribute
{
public int Order { get; }
public DeserializeTimerFieldAttribute(int order) => Order = order;
}
}

View file

@ -1,32 +0,0 @@
/*************************************************************************
* ModernUO *
* Copyright 2019-2021 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: EmbeddedSerializableAttribute.cs *
* *
* This program 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. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using System;
namespace Server
{
[AttributeUsage(AttributeTargets.Class)]
public sealed class EmbeddedSerializableAttribute : Attribute
{
public int Version { get; }
public bool EncodedVersion { get; }
public EmbeddedSerializableAttribute(int version, bool encodedVersion = true)
{
Version = version;
EncodedVersion = encodedVersion;
}
}
}

View file

@ -1,27 +0,0 @@
/*************************************************************************
* ModernUO *
* Copyright 2019-2021 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: EncodedIntAttribute.cs *
* *
* This program 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. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using System;
namespace Server
{
/// <summary>
/// Hints to the source generator that a serializable int field or property should be encoded
/// </summary>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public class EncodedIntAttribute : Attribute
{
}
}

View file

@ -1,27 +0,0 @@
/*************************************************************************
* ModernUO *
* Copyright 2019-2021 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: InternalizeString.cs *
* *
* This program 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. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using System;
namespace Server
{
/// <summary>
/// Hints to the source generator that a serializable string field or property should be internalized on deserialization
/// </summary>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public class InternStringAttribute : Attribute
{
}
}

View file

@ -1,28 +0,0 @@
/*************************************************************************
* ModernUO *
* Copyright 2019-2021 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: InvalidatePropertiesAttribute.cs *
* *
* This program 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. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using System;
namespace Server
{
/// <summary>
/// Hints to the source generator that this field will execute an InvalidateProperties when the value is set
/// and the value is different from the current value.
/// </summary>
[AttributeUsage(AttributeTargets.Field)]
public class InvalidatePropertiesAttribute : Attribute
{
}
}

View file

@ -1,32 +0,0 @@
/*************************************************************************
* ModernUO *
* Copyright (C) 2019-2021 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: SerializableEntityAttribute.cs *
* *
* This program 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. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using System;
namespace Server
{
[AttributeUsage(AttributeTargets.Class)]
public sealed class SerializableAttribute : Attribute
{
public int Version { get; }
public bool EncodedVersion { get; }
public SerializableAttribute(int version, bool encodedVersion = true)
{
Version = version;
EncodedVersion = encodedVersion;
}
}
}

View file

@ -1,46 +0,0 @@
/*************************************************************************
* ModernUO *
* Copyright (C) 2019-2021 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: SerializableFieldAttribute.cs *
* *
* This program 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. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using System;
namespace Server
{
/// <summary>
/// Hints to the source generator that this field or property should be serialized.
/// When used on a field, the source generator will generate the property entirely.
/// When used on a property, the user must call this.MarkDirty() after reassigning the value or modifying the value internally.
/// </summary>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public sealed class SerializableFieldAttribute : Attribute
{
public int Order { get; }
public string PropertyGetter { get; }
public string? PropertySetter { get; }
public bool IsVirtual { get; }
public SerializableFieldAttribute(
int order,
string getter = "public",
string setter = "public",
bool isVirtual = false
)
{
Order = order;
PropertyGetter = getter;
PropertySetter = setter;
IsVirtual = isVirtual;
}
}
}

View file

@ -1,46 +0,0 @@
/*************************************************************************
* ModernUO *
* Copyright 2019-2021 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: SerializableFieldAttributeAttribute.cs *
* *
* This program 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. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using System;
namespace Server
{
/// <summary>
/// Hints to the source generator that this field will need this attribute on the generated property
/// [SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")]
/// -or-
/// [SerializableFieldAttr(typeof(CommandPropertyAttribute), AccessLevel.GameMaster)]
/// </summary>
[AttributeUsage(AttributeTargets.Field, AllowMultiple = true)]
public sealed class SerializableFieldAttrAttribute : Attribute
{
public string AttributeString { get; }
public Type AttributeType { get; }
public object[] Arguments { get; }
public SerializableFieldAttrAttribute(string attrString) => AttributeString = attrString;
public SerializableFieldAttrAttribute(Type type, params object[] args)
{
if (typeof(Attribute).IsAssignableFrom(type))
{
throw new ArgumentException($"Argument {nameof(type)} must be an attribute.");
}
AttributeType = type;
Arguments = args;
}
}
}

View file

@ -1,35 +0,0 @@
/*************************************************************************
* ModernUO *
* Copyright 2019-2021 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: SerializableFieldDefaultAttribute.cs *
* *
* This program 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. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using System;
namespace Server
{
/// <summary>
/// Hints to the source generator that the field with the same order should use this default value
/// while deserializing. The default is used when the save flag indicates that we don't need to serialize the value
/// because this default can be used instead.
///
/// Note: This is only used for the current version, not previous versions. Previous versions will always use a default
/// value for that type if it is not deserialized.
/// </summary>
[AttributeUsage(AttributeTargets.Method)]
public sealed class SerializableFieldDefaultAttribute : Attribute
{
public int Order { get; }
public SerializableFieldDefaultAttribute(int order) => Order = order;
}
}

View file

@ -1,30 +0,0 @@
/*************************************************************************
* ModernUO *
* Copyright 2019-2021 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: SerializableFieldSaveFlagAttribute.cs *
* *
* This program 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. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using System;
namespace Server
{
/// <summary>
/// Hints to the source generator that the field with the same order value should use a save flag.
/// </summary>
[AttributeUsage(AttributeTargets.Method)]
public sealed class SerializableFieldSaveFlagAttribute : Attribute
{
public int Order { get; }
public SerializableFieldSaveFlagAttribute(int order) => Order = order;
}
}

View file

@ -1,30 +0,0 @@
/*************************************************************************
* ModernUO *
* Copyright 2019-2021 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: SerializableParentAttribute.cs *
* *
* This program 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. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using System;
namespace Server
{
/// <summary>
/// Hints to the source generator that this field or property indicates the ISerializable parent of this class.
/// </summary>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public sealed class SerializableParentAttribute : Attribute
{
public SerializableParentAttribute()
{
}
}
}

View file

@ -1,27 +0,0 @@
/*************************************************************************
* ModernUO *
* Copyright 2019-2021 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: TidyAttribute.cs *
* *
* This program 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. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using System;
namespace Server
{
/// <summary>
/// Hints to the source generator that a serializable list should be tidied up
/// </summary>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public class TidyAttribute : Attribute
{
}
}

View file

@ -1,28 +0,0 @@
/*************************************************************************
* ModernUO *
* Copyright 2019-2021 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: TimerDriftAttribute.cs *
* *
* This program 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. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using System;
namespace Server
{
/// <summary>
/// Hints to the source generator that this serializable timer field or property will drift
/// during deserialization.
/// </summary>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public class TimerDriftAttribute : Attribute
{
}
}