Question

I have a change tracking framework that tracks changed made to domain objects on the client. It uses Castle.Windsor as the tool for creating proxy objects. After I changed Castle to version 3.0 calls of properties inside methods that are not intercepted are not forwarded to the target object anymore.

sequence diagram http://www.pictureupload.de/originals/pictures/200312135214_ct.png

ChangeTracker is a class of my own that handles the tracking of the changed made to the inner object.

A custom ProxyGenerationHook is used, which worked correctly with Castle 2.5:

private sealed class ProxyGenerationHook : IProxyGenerationHook
{
    public void MethodsInspected()
    { }

    public void NonProxyableMemberNotification(Type type, MemberInfo memberInfo)
    { }

    public bool ShouldInterceptMethod(Type type, MethodInfo methodInfo)
    {
       if (methodInfo == null)
       {
          throw ExceptionBuilder.ArgumentNull("methodInfo");
       }

       string methodName = methodInfo.Name;
       bool result = methodName.StartsWith("set_", StringComparison.OrdinalIgnoreCase) ||
                     methodName.StartsWith("get_", StringComparison.OrdinalIgnoreCase);

       return result;
    }
 }

This is the domain class used:

public class Person
{
  public virtual int Id { set; get; }
  public virtual string Name { set; get; }

  protected virtual int Age { set; get; }

  public void SetAgeTo(int value)
  {
     Age = value;
  }
}

Is this now the intended behaviour or is this a bug of Castle 3.0?

Was it helpful?

Solution

This is a regression bug. It will be fixed in version 3.1

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top