Error override virtual function

Dec 16, 2016 at 7:34 PM
Really good job.
I have error with override/virtual function the Aspect.Directory.Populate fail to add
methoinfo in Aspect.Directory.m_Dictionary.

with this code you have error :
    public class Logging : IAspect
    {
        public IEnumerable<IAdvice> Advise(MethodInfo method)
        {
            yield return Advice.Basic.Around(new Func<object, object[], Func<object>, object>((_Instance, _Arguments, _Body) =>
            {
                var _trace = new Trace(method, _Arguments.Select(_Argument => _Argument.ToString()).ToArray());
                try
                {
                    var _return = _Body();
                    _trace.Dispose(_return.ToString());
                    return _return;
                }
                catch (Exception exception)
                {
                    _trace.Dispose(exception);
                    throw;
                }
            }));
        }
    }
    class Program
    {
        static void Main(string[] args)
        {

            var _operationContractJoinpoint = new Func<MethodInfo, bool>(_Method => _Method.IsDefined(typeof(MyAttribute), false));

            Aspect.Weave<Logging>(_operationContractJoinpoint);

            Chat ca = new TestFAM.Chat { Age = 5, Kg = 2 };

            Chien ci = new Chien();

            ci.Age = 3;
            ci.Kg = 15;

            ca.SpeedMax(1);
            ci.SpeedMax(5);

        }
    }

    [AttributeUsage(AttributeTargets.All)]
    public class MyAttribute : Attribute
    {
        private string myName;
        public MyAttribute(string name)
        {
            myName = name;
        }
        public string Name
        {
            get
            {
                return myName;
            }
        }
    }

    interface IAnimals
    {
        int Age { get; set; }

        [MyAttribute("IKg")]
        int Kg { get; set; }

        int SpeedMax(int l);
    }

    [MyAttribute("Animals")]
    public abstract class Animals : IAnimals
    {
        private int age;
        [MyAttribute("Age")]
        public int Age
        {
            get { return age; }
            set { age = value; }
        }


        private int kg;

        public int Kg
        {
            get { return kg; }
            set { kg = value; }
        }

        [MyAttribute("VSpeedMax")]
        public virtual int SpeedMax(int l)
        {

            return Kg / l;
        }
    }

    public class Chien:Animals
    {
        [MyAttribute("OSpeedMax")]
        public override int SpeedMax(int l)
        {
            return (Kg / l) * 2;
        }
    }

    public class Chat : Animals
    {

    }
Coordinator
Dec 17, 2016 at 10:09 AM
Edited Dec 17, 2016 at 10:06 PM
Hi, thank you for your interest, I tried your case today and I am working on a stable fix.

I corrected Virtualization class to work now (not committed) but it is not enough... after full testing, an other issue come from a breaking change on vtable layout in CLR4 when classes implements an interface. If I remove IAnimal, it work for example.

I continue working on good fix.
Coordinator
Dec 21, 2016 at 7:28 AM
The issue is now fixed. There is a bug with github integration with codeplex, I cannot push the fix now but you can find it in my official Github mirror here : https://github.com/Neptune1981/NConcern