Added MethodToSkip to public
What does this change: I need the function to pass through certain methods to the orginal target (like the funtion ToString or Equals).
Now you can add or remove method names which should be ignored.
ChangeTrackingFactory.Default.MethodsToSkip.Remove(nameof(Equals));
I am missing something, ToString() is not intercepted and is passed thru to the original target.
void Main()
{
Order order = new Order { Id = 123 };
var trackable = order.AsTrackable();
Console.WriteLine(order.ToString());
trackable.Id = 321;
Console.WriteLine(order.ToString());
}
public class Order
{
public virtual int Id { get; set; }
public override string ToString() => $"Id={Id}";
}
puts out
Id=123
Id=321
If you can please clarify. Thanks.
I am missing something,
ToString()is not intercepted and is passed thru to the original target.void Main() { Order order = new Order { Id = 123 }; var trackable = order.AsTrackable(); Console.WriteLine(order.ToString()); trackable.Id = 321; Console.WriteLine(order.ToString()); } public class Order { public virtual int Id { get; set; } public override string ToString() => $"Id={Id}"; }puts out
Id=123 Id=321If you can please clarify. Thanks.
I will check this and will add a Unit Test for this case.
I was able to elicit the behavior. It is because of the "override" of ToString which causes this behavior. (This also happened before my change.) If the ToString method was overridden, it will be called in the target and not the method in the proxy. However, if the method was not overridden, then it does not find this method in the target and automatically calls the proxy method. In this case, the MethodsToSkip works as expected.
please provide me with an example of what happens and what you expect to happen.