提交 0e7a3971 编写于 作者: A Atsushi Eno

Do not reject contract from the same method, could happen by a type with...

Do not reject contract from the same method, could happen by a type with multiple service contracts within the typie hierarchy.

For details, see: http://lists.ximian.com/pipermail/mono-devel-list/2010-September/035940.html
上级 714812b6
...@@ -255,8 +255,8 @@ namespace System.ServiceModel.Description ...@@ -255,8 +255,8 @@ namespace System.ServiceModel.Description
} }
cd.Operations.Add (od); cd.Operations.Add (od);
} }
else if (oca.AsyncPattern && od.BeginMethod != null || else if (oca.AsyncPattern && od.BeginMethod != null && od.BeginMethod != mi ||
!oca.AsyncPattern && od.SyncMethod != null) !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)); 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) if (oca.AsyncPattern)
......
...@@ -420,6 +420,14 @@ namespace MonoTests.System.ServiceModel.Description ...@@ -420,6 +420,14 @@ namespace MonoTests.System.ServiceModel.Description
Assert.AreEqual (typeof (IFoo3), cd.ContractType, "#3"); Assert.AreEqual (typeof (IFoo3), cd.ContractType, "#3");
Assert.AreEqual (3, cd.Operations.Count, "#4"); 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. // It is for testing attribute search in interfaces.
public class Foo : IFoo public class Foo : IFoo
...@@ -628,5 +636,33 @@ namespace MonoTests.System.ServiceModel.Description ...@@ -628,5 +636,33 @@ namespace MonoTests.System.ServiceModel.Description
set { foo = value; } 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() { }
}
}
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册