2

For example, let's say I've defined an interface as follows:

public interface IWhatever
{
     string Text { get; set; }
}

And I implement it in a mixin:

public class WhateverMixin : IWhatever
{
     string IWhatever.Text { get; set; }
}

When I build a proxy of some given class, the whole explicitly-implemented interface member appears as implicitly implemented so it gets published.

Do you know if there's some option I can give to Castle DynamicProxy to force implementing an interface with explicit implementations?

Matías Fidemraizer
  • 63,804
  • 18
  • 124
  • 206

1 Answers1

2

Unfortunately, DynamicProx doesn't seem to have any options for this. There's no such setting in the ProxyGenerationOptions or MixinData classes, and if you look into the code (starting from MixinContributor, which leads to MethodGenerator), you can see that it simply copies the name and attributes (visibility, etc.) from the interface method.

Fabian Schmied
  • 3,885
  • 3
  • 30
  • 49
  • Just curious... Do you know any other proxy generator that has already implemented such feature? – Matías Fidemraizer Jul 26 '16 at 21:49
  • No, sorry, I don't know of any other proxy generators, although you could probably use the [TypePipe](http://typepipe.codeplex.com/) to build your own. Alternatively, if you just need mixin capabilities, you could try re-motion's [re-mix](https://remix.codeplex.com/) - that library implements mixin interfaces explicitly by default. (Note that I'm one of the original authors of both of these libraries.) – Fabian Schmied Jul 27 '16 at 06:21
  • Well, actually another alternative would be using IL weaving with PostSharp. At the end of the day, if you want to know what's the backgorund of this Q&A... it's because of some open source I've been developing during last year: http://matiasfidemraizer.com/trackerdog – Matías Fidemraizer Jul 27 '16 at 08:27
  • It's a generic change tracking library for .NET. And I'm asking this question because of the following issue contributed by some user: https://github.com/mfidemraizer/trackerdog/issues/10 – Matías Fidemraizer Jul 27 '16 at 08:28