For those who are interested - the promised patch:

--- a/Rhino.Mocks/Impl/ProxyInstance.cs
+++ b/Rhino.Mocks/Impl/ProxyInstance.cs
@@ -327,7 +327,8 @@ namespace Rhino.Mocks.Impl

                private static string GenerateKey(MethodInfo method, object[] 
args)
                {
-            var baseName = method.DeclaringType.FullName +
method.Name.Substring(4);
+            var propertyType = method.Name.StartsWith("get_") ?
method.ReturnType : method.GetParameters()[args.Length -
1].ParameterType;
+            var baseName = propertyType.FullName +
method.Name.Substring(4);
             if ((method.Name.StartsWith("get_") && args.Length == 0)
||
                            (method.Name.StartsWith("set_") && args.Length == 
1))
                                return baseName;

This solves the described problem - as proven by the following test.

--- a/Rhino.Mocks.Tests/StubAllTest.cs
+++ b/Rhino.Mocks.Tests/StubAllTest.cs
@@ -161,6 +161,14 @@ namespace Rhino.Mocks.Tests
             Assert.Equal(5, aquarium.DetermineAge(new
SpecificFish()));
         }

+        [Fact]
+        public void
StubDoesNotDistinguishInheritedPropertiesWithSameName()
+        {
+            IDog dog = MockRepository.GenerateStub<IDog>();
+            dog.Name = "Bello";
+
+            Assert.Equal("Bello", ((IAnimal)dog).Name);
+        }
        }

        public interface ICat : IAnimal
@@ -168,6 +176,11 @@ namespace Rhino.Mocks.Tests
                bool IsDeclawed { get; set; }
        }

+       public interface IDog : IAnimal
+       {
+               new string Name { get; set; }
+       }
+
        public class Feline
        {
                private int _furLength;

Br,
Andreas

On 15 Nov., 11:30, haifisch <[email protected]> wrote:
> Hello,
>
> the attached test will print "20" twice with the initial 3.6 version -
> but the behavior has changed - now it will print "20" and "0". What
> I'm interested in - what is/was the intended/correct behavior?
>
> Was this a side effect of the two attached changesets? At least at my
> interpretation it was - but that doesn't need to mean that the old
> behavior was correct.
>
> I'll try to write a patch for ProxyInstance.cs that considers only the
> Name and the Type of a property. Sounds this like a reasonable
> solution?
>
> Br,
>
> Andreas
>
> public interface IReadOnly
>   {
>     int MyProperty { get; }
>   }
>
>   public interface IWriteable : IReadOnly
>   {
>     new int MyProperty { get; set; }
>   }
>
>   [TestFixture]
>   public class Class1
>   {
>     [Test]
>     public void ExplorationTest()
>     {
>       var proc = MockRepository.GenerateStub<IWriteable>();
>       proc.MyProperty = 20;
>
>       Console.WriteLine(proc.MyProperty);
>       Console.WriteLine(((IReadOnly)proc).MyProperty);
>     }
>   }
>
> This revision leads to a implicit implementation of the interface in
> the proxy - and therefore enables the distinction of the "two"
> properties.
>
> Revision: 625425fda3055d3ffb5161329c7767ef8395b7f5
> Author: Tim Barcz
> Date: 09.09.2009 20:17:15
> Message:
> Updated Castle.Core and Castle.DynamicProxy2 dlls to version running
> on the trunk. This is in efforts to fix bug around
> BadImageFormatException when mocking some interfaces (ie.
> IUnityContainer)
>
> ----
> Modified : Rhino.Mocks.Tests/Expectations/AnyArgsExpectationTests.cs
> Modified : Rhino.Mocks.Tests/MockRepositoryTests.cs
> Modified : Rhino.Mocks.Tests/MockingClassesTests.cs
> Modified : Rhino.Mocks.Tests/MockingDelegatesTests.cs
> Modified : Rhino.Mocks.Tests/Rhino.Mocks.Tests 3.5.csproj
> Modified : SharedLibs/Castle.Core.dll
> Modified : SharedLibs/Castle.DynamicProxy2.dll
>
> And this revision enables the distinction in RhinoMocks - it's funny
> that this is the older revision, meaning that the breaking change was
> a side effect of the subsequent DynamicProxy update ;-)
>
> Revision: 884e302fa4981ef344dd85a665711606515b3f43
> Author: Ayende Rahien
> Date: 01.09.2009 14:01:40
> Message:
> Removing old release.cmd file
>
> Patch from Alexander Groß, fixing an issue with stubbing properties of
> generic interfaces implemented twice using different generic
> parameters
> ----
> Added : Rhino.Mocks.Tests/FieldsProblem/FieldProblem_Alex.cs
> Modified : Rhino.Mocks.Tests/Rhino.Mocks.Tests 3.5.csproj
> Modified : Rhino.Mocks/Impl/ProxyInstance.cs
> Deleted : release.cmd

-- 
You received this message because you are subscribed to the Google Groups 
"Rhino.Mocks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rhinomocks?hl=en.

Reply via email to