Warpten / DBClientFiles.NET

The new version of DBFilesClient.NET.
GNU General Public License v3.0
11 stars 5 forks source link

Avoid using property getters and setters when deserializing #11

Open Warpten opened 6 years ago

Warpten commented 6 years ago

This is not a pretty solution but it would help avoiding the issue of value type getters returning temporary copies of the underlying types. The problem is that autogenerated getters typically retrieve a field named <prop>k_BackingField, (IsSpecialName returns true) which is compiler-specific. So not exactly portable.

The idea is to not limit the user to reference type substructures:

    public class C3Vector // Runtime exception if value type.
    {
        public float X { get; set; }
        public float Y { get; set; }
        public float Z { get; set; }
    }

    public struct AreaTriggerEntry
    {
        public uint ID { get; set; }
        public uint MapID { get; set; }
        public C3Vector Position { get; set; }
        public float Radius { get; set; }
        public C3Vector BoxSize { get; set; }
        public float BoxOrientation { get; set; }
    }
Warpten commented 6 years ago

GetMethodBody into ResolveField?

Warpten commented 6 years ago

basic autogenerated getter body

ldloc.0
ldflda <prop>k_BackingField
ret

[CommpilerGenerated] is applied to the getter and the backing field

Warpten commented 6 years ago

ditched for 1.0

Warpten commented 5 years ago

This would be fixed by ref returns properties but auto implemented ref properties are not implemented in the language (and that would ban setters, which is annoying)

Warpten commented 5 years ago

Back in 1.0