2 // ContractDescriptionTest.cs
5 // Atsushi Enomoto <atsushi@ximian.com>
7 // Copyright (C) 2005 Novell, Inc. http://www.novell.com
8 // Copyright (C) 2011 Xamarin, Inc. http://xamarin.com
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 using System.Collections.ObjectModel;
32 using System.Net.Security;
33 using System.Reflection;
34 using System.ServiceModel;
35 using System.ServiceModel.Channels;
36 using System.ServiceModel.Description;
37 using System.ServiceModel.Dispatcher;
38 using NUnit.Framework;
40 namespace MonoTests.System.ServiceModel.Description
43 public class ContractDescriptionTest
46 [ExpectedException (typeof (InvalidOperationException))]
47 public void GetNonContract ()
49 ContractDescription cd = ContractDescription.GetContract (
54 public void GetContract ()
56 InternalTestGetContract (
57 ContractDescription.GetContract (typeof (IFoo)));
61 public void GetContractParamRenamed ()
63 ContractDescription cd = ContractDescription.GetContract (typeof (IFooMsgParams));
65 Assert.AreEqual (1, cd.Operations.Count, "Operation count");
68 OperationDescription od = cd.Operations [0];
70 ServiceAssert.AssertOperationDescription (
72 typeof (IFooMsgParams).GetMethod ("Foo"),
76 // Operation #1 -> Message #1
77 MessageDescription md = od.Messages [0];
79 ServiceAssert.AssertMessageAndBodyDescription (
80 "http://tempuri.org/IFooMsgParams/MyFoo",
81 MessageDirection.Input,
82 null, "MyFoo", "http://tempuri.org/", false,
85 ServiceAssert.AssertMessagePartDescription (
86 "MyParam", "http://tempuri.org/", 0, false,
87 ProtectionLevel.None, typeof (string), md.Body.Parts [0], "MyFoo.msg");
91 ServiceAssert.AssertMessageAndBodyDescription (
92 "http://tempuri.org/IFooMsgParams/MyFooResponse",
93 MessageDirection.Output,
94 null, "MyFooResponse",
95 "http://tempuri.org/", true,
98 ServiceAssert.AssertMessagePartDescription (
99 "MyResult", "http://tempuri.org/", 0, false,
100 ProtectionLevel.None, typeof (string), md.Body.ReturnValue, "MyResult ReturnValue");
104 public void GetContractConfigName ()
106 ContractDescription cd = ContractDescription.GetContract (typeof (ICtorUseCase2));
107 Assert.AreEqual("CtorUseCase2", cd.ConfigurationName);
108 Assert.AreEqual("ICtorUseCase2", cd.Name);
109 cd = ContractDescription.GetContract (typeof (ICtorUseCase1));
110 Assert.AreEqual("MonoTests.System.ServiceModel.ICtorUseCase1", cd.ConfigurationName);
111 Assert.AreEqual("ICtorUseCase1", cd.Name);
115 public void GetContract2 ()
117 InternalTestGetContract (
118 ContractDescription.GetContract (typeof (Foo)));
121 public void InternalTestGetContract (ContractDescription cd)
123 ServiceAssert.AssertContractDescription (
124 "IFoo", "http://tempuri.org/", SessionMode.Allowed, typeof (IFoo), null,
127 Assert.AreEqual (2, cd.Operations.Count, "Operation count");
130 OperationDescription od = cd.Operations [0];
132 ServiceAssert.AssertOperationDescription (
133 "HeyDude", null, null,
134 typeof (IFoo).GetMethod ("HeyDude"),
138 // Operation #1 -> Message #1
139 MessageDescription md = od.Messages [0];
141 ServiceAssert.AssertMessageAndBodyDescription (
142 "http://tempuri.org/IFoo/HeyDude",
143 MessageDirection.Input,
144 null, "HeyDude", "http://tempuri.org/", false,
147 ServiceAssert.AssertMessagePartDescription (
148 "msg", "http://tempuri.org/", 0, false,
149 ProtectionLevel.None, typeof (string), md.Body.Parts [0], "HeyDude.msg");
150 ServiceAssert.AssertMessagePartDescription (
151 "msg2", "http://tempuri.org/", 1, false,
152 ProtectionLevel.None, typeof (string), md.Body.Parts [1], "HeyDude.msg");
154 // Operation #1 -> Message #2
155 md = od.Messages [1];
157 ServiceAssert.AssertMessageAndBodyDescription (
158 "http://tempuri.org/IFoo/HeyDudeResponse",
159 MessageDirection.Output,
160 null, "HeyDudeResponse",
161 "http://tempuri.org/", true,
164 ServiceAssert.AssertMessagePartDescription (
165 "HeyDudeResult", "http://tempuri.org/", 0, false,
166 ProtectionLevel.None, typeof (string), md.Body.ReturnValue, "HeyDudeResponse ReturnValue");
169 od = cd.Operations [1];
171 ServiceAssert.AssertOperationDescription (
172 "HeyHey", null, null,
173 typeof (IFoo).GetMethod ("HeyHey"),
177 // Operation #2 -> Message #1
178 md = od.Messages [0];
180 ServiceAssert.AssertMessageAndBodyDescription (
181 "http://tempuri.org/IFoo/HeyHey",
182 MessageDirection.Input,
183 null, "HeyHey", "http://tempuri.org/", false,
186 ServiceAssert.AssertMessagePartDescription (
187 "ref1", "http://tempuri.org/", 0, false,
188 ProtectionLevel.None, typeof (string), md.Body.Parts [0], "HeyHey.ref1");
190 // Operation #2 -> Message #2
191 md = od.Messages [1];
193 ServiceAssert.AssertMessageAndBodyDescription (
194 "http://tempuri.org/IFoo/HeyHeyResponse",
195 MessageDirection.Output,
196 null, "HeyHeyResponse",
197 "http://tempuri.org/", true,
200 ServiceAssert.AssertMessagePartDescription (
201 "HeyHeyResult", "http://tempuri.org/", 0, false,
202 ProtectionLevel.None, typeof (void), md.Body.ReturnValue, "HeyHeyResponse ReturnValue");
204 ServiceAssert.AssertMessagePartDescription (
205 "out1", "http://tempuri.org/", 0, false,
206 ProtectionLevel.None, typeof (string), md.Body.Parts [0], "HeyHey.out1");
207 ServiceAssert.AssertMessagePartDescription (
208 "ref1", "http://tempuri.org/", 1, false,
209 ProtectionLevel.None, typeof (string), md.Body.Parts [1], "HeyHey.ref1");
213 public void GetContractInherit ()
215 ContractDescription.GetContract (typeof (Foo));
219 [ExpectedException (typeof (InvalidOperationException))]
220 public void GetMultipleServiceContract ()
222 ContractDescription.GetContract (typeof (FooBar));
226 // [ExpectedException (typeof (InvalidOperationException))]
227 public void GetContractNoOperation ()
229 ContractDescription.GetContract (typeof (INoOperation));
233 [Category ("NotWorking")]
234 public void GetContractMessageParameter ()
236 ContractDescription cd = ContractDescription.GetContract (typeof (IMessageParameter));
238 ServiceAssert.AssertContractDescription (
239 "IMessageParameter", "http://tempuri.org/",
240 SessionMode.Allowed, typeof (IMessageParameter), null,
243 OperationDescription od = cd.Operations [0];
245 ServiceAssert.AssertOperationDescription (
246 "ReturnMessage", null, null,
247 typeof (IMessageParameter).GetMethod ("ReturnMessage"),
251 MessageDescription md = od.Messages [0];
253 ServiceAssert.AssertMessageAndBodyDescription (
254 "http://tempuri.org/IMessageParameter/ReturnMessage",
255 MessageDirection.Input,
256 // Body.WrapperName is null
257 null, null, null, false,
258 md, "ReturnMessage");
260 ServiceAssert.AssertMessagePartDescription (
261 "arg", "http://tempuri.org/", 0, false,
262 ProtectionLevel.None, typeof (Message), md.Body.Parts [0], "ReturnMessage input");
266 [ExpectedException (typeof (InvalidOperationException))]
267 public void GetContractInvalidAsync ()
269 ContractDescription.GetContract (typeof (IInvalidAsync));
273 // IMetadataExchange contains async patterns.
274 public void GetContractIMetadataExchange ()
276 ContractDescription cd = ContractDescription.GetContract (typeof (IMetadataExchange));
277 OperationDescription od = cd.Operations [0];
278 Assert.AreEqual (2, od.Messages.Count, "premise: message count");
279 foreach (MessageDescription md in od.Messages) {
280 if (md.Direction == MessageDirection.Input) {
281 Assert.AreEqual ("http://schemas.xmlsoap.org/ws/2004/09/transfer/Get", md.Action, "#1-1");
282 Assert.AreEqual (1, md.Body.Parts.Count, "#1-2");
283 Assert.IsNull (md.Body.ReturnValue, "#1-3");
284 Assert.AreEqual (typeof (Message), md.Body.Parts [0].Type, "#1-4");
286 Assert.AreEqual ("http://schemas.xmlsoap.org/ws/2004/09/transfer/GetResponse", md.Action, "#2-1");
287 Assert.AreEqual (0, md.Body.Parts.Count, "#2-2");
288 Assert.IsNotNull (md.Body.ReturnValue, "#2-3");
289 Assert.AreEqual (typeof (Message), md.Body.ReturnValue.Type, "#2-4");
295 // enable it if we want to become a compatibility kid. It has
296 // no ServiceContract, thus it should not be accepted. But
297 // there is an abuse of ChannelFactory<IRequestChannel> in
298 // MSDN documentations and probably examples.
299 [Category ("NotWorking")]
300 public void GetContractIRequestChannel ()
302 ContractDescription cd = ContractDescription.GetContract (typeof (IRequestChannel));
303 Assert.AreEqual (typeof (IRequestChannel), cd.ContractType, "#_1");
304 Assert.AreEqual ("IRequestChannel", cd.Name, "#_2");
305 Assert.AreEqual ("http://schemas.microsoft.com/2005/07/ServiceModel", cd.Namespace, "#_3");
306 Assert.AreEqual (false, cd.HasProtectionLevel, "#_4");
307 Assert.AreEqual (SessionMode.NotAllowed, cd.SessionMode, "#_5");
308 Assert.AreEqual (0, cd.Behaviors.Count, "#_6");
309 Assert.AreEqual (1, cd.Operations.Count, "#_7");
310 OperationDescription od = cd.Operations [0];
311 Assert.IsNull (od.SyncMethod, "#_8");
312 Assert.IsNull (od.BeginMethod, "#_9");
313 Assert.IsNull (od.EndMethod, "#_10");
314 Assert.AreEqual (false, od.IsOneWay, "#_11");
315 Assert.AreEqual (false, od.HasProtectionLevel, "#_12");
316 Assert.AreEqual ("Request", od.Name, "#_13");
317 Assert.AreEqual (true, od.IsInitiating, "#_14");
318 Assert.AreEqual (0, od.Behaviors.Count, "#_15");
319 Assert.AreEqual (2, od.Messages.Count, "#_16");
320 foreach (MessageDescription md in od.Messages) {
321 if (md.Direction == MessageDirection.Output) {
322 Assert.AreEqual ("*", md.Action, "#_17");
323 Assert.AreEqual (false, md.HasProtectionLevel, "#_18");
324 Assert.AreEqual (0, md.Headers.Count, "#_19");
325 Assert.AreEqual (0, md.Properties.Count, "#_20");
326 Assert.IsNull (md.MessageType, "#_21");
327 MessageBodyDescription mb = md.Body;
328 Assert.AreEqual (null, mb.WrapperName, "#_22");
329 Assert.AreEqual (null, mb.WrapperNamespace, "#_23");
330 Assert.IsNull (mb.ReturnValue, "#_24");
331 Assert.AreEqual (0, mb.Parts.Count, "#_25");
333 Assert.AreEqual ("*", md.Action, "#_17_");
334 Assert.AreEqual (false, md.HasProtectionLevel, "#_18_");
335 Assert.AreEqual (0, md.Headers.Count, "#_19_");
336 Assert.AreEqual (0, md.Properties.Count, "#_20_");
337 Assert.IsNull (md.MessageType, "#_21_");
338 MessageBodyDescription mb = md.Body;
339 Assert.AreEqual (null, mb.WrapperName, "#_22_");
340 Assert.AreEqual (null, mb.WrapperNamespace, "#_23_");
341 Assert.IsNull (mb.ReturnValue, "#_24_");
342 Assert.AreEqual (0, mb.Parts.Count, "#_25_");
348 [ExpectedException (typeof (InvalidOperationException))]
349 public void WrongAsyncEndContract ()
351 ContractDescription.GetContract (typeof (IWrongAsyncEndContract));
355 public void AsyncContract1 ()
357 ContractDescription cd =
358 ContractDescription.GetContract (typeof (IAsyncContract1));
359 Assert.AreEqual (1, cd.Operations.Count);
360 OperationDescription od = cd.Operations [0];
361 Assert.AreEqual ("Sum", od.Name, "#1");
362 Assert.IsNotNull (od.BeginMethod, "#2");
363 Assert.IsNotNull (od.EndMethod, "#3");
367 [ExpectedException (typeof (InvalidOperationException))]
368 public void DuplicateOperationNames ()
370 ContractDescription.GetContract (typeof (IDuplicateOperationNames));
374 [ExpectedException (typeof (InvalidOperationException))]
375 public void AsyncMethodNameDoesNotStartWithBegin ()
377 ContractDescription.GetContract (typeof (IAsyncMethodNameDoesNotStartWithBegin));
381 [ExpectedException (typeof (InvalidOperationException))]
382 public void AsyncNameDoesNotStartWithBeginButExplicitName ()
384 // it is still invalid ...
385 ContractDescription.GetContract (typeof (IAsyncNameDoesNotStartWithBeginButExplicitName));
389 public void MessageBodyMemberIsNotInferred ()
391 ContractDescription cd = ContractDescription.GetContract (typeof (MessageBodyMemberIsNotInferredService));
392 OperationDescription od = cd.Operations [0];
393 MessageDescription md = od.Messages [0];
394 Assert.AreEqual (0, md.Body.Parts.Count);
398 public void TestContractFromObject () {
399 ContractDescription cd = ContractDescription.GetContract (typeof (Foo));
400 ServiceAssert.AssertContractDescription (typeof (IFoo).Name, "http://tempuri.org/", SessionMode.Allowed, typeof (IFoo), null, cd, "#1");
401 Assert.AreEqual (cd.Operations.Count, 2);
402 OperationBehaviorAttribute op = cd.Operations.Find ("HeyHey").Behaviors.Find<OperationBehaviorAttribute> ();
403 Assert.IsNotNull (op);
405 op.ReleaseInstanceMode,
406 ReleaseInstanceMode.None, "#2");
408 cd = ContractDescription.GetContract (typeof (IFoo), typeof (Foo));
409 ServiceAssert.AssertContractDescription (typeof (IFoo).Name, "http://tempuri.org/", SessionMode.Allowed, typeof (IFoo), null, cd, "#3");
410 Assert.AreEqual (cd.Operations.Count, 2, "#4");
412 cd.Operations.Find ("HeyHey").Behaviors.Find<OperationBehaviorAttribute> ().ReleaseInstanceMode,
413 ReleaseInstanceMode.AfterCall, "#5");
417 public void GetDerivedContract ()
419 var cd = ContractDescription.GetContract (typeof (IFoo3));
420 Assert.AreEqual (typeof (IFoo3), cd.ContractType, "#1");
421 Assert.AreEqual (3, cd.Operations.Count, "#2");
422 cd = ContractDescription.GetContract (typeof (Foo3));
423 Assert.AreEqual (typeof (IFoo3), cd.ContractType, "#3");
424 Assert.AreEqual (3, cd.Operations.Count, "#4");
428 public void MultipleContractsInTypeHierarchy ()
430 ContractDescription.GetContract (typeof (DuplicateCheckClassWrapper.ServiceInterface));
432 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"
436 public void GetInheritedContracts ()
438 var cd = ContractDescription.GetContract (typeof (IService));
439 var ccd = cd.GetInheritedContracts ();
440 Assert.AreEqual (1, ccd.Count, "#1");
441 Assert.AreEqual (typeof (IServiceBase), ccd [0].ContractType, "#2");
445 public void InheritedContractAndNamespaces ()
447 var cd = ContractDescription.GetContract (typeof (IService));
448 Assert.IsTrue (cd.Operations.Any (od => od.Messages.Any (md => md.Action == "http://tempuri.org/IServiceBase/Say")), "#1"); // inherited
449 Assert.IsTrue (cd.Operations.Any (od => od.SyncMethod == typeof (IService).GetMethod ("Join") && od.Messages.Any (md => md.Action == "http://tempuri.org/IService/Join")), "#2"); // self
450 Assert.IsTrue (cd.Operations.Any (od => od.SyncMethod == typeof (IService2).GetMethod ("Join") && od.Messages.Any (md => md.Action == "http://tempuri.org/IService/Join")), "#3"); // callback
454 public void AsyncContractWithSymmetricCallbackContract ()
456 var cd = ContractDescription.GetContract (typeof(IAsyncContractWithSymmetricCallbackContract));
457 Assert.AreEqual (2, cd.Operations.Count, "#1");
458 Assert.AreSame (typeof (IAsyncContractWithSymmetricCallbackContract), cd.ContractType, "#2");
459 Assert.AreSame (typeof (IAsyncContractWithSymmetricCallbackContract), cd.CallbackContractType, "#3");
463 public void InheritingDuplexContract ()
465 var cd = ContractDescription.GetContract (typeof (IDerivedDuplexContract));
466 Assert.AreEqual (4, cd.Operations.Count, "#1");
467 Assert.AreSame (typeof (IDerivedDuplexContract), cd.ContractType, "#2");
468 Assert.AreSame (typeof (IDerivedDuplexCallback), cd.CallbackContractType, "#3");
469 Assert.IsTrue (cd.Operations.Any (od => od.SyncMethod == typeof (IBaseDuplexCallback).GetMethod ("CallbackMethod")), "#4");
470 Assert.IsTrue (cd.Operations.Any (od => od.SyncMethod == typeof (IDerivedDuplexCallback).GetMethod ("CallbackSomething")), "#5");
471 Assert.IsTrue (cd.Operations.Any (od => od.SyncMethod == typeof (IBaseDuplexContract).GetMethod ("ContractMethod")), "#6");
472 Assert.IsTrue (cd.Operations.Any (od => od.SyncMethod == typeof (IDerivedDuplexContract).GetMethod ("Something")), "#7");
476 public void SymmetricInheritingContract ()
478 var cd = ContractDescription.GetContract (typeof(ISymmetricInheritance));
479 Assert.AreEqual (4, cd.Operations.Count, "#1");
480 Assert.AreSame (typeof (ISymmetricInheritance), cd.ContractType, "#2");
481 Assert.AreSame (typeof (ISymmetricInheritance), cd.CallbackContractType, "#3");
482 Assert.AreEqual (2, cd.Operations.Count(od => od.SyncMethod == typeof (IAsyncContractWithSymmetricCallbackContract).GetMethod ("Foo")), "#4");
483 Assert.AreEqual (2, cd.Operations.Count(od => od.SyncMethod == typeof (ISymmetricInheritance).GetMethod ("Bar")), "#5");
487 public void DeepContractHierarchyTest ()
489 var cd = ContractDescription.GetContract (typeof(IDeepContractHierarchy));
490 Assert.AreEqual (6, cd.Operations.Count, "#1");
491 Assert.AreSame (typeof (IDeepContractHierarchy), cd.ContractType, "#2");
492 Assert.AreSame (typeof (IDeepContractHierarchy), cd.CallbackContractType, "#3");
496 public void MessageContractAttributes ()
498 var cd = ContractDescription.GetContract (typeof (IFoo2));
499 var od = cd.Operations.First (o => o.Name == "Nanoda");
500 var md = od.Messages.First (m => m.Direction == MessageDirection.Input);
501 Assert.AreEqual (typeof (OregoMessage), md.MessageType, "message type");
502 Assert.AreEqual ("http://tempuri.org/IFoo2/Nanoda", md.Action, "action");
503 Assert.AreEqual (1, md.Headers.Count, "headers");
504 Assert.AreEqual (3, md.Body.Parts.Count, "body parts");
505 Assert.AreEqual (0, md.Properties.Count, "properties");
508 // .NET complains: The operation Nanoda2 either has a parameter or a return type that is attributed with MessageContractAttribute. In order to represent the request message using a Message Contract, the operation must have a single parameter attributed with MessageContractAttribute. In order to represent the response message using a Message Contract, the operation's return value must be a type that is attributed with MessageContractAttribute and the operation may not have any out or ref parameters.
510 [ExpectedException (typeof (InvalidOperationException))]
511 public void MessageContractAttributes2 ()
513 ContractDescription.GetContract (typeof (IFoo2_2));
517 public void MessageContractAttributes3 ()
519 ContractDescription.GetContract (typeof (IFoo2_3));
523 public void MessageContractAttributes4 ()
525 ContractDescription.GetContract (typeof (IFoo2_4));
529 public void MessageContractAttributes5 ()
531 ContractDescription.GetContract (typeof (IFoo2_5));
535 public void MessageContractAttributes6 ()
537 ContractDescription.GetContract (typeof (IFoo2_6));
541 public void XmlSerializedOperation ()
543 var cd = ContractDescription.GetContract (typeof (XmlSerializedService));
544 var od = cd.Operations.First ();
545 var xb = od.Behaviors.Find<XmlSerializerOperationBehavior> ();
546 Assert.IsNotNull (xb, "#1");
550 public void MessageParameterDescriptionInUse ()
553 var cd = ContractDescription.GetContract (typeof (Dealerinfo.wsvDealerinfo.WSVDealerInfoServices));
554 foreach (var od in cd.Operations)
555 foreach (var md in od.Messages)
556 if (md.Action == "*") // return
557 Assert.IsNotNull (md.Body.ReturnValue, od.Name);
561 public void BugX206Contract ()
563 var cd = ContractDescription.GetContract (typeof (BugX206Service));
564 bool examined = false;
565 foreach (var md in cd.Operations.First ().Messages) {
566 if (md.Direction == MessageDirection.Input)
568 var pd = md.Body.ReturnValue;
569 Assert.IsNotNull (pd, "#1");
570 Assert.AreEqual ("DoWorkResult", pd.Name, "#2");
571 Assert.IsNull (pd.MemberInfo, "#3");
572 Assert.AreEqual (typeof (void), pd.Type, "#4");
575 Assert.IsTrue (examined, "end");
578 // It is for testing attribute search in interfaces.
579 public class Foo : IFoo
581 public string HeyDude (string msg, string msg2)
586 [OperationBehavior (ReleaseInstanceMode = ReleaseInstanceMode.AfterCall)]
587 public void HeyHey (out string out1, ref string ref1)
593 // It inherits both IFoo and IBar, thus cannot be a contract.
594 public class FooBar : IFoo, IBar
596 public string HeyDude (string msg, string msg2)
601 public void HeyHey (out string out1, ref string ref1)
606 public void OpenBar () {}
610 public interface IFoo
613 string HeyDude (string msg, string msg2);
616 void HeyHey (out string out1, ref string ref1);
620 public interface IFoo2
622 // FIXME: it does not pass yet
624 OregoMessage Nanoda (OregoMessage msg);
626 // FIXME: it does not pass yet
628 Mona NewMona (Mona source);
632 public interface IFoo2_2
634 [OperationContract] // wrong operation contract, must have only one parameter with MessageContractAttribute
635 OregoMessage Nanoda2 (OregoMessage msg1, OregoMessage msg2);
639 public interface IFoo2_3
642 string Nanoda2 (OregoMessage msg1);
646 public interface IFoo2_4
649 OregoMessage Nanoda2 (string s, string s2);
653 public interface IFoo2_5
656 Message Nanoda2 (OregoMessage msg1);
660 public interface IFoo2_6
663 OregoMessage Nanoda2 (Message msg1);
667 public interface IFoo3 : IFoo
670 string HeyMan (string msg, string msg2);
673 public class Foo3 : Foo, IFoo3
675 public string HeyMan (string msg, string msg2)
682 public interface IBar
689 public class OregoMessage
694 public string Neutral;
697 [MessageBodyMember] // it should be ignored ...
698 public string Setter { set { } }
699 public string NonMember;
704 public string OmaeMona;
705 public string OreMona;
709 public interface INoOperation
714 public interface IMessageParameter
717 Message ReturnMessage (Message arg);
721 public interface IInvalidAsync
724 Message ReturnMessage (Message arg);
726 [OperationContract (AsyncPattern = true)]
727 IAsyncResult BeginReturnMessage (Message arg, AsyncCallback callback, object state);
729 // and no EndReturnMessage().
733 public interface IWrongAsyncEndContract
736 int Sum (int a, int b);
738 [OperationContract (AsyncPattern = true)]
739 IAsyncResult BeginSum (int a, int b, AsyncCallback cb, object state);
741 // this OperationContractAttribute is not allowed.
742 [OperationContract (AsyncPattern = true)]
743 int EndSum (IAsyncResult result);
747 public interface IAsyncContract1
750 int Sum (int a, int b);
752 [OperationContract (AsyncPattern = true)]
753 IAsyncResult BeginSum (int a, int b, AsyncCallback cb, object state);
755 int EndSum (IAsyncResult result);
759 public interface IAsyncMethodNameDoesNotStartWithBegin
762 int Sum (int a, int b);
764 [OperationContract (AsyncPattern = true)]
765 IAsyncResult StartSum (int a, int b, AsyncCallback cb, object state);
767 int EndSum (IAsyncResult result);
771 public interface IAsyncNameDoesNotStartWithBeginButExplicitName
774 int Sum (int a, int b);
776 [OperationContract (Name = "Sum", AsyncPattern = true)]
777 IAsyncResult StartSum (int a, int b, AsyncCallback cb, object state);
779 int EndSum (IAsyncResult result);
783 public interface IDuplicateOperationNames
786 string Echo (string s);
789 string Echo (string s1, string s2);
793 public interface IFooMsgParams
795 [OperationContract (Name = "MyFoo")]
796 [return: MessageParameter (Name = "MyResult")]
797 string Foo ([MessageParameter (Name = "MyParam")] string param);
801 public class MessageBodyMemberIsNotInferredService
804 public void Echo (MessageBodyMemberIsNotInferredContract msg)
810 public class MessageBodyMemberIsNotInferredContract
819 public class DuplicateCheckClassWrapper
823 internal interface ServiceInterface : Foo
828 internal interface Foo : Bar
830 [OperationContract] void Foo();
834 internal interface Bar
836 [OperationContract] void FooBar();
839 internal class DummyService : ServiceInterface
841 public void FooBar() { }
843 public void Foo() { }
848 public interface IServiceBase
850 [OperationContract (IsOneWay = true)]
851 void Say (string word);
854 [ServiceContract (CallbackContract = typeof (IService2))]
855 public interface IService : IServiceBase
862 public interface IServiceBase2
864 [OperationContract (IsOneWay = true)]
865 void Say (string word);
869 public interface IService2 : IServiceBase2
875 [ServiceContract (CallbackContract = typeof (IAsyncContractWithSymmetricCallbackContract))]
876 public interface IAsyncContractWithSymmetricCallbackContract
881 [OperationContract (AsyncPattern = true)]
882 IAsyncResult BeginFoo (AsyncCallback callback, object asyncState);
884 void EndFoo (IAsyncResult result);
887 [ServiceContract (CallbackContract = typeof (ISymmetricInheritance))]
888 public interface ISymmetricInheritance : IAsyncContractWithSymmetricCallbackContract
893 [OperationContract (AsyncPattern = true)]
894 IAsyncResult BeginBar (AsyncCallback callback, object asyncState);
896 void EndBar (IAsyncResult result);
899 [ServiceContract (CallbackContract = typeof (IDeepContractHierarchy))]
900 public interface IDeepContractHierarchy : ISymmetricInheritance
906 public interface IBaseDuplexCallback
909 void CallbackMethod ();
912 [ServiceContract (CallbackContract = typeof (IBaseDuplexCallback))]
913 public interface IBaseDuplexContract
916 void ContractMethod ();
919 public interface IDerivedDuplexCallback : IBaseDuplexCallback
922 void CallbackSomething ();
925 [ServiceContract (CallbackContract = typeof(IDerivedDuplexCallback))]
926 public interface IDerivedDuplexContract : IBaseDuplexContract
933 public interface XmlSerializedService
936 [XmlSerializerFormat]
937 string Echo (string input);
941 public interface BugX206Service
944 BugX206Response DoWork ();
947 [MessageContract (IsWrapped = true)]
948 public partial class BugX206Response
953 public void TestInterfaceInheritance ()
955 var cd = ContractDescription.GetContract (typeof (InterfaceInheritance));
956 var inherited = cd.GetInheritedContracts ();
957 Assert.AreEqual (1, inherited.Count, "#1");
960 public class MyWebGetAttribute : Attribute, IOperationBehavior
962 void IOperationBehavior.AddBindingParameters (OperationDescription operation, BindingParameterCollection parameters)
967 void IOperationBehavior.ApplyClientBehavior (OperationDescription operation, ClientOperation client)
972 void IOperationBehavior.ApplyDispatchBehavior (OperationDescription operation, DispatchOperation service)
977 void IOperationBehavior.Validate (OperationDescription operation)
983 [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
984 public class InterfaceInheritance : IInterfaceInheritance
988 throw new NotImplementedException ();
991 public string Test ()
993 throw new NotImplementedException ();
998 public interface IInterfaceInheritance: IBaseInterface
1006 public interface IBaseInterface