diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Description/ContractDescriptionGenerator.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Description/ContractDescriptionGenerator.cs index 2f135566e59b2fdc7f8d7f7f5447f3e285a20a1e..26e3d609e6cbed100cc5620d9c06df8836afe252 100644 --- a/mcs/class/System.ServiceModel/System.ServiceModel.Description/ContractDescriptionGenerator.cs +++ b/mcs/class/System.ServiceModel/System.ServiceModel.Description/ContractDescriptionGenerator.cs @@ -255,8 +255,8 @@ namespace System.ServiceModel.Description } cd.Operations.Add (od); } - else if (oca.AsyncPattern && od.BeginMethod != null || - !oca.AsyncPattern && od.SyncMethod != null) + else if (oca.AsyncPattern && od.BeginMethod != null && od.BeginMethod != mi || + !oca.AsyncPattern && od.SyncMethod != null && od.SyncMethod != mi) throw new InvalidOperationException (String.Format ("contract '{1}' cannot have two operations for '{0}' that have the identical names and different set of parameters.", name, cd.Name)); if (oca.AsyncPattern) diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/ContractDescriptionTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/ContractDescriptionTest.cs index 310c396dc548f6d42d8b8f0a0cc1d0becdaf4f39..a44b6a13571d3ad9e5058884a4f6fd8bd14d4d98 100644 --- a/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/ContractDescriptionTest.cs +++ b/mcs/class/System.ServiceModel/Test/System.ServiceModel.Description/ContractDescriptionTest.cs @@ -420,6 +420,14 @@ namespace MonoTests.System.ServiceModel.Description Assert.AreEqual (typeof (IFoo3), cd.ContractType, "#3"); Assert.AreEqual (3, cd.Operations.Count, "#4"); } + + [Test] + public static void MultipleContractsInTypeHierarchy () + { + ContractDescription.GetContract (typeof (DuplicateCheckClassWrapper.ServiceInterface)); + + var host = new ServiceHost (typeof (DuplicateCheckClassWrapper.DummyService)); // fine in MS, fails in Mono with "A contract cannot have two operations that have the identical names and different set of parameters" + } // It is for testing attribute search in interfaces. public class Foo : IFoo @@ -628,5 +636,33 @@ namespace MonoTests.System.ServiceModel.Description set { foo = value; } } } + + public class DuplicateCheckClassWrapper + { + + [ServiceContract] + internal interface ServiceInterface : Foo + { + } + + [ServiceContract] + internal interface Foo : Bar + { + [OperationContract] void Foo(); + } + + [ServiceContract] + internal interface Bar + { + [OperationContract] void FooBar(); + } + + internal class DummyService : ServiceInterface + { + public void FooBar() { } + + public void Foo() { } + } + } } }