Пример #1
0
        private FieldDefinition CreateAtomField(PropertyDefinition property)
        {
            var name          = Helpers.GenerateUniqueFieldName(property.DeclaringType, $"__{property.Name}");
            var atomFieldType = Helpers.MakeGenericType(_atomType, property.PropertyType);

            return(new FieldDefinition(name, FieldAttributes.Private, atomFieldType));
        }
Пример #2
0
        private void FixAutoPropertyBackingField(PropertyDefinition property)
        {
            var il = property.GetMethod.Body.Instructions;

            if (il.Count == 3 &&
                il[0].OpCode == OpCodes.Ldarg_0 &&
                il[2].OpCode == OpCodes.Ret &&
                il[1].OpCode == OpCodes.Ldfld &&
                il[1].Operand is FieldDefinition backingField &&
                backingField.Name.Equals($"<{property.Name}>k__BackingField"))
            {
                var name = $"__{property.Name}__BackingField";
                backingField.Name = Helpers.GenerateUniqueFieldName(property.DeclaringType, name);
            }
        }