1 // Licensed to the .NET Foundation under one or more agreements. 2 // The .NET Foundation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using Xunit; 6 7 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload01.overload01 8 { 9 // <Area> of Methods with Optional Parameters and named arguments</Area> 10 // <Title>Overload resolution of named params and optionals</Title> 11 // <Description>Basic Overload resolution</Description> 12 // <Expects status=success></Expects> 13 // <Code> 14 public class Parent 15 { Foo(int i = 0)16 public int Foo(int i = 0) 17 { 18 return 1; 19 } 20 Foo()21 public int Foo() 22 { 23 return 0; 24 } 25 } 26 27 public class Test 28 { 29 [Fact] DynamicCSharpRunTest()30 public static void DynamicCSharpRunTest() 31 { 32 Assert.Equal(0, MainMethod()); 33 } 34 MainMethod()35 public static int MainMethod() 36 { 37 dynamic p = new Parent(); 38 return p.Foo(); 39 } 40 } 41 //</Code> 42 } 43 44 45 46 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload01a.overload01a 47 { 48 // <Area> of Methods with Optional Parameters and named arguments</Area> 49 // <Title>Overload resolution of named params and optionals</Title> 50 // <Description>Basic Overload resolution</Description> 51 // <Expects status=success></Expects> 52 // <Code> 53 public class Parent 54 { Foo(dynamic i = null)55 public int Foo(dynamic i = null) 56 { 57 return 1; 58 } 59 Foo()60 public int Foo() 61 { 62 return 0; 63 } 64 } 65 66 public class Test 67 { 68 [Fact] DynamicCSharpRunTest()69 public static void DynamicCSharpRunTest() 70 { 71 Assert.Equal(0, MainMethod()); 72 } 73 MainMethod()74 public static int MainMethod() 75 { 76 Parent p = new Parent(); 77 return p.Foo(); 78 } 79 } 80 //</Code> 81 } 82 83 84 85 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload01b.overload01b 86 { 87 // <Area> of Methods with Optional Parameters and named arguments</Area> 88 // <Title>Overload resolution of named params and optionals</Title> 89 // <Description>Basic Overload resolution</Description> 90 // <Expects status=success></Expects> 91 // <Code> 92 public class Parent 93 { Foo(dynamic i = default(dynamic))94 public int Foo(dynamic i = default(dynamic)) 95 { 96 return 1; 97 } 98 Foo()99 public int Foo() 100 { 101 return 0; 102 } 103 } 104 105 public class Test 106 { 107 [Fact] DynamicCSharpRunTest()108 public static void DynamicCSharpRunTest() 109 { 110 Assert.Equal(0, MainMethod()); 111 } 112 MainMethod()113 public static int MainMethod() 114 { 115 dynamic p = new Parent(); 116 return p.Foo(); 117 } 118 } 119 //</Code> 120 } 121 122 123 124 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload02.overload02 125 { 126 // <Area> of Methods with Optional Parameters and named arguments</Area> 127 // <Title>Overload resolution of named params and optionals</Title> 128 // <Description>Basic Overload resolution</Description> 129 // <Expects status=success></Expects> 130 // <Code> 131 public class Parent 132 { Foo(int i = 0, int j = 0)133 public int Foo(int i = 0, int j = 0) 134 { 135 return 1; 136 } 137 Foo(int i = 0)138 public int Foo(int i = 0) 139 { 140 return 0; 141 } 142 } 143 144 public class Test 145 { 146 [Fact] DynamicCSharpRunTest()147 public static void DynamicCSharpRunTest() 148 { 149 Assert.Equal(0, MainMethod()); 150 } 151 MainMethod()152 public static int MainMethod() 153 { 154 dynamic p = new Parent(); 155 try 156 { 157 p.Foo(); //No CS0121 158 } 159 catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e) 160 { 161 bool ret = ErrorVerifier.Verify(ErrorMessageId.AmbigCall, e.Message, "Parent.Foo(int, int)", "Parent.Foo(int)"); 162 if (ret) 163 return 0; 164 } 165 166 return 1; 167 } 168 } 169 //</Code> 170 } 171 172 173 174 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload02b.overload02b 175 { 176 // <Area> of Methods with Optional Parameters and named arguments</Area> 177 // <Title>Overload resolution of named params and optionals</Title> 178 // <Description>Basic Overload resolution</Description> 179 // <Expects status=success></Expects> 180 // <RelatedBugs></RelatedBugs> 181 // <Code> 182 public class Parent 183 { Foo(dynamic i = null, dynamic j = default(dynamic))184 public int Foo(dynamic i = null, dynamic j = default(dynamic)) 185 { 186 return 1; 187 } 188 Foo(dynamic i = default(dynamic))189 public int Foo(dynamic i = default(dynamic)) 190 { 191 return 0; 192 } 193 } 194 195 public class Test 196 { 197 [Fact] DynamicCSharpRunTest()198 public static void DynamicCSharpRunTest() 199 { 200 Assert.Equal(0, MainMethod()); 201 } 202 MainMethod()203 public static int MainMethod() 204 { 205 dynamic p = new Parent(); 206 try 207 { 208 p.Foo(); //No CS0121 209 } 210 catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e) 211 { 212 bool ret = ErrorVerifier.Verify(ErrorMessageId.AmbigCall, e.Message, "Parent.Foo(object, object)", "Parent.Foo(object)"); 213 if (ret) 214 return 0; 215 } 216 217 return 1; 218 } 219 } 220 //</Code> 221 } 222 223 224 225 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload03.overload03 226 { 227 // <Area> of Methods with Optional Parameters and named arguments</Area> 228 // <Title>Overload resolution of named params and optionals</Title> 229 // <Description>Should be ambiguous</Description> 230 // <Expects status=success></Expects> 231 // <Code> 232 public class Parent 233 { Foo(int i = 0, int j = 0)234 public int Foo(int i = 0, int j = 0) 235 { 236 return 1; 237 } 238 Foo(int i = 0)239 public int Foo(int i = 0) 240 { 241 return 1; 242 } 243 Foo(string s = R)244 public int Foo(string s = "") 245 { 246 return 1; 247 } 248 } 249 250 public class Test 251 { 252 [Fact] DynamicCSharpRunTest()253 public static void DynamicCSharpRunTest() 254 { 255 Assert.Equal(0, MainMethod()); 256 } 257 MainMethod()258 public static int MainMethod() 259 { 260 dynamic p = new Parent(); 261 try 262 { 263 p.Foo(); 264 } 265 catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e) 266 { 267 bool ret = ErrorVerifier.Verify(ErrorMessageId.AmbigCall, e.Message, "Parent.Foo(string)", "Parent.Foo(int, int)"); 268 if (ret) 269 return 0; 270 } 271 272 return 1; 273 } 274 } 275 //</Code> 276 } 277 278 279 280 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload03b.overload03b 281 { 282 // <Area> of Methods with Optional Parameters and named arguments</Area> 283 // <Title>Overload resolution of named params and optionals</Title> 284 // <Description>Should be ambiguous</Description> 285 // <Expects status=success></Expects> 286 // <Code> 287 public class Parent 288 { Foo(dynamic i = null, dynamic j = null)289 public int Foo(dynamic i = null, dynamic j = null) 290 { 291 return 1; 292 } 293 Foo(dynamic i = default(dynamic))294 public int Foo(dynamic i = default(dynamic)) 295 { 296 return 1; 297 } 298 Foo(string s = R)299 public int Foo(string s = "") 300 { 301 return 1; 302 } 303 } 304 305 public class Test 306 { 307 [Fact] DynamicCSharpRunTest()308 public static void DynamicCSharpRunTest() 309 { 310 Assert.Equal(0, MainMethod()); 311 } 312 MainMethod()313 public static int MainMethod() 314 { 315 dynamic p = new Parent(); 316 try 317 { 318 p.Foo(); 319 } 320 catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e) 321 { 322 bool ret = ErrorVerifier.Verify(ErrorMessageId.AmbigCall, e.Message, "Parent.Foo(string)", "Parent.Foo(object, object)"); 323 if (ret) 324 return 0; 325 } 326 327 return 1; 328 } 329 } 330 //</Code> 331 } 332 333 334 335 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload04.overload04 336 { 337 // <Area> of Methods with Optional Parameters and named arguments</Area> 338 // <Title>Overload resolution of named params and optionals</Title> 339 // <Description>Basic Overload resolution</Description> 340 // <Expects status=success></Expects> 341 // <Code> 342 public class Parent 343 { Foo(int i = 0, int j = 0)344 public int Foo(int i = 0, int j = 0) 345 { 346 return 1; 347 } 348 Foo(int i = 0)349 public int Foo(int i = 0) 350 { 351 return 1; 352 } 353 Foo()354 public int Foo() 355 { 356 return 0; 357 } 358 } 359 360 public class Test 361 { 362 [Fact] DynamicCSharpRunTest()363 public static void DynamicCSharpRunTest() 364 { 365 Assert.Equal(0, MainMethod()); 366 } 367 MainMethod()368 public static int MainMethod() 369 { 370 dynamic p = new Parent(); 371 return p.Foo(); 372 } 373 } 374 //</Code> 375 } 376 377 378 379 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload04a.overload04a 380 { 381 // <Area> of Methods with Optional Parameters and named arguments</Area> 382 // <Title>Overload resolution of named params and optionals</Title> 383 // <Description>Basic Overload resolution</Description> 384 // <Expects status=success></Expects> 385 // <Code> 386 public class Parent 387 { Foo(dynamic i = null, dynamic j = null)388 public dynamic Foo(dynamic i = null, dynamic j = null) 389 { 390 return 1; 391 } 392 Foo(dynamic i = null)393 public dynamic Foo(dynamic i = null) 394 { 395 return 1; 396 } 397 Foo()398 public dynamic Foo() 399 { 400 return 0; 401 } 402 } 403 404 public class Test 405 { 406 [Fact] DynamicCSharpRunTest()407 public static void DynamicCSharpRunTest() 408 { 409 Assert.Equal(0, MainMethod()); 410 } 411 MainMethod()412 public static int MainMethod() 413 { 414 Parent p = new Parent(); 415 return p.Foo(); 416 } 417 } 418 //</Code> 419 } 420 421 422 423 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload04b.overload04b 424 { 425 // <Area> of Methods with Optional Parameters and named arguments</Area> 426 // <Title>Overload resolution of named params and optionals</Title> 427 // <Description>Basic Overload resolution</Description> 428 // <Expects status=success></Expects> 429 // <Code> 430 public class Parent 431 { Foo(dynamic i = null, dynamic j = null)432 public dynamic Foo(dynamic i = null, dynamic j = null) 433 { 434 return 1; 435 } 436 Foo(dynamic i = null)437 public dynamic Foo(dynamic i = null) 438 { 439 return 1; 440 } 441 Foo()442 public dynamic Foo() 443 { 444 return 0; 445 } 446 } 447 448 public class Test 449 { 450 [Fact] DynamicCSharpRunTest()451 public static void DynamicCSharpRunTest() 452 { 453 Assert.Equal(0, MainMethod()); 454 } 455 MainMethod()456 public static int MainMethod() 457 { 458 dynamic p = new Parent(); 459 return p.Foo(); 460 } 461 } 462 //</Code> 463 } 464 465 466 467 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload05.overload05 468 { 469 // <Area> of Methods with Optional Parameters and named arguments</Area> 470 // <Title>Overload resolution of named params and optionals</Title> 471 // <Description>Ambiguous on the second param</Description> 472 // <Expects status=success></Expects> 473 // <Code> 474 public class Parent 475 { Foo(int i = 0, int j = 0)476 public int Foo(int i = 0, int j = 0) 477 { 478 return 1; 479 } 480 Foo(int i = 0, string s = R)481 public int Foo(int i = 0, string s = "") 482 { 483 return 1; 484 } 485 } 486 487 public class Test 488 { 489 [Fact] DynamicCSharpRunTest()490 public static void DynamicCSharpRunTest() 491 { 492 Assert.Equal(0, MainMethod()); 493 } 494 MainMethod()495 public static int MainMethod() 496 { 497 dynamic p = new Parent(); 498 try 499 { 500 p.Foo(); 501 } 502 catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e) 503 { 504 bool ret = ErrorVerifier.Verify(ErrorMessageId.AmbigCall, e.Message, "Parent.Foo(int, int)", "Parent.Foo(int, string)"); 505 if (ret) 506 return 0; 507 } 508 509 return 1; 510 } 511 } 512 //</Code> 513 } 514 515 516 517 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload05b.overload05b 518 { 519 // <Area> of Methods with Optional Parameters and named arguments</Area> 520 // <Title>Overload resolution of named params and optionals</Title> 521 // <Description>Ambiguous on the second param</Description> 522 // <Expects status=success></Expects> 523 // <Code> 524 public class Parent 525 { Foo(dynamic i = null, int j = 0)526 public dynamic Foo(dynamic i = null, int j = 0) 527 { 528 return 1; 529 } 530 Foo(dynamic i = default(dynamic), string s = R)531 public dynamic Foo(dynamic i = default(dynamic), string s = "") 532 { 533 return 1; 534 } 535 } 536 537 public class Test 538 { 539 [Fact] DynamicCSharpRunTest()540 public static void DynamicCSharpRunTest() 541 { 542 Assert.Equal(0, MainMethod()); 543 } 544 MainMethod()545 public static int MainMethod() 546 { 547 dynamic p = new Parent(); 548 try 549 { 550 p.Foo(); 551 } 552 catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e) 553 { 554 bool ret = ErrorVerifier.Verify(ErrorMessageId.AmbigCall, e.Message, "Parent.Foo(object, int)", "Parent.Foo(object, string)"); 555 if (ret) 556 return 0; 557 } 558 559 return 1; 560 } 561 } 562 //</Code> 563 } 564 565 566 567 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload06.overload06 568 { 569 // <Area> of Methods with Optional Parameters and named arguments</Area> 570 // <Title>Overload resolution of named params and optionals</Title> 571 // <Description>Basic Overload resolution with named params</Description> 572 // <Expects status=success></Expects> 573 // <Code> 574 public class Parent 575 { Foo(int i = 0, int j = 0)576 public int Foo(int i = 0, int j = 0) 577 { 578 return 1; 579 } 580 Foo(int i = 0)581 public int Foo(int i = 0) 582 { 583 return 0; 584 } 585 } 586 587 public class Test 588 { 589 [Fact] DynamicCSharpRunTest()590 public static void DynamicCSharpRunTest() 591 { 592 Assert.Equal(0, MainMethod()); 593 } 594 MainMethod()595 public static int MainMethod() 596 { 597 dynamic p = new Parent(); 598 return p.Foo(i: 2); 599 } 600 } 601 //</Code> 602 } 603 604 605 606 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload06a.overload06a 607 { 608 // <Area> of Methods with Optional Parameters and named arguments</Area> 609 // <Title>Overload resolution of named params and optionals</Title> 610 // <Description>Basic Overload resolution with named params</Description> 611 // <Expects status=success></Expects> 612 // <Code> 613 public class Parent 614 { Foo(int i = 0, dynamic j = null)615 public int Foo(int i = 0, dynamic j = null) 616 { 617 return 1; 618 } 619 Foo(int i = 0)620 public int Foo(int i = 0) 621 { 622 return 0; 623 } 624 } 625 626 public class Test 627 { 628 [Fact] DynamicCSharpRunTest()629 public static void DynamicCSharpRunTest() 630 { 631 Assert.Equal(0, MainMethod()); 632 } 633 MainMethod()634 public static int MainMethod() 635 { 636 Parent p = new Parent(); 637 return p.Foo(i: 2); 638 } 639 } 640 //</Code> 641 } 642 643 644 645 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload06b.overload06b 646 { 647 // <Area> of Methods with Optional Parameters and named arguments</Area> 648 // <Title>Overload resolution of named params and optionals</Title> 649 // <Description>Basic Overload resolution with named params</Description> 650 // <Expects status=success></Expects> 651 // <Code> 652 public class Parent 653 { Foo(int i = 0, dynamic j = null)654 public int Foo(int i = 0, dynamic j = null) 655 { 656 return 1; 657 } 658 Foo(int i = 0)659 public int Foo(int i = 0) 660 { 661 return 0; 662 } 663 } 664 665 public class Test 666 { 667 [Fact] DynamicCSharpRunTest()668 public static void DynamicCSharpRunTest() 669 { 670 Assert.Equal(0, MainMethod()); 671 } 672 MainMethod()673 public static int MainMethod() 674 { 675 dynamic p = new Parent(); 676 return p.Foo(i: 2); 677 } 678 } 679 //</Code> 680 } 681 682 683 684 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload06c.overload06c 685 { 686 // <Area> of Methods with Optional Parameters and named arguments</Area> 687 // <Title>Overload resolution of named params and optionals</Title> 688 // <Description>Basic Overload resolution with named params</Description> 689 // <Expects status=success></Expects> 690 // <Code> 691 public class Parent 692 { Foo(int i = 0, int j = 0)693 public int Foo(int i = 0, int j = 0) 694 { 695 return 1; 696 } 697 Foo(int i = 0)698 public int Foo(int i = 0) 699 { 700 return 0; 701 } 702 } 703 704 public class Test 705 { 706 [Fact] DynamicCSharpRunTest()707 public static void DynamicCSharpRunTest() 708 { 709 Assert.Equal(0, MainMethod()); 710 } 711 MainMethod()712 public static int MainMethod() 713 { 714 Parent p = new Parent(); 715 dynamic i = 2; 716 return p.Foo(i: i); 717 } 718 } 719 //</Code> 720 } 721 722 723 724 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload07.overload07 725 { 726 // <Area> of Methods with Optional Parameters and named arguments</Area> 727 // <Title>Overload resolution of named params and optionals</Title> 728 // <Description>Basic Overload resolution with named</Description> 729 // <Expects status=success></Expects> 730 // <Code> 731 public class Parent 732 { Foo(int i, int j, int z = 1)733 public int Foo(int i, int j, int z = 1) 734 { 735 return 1; 736 } 737 Foo(int i = 0, int j = 0)738 public int Foo(int i = 0, int j = 0) 739 { 740 return 0; 741 } 742 Foo(int i = 0)743 public int Foo(int i = 0) 744 { 745 return 1; 746 } 747 } 748 749 public class Test 750 { 751 [Fact] DynamicCSharpRunTest()752 public static void DynamicCSharpRunTest() 753 { 754 Assert.Equal(0, MainMethod()); 755 } 756 MainMethod()757 public static int MainMethod() 758 { 759 dynamic p = new Parent(); 760 return p.Foo(i: 2, j: 1); 761 } 762 } 763 //</Code> 764 } 765 766 767 768 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload07a.overload07a 769 { 770 // <Area> of Methods with Optional Parameters and named arguments</Area> 771 // <Title>Overload resolution of named params and optionals</Title> 772 // <Description>Basic Overload resolution with named</Description> 773 // <Expects status=success></Expects> 774 // <Code> 775 public class Parent 776 { Foo(int i, dynamic j, dynamic z = null)777 public dynamic Foo(int i, dynamic j, dynamic z = null) 778 { 779 return 1; 780 } 781 Foo(int i = 0, int j = 0)782 public dynamic Foo(int i = 0, int j = 0) 783 { 784 return 0; 785 } 786 Foo(int i = 0)787 public dynamic Foo(int i = 0) 788 { 789 return 1; 790 } 791 } 792 793 public class Test 794 { 795 [Fact] DynamicCSharpRunTest()796 public static void DynamicCSharpRunTest() 797 { 798 Assert.Equal(0, MainMethod()); 799 } 800 MainMethod()801 public static int MainMethod() 802 { 803 Parent p = new Parent(); 804 return p.Foo(i: 2, j: 1); 805 } 806 } 807 //</Code> 808 } 809 810 811 812 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload07b.overload07b 813 { 814 // <Area> of Methods with Optional Parameters and named arguments</Area> 815 // <Title>Overload resolution of named params and optionals</Title> 816 // <Description>Basic Overload resolution with named</Description> 817 // <Expects status=success></Expects> 818 // <Code> 819 public class Parent 820 { Foo(int i, dynamic j, dynamic z = default(dynamic))821 public dynamic Foo(int i, dynamic j, dynamic z = default(dynamic)) 822 { 823 return 1; 824 } 825 Foo(int i = 0, int j = 0)826 public dynamic Foo(int i = 0, int j = 0) 827 { 828 return 0; 829 } 830 Foo(int i = 0)831 public dynamic Foo(int i = 0) 832 { 833 return 1; 834 } 835 } 836 837 public class Test 838 { 839 [Fact] DynamicCSharpRunTest()840 public static void DynamicCSharpRunTest() 841 { 842 Assert.Equal(0, MainMethod()); 843 } 844 MainMethod()845 public static int MainMethod() 846 { 847 dynamic p = new Parent(); 848 return p.Foo(i: 2, j: 1); 849 } 850 } 851 //</Code> 852 } 853 854 855 856 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload07c.overload07c 857 { 858 // <Area> of Methods with Optional Parameters and named arguments</Area> 859 // <Title>Overload resolution of named params and optionals</Title> 860 // <Description>Basic Overload resolution with named</Description> 861 // <Expects status=success></Expects> 862 // <Code> 863 public class Parent 864 { Foo(int i, int j, int z = 1)865 public int Foo(int i, int j, int z = 1) 866 { 867 return 1; 868 } 869 Foo(int i = 0, int j = 0)870 public int Foo(int i = 0, int j = 0) 871 { 872 return 0; 873 } 874 Foo(int i = 0)875 public int Foo(int i = 0) 876 { 877 return 1; 878 } 879 } 880 881 public class Test 882 { 883 [Fact] DynamicCSharpRunTest()884 public static void DynamicCSharpRunTest() 885 { 886 Assert.Equal(0, MainMethod()); 887 } 888 MainMethod()889 public static int MainMethod() 890 { 891 Parent p = new Parent(); 892 dynamic i = 2; 893 dynamic j = 1; 894 return p.Foo(i: i, j: j); 895 } 896 } 897 //</Code> 898 } 899 900 901 902 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload09.overload09 903 { 904 // <Area> of Methods with Optional Parameters and named arguments</Area> 905 // <Title>Overload resolution of named params and optionals</Title> 906 // <Description>Basic Overload resolution with named. This is here mostly as a regression test</Description> 907 // <Expects status=success></Expects> 908 // <Code> 909 public class Parent 910 { Foo(long i)911 public int Foo(long i) 912 { 913 return 0; 914 } 915 //public int Foo(int i) {return 1;} 916 } 917 918 public class Test 919 { 920 [Fact] DynamicCSharpRunTest()921 public static void DynamicCSharpRunTest() 922 { 923 Assert.Equal(0, MainMethod()); 924 } 925 MainMethod()926 public static int MainMethod() 927 { 928 dynamic p = new Parent(); 929 return p.Foo(i: 2); 930 } 931 } 932 //</Code> 933 } 934 935 936 937 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload09a.overload09a 938 { 939 // <Area> of Methods with Optional Parameters and named arguments</Area> 940 // <Title>Overload resolution of named params and optionals</Title> 941 // <Description>Basic Overload resolution with named. This is here mostly as a regression test</Description> 942 // <Expects status=success></Expects> 943 // <Code> 944 public class Parent 945 { Foo(long i)946 public dynamic Foo(long i) 947 { 948 return 0; 949 } 950 //public int Foo(int i) {return 1;} 951 } 952 953 public class Test 954 { 955 [Fact] DynamicCSharpRunTest()956 public static void DynamicCSharpRunTest() 957 { 958 Assert.Equal(0, MainMethod()); 959 } 960 MainMethod()961 public static int MainMethod() 962 { 963 Parent p = new Parent(); 964 return p.Foo(i: 2); 965 } 966 } 967 //</Code> 968 } 969 970 971 972 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload09b.overload09b 973 { 974 // <Area> of Methods with Optional Parameters and named arguments</Area> 975 // <Title>Overload resolution of named params and optionals</Title> 976 // <Description>Basic Overload resolution with named. This is here mostly as a regression test</Description> 977 // <Expects status=success></Expects> 978 // <Code> 979 public class Parent 980 { Foo(long i)981 public dynamic Foo(long i) 982 { 983 return 0; 984 } 985 //public int Foo(int i) {return 1;} 986 } 987 988 public class Test 989 { 990 [Fact] DynamicCSharpRunTest()991 public static void DynamicCSharpRunTest() 992 { 993 Assert.Equal(0, MainMethod()); 994 } 995 MainMethod()996 public static int MainMethod() 997 { 998 dynamic p = new Parent(); 999 return p.Foo(i: 2); 1000 } 1001 } 1002 //</Code> 1003 } 1004 1005 1006 1007 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload09c.overload09c 1008 { 1009 // <Area> of Methods with Optional Parameters and named arguments</Area> 1010 // <Title>Overload resolution of named params and optionals</Title> 1011 // <Description>Basic Overload resolution with named. This is here mostly as a regression test</Description> 1012 // <Expects status=success></Expects> 1013 // <Code> 1014 public class Parent 1015 { Foo(long i)1016 public int Foo(long i) 1017 { 1018 return 0; 1019 } 1020 //public int Foo(int i) {return 1;} 1021 } 1022 1023 public class Test 1024 { 1025 [Fact] DynamicCSharpRunTest()1026 public static void DynamicCSharpRunTest() 1027 { 1028 Assert.Equal(0, MainMethod()); 1029 } 1030 MainMethod()1031 public static int MainMethod() 1032 { 1033 Parent p = new Parent(); 1034 dynamic i = 2; 1035 return p.Foo(i: i); 1036 } 1037 } 1038 //</Code> 1039 } 1040 1041 1042 1043 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload10.overload10 1044 { 1045 // <Area> of Methods with Optional Parameters and named arguments</Area> 1046 // <Title>Overload resolution of named params and optionals</Title> 1047 // <Description>Basic Overload resolution with named. This is here mostly as a regression test</Description> 1048 // <Expects status=success></Expects> 1049 // <Code> 1050 public class Parent 1051 { Foo(long i)1052 public int Foo(long i) 1053 { 1054 return 1; 1055 } 1056 Foo(int i)1057 public int Foo(int i) 1058 { 1059 return 0; 1060 } 1061 } 1062 1063 public class Test 1064 { 1065 [Fact] DynamicCSharpRunTest()1066 public static void DynamicCSharpRunTest() 1067 { 1068 Assert.Equal(0, MainMethod()); 1069 } 1070 MainMethod()1071 public static int MainMethod() 1072 { 1073 dynamic p = new Parent(); 1074 return p.Foo(i: 2); 1075 } 1076 } 1077 //</Code> 1078 } 1079 1080 1081 1082 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload10a.overload10a 1083 { 1084 // <Area> of Methods with Optional Parameters and named arguments</Area> 1085 // <Title>Overload resolution of named params and optionals</Title> 1086 // <Description>Basic Overload resolution with named. This is here mostly as a regression test</Description> 1087 // <Expects status=success></Expects> 1088 // <Code> 1089 public class Parent 1090 { Foo(long i)1091 public dynamic Foo(long i) 1092 { 1093 return 1; 1094 } 1095 Foo(int i)1096 public int Foo(int i) 1097 { 1098 return 0; 1099 } 1100 } 1101 1102 public class Test 1103 { 1104 [Fact] DynamicCSharpRunTest()1105 public static void DynamicCSharpRunTest() 1106 { 1107 Assert.Equal(0, MainMethod()); 1108 } 1109 MainMethod()1110 public static int MainMethod() 1111 { 1112 Parent p = new Parent(); 1113 return p.Foo(i: 2); 1114 } 1115 } 1116 //</Code> 1117 } 1118 1119 1120 1121 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload10b.overload10b 1122 { 1123 // <Area> of Methods with Optional Parameters and named arguments</Area> 1124 // <Title>Overload resolution of named params and optionals</Title> 1125 // <Description>Basic Overload resolution with named. This is here mostly as a regression test</Description> 1126 // <Expects status=success></Expects> 1127 // <Code> 1128 public class Parent 1129 { Foo(long i)1130 public dynamic Foo(long i) 1131 { 1132 return 1; 1133 } 1134 Foo(int i)1135 public int Foo(int i) 1136 { 1137 return 0; 1138 } 1139 } 1140 1141 public class Test 1142 { 1143 [Fact] DynamicCSharpRunTest()1144 public static void DynamicCSharpRunTest() 1145 { 1146 Assert.Equal(0, MainMethod()); 1147 } 1148 MainMethod()1149 public static int MainMethod() 1150 { 1151 dynamic p = new Parent(); 1152 return p.Foo(i: 2); 1153 } 1154 } 1155 //</Code> 1156 } 1157 1158 1159 1160 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload10c.overload10c 1161 { 1162 // <Area> of Methods with Optional Parameters and named arguments</Area> 1163 // <Title>Overload resolution of named params and optionals</Title> 1164 // <Description>Basic Overload resolution with named. This is here mostly as a regression test</Description> 1165 // <Expects status=success></Expects> 1166 // <Code> 1167 public class Parent 1168 { Foo(long i)1169 public int Foo(long i) 1170 { 1171 return 1; 1172 } 1173 Foo(int i)1174 public int Foo(int i) 1175 { 1176 return 0; 1177 } 1178 } 1179 1180 public class Test 1181 { 1182 [Fact] DynamicCSharpRunTest()1183 public static void DynamicCSharpRunTest() 1184 { 1185 Assert.Equal(0, MainMethod()); 1186 } 1187 MainMethod()1188 public static int MainMethod() 1189 { 1190 Parent p = new Parent(); 1191 dynamic i = 2; 1192 return p.Foo(i: i); 1193 } 1194 } 1195 //</Code> 1196 } 1197 1198 1199 1200 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload11.overload11 1201 { 1202 // <Area> of Methods with Optional Parameters and named arguments</Area> 1203 // <Title>Overload resolution of named params and optionals</Title> 1204 // <Description>Basic Overload resolution</Description> 1205 // <Expects status=success></Expects> 1206 // <Code> 1207 public class Parent 1208 { Foo(int i = 0, int j = 0)1209 public int Foo(int i = 0, int j = 0) 1210 { 1211 return 0; 1212 } 1213 Foo(int i = 0, params int[] arr)1214 public int Foo(int i = 0, params int[] arr) 1215 { 1216 return 1; 1217 } 1218 } 1219 1220 public class Test 1221 { 1222 [Fact] DynamicCSharpRunTest()1223 public static void DynamicCSharpRunTest() 1224 { 1225 Assert.Equal(0, MainMethod()); 1226 } 1227 MainMethod()1228 public static int MainMethod() 1229 { 1230 dynamic p = new Parent(); 1231 return p.Foo(); 1232 } 1233 } 1234 //</Code> 1235 } 1236 1237 1238 1239 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload11a.overload11a 1240 { 1241 // <Area> of Methods with Optional Parameters and named arguments</Area> 1242 // <Title>Overload resolution of named params and optionals</Title> 1243 // <Description>Basic Overload resolution</Description> 1244 // <Expects status=success></Expects> 1245 // <Code> 1246 public class Parent 1247 { Foo(int i = 0, dynamic j = null)1248 public dynamic Foo(int i = 0, dynamic j = null) 1249 { 1250 return 0; 1251 } 1252 Foo(int i = 0, params int[] arr)1253 public int Foo(int i = 0, params int[] arr) 1254 { 1255 return 1; 1256 } 1257 } 1258 1259 public class Test 1260 { 1261 [Fact] DynamicCSharpRunTest()1262 public static void DynamicCSharpRunTest() 1263 { 1264 Assert.Equal(0, MainMethod()); 1265 } 1266 MainMethod()1267 public static int MainMethod() 1268 { 1269 Parent p = new Parent(); 1270 return p.Foo(); 1271 } 1272 } 1273 //</Code> 1274 } 1275 1276 1277 1278 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload11b.overload11b 1279 { 1280 // <Area> of Methods with Optional Parameters and named arguments</Area> 1281 // <Title>Overload resolution of named params and optionals</Title> 1282 // <Description>Basic Overload resolution</Description> 1283 // <Expects status=success></Expects> 1284 // <Code> 1285 public class Parent 1286 { Foo(int i = 0, dynamic j = null)1287 public dynamic Foo(int i = 0, dynamic j = null) 1288 { 1289 return 0; 1290 } 1291 Foo(int i = 0, params int[] arr)1292 public int Foo(int i = 0, params int[] arr) 1293 { 1294 return 1; 1295 } 1296 } 1297 1298 public class Test 1299 { 1300 [Fact] DynamicCSharpRunTest()1301 public static void DynamicCSharpRunTest() 1302 { 1303 Assert.Equal(0, MainMethod()); 1304 } 1305 MainMethod()1306 public static int MainMethod() 1307 { 1308 dynamic p = new Parent(); 1309 return p.Foo(); 1310 } 1311 } 1312 //</Code> 1313 } 1314 1315 1316 1317 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload12.overload12 1318 { 1319 // <Area> of Methods with Optional Parameters and named arguments</Area> 1320 // <Title>Overload resolution of named params and optionals</Title> 1321 // <Description>Basic Overload resolution</Description> 1322 // <Expects status=success></Expects> 1323 // <Code> 1324 public class Parent 1325 { Foo(int i = 0, int j = 0)1326 public int Foo(int i = 0, int j = 0) 1327 { 1328 return 0; 1329 } 1330 Foo(params int[] arr)1331 public int Foo(params int[] arr) 1332 { 1333 return 1; 1334 } 1335 } 1336 1337 public class Test 1338 { 1339 [Fact] DynamicCSharpRunTest()1340 public static void DynamicCSharpRunTest() 1341 { 1342 Assert.Equal(0, MainMethod()); 1343 } 1344 MainMethod()1345 public static int MainMethod() 1346 { 1347 dynamic p = new Parent(); 1348 return p.Foo(); 1349 } 1350 } 1351 //</Code> 1352 } 1353 1354 1355 1356 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload12a.overload12a 1357 { 1358 // <Area> of Methods with Optional Parameters and named arguments</Area> 1359 // <Title>Overload resolution of named params and optionals</Title> 1360 // <Description>Basic Overload resolution</Description> 1361 // <Expects status=success></Expects> 1362 // <Code> 1363 public class Parent 1364 { Foo(int i = 0, dynamic j = null)1365 public int Foo(int i = 0, dynamic j = null) 1366 { 1367 return 0; 1368 } 1369 Foo(params dynamic[] arr)1370 public int Foo(params dynamic[] arr) 1371 { 1372 return 1; 1373 } 1374 } 1375 1376 public class Test 1377 { 1378 [Fact] DynamicCSharpRunTest()1379 public static void DynamicCSharpRunTest() 1380 { 1381 Assert.Equal(0, MainMethod()); 1382 } 1383 MainMethod()1384 public static int MainMethod() 1385 { 1386 Parent p = new Parent(); 1387 return p.Foo(); 1388 } 1389 } 1390 //</Code> 1391 } 1392 1393 1394 1395 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload12b.overload12b 1396 { 1397 // <Area> of Methods with Optional Parameters and named arguments</Area> 1398 // <Title>Overload resolution of named params and optionals</Title> 1399 // <Description>Basic Overload resolution</Description> 1400 // <Expects status=success></Expects> 1401 // <RelatedBugs></RelatedBugs> 1402 // <Code> 1403 public class Parent 1404 { Foo(int i = 0, dynamic j = null)1405 public int Foo(int i = 0, dynamic j = null) 1406 { 1407 return 0; 1408 } 1409 Foo(params dynamic[] arr)1410 public int Foo(params dynamic[] arr) 1411 { 1412 return 1; 1413 } 1414 } 1415 1416 public class Test 1417 { 1418 [Fact] DynamicCSharpRunTest()1419 public static void DynamicCSharpRunTest() 1420 { 1421 Assert.Equal(0, MainMethod()); 1422 } 1423 MainMethod()1424 public static int MainMethod() 1425 { 1426 dynamic p = new Parent(); 1427 return p.Foo(); 1428 } 1429 } 1430 //</Code> 1431 } 1432 1433 1434 1435 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload13.overload13 1436 { 1437 // <Area> of Methods with Optional Parameters and named arguments</Area> 1438 // <Title>Overload resolution of named params and optionals</Title> 1439 // <Description>Basic Overload resolution</Description> 1440 // <Expects status=success></Expects> 1441 // <Code> 1442 public class Parent 1443 { Foo(int i = 0, int j = 0)1444 public int Foo(int i = 0, int j = 0) 1445 { 1446 return 0; 1447 } 1448 Foo(int i = 0, params int[] arr)1449 public int Foo(int i = 0, params int[] arr) 1450 { 1451 return 1; 1452 } 1453 } 1454 1455 public class Test 1456 { 1457 [Fact] DynamicCSharpRunTest()1458 public static void DynamicCSharpRunTest() 1459 { 1460 Assert.Equal(0, MainMethod()); 1461 } 1462 MainMethod()1463 public static int MainMethod() 1464 { 1465 dynamic p = new Parent(); 1466 return p.Foo(i: 0); 1467 } 1468 } 1469 //</Code> 1470 } 1471 1472 1473 1474 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload13a.overload13a 1475 { 1476 // <Area> of Methods with Optional Parameters and named arguments</Area> 1477 // <Title>Overload resolution of named params and optionals</Title> 1478 // <Description>Basic Overload resolution</Description> 1479 // <Expects status=success></Expects> 1480 // <Code> 1481 public class Parent 1482 { Foo(dynamic i = null, int j = 0)1483 public int Foo(dynamic i = null, int j = 0) 1484 { 1485 return 0; 1486 } 1487 Foo(int i = 0, params int[] arr)1488 public dynamic Foo(int i = 0, params int[] arr) 1489 { 1490 return 1; 1491 } 1492 } 1493 1494 public class Test 1495 { 1496 [Fact] DynamicCSharpRunTest()1497 public static void DynamicCSharpRunTest() 1498 { 1499 Assert.Equal(0, MainMethod()); 1500 } 1501 MainMethod()1502 public static int MainMethod() 1503 { 1504 Parent p = new Parent(); 1505 // select 2nd Foo as the first type is int 1506 return p.Foo(i: 0) - 1; 1507 } 1508 } 1509 //</Code> 1510 } 1511 1512 1513 1514 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload13b.overload13b 1515 { 1516 // <Area> of Methods with Optional Parameters and named arguments</Area> 1517 // <Title>Overload resolution of named params and optionals</Title> 1518 // <Description>Basic Overload resolution</Description> 1519 // <Expects status=success></Expects> 1520 // <Code> 1521 public class Parent 1522 { Foo(dynamic i = null, int j = 0)1523 public int Foo(dynamic i = null, int j = 0) 1524 { 1525 return 1; 1526 } 1527 Foo(int i = 0, params int[] arr)1528 public dynamic Foo(int i = 0, params int[] arr) 1529 { 1530 return 0; 1531 } //we should pick this method 1532 } 1533 1534 public class Test 1535 { 1536 [Fact] DynamicCSharpRunTest()1537 public static void DynamicCSharpRunTest() 1538 { 1539 Assert.Equal(0, MainMethod()); 1540 } 1541 MainMethod()1542 public static int MainMethod() 1543 { 1544 dynamic p = new Parent(); 1545 return p.Foo(i: 0); 1546 } 1547 } 1548 //</Code> 1549 } 1550 1551 1552 1553 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload13c.overload13c 1554 { 1555 // <Area> of Methods with Optional Parameters and named arguments</Area> 1556 // <Title>Overload resolution of named params and optionals</Title> 1557 // <Description>Basic Overload resolution</Description> 1558 // <Expects status=success></Expects> 1559 // <Code> 1560 public class Parent 1561 { Foo(int i = 0, int j = 0)1562 public int Foo(int i = 0, int j = 0) 1563 { 1564 return 0; 1565 } 1566 Foo(int i = 0, params int[] arr)1567 public int Foo(int i = 0, params int[] arr) 1568 { 1569 return 1; 1570 } 1571 } 1572 1573 public class Test 1574 { 1575 [Fact] DynamicCSharpRunTest()1576 public static void DynamicCSharpRunTest() 1577 { 1578 Assert.Equal(0, MainMethod()); 1579 } 1580 MainMethod()1581 public static int MainMethod() 1582 { 1583 Parent p = new Parent(); 1584 dynamic i = 0; 1585 return p.Foo(i: i); 1586 } 1587 } 1588 //</Code> 1589 } 1590 1591 1592 1593 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload14.overload14 1594 { 1595 // <Area> of Methods with Optional Parameters and named arguments</Area> 1596 // <Title>Overload resolution of named params and optionals</Title> 1597 // <Description>Basic Overload resolution</Description> 1598 // <Expects status=success></Expects> 1599 // <Code> 1600 public class Parent 1601 { Foo(int i = 0, int j = 0)1602 public int Foo(int i = 0, int j = 0) 1603 { 1604 return 0; 1605 } 1606 Foo(int i = 0, params int[] arr)1607 public int Foo(int i = 0, params int[] arr) 1608 { 1609 return 1; 1610 } 1611 } 1612 1613 public class Test 1614 { 1615 [Fact] DynamicCSharpRunTest()1616 public static void DynamicCSharpRunTest() 1617 { 1618 Assert.Equal(0, MainMethod()); 1619 } 1620 MainMethod()1621 public static int MainMethod() 1622 { 1623 dynamic p = new Parent(); 1624 return p.Foo(j: 0); 1625 } 1626 } 1627 //</Code> 1628 } 1629 1630 1631 1632 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload14a.overload14a 1633 { 1634 // <Area> of Methods with Optional Parameters and named arguments</Area> 1635 // <Title>Overload resolution of named params and optionals</Title> 1636 // <Description>Basic Overload resolution</Description> 1637 // <Expects status=success></Expects> 1638 // <Code> 1639 public class Parent 1640 { Foo(int i = 0, int j = 0)1641 public dynamic Foo(int i = 0, int j = 0) 1642 { 1643 return 0; 1644 } 1645 Foo(dynamic i = null, params int[] arr)1646 public int Foo(dynamic i = null, params int[] arr) 1647 { 1648 return 1; 1649 } 1650 } 1651 1652 public class Test 1653 { 1654 [Fact] DynamicCSharpRunTest()1655 public static void DynamicCSharpRunTest() 1656 { 1657 Assert.Equal(0, MainMethod()); 1658 } 1659 MainMethod()1660 public static int MainMethod() 1661 { 1662 Parent p = new Parent(); 1663 return p.Foo(j: 0); 1664 } 1665 } 1666 //</Code> 1667 } 1668 1669 1670 1671 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload14b.overload14b 1672 { 1673 // <Area> of Methods with Optional Parameters and named arguments</Area> 1674 // <Title>Overload resolution of named params and optionals</Title> 1675 // <Description>Basic Overload resolution</Description> 1676 // <Expects status=success></Expects> 1677 // <Code> 1678 public class Parent 1679 { Foo(int i = 0, int j = 0)1680 public dynamic Foo(int i = 0, int j = 0) 1681 { 1682 return 0; 1683 } 1684 Foo(dynamic i = null, params int[] arr)1685 public int Foo(dynamic i = null, params int[] arr) 1686 { 1687 return 1; 1688 } 1689 } 1690 1691 public class Test 1692 { 1693 [Fact] DynamicCSharpRunTest()1694 public static void DynamicCSharpRunTest() 1695 { 1696 Assert.Equal(0, MainMethod()); 1697 } 1698 MainMethod()1699 public static int MainMethod() 1700 { 1701 dynamic p = new Parent(); 1702 return p.Foo(j: 0); 1703 } 1704 } 1705 //</Code> 1706 } 1707 1708 1709 1710 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload14c.overload14c 1711 { 1712 // <Area> of Methods with Optional Parameters and named arguments</Area> 1713 // <Title>Overload resolution of named params and optionals</Title> 1714 // <Description>Basic Overload resolution</Description> 1715 // <Expects status=success></Expects> 1716 // <Code> 1717 public class Parent 1718 { Foo(int i = 0, int j = 0)1719 public int Foo(int i = 0, int j = 0) 1720 { 1721 return 0; 1722 } 1723 Foo(int i = 0, params int[] arr)1724 public int Foo(int i = 0, params int[] arr) 1725 { 1726 return 1; 1727 } 1728 } 1729 1730 public class Test 1731 { 1732 [Fact] DynamicCSharpRunTest()1733 public static void DynamicCSharpRunTest() 1734 { 1735 Assert.Equal(0, MainMethod()); 1736 } 1737 MainMethod()1738 public static int MainMethod() 1739 { 1740 Parent p = new Parent(); 1741 dynamic j = 0; 1742 return p.Foo(j: j); 1743 } 1744 } 1745 //</Code> 1746 } 1747 1748 1749 1750 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload15.overload15 1751 { 1752 // <Area> of Methods with Optional Parameters and named arguments</Area> 1753 // <Title>Overload resolution of named params and optionals</Title> 1754 // <Description>Basic Overload resolution</Description> 1755 // <Expects status=success></Expects> 1756 // <Code> 1757 public class Parent 1758 { Foo(int i = 0, int j = 0)1759 public int Foo(int i = 0, int j = 0) 1760 { 1761 return 0; 1762 } 1763 Foo(int i = 0, params int[] arr)1764 public int Foo(int i = 0, params int[] arr) 1765 { 1766 return 1; 1767 } 1768 } 1769 1770 public class Test 1771 { 1772 [Fact] DynamicCSharpRunTest()1773 public static void DynamicCSharpRunTest() 1774 { 1775 Assert.Equal(0, MainMethod()); 1776 } 1777 MainMethod()1778 public static int MainMethod() 1779 { 1780 dynamic p = new Parent(); 1781 return p.Foo(1, 2); 1782 } 1783 } 1784 //</Code> 1785 } 1786 1787 1788 1789 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload15a.overload15a 1790 { 1791 // <Area> of Methods with Optional Parameters and named arguments</Area> 1792 // <Title>Overload resolution of named params and optionals</Title> 1793 // <Description>Basic Overload resolution</Description> 1794 // <RelatedBugs></RelatedBugs> 1795 // <Expects status=success></Expects> 1796 // <Code> 1797 public class Parent 1798 { Foo(dynamic i = null, dynamic j = null)1799 public dynamic Foo(dynamic i = null, dynamic j = null) 1800 { 1801 return 1; 1802 } 1803 Foo(int i = 0, params int[] arr)1804 public int Foo(int i = 0, params int[] arr) 1805 { 1806 return 0; 1807 } 1808 } 1809 1810 public class Test 1811 { 1812 [Fact] DynamicCSharpRunTest()1813 public static void DynamicCSharpRunTest() 1814 { 1815 Assert.Equal(0, MainMethod()); 1816 } 1817 MainMethod()1818 public static int MainMethod() 1819 { 1820 Parent p = new Parent(); 1821 dynamic d1 = 1; 1822 dynamic d2 = 'c'; 1823 // the conversion from (int, char) to (int int) is better than 1824 // to (object, object), so the second Foo is picked. 1825 return p.Foo(d1, d2); 1826 } 1827 } 1828 //</Code> 1829 } 1830 1831 1832 1833 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload15b.overload15b 1834 { 1835 // <Area> of Methods with Optional Parameters and named arguments</Area> 1836 // <Title>Overload resolution of named params and optionals</Title> 1837 // <Description>Basic Overload resolution</Description> 1838 // <Expects status=success></Expects> 1839 // <Code> 1840 public class Parent 1841 { Foo(dynamic i = null, dynamic j = null)1842 public dynamic Foo(dynamic i = null, dynamic j = null) 1843 { 1844 return 1; 1845 } 1846 Foo(int i = 0, params int[] arr)1847 public int Foo(int i = 0, params int[] arr) 1848 { 1849 return 0; 1850 } 1851 } 1852 1853 public class Test 1854 { 1855 [Fact] DynamicCSharpRunTest()1856 public static void DynamicCSharpRunTest() 1857 { 1858 Assert.Equal(0, MainMethod()); 1859 } 1860 MainMethod()1861 public static int MainMethod() 1862 { 1863 dynamic p = new Parent(); 1864 return p.Foo(1, 2); 1865 } 1866 } 1867 //</Code> 1868 } 1869 1870 1871 1872 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload15c.overload15c 1873 { 1874 // <Area> of Methods with Optional Parameters and named arguments</Area> 1875 // <Title>Overload resolution of named params and optionals</Title> 1876 // <Description>Basic Overload resolution</Description> 1877 // <Expects status=success></Expects> 1878 // <Code> 1879 public class Parent 1880 { Foo(int i = 0, int j = 0)1881 public int Foo(int i = 0, int j = 0) 1882 { 1883 return 0; 1884 } 1885 Foo(int i = 0, params int[] arr)1886 public int Foo(int i = 0, params int[] arr) 1887 { 1888 return 1; 1889 } 1890 } 1891 1892 public class Test 1893 { 1894 [Fact] DynamicCSharpRunTest()1895 public static void DynamicCSharpRunTest() 1896 { 1897 Assert.Equal(0, MainMethod()); 1898 } 1899 MainMethod()1900 public static int MainMethod() 1901 { 1902 Parent p = new Parent(); 1903 dynamic i = 1; 1904 dynamic j = 2; 1905 return p.Foo(i, j); 1906 } 1907 } 1908 //</Code> 1909 } 1910 1911 1912 1913 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload16.overload16 1914 { 1915 // <Area> of Methods with Optional Parameters and named arguments</Area> 1916 // <Title>Overload resolution of named params and optionals</Title> 1917 // <Description>Basic Overload resolution</Description> 1918 // <Expects status=success></Expects> 1919 // <Code> 1920 public class Parent 1921 { Foo(int i = 0, int j = 0)1922 public int Foo(int i = 0, int j = 0) 1923 { 1924 return 0; 1925 } 1926 Foo(int i = 0, params int[] arr)1927 public int Foo(int i = 0, params int[] arr) 1928 { 1929 return 1; 1930 } 1931 } 1932 1933 public class Test 1934 { 1935 [Fact] DynamicCSharpRunTest()1936 public static void DynamicCSharpRunTest() 1937 { 1938 Assert.Equal(0, MainMethod()); 1939 } 1940 MainMethod()1941 public static int MainMethod() 1942 { 1943 dynamic p = new Parent(); 1944 return p.Foo(1, j: 2); 1945 } 1946 } 1947 //</Code> 1948 } 1949 1950 1951 1952 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload16a.overload16a 1953 { 1954 // <Area> of Methods with Optional Parameters and named arguments</Area> 1955 // <Title>Overload resolution of named params and optionals</Title> 1956 // <Description>Basic Overload resolution</Description> 1957 // <Expects status=success></Expects> 1958 // <Code> 1959 public class Parent 1960 { Foo(int i = 0, dynamic j = null)1961 public int Foo(int i = 0, dynamic j = null) 1962 { 1963 return 0; 1964 } 1965 Foo(dynamic i = null, params dynamic[] arr)1966 public int Foo(dynamic i = null, params dynamic[] arr) 1967 { 1968 return 1; 1969 } 1970 } 1971 1972 public class Test 1973 { 1974 [Fact] DynamicCSharpRunTest()1975 public static void DynamicCSharpRunTest() 1976 { 1977 Assert.Equal(0, MainMethod()); 1978 } 1979 MainMethod()1980 public static int MainMethod() 1981 { 1982 Parent p = new Parent(); 1983 return p.Foo(1, j: 2); 1984 } 1985 } 1986 //</Code> 1987 } 1988 1989 1990 1991 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload16b.overload16b 1992 { 1993 // <Area> of Methods with Optional Parameters and named arguments</Area> 1994 // <Title>Overload resolution of named params and optionals</Title> 1995 // <Description>Basic Overload resolution</Description> 1996 // <Expects status=success></Expects> 1997 // <Code> 1998 public class Parent 1999 { Foo(int i = 0, dynamic j = null)2000 public int Foo(int i = 0, dynamic j = null) 2001 { 2002 return 0; 2003 } 2004 Foo(dynamic i = null, params dynamic[] arr)2005 public int Foo(dynamic i = null, params dynamic[] arr) 2006 { 2007 return 1; 2008 } 2009 } 2010 2011 public class Test 2012 { 2013 [Fact] DynamicCSharpRunTest()2014 public static void DynamicCSharpRunTest() 2015 { 2016 Assert.Equal(0, MainMethod()); 2017 } 2018 MainMethod()2019 public static int MainMethod() 2020 { 2021 dynamic p = new Parent(); 2022 return p.Foo(1, j: 2); 2023 } 2024 } 2025 //</Code> 2026 } 2027 2028 2029 2030 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload16c.overload16c 2031 { 2032 // <Area> of Methods with Optional Parameters and named arguments</Area> 2033 // <Title>Overload resolution of named params and optionals</Title> 2034 // <Description>Basic Overload resolution</Description> 2035 // <Expects status=success></Expects> 2036 // <Code> 2037 public class Parent 2038 { Foo(int i = 0, int j = 0)2039 public int Foo(int i = 0, int j = 0) 2040 { 2041 return 0; 2042 } 2043 Foo(int i = 0, params int[] arr)2044 public int Foo(int i = 0, params int[] arr) 2045 { 2046 return 1; 2047 } 2048 } 2049 2050 public class Test 2051 { 2052 [Fact] DynamicCSharpRunTest()2053 public static void DynamicCSharpRunTest() 2054 { 2055 Assert.Equal(0, MainMethod()); 2056 } 2057 MainMethod()2058 public static int MainMethod() 2059 { 2060 Parent p = new Parent(); 2061 dynamic j = 2; 2062 return p.Foo(1, j: j); 2063 } 2064 } 2065 //</Code> 2066 } 2067 2068 2069 2070 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload17.overload17 2071 { 2072 // <Area> of Methods with Optional Parameters and named arguments</Area> 2073 // <Title>Overload resolution of named params and optionals</Title> 2074 // <Description>Basic Overload resolution</Description> 2075 // <Expects status=success></Expects> 2076 // <Code> 2077 public class Parent 2078 { Foo(int i = 0, int j = 0)2079 public int Foo(int i = 0, int j = 0) 2080 { 2081 return 0; 2082 } 2083 Foo(int i = 0, params int[] arr)2084 public int Foo(int i = 0, params int[] arr) 2085 { 2086 return 1; 2087 } 2088 } 2089 2090 public class Test 2091 { 2092 [Fact] DynamicCSharpRunTest()2093 public static void DynamicCSharpRunTest() 2094 { 2095 Assert.Equal(0, MainMethod()); 2096 } 2097 MainMethod()2098 public static int MainMethod() 2099 { 2100 dynamic p = new Parent(); 2101 return p.Foo(1, j: 2); 2102 } 2103 } 2104 //</Code> 2105 } 2106 2107 2108 2109 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload17a.overload17a 2110 { 2111 // <Area> of Methods with Optional Parameters and named arguments</Area> 2112 // <Title>Overload resolution of named params and optionals</Title> 2113 // <Description>Basic Overload resolution</Description> 2114 // <Expects status=success></Expects> 2115 // <Code> 2116 public class Parent 2117 { Foo(dynamic i = null, dynamic j = null)2118 public int Foo(dynamic i = null, dynamic j = null) 2119 { 2120 return 0; 2121 } 2122 Foo(int i = 0, params int[] arr)2123 public dynamic Foo(int i = 0, params int[] arr) 2124 { 2125 return 1; 2126 } 2127 } 2128 2129 public class Test 2130 { 2131 [Fact] DynamicCSharpRunTest()2132 public static void DynamicCSharpRunTest() 2133 { 2134 Assert.Equal(0, MainMethod()); 2135 } 2136 MainMethod()2137 public static int MainMethod() 2138 { 2139 Parent p = new Parent(); 2140 return p.Foo(1, j: 2); 2141 } 2142 } 2143 //</Code> 2144 } 2145 2146 2147 2148 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload17b.overload17b 2149 { 2150 // <Area> of Methods with Optional Parameters and named arguments</Area> 2151 // <Title>Overload resolution of named params and optionals</Title> 2152 // <Description>Basic Overload resolution</Description> 2153 // <Expects status=success></Expects> 2154 // <Code> 2155 public class Parent 2156 { Foo(dynamic i = null, dynamic j = null)2157 public int Foo(dynamic i = null, dynamic j = null) 2158 { 2159 return 0; 2160 } 2161 Foo(int i = 0, params int[] arr)2162 public dynamic Foo(int i = 0, params int[] arr) 2163 { 2164 return 1; 2165 } 2166 } 2167 2168 public class Test 2169 { 2170 [Fact] DynamicCSharpRunTest()2171 public static void DynamicCSharpRunTest() 2172 { 2173 Assert.Equal(0, MainMethod()); 2174 } 2175 MainMethod()2176 public static int MainMethod() 2177 { 2178 dynamic p = new Parent(); 2179 return p.Foo(1, j: 2); 2180 } 2181 } 2182 //</Code> 2183 } 2184 2185 2186 2187 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload17c.overload17c 2188 { 2189 // <Area> of Methods with Optional Parameters and named arguments</Area> 2190 // <Title>Overload resolution of named params and optionals</Title> 2191 // <Description>Basic Overload resolution</Description> 2192 // <Expects status=success></Expects> 2193 // <Code> 2194 public class Parent 2195 { Foo(int i = 0, int j = 0)2196 public int Foo(int i = 0, int j = 0) 2197 { 2198 return 0; 2199 } 2200 Foo(int i = 0, params int[] arr)2201 public int Foo(int i = 0, params int[] arr) 2202 { 2203 return 1; 2204 } 2205 } 2206 2207 public class Test 2208 { 2209 [Fact] DynamicCSharpRunTest()2210 public static void DynamicCSharpRunTest() 2211 { 2212 Assert.Equal(0, MainMethod()); 2213 } 2214 MainMethod()2215 public static int MainMethod() 2216 { 2217 Parent p = new Parent(); 2218 dynamic i = 1; 2219 dynamic j = 2; 2220 return p.Foo(i, j: j); 2221 } 2222 } 2223 //</Code> 2224 } 2225 2226 2227 2228 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload18.overload18 2229 { 2230 // <Area> of Methods with Optional Parameters and named arguments</Area> 2231 // <Title>Overload resolution of named params and optionals</Title> 2232 // <Description>Basic Overload resolution</Description> 2233 // <Expects status=success></Expects> 2234 // <Code> 2235 public class Parent 2236 { Foo(int i = 0, int j = 0)2237 public int Foo(int i = 0, int j = 0) 2238 { 2239 return 0; 2240 } 2241 } 2242 2243 public class Derived : Parent 2244 { Foo(int i = 0, params int[] arr)2245 public int Foo(int i = 0, params int[] arr) 2246 { 2247 return 1; 2248 } 2249 } 2250 2251 public class Test 2252 { 2253 [Fact] DynamicCSharpRunTest()2254 public static void DynamicCSharpRunTest() 2255 { 2256 Assert.Equal(0, MainMethod()); 2257 } 2258 MainMethod()2259 public static int MainMethod() 2260 { 2261 dynamic p = new Derived(); 2262 return p.Foo(1, j: 2); 2263 } 2264 } 2265 //</Code> 2266 } 2267 2268 2269 2270 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload18a.overload18a 2271 { 2272 // <Area> of Methods with Optional Parameters and named arguments</Area> 2273 // <Title>Overload resolution of named params and optionals</Title> 2274 // <Description>Basic Overload resolution</Description> 2275 // <Expects status=success></Expects> 2276 // <Code> 2277 public class Parent 2278 { Foo(dynamic i = null, int j = 0)2279 public int Foo(dynamic i = null, int j = 0) 2280 { 2281 return 0; 2282 } 2283 } 2284 2285 public class Derived : Parent 2286 { Foo(dynamic i = null, params int[] arr)2287 public int Foo(dynamic i = null, params int[] arr) 2288 { 2289 return 1; 2290 } 2291 } 2292 2293 public class Test 2294 { 2295 [Fact] DynamicCSharpRunTest()2296 public static void DynamicCSharpRunTest() 2297 { 2298 Assert.Equal(0, MainMethod()); 2299 } 2300 MainMethod()2301 public static int MainMethod() 2302 { 2303 Derived p = new Derived(); 2304 return p.Foo(1, j: 2); 2305 } 2306 } 2307 //</Code> 2308 } 2309 2310 2311 2312 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload18b.overload18b 2313 { 2314 // <Area> of Methods with Optional Parameters and named arguments</Area> 2315 // <Title>Overload resolution of named params and optionals</Title> 2316 // <Description>Basic Overload resolution</Description> 2317 // <Expects status=success></Expects> 2318 // <Code> 2319 public class Parent 2320 { Foo(dynamic i = null, int j = 0)2321 public int Foo(dynamic i = null, int j = 0) 2322 { 2323 return 0; 2324 } 2325 } 2326 2327 public class Derived : Parent 2328 { Foo(dynamic i = null, params int[] arr)2329 public int Foo(dynamic i = null, params int[] arr) 2330 { 2331 return 1; 2332 } 2333 } 2334 2335 public class Test 2336 { 2337 [Fact] DynamicCSharpRunTest()2338 public static void DynamicCSharpRunTest() 2339 { 2340 Assert.Equal(0, MainMethod()); 2341 } 2342 MainMethod()2343 public static int MainMethod() 2344 { 2345 dynamic p = new Derived(); 2346 return p.Foo(1, j: 2); 2347 } 2348 } 2349 //</Code> 2350 } 2351 2352 2353 2354 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload18c.overload18c 2355 { 2356 // <Area> of Methods with Optional Parameters and named arguments</Area> 2357 // <Title>Overload resolution of named params and optionals</Title> 2358 // <Description>Basic Overload resolution</Description> 2359 // <Expects status=success></Expects> 2360 // <Code> 2361 public class Parent 2362 { Foo(int i = 0, int j = 0)2363 public int Foo(int i = 0, int j = 0) 2364 { 2365 return 0; 2366 } 2367 } 2368 2369 public class Derived : Parent 2370 { Foo(int i = 0, params int[] arr)2371 public int Foo(int i = 0, params int[] arr) 2372 { 2373 return 1; 2374 } 2375 } 2376 2377 public class Test 2378 { 2379 [Fact] DynamicCSharpRunTest()2380 public static void DynamicCSharpRunTest() 2381 { 2382 Assert.Equal(0, MainMethod()); 2383 } 2384 MainMethod()2385 public static int MainMethod() 2386 { 2387 Derived p = new Derived(); 2388 dynamic i = 1; 2389 dynamic j = 2; 2390 return p.Foo(i, j: j); 2391 } 2392 } 2393 //</Code> 2394 } 2395 2396 2397 2398 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload19.overload19 2399 { 2400 // <Area> of Methods with Optional Parameters and named arguments</Area> 2401 // <Title>Overload resolution of named params and optionals</Title> 2402 // <Description>Basic Overload resolution - based on overload resolution rules</Description> 2403 // <Expects status=success></Expects> 2404 // <Code> 2405 public class Parent 2406 { Foo(int i = 0, int j = 0)2407 public int Foo(int i = 0, int j = 0) 2408 { 2409 return 1; 2410 } 2411 } 2412 2413 public class Derived : Parent 2414 { Foo(int i = 0, params int[] arr)2415 public int Foo(int i = 0, params int[] arr) 2416 { 2417 return 0; 2418 } 2419 } 2420 2421 public class Test 2422 { 2423 [Fact] DynamicCSharpRunTest()2424 public static void DynamicCSharpRunTest() 2425 { 2426 Assert.Equal(0, MainMethod()); 2427 } 2428 MainMethod()2429 public static int MainMethod() 2430 { 2431 dynamic p = new Derived(); 2432 return p.Foo(1, 2); 2433 } 2434 } 2435 //</Code> 2436 } 2437 2438 2439 2440 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload19a.overload19a 2441 { 2442 // <Area> of Methods with Optional Parameters and named arguments</Area> 2443 // <Title>Overload resolution of named params and optionals</Title> 2444 // <Description>Basic Overload resolution - based on overload resolution rules</Description> 2445 // <Expects status=success></Expects> 2446 // <Code> 2447 public class Parent 2448 { Foo(int i = 0, dynamic j = null)2449 public int Foo(int i = 0, dynamic j = null) 2450 { 2451 return 1; 2452 } 2453 } 2454 2455 public class Derived : Parent 2456 { Foo(int i = 0, params dynamic[] arr)2457 public dynamic Foo(int i = 0, params dynamic[] arr) 2458 { 2459 return 0; 2460 } 2461 } 2462 2463 public class Test 2464 { 2465 [Fact] DynamicCSharpRunTest()2466 public static void DynamicCSharpRunTest() 2467 { 2468 Assert.Equal(0, MainMethod()); 2469 } 2470 MainMethod()2471 public static int MainMethod() 2472 { 2473 Derived p = new Derived(); 2474 return p.Foo(1, 2); 2475 } 2476 } 2477 //</Code> 2478 } 2479 2480 2481 2482 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload19b.overload19b 2483 { 2484 // <Area> of Methods with Optional Parameters and named arguments</Area> 2485 // <Title>Overload resolution of named params and optionals</Title> 2486 // <Description>Basic Overload resolution - based on overload resolution rules</Description> 2487 // <Expects status=success></Expects> 2488 // <Code> 2489 public class Parent 2490 { Foo(int i = 0, dynamic j = null)2491 public int Foo(int i = 0, dynamic j = null) 2492 { 2493 return 1; 2494 } 2495 } 2496 2497 public class Derived : Parent 2498 { Foo(int i = 0, params dynamic[] arr)2499 public dynamic Foo(int i = 0, params dynamic[] arr) 2500 { 2501 return 0; 2502 } 2503 } 2504 2505 public class Test 2506 { 2507 [Fact] DynamicCSharpRunTest()2508 public static void DynamicCSharpRunTest() 2509 { 2510 Assert.Equal(0, MainMethod()); 2511 } 2512 MainMethod()2513 public static int MainMethod() 2514 { 2515 dynamic p = new Derived(); 2516 return p.Foo(1, 2); 2517 } 2518 } 2519 //</Code> 2520 } 2521 2522 2523 2524 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload19c.overload19c 2525 { 2526 // <Area> of Methods with Optional Parameters and named arguments</Area> 2527 // <Title>Overload resolution of named params and optionals</Title> 2528 // <Description>Basic Overload resolution - based on overload resolution rules</Description> 2529 // <Expects status=success></Expects> 2530 // <Code> 2531 public class Parent 2532 { Foo(int i = 0, int j = 0)2533 public int Foo(int i = 0, int j = 0) 2534 { 2535 return 1; 2536 } 2537 } 2538 2539 public class Derived : Parent 2540 { Foo(int i = 0, params int[] arr)2541 public int Foo(int i = 0, params int[] arr) 2542 { 2543 return 0; 2544 } 2545 } 2546 2547 public class Test 2548 { 2549 [Fact] DynamicCSharpRunTest()2550 public static void DynamicCSharpRunTest() 2551 { 2552 Assert.Equal(0, MainMethod()); 2553 } 2554 MainMethod()2555 public static int MainMethod() 2556 { 2557 Derived p = new Derived(); 2558 dynamic i = 1; 2559 dynamic j = 2; 2560 return p.Foo(i, j); 2561 } 2562 } 2563 //</Code> 2564 } 2565 2566 2567 2568 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload20.overload20 2569 { 2570 // <Area> of Methods with Optional Parameters and named arguments</Area> 2571 // <Title>Overload resolution of named params and optionals</Title> 2572 // <Description>Basic Overload resolution</Description> 2573 // <Expects status=success></Expects> 2574 // <Code> 2575 public class Parent 2576 { Foo(int i = 0, int j = 0)2577 public int Foo(int i = 0, int j = 0) 2578 { 2579 return 1; 2580 } 2581 } 2582 2583 public class Derived : Parent 2584 { Foo(int i = 0, params int[] arr)2585 public int Foo(int i = 0, params int[] arr) 2586 { 2587 return 0; 2588 } 2589 } 2590 2591 public class Test 2592 { 2593 [Fact] DynamicCSharpRunTest()2594 public static void DynamicCSharpRunTest() 2595 { 2596 Assert.Equal(0, MainMethod()); 2597 } 2598 MainMethod()2599 public static int MainMethod() 2600 { 2601 dynamic p = new Derived(); 2602 return p.Foo(); 2603 } 2604 } 2605 //</Code> 2606 } 2607 2608 2609 2610 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload20a.overload20a 2611 { 2612 // <Area> of Methods with Optional Parameters and named arguments</Area> 2613 // <Title>Overload resolution of named params and optionals</Title> 2614 // <Description>Basic Overload resolution</Description> 2615 // <Expects status=success></Expects> 2616 // <Code> 2617 public class Parent 2618 { Foo(int i = 0, int j = 0)2619 public dynamic Foo(int i = 0, int j = 0) 2620 { 2621 return 1; 2622 } 2623 } 2624 2625 public class Derived : Parent 2626 { Foo(dynamic i = null, params int[] arr)2627 public int Foo(dynamic i = null, params int[] arr) 2628 { 2629 return 0; 2630 } 2631 } 2632 2633 public class Test 2634 { 2635 [Fact] DynamicCSharpRunTest()2636 public static void DynamicCSharpRunTest() 2637 { 2638 Assert.Equal(0, MainMethod()); 2639 } 2640 MainMethod()2641 public static int MainMethod() 2642 { 2643 Derived p = new Derived(); 2644 return p.Foo(); 2645 } 2646 } 2647 //</Code> 2648 } 2649 2650 2651 2652 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload20b.overload20b 2653 { 2654 // <Area> of Methods with Optional Parameters and named arguments</Area> 2655 // <Title>Overload resolution of named params and optionals</Title> 2656 // <Description>Basic Overload resolution</Description> 2657 // <Expects status=success></Expects> 2658 // <Code> 2659 public class Parent 2660 { Foo(int i = 0, int j = 0)2661 public dynamic Foo(int i = 0, int j = 0) 2662 { 2663 return 1; 2664 } 2665 } 2666 2667 public class Derived : Parent 2668 { Foo(dynamic i = null, params int[] arr)2669 public int Foo(dynamic i = null, params int[] arr) 2670 { 2671 return 0; 2672 } 2673 } 2674 2675 public class Test 2676 { 2677 [Fact] DynamicCSharpRunTest()2678 public static void DynamicCSharpRunTest() 2679 { 2680 Assert.Equal(0, MainMethod()); 2681 } 2682 MainMethod()2683 public static int MainMethod() 2684 { 2685 dynamic p = new Derived(); 2686 return p.Foo(); 2687 } 2688 } 2689 //</Code> 2690 } 2691 2692 2693 2694 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload21.overload21 2695 { 2696 // <Area> of Methods with Optional Parameters and named arguments</Area> 2697 // <Title>Overload resolution of named params and optionals</Title> 2698 // <Description>Basic Overload resolution</Description> 2699 // <Expects status=success></Expects> 2700 // <Code> 2701 public class Parent 2702 { Foo(int j = 0)2703 public int Foo(int j = 0) 2704 { 2705 return 0; 2706 } 2707 Foo(params int[] arr)2708 public int Foo(params int[] arr) 2709 { 2710 return 1; 2711 } 2712 } 2713 2714 public class Test 2715 { 2716 [Fact] DynamicCSharpRunTest()2717 public static void DynamicCSharpRunTest() 2718 { 2719 Assert.Equal(0, MainMethod()); 2720 } 2721 MainMethod()2722 public static int MainMethod() 2723 { 2724 dynamic p = new Parent(); 2725 return p.Foo(); 2726 } 2727 } 2728 //</Code> 2729 } 2730 2731 2732 2733 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload21b.overload21b 2734 { 2735 // <Area> of Methods with Optional Parameters and named arguments</Area> 2736 // <Title>Overload resolution of named params and optionals</Title> 2737 // <Description>Basic Overload resolution</Description> 2738 // <RelatedBugs></RelatedBugs> 2739 // <Expects status=success></Expects> 2740 // <Code> 2741 public class Parent 2742 { Foo(dynamic j = null)2743 public int Foo(dynamic j = null) 2744 { 2745 return 0; 2746 } 2747 Foo(params int[] arr)2748 public dynamic Foo(params int[] arr) 2749 { 2750 return 1; 2751 } 2752 } 2753 2754 public class Test 2755 { 2756 [Fact] DynamicCSharpRunTest()2757 public static void DynamicCSharpRunTest() 2758 { 2759 Assert.Equal(0, MainMethod()); 2760 } 2761 MainMethod()2762 public static int MainMethod() 2763 { 2764 dynamic p = new Parent(); 2765 return p.Foo(); 2766 } 2767 } 2768 //</Code> 2769 } 2770 2771 2772 2773 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload22.overload22 2774 { 2775 // <Area> of Methods with Optional Parameters and named arguments</Area> 2776 // <Title>Overload resolution of named params and optionals</Title> 2777 // <Description>Basic Overload resolution - based on overload resolution rules</Description> 2778 // <Expects status=success></Expects> 2779 // <Code> 2780 public class Derived 2781 { Foo(int i = 0, params int[] arr)2782 public int Foo(int i = 0, params int[] arr) 2783 { 2784 return 1; 2785 } 2786 Foo(int i = 0, int j = 0)2787 public int Foo(int i = 0, int j = 0) 2788 { 2789 return 0; 2790 } 2791 } 2792 2793 public class Test 2794 { 2795 [Fact] DynamicCSharpRunTest()2796 public static void DynamicCSharpRunTest() 2797 { 2798 Assert.Equal(0, MainMethod()); 2799 } 2800 MainMethod()2801 public static int MainMethod() 2802 { 2803 dynamic p = new Derived(); 2804 return p.Foo(1, 2); 2805 } 2806 } 2807 //</Code> 2808 } 2809 2810 2811 2812 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload22a.overload22a 2813 { 2814 // <Area> of Methods with Optional Parameters and named arguments</Area> 2815 // <Title>Overload resolution of named params and optionals</Title> 2816 // <Description>Basic Overload resolution - based on overload resolution rules</Description> 2817 // <Expects status=success></Expects> 2818 // <Code> 2819 public class Derived 2820 { Foo(int i = 0, params dynamic[] arr)2821 public dynamic Foo(int i = 0, params dynamic[] arr) 2822 { 2823 return 1; 2824 } 2825 Foo(int i = 0, int j = 0)2826 public dynamic Foo(int i = 0, int j = 0) 2827 { 2828 return 0; 2829 } 2830 } 2831 2832 public class Test 2833 { 2834 [Fact] DynamicCSharpRunTest()2835 public static void DynamicCSharpRunTest() 2836 { 2837 Assert.Equal(0, MainMethod()); 2838 } 2839 MainMethod()2840 public static int MainMethod() 2841 { 2842 Derived p = new Derived(); 2843 return p.Foo(1, 2); 2844 } 2845 } 2846 //</Code> 2847 } 2848 2849 2850 2851 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload22b.overload22b 2852 { 2853 // <Area> of Methods with Optional Parameters and named arguments</Area> 2854 // <Title>Overload resolution of named params and optionals</Title> 2855 // <Description>Basic Overload resolution - based on overload resolution rules</Description> 2856 // <Expects status=success></Expects> 2857 // <Code> 2858 public class Derived 2859 { Foo(int i = 0, params dynamic[] arr)2860 public dynamic Foo(int i = 0, params dynamic[] arr) 2861 { 2862 return 1; 2863 } 2864 Foo(int i = 0, int j = 0)2865 public dynamic Foo(int i = 0, int j = 0) 2866 { 2867 return 0; 2868 } 2869 } 2870 2871 public class Test 2872 { 2873 [Fact] DynamicCSharpRunTest()2874 public static void DynamicCSharpRunTest() 2875 { 2876 Assert.Equal(0, MainMethod()); 2877 } 2878 MainMethod()2879 public static int MainMethod() 2880 { 2881 dynamic p = new Derived(); 2882 return p.Foo(1, 2); 2883 } 2884 } 2885 //</Code> 2886 } 2887 2888 2889 2890 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload22c.overload22c 2891 { 2892 // <Area> of Methods with Optional Parameters and named arguments</Area> 2893 // <Title>Overload resolution of named params and optionals</Title> 2894 // <Description>Basic Overload resolution - based on overload resolution rules</Description> 2895 // <Expects status=success></Expects> 2896 // <Code> 2897 public class Derived 2898 { Foo(int i = 0, params int[] arr)2899 public int Foo(int i = 0, params int[] arr) 2900 { 2901 return 1; 2902 } 2903 Foo(int i = 0, int j = 0)2904 public int Foo(int i = 0, int j = 0) 2905 { 2906 return 0; 2907 } 2908 } 2909 2910 public class Test 2911 { 2912 [Fact] DynamicCSharpRunTest()2913 public static void DynamicCSharpRunTest() 2914 { 2915 Assert.Equal(0, MainMethod()); 2916 } 2917 MainMethod()2918 public static int MainMethod() 2919 { 2920 Derived p = new Derived(); 2921 dynamic i = 1; 2922 dynamic j = 2; 2923 return p.Foo(1, 2); 2924 } 2925 } 2926 //</Code> 2927 } 2928 2929 2930 2931 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload23.overload23 2932 { 2933 // <Area> of Methods with Optional Parameters and named arguments</Area> 2934 // <Title>Overload resolution of named params and optionals</Title> 2935 // <Description>Basic Overload resolution - based on overload resolution rules</Description> 2936 // <Expects status=success></Expects> 2937 // <Code> 2938 2939 public class C 2940 { 2941 [Fact] DynamicCSharpRunTest()2942 public static void DynamicCSharpRunTest() 2943 { 2944 Assert.Equal(0, MainMethod()); 2945 } 2946 MainMethod()2947 public static int MainMethod() 2948 { 2949 dynamic d = new C(); 2950 try 2951 { 2952 d.Foo(x: 1, y: "", z: ""); 2953 } 2954 catch (Microsoft.CSharp.RuntimeBinder.RuntimeBinderException e) 2955 { 2956 bool ret = ErrorVerifier.Verify(ErrorMessageId.AmbigCall, e.Message, "C.Foo(int, string, string)", "C.Foo(string, int, string)"); 2957 if (ret) 2958 return 0; 2959 } 2960 2961 return 1; 2962 } 2963 Foo(int x, string y, string z)2964 public void Foo(int x, string y, string z) 2965 { 2966 } 2967 Foo(string y, int x, string z)2968 public void Foo(string y, int x, string z) 2969 { 2970 } 2971 Foo(string z, string y, int? x)2972 public void Foo(string z, string y, int? x) 2973 { 2974 } 2975 } 2976 //</Code> 2977 } 2978 2979 2980 2981 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload24.overload24 2982 { 2983 // <Area> of Methods with Optional Parameters and named arguments</Area> 2984 // <Title>Overload resolution of named params and optionals</Title> 2985 // <Description>Basic Overload resolution - based on overload resolution rules</Description> 2986 // <RelatedBugs></RelatedBugs> 2987 // <Expects status=success></Expects> 2988 // <Code> 2989 public class Derived 2990 { Foo(object i, object j = null)2991 public int Foo(object i, object j = null) 2992 { 2993 return 2; 2994 } 2995 Foo(int i = 0, params object[] arr)2996 public int Foo(int i = 0, params object[] arr) 2997 { 2998 return 0; 2999 } 3000 } 3001 3002 public class Test 3003 { 3004 [Fact] DynamicCSharpRunTest()3005 public static void DynamicCSharpRunTest() 3006 { 3007 Assert.Equal(0, MainMethod()); 3008 } 3009 MainMethod()3010 public static int MainMethod() 3011 { 3012 dynamic p = new Derived(); 3013 return p.Foo(1); 3014 } 3015 } 3016 //</Code> 3017 } 3018 3019 3020 3021 namespace ManagedTests.DynamicCSharp.Conformance.dynamic.namedandoptional.usage.overload.overload25.overload25 3022 { 3023 // <Area>N&O</Area> 3024 // <Title>overload resolution</Title> 3025 // <Description> 3026 // Overload resolution with generics and optional args 3027 // </Description> 3028 // <Related Bugs></Related Bugs> 3029 //<Expects Status=success></Expects> 3030 // <Code> 3031 3032 public class A 3033 { Foo(int x, string y = null)3034 public int Foo(int x, string y = null) 3035 { 3036 return 0; 3037 } 3038 Foo(T x)3039 public int Foo<T>(T x) 3040 { 3041 return 1; 3042 } 3043 3044 [Fact] DynamicCSharpRunTest()3045 public static void DynamicCSharpRunTest() 3046 { 3047 Assert.Equal(1, MainMethod()); 3048 } 3049 MainMethod()3050 public static int MainMethod() 3051 { 3052 dynamic d = new A(); 3053 return d.Foo(0); 3054 } 3055 } 3056 //</Code> 3057 } 3058