Home Bug Reports

[Ice 3.6b] Bug if change member position in class

PapayPapay Member Dmitriy EvsyukovOrganization: AigrindProject: Best MMORPG
I defined a class in the slice (fragment):
                    ["clr:property"]
                    class AbilityDto
                    {
                        int Id;
                        ConsumableResourceDto ConsumableResource;
                        int CostValue;
                        bool CostIsPercent;
                        ClrTimeSpan CastTime;
                        float Radius;
                        ClrTimeSpan CooldownTime;
[B]                       TargetTypes::AbilityTargetTypeDto TargetType;
                        optional(1) AbilityGroupDto AbilityGroup;[/B]
                       AbilityLimitationDtoList CasterLimitations;
                        AbilityLimitationDtoList TargetLimitations;
                        AbilityComponentDtoList Components;
                        optional(2) CooldownGroupDto CooldownGroup;
                    };
Ice compiler made cs file (fragment):
                        [_System.CodeDom.Compiler.GeneratedCodeAttribute("slice2cs", "3.6b")]
                        public sealed class Patcher__ : IceInternal.Patcher
                        {
                            internal Patcher__(string type, Ice.Object instance, int member) : base(type)
                            {
                                _instance = (AbilityDto)instance;
                                _member = member;
                            }

                            public override void patch(Ice.Object v)
                            {
                                try
                                {
                                    switch(_member)
                                    {
                                    case 0:
                                        _instance.TargetType = (Slice.Core.Abilities.TargetTypes.AbilityTargetTypeDto)v;
                                        break;
                                    case 1:
                                        _instance.AbilityGroup = new Ice.Optional<Slice.Core.Abilities.AbilityGroupDto>((Slice.Core.Abilities.AbilityGroupDto)v);
                                        break;
                                    }
                                }
                                catch(_System.InvalidCastException)
                                {
                                    IceInternal.Ex.throwUOE(type(), v.ice_id());
                                }
                            }

                            private AbilityDto _instance;
                            private int _member;
                        }

                        [_System.CodeDom.Compiler.GeneratedCodeAttribute("slice2cs", "3.6b")]
                        protected virtual void readImpl__(IceInternal.BasicStream is__)
                        {
                            is__.startReadSlice();
                            Id__prop = is__.readInt();
                            ConsumableResource__prop = (Slice.Core.Abilities.ConsumableResourceDto)is__.readEnum(1);
                            CostValue__prop = is__.readInt();
                            CostIsPercent__prop = is__.readBool();
                            CastTime__prop = Slice.Core.Abilities.ClrTimeSpanHelper.read(is__);
                            Radius__prop = is__.readFloat();
                            CooldownTime__prop = Slice.Core.Abilities.ClrTimeSpanHelper.read(is__);
                            is__.readObject(new Patcher__(Slice.Core.Abilities.TargetTypes.AbilityTargetTypeDto.ice_staticId(), this, 0));
                            CasterLimitations__prop = Slice.Core.Abilities.AbilityLimitationDtoListHelper.read(is__);
                            TargetLimitations__prop = Slice.Core.Abilities.AbilityLimitationDtoListHelper.read(is__);
                            Components__prop = Slice.Core.Abilities.AbilityComponentDtoListHelper.read(is__);
                            is__.readObject(1, new Patcher__(Slice.Core.Abilities.AbilityGroupDto.ice_staticId(), this, 1));
                            if(is__.readOpt(2, Ice.OptionalFormat.VSize))
                            {
                                is__.skipSize();
                                Slice.Core.Abilities.CooldownGroupDto tmpVal__ = new Slice.Core.Abilities.CooldownGroupDto();
                                tmpVal__.read__(is__);
                                CooldownGroup__prop = new Ice.Optional<Slice.Core.Abilities.CooldownGroupDto>(tmpVal__);
                            }
                            else
                            {
                                CooldownGroup__prop = new Ice.Optional<Slice.Core.Abilities.CooldownGroupDto>();
                            }
                            is__.endReadSlice();
                        }

If I change class definition (swap 2 line):
                    ["clr:property"]
                    class AbilityDto
                    {
                        int Id;
                        ConsumableResourceDto ConsumableResource;
                        int CostValue;
                        bool CostIsPercent;
                        ClrTimeSpan CastTime;
                        float Radius;
                        ClrTimeSpan CooldownTime;
[B]                       optional(1) AbilityGroupDto AbilityGroup;
                        TargetTypes::AbilityTargetTypeDto TargetType;[/B]
                       AbilityLimitationDtoList CasterLimitations;
                        AbilityLimitationDtoList TargetLimitations;
                        AbilityComponentDtoList Components;
                        optional(2) CooldownGroupDto CooldownGroup;
                    };
Ice compiler made cs file (fragment):
                        [_System.CodeDom.Compiler.GeneratedCodeAttribute("slice2cs", "3.6b")]
                        public sealed class Patcher__ : IceInternal.Patcher
                        {
                            internal Patcher__(string type, Ice.Object instance, int member) : base(type)
                            {
                                _instance = (AbilityDto)instance;
                                _member = member;
                            }

                            public override void patch(Ice.Object v)
                            {
                                try
                                {
                                    switch(_member)
                                    {
                                    case 0:
                                        _instance.AbilityGroup = new Ice.Optional<Slice.Core.Abilities.AbilityGroupDto>((Slice.Core.Abilities.AbilityGroupDto)v);
                                        break;
                                    case 1:
                                        _instance.TargetType = (Slice.Core.Abilities.TargetTypes.AbilityTargetTypeDto)v;
                                        break;
                                    }
                                }
                                catch(_System.InvalidCastException)
                                {
                                    IceInternal.Ex.throwUOE(type(), v.ice_id());
                                }
                            }

                            private AbilityDto _instance;
                            private int _member;
                        }
Method "void readImpl__(IceInternal.BasicStream is__)" not changed, but method "void patch(Ice.Object v)" changed. This changes generate exception Ice.UnexpectedObjectException in runtime because .Net runtime can't cast one type to another type (absolute different types). See cast in switch operator.

Comments

  • PapayPapay Member Dmitriy EvsyukovOrganization: AigrindProject: Best MMORPG
    slice2cs bug

    May be this is slice2cs bug.
  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Hi,

    This is indeed a bug, a fix is already available in our github repository, and will be included in upcoming 3.6.0 release.

    Thanks for reporting the issue.
  • PapayPapay Member Dmitriy EvsyukovOrganization: AigrindProject: Best MMORPG
    Release 3.6

    Can you clarify when the scheduled release?
Sign In or Register to comment.