ModernUO/Projects/UOContent
Kamron Batman 312e3873f1
fix(core): Fixes encoded int. Adds dirty checking opt-out (#619)
### Additions
- Automatically opts-out `Item/Mobile/Guild/Accounts` from dirty checking with a new property `UseDirtyChecking`
- Codegen now enables `UseDirtyChecking` via getter. This requires that the property is `virtual` for derived types.

### Fixes
- Fixes `EncodedInt` being broken
- Fixes issues with new custom serializable types that are not derived from Item/Mobile/etc.
- Removes double dirty checking.

### Example of a brand new serializable type that isn't an Item/Mobile/etc.
User created code:
```cs
using System;

namespace Server.Items
{
    [Serializable(0)]
    public partial class NewTestEntityObject : ISerializable
    {
        [EncodedInt]
        [SerializableField(0)]
        private int _someProperty;

        public NewTestEntityObject()
        {
            SetTypeRef(GetType());
            // Add to serial tracking like World.Item
            /*
            Serial = World.NewEntity;
            World.AddEntity(this);
            */
        }

        [AfterDeserialization]
        private void AfterDeserialization()
        {
            Console.WriteLine("This ran!");
        }

        public int TypeRef { get; }
        public Serial Serial { get; }
        public void Delete()
        {
        }

        public bool Deleted { get; set; }
        public void SetTypeRef(Type type)
        {
            // Type tracking for persistence goes here
            /*
            TypeRef = World.NewEntityTypes.IndexOf(type);
            if (TypeRef == -1)
            {
                World.NewEntityTypes.Add(type);
                TypeRef = World.NewEntityTypes.Count - 1;
            }
            */
        }
    }
}
```

Generated code:
```cs
namespace Server.Items
{
    public partial class NewTestEntityObject
    {
#pragma warning disable 0414
        private const int _version = 0;
#pragma warning restore 0414

        public int SomeProperty
        {
            get => _someProperty;
            set
            {
                if (value != _someProperty)
                {
                    _someProperty = value;
                    ((ISerializable)this).MarkDirty();
                }
            }
        }

        long ISerializable.SavePosition { get; set; } = -1;
        BufferWriter ISerializable.SaveBuffer { get; set; }
        bool ISerializable.UseDirtyChecking => true;

        public NewTestEntityObject(Serial serial)
        {
            Serial = serial;
            SetTypeRef(typeof(NewTestEntityObject));
        }

        public void Serialize(IGenericWriter writer)
        {

            writer.WriteEncodedInt(_version);

            writer.WriteEncodedInt(SomeProperty);
        }

        public void Deserialize(IGenericReader reader)
        {
            var version = reader.ReadEncodedInt();

            SomeProperty = reader.ReadEncodedInt();

            Timer.DelayCall(AfterDeserialization);
        }
    }
}
```
2021-05-26 19:25:05 -07:00
..
Accounting fix(core): Fixes encoded int. Adds dirty checking opt-out (#619) 2021-05-26 19:25:05 -07:00
Commands fix(core): Updates slice with range selectors (#583) 2021-04-23 20:57:24 -07:00
Configuration chore(logging): Migrate some logs to ILogger (#582) 2021-04-22 08:45:49 -07:00
Context Menus Cleanup & Fixes for .NET 5 (#309) 2020-11-15 10:03:50 -08:00
Engines feat: Source generated Serialization/Deserialization (#550) 2021-05-23 21:06:23 -07:00
Gumps fix(core): Fixes some properties that cannot be modified ingame (#604) 2021-05-15 23:47:33 -07:00
Holiday Stuff fix(core): Caches DateTime.NowUtc (#548) 2021-03-13 01:32:04 -08:00
Items fix(core): Fixes some properties that cannot be modified ingame (#604) 2021-05-15 23:47:33 -07:00
Json/Converters Fixes brace style (#248) 2020-09-13 21:49:46 -07:00
Misc fix(core): Updates slice with range selectors (#583) 2021-04-23 20:57:24 -07:00
Mobiles fix(content): Fixes duplicate alias type (#588) 2021-04-30 00:59:53 -07:00
Multis fix(houses): Fixes custom house packets (#594) 2021-05-11 00:07:37 -07:00
Network chore(logging): Migrate some logs to ILogger (#582) 2021-04-22 08:45:49 -07:00
Regions chore(logging): Migrate some logs to ILogger (#582) 2021-04-22 08:45:49 -07:00
Skills fix(network): Adds UOG & Fixes ConnectUO packet (#552) 2021-03-15 16:18:28 -07:00
Special Systems fix(core): Caches DateTime.NowUtc (#548) 2021-03-13 01:32:04 -08:00
Spells feat(champs): Ports Casiopia champions (#584) 2021-05-09 00:20:43 -07:00
Targets fix(core): Removes some uses of Linq (#421) 2021-01-18 21:05:11 -08:00
Utilities fix(cleanup): Consolidate the duplicate code in Properties, PropsGump, and PropsConfig (#540) 2021-04-14 22:58:56 -07:00
UOContent.csproj feat: Source generated Serialization/Deserialization (#550) 2021-05-23 21:06:23 -07:00