PageRenderTime 56ms CodeModel.GetById 12ms app.highlight 38ms RepoModel.GetById 1ms app.codeStats 0ms

/ICSharpCode.Decompiler/Tests/Types/S_TypeMemberDeclarations.cs

http://github.com/icsharpcode/ILSpy
C# | 1138 lines | 1076 code | 2 blank | 60 comment | 0 complexity | b4dea34ce3a0b762a51c3830434cd757 MD5 | raw file
   1// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
   2// 
   3// Permission is hereby granted, free of charge, to any person obtaining a copy of this
   4// software and associated documentation files (the "Software"), to deal in the Software
   5// without restriction, including without limitation the rights to use, copy, modify, merge,
   6// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
   7// to whom the Software is furnished to do so, subject to the following conditions:
   8// 
   9// The above copyright notice and this permission notice shall be included in all copies or
  10// substantial portions of the Software.
  11// 
  12// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  13// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  14// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
  15// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  16// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  17// DEALINGS IN THE SOFTWARE.
  18
  19//$CS
  20using System;
  21//$CE
  22
  23//$$ IndexerWithGetOnly
  24namespace IndexerWithGetOnly
  25{
  26	public class MyClass
  27	{
  28		public int this[int i]
  29		{
  30			get
  31			{
  32				return i;
  33			}
  34		}
  35	}
  36}
  37//$$ IndexerWithSetOnly
  38namespace IndexerWithSetOnly
  39{
  40	public class MyClass
  41	{
  42		public int this[int i]
  43		{
  44			set
  45			{
  46			}
  47		}
  48	}
  49}
  50//$$ IndexerWithMoreParameters
  51namespace IndexerWithMoreParameters
  52{
  53	public class MyClass
  54	{
  55		public int this[int i, string s, Type t]
  56		{
  57			get
  58			{
  59				return 0;
  60			}
  61		}
  62	}
  63}
  64//$$ IndexerInGenericClass
  65namespace IndexerInGenericClass
  66{
  67	public class MyClass<T>
  68	{
  69		public int this[T t]
  70		{
  71			get
  72			{
  73				return 0;
  74			}
  75		}
  76	}
  77}
  78//$$ OverloadedIndexer
  79namespace OverloadedIndexer
  80{
  81	public class MyClass
  82	{
  83		public int this[int t]
  84		{
  85			get
  86			{
  87				return 0;
  88			}
  89		}
  90		public int this[string s]
  91		{
  92			get
  93			{
  94				return 0;
  95			}
  96			set
  97			{
  98				Console.WriteLine(value + " " + s);
  99			}
 100		}
 101	}
 102}
 103//$$ IndexerInInterface
 104namespace IndexerInInterface
 105{
 106	public interface IInterface
 107	{
 108		int this[string s, string s2]
 109		{
 110			set;
 111		}
 112	}
 113}
 114//$$ IndexerInterfaceExplicitImplementation
 115namespace IndexerInterfaceExplicitImplementation
 116{
 117	public interface IMyInterface
 118	{
 119		int this[string s]
 120		{
 121			get;
 122		}
 123	}
 124	public class MyClass : IMyInterface
 125	{
 126		int IMyInterface.this[string s]
 127		{
 128			get
 129			{
 130				return 3;
 131			}
 132		}
 133	}
 134}
 135//$$ IndexerInterfaceImplementation
 136namespace IndexerInterfaceImplementation
 137{
 138	public interface IMyInterface
 139	{
 140		int this[string s]
 141		{
 142			get;
 143		}
 144	}
 145	public class MyClass : IMyInterface
 146	{
 147		public int this[string s]
 148		{
 149			get
 150			{
 151				return 3;
 152			}
 153		}
 154	}
 155}
 156//$$ IndexerAbstract
 157namespace IndexerAbstract
 158{
 159	public abstract class MyClass
 160	{
 161		public abstract int this[string s, string s2]
 162		{
 163			set;
 164		}
 165		protected abstract string this[int index]
 166		{
 167			get;
 168		}
 169	}
 170}
 171//$$ MethodExplicit
 172namespace MethodExplicit
 173{
 174	public interface IMyInterface
 175	{
 176		void MyMethod();
 177	}
 178	public class MyClass : IMyInterface
 179	{
 180		void IMyInterface.MyMethod()
 181		{
 182		}
 183	}
 184}
 185//$$ MethodFromInterfaceVirtual
 186namespace MethodFromInterfaceVirtual
 187{
 188	public interface IMyInterface
 189	{
 190		void MyMethod();
 191	}
 192	public class MyClass : IMyInterface
 193	{
 194		public virtual void MyMethod()
 195		{
 196		}
 197	}
 198}
 199//$$ MethodFromInterface
 200namespace MethodFromInterface
 201{
 202	public interface IMyInterface
 203	{
 204		void MyMethod();
 205	}
 206	public class MyClass : IMyInterface
 207	{
 208		public void MyMethod()
 209		{
 210		}
 211	}
 212}
 213//$$ MethodFromInterfaceAbstract
 214namespace MethodFromInterfaceAbstract
 215{
 216	public interface IMyInterface
 217	{
 218		void MyMethod();
 219	}
 220	public abstract class MyClass : IMyInterface
 221	{
 222		public abstract void MyMethod();
 223	}
 224}
 225//$$ PropertyInterface
 226namespace PropertyInterface
 227{
 228	public interface IMyInterface
 229	{
 230		int MyProperty
 231		{
 232			get;
 233			set;
 234		}
 235	}
 236}
 237//$$ PropertyInterfaceExplicitImplementation
 238namespace PropertyInterfaceExplicitImplementation
 239{
 240	public interface IMyInterface
 241	{
 242		int MyProperty
 243		{
 244			get;
 245			set;
 246		}
 247	}
 248	public class MyClass : IMyInterface
 249	{
 250		int IMyInterface.MyProperty
 251		{
 252			get
 253			{
 254				return 0;
 255			}
 256			set
 257			{
 258			}
 259		}
 260	}
 261}
 262//$$ PropertyInterfaceImplementation
 263namespace PropertyInterfaceImplementation
 264{
 265	public interface IMyInterface
 266	{
 267		int MyProperty
 268		{
 269			get;
 270			set;
 271		}
 272	}
 273	public class MyClass : IMyInterface
 274	{
 275		public int MyProperty
 276		{
 277			get
 278			{
 279				return 0;
 280			}
 281			set
 282			{
 283			}
 284		}
 285	}
 286}
 287//$$ PropertyPrivateGetPublicSet
 288namespace PropertyPrivateGetPublicSet
 289{
 290	public class MyClass
 291	{
 292		public int MyProperty
 293		{
 294			private get
 295			{
 296				return 3;
 297			}
 298			set
 299			{
 300			}
 301		}
 302	}
 303}
 304//$$ PropertyPublicGetProtectedSet
 305namespace PropertyPublicGetProtectedSet
 306{
 307	public class MyClass
 308	{
 309		public int MyProperty
 310		{
 311			get
 312			{
 313				return 3;
 314			}
 315			protected set
 316			{
 317			}
 318		}
 319	}
 320}
 321//$$ PropertyOverrideDefaultAccessorOnly
 322namespace PropertyOverrideDefaultAccessorOnly
 323{
 324	public class MyClass
 325	{
 326		public virtual int MyProperty
 327		{
 328			get
 329			{
 330				return 3;
 331			}
 332			protected set
 333			{
 334			}
 335		}
 336	}
 337	public class Derived : MyClass
 338	{
 339		public override int MyProperty
 340		{
 341			get
 342			{
 343				return 4;
 344			}
 345		}
 346	}
 347}
 348//$$ PropertyOverrideRestrictedAccessorOnly
 349namespace PropertyOverrideRestrictedAccessorOnly
 350{
 351	public class MyClass
 352	{
 353		public virtual int MyProperty
 354		{
 355			get
 356			{
 357				return 3;
 358			}
 359			protected set
 360			{
 361			}
 362		}
 363	}
 364	public class Derived : MyClass
 365	{
 366		public override int MyProperty
 367		{
 368			protected set
 369			{
 370			}
 371		}
 372	}
 373}
 374//$$ PropertyOverrideOneAccessor
 375namespace PropertyOverrideOneAccessor
 376{
 377	public class MyClass
 378	{
 379		protected internal virtual int MyProperty
 380		{
 381			get
 382			{
 383				return 3;
 384			}
 385			protected set
 386			{
 387			}
 388		}
 389	}
 390	public class DerivedNew : MyClass
 391	{
 392		public new virtual int MyProperty
 393		{
 394			set
 395			{
 396			}
 397		}
 398	}
 399	public class DerivedOverride : DerivedNew
 400	{
 401		public override int MyProperty
 402		{
 403			set
 404			{
 405			}
 406		}
 407	}
 408}
 409//$$ IndexerOverrideRestrictedAccessorOnly
 410namespace IndexerOverrideRestrictedAccessorOnly
 411{
 412	public class MyClass
 413	{
 414		public virtual int this[string s]
 415		{
 416			get
 417			{
 418				return 3;
 419			}
 420			protected set
 421			{
 422			}
 423		}
 424		protected internal virtual int this[int i]
 425		{
 426			protected get
 427			{
 428				return 2;
 429			}
 430			set
 431			{
 432			}
 433		}
 434	}
 435	public class Derived : MyClass
 436	{
 437		protected internal override int this[int i]
 438		{
 439			protected get
 440			{
 441				return 4;
 442			}
 443		}
 444	}
 445}
 446//$$ HideProperty
 447namespace HideProperty
 448{
 449	public class A
 450	{
 451		public virtual int P
 452		{
 453			get
 454			{
 455				return 0;
 456			}
 457			set
 458			{
 459			}
 460		}
 461	}
 462	public class B : A
 463	{
 464		private new int P
 465		{
 466			get
 467			{
 468				return 0;
 469			}
 470			set
 471			{
 472			}
 473		}
 474	}
 475	public class C : B
 476	{
 477		public override int P
 478		{
 479			set
 480			{
 481			}
 482		}
 483	}
 484}
 485//$$ HideMembers
 486namespace HideMembers
 487{
 488	public class A
 489	{
 490		public int F;
 491		public int Prop
 492		{
 493			get
 494			{
 495				return 3;
 496			}
 497		}
 498		public int G
 499		{
 500			get
 501			{
 502				return 3;
 503			}
 504		}
 505	}
 506	public class B : A
 507	{
 508		public new int F
 509		{
 510			get
 511			{
 512				return 3;
 513			}
 514		}
 515		public new string Prop
 516		{
 517			get
 518			{
 519				return "a";
 520			}
 521		}
 522	}
 523	public class C : A
 524	{
 525		public new int G;
 526	}
 527	public class D : A
 528	{
 529		public new void F()
 530		{
 531		}
 532	}
 533	public class D1 : D
 534	{
 535		public new int F;
 536	}
 537	public class E : A
 538	{
 539		private new class F
 540		{
 541		}
 542	}
 543}
 544//$$ HideMembers2
 545namespace HideMembers2
 546{
 547	public class G
 548	{
 549		public int Item
 550		{
 551			get
 552			{
 553				return 1;
 554			}
 555		}
 556	}
 557	public class G2 : G
 558	{
 559		public int this[int i]
 560		{
 561			get
 562			{
 563				return 2;
 564			}
 565		}
 566	}
 567	public class G3 : G2
 568	{
 569		public new int Item
 570		{
 571			get
 572			{
 573				return 4;
 574			}
 575		}
 576	}
 577	public class H
 578	{
 579		public int this[int j]
 580		{
 581			get
 582			{
 583				return 0;
 584			}
 585		}
 586	}
 587	public class H2 : H
 588	{
 589		public int Item
 590		{
 591			get
 592			{
 593				return 2;
 594			}
 595		}
 596	}
 597	public class H3 : H2
 598	{
 599		public new string this[int j]
 600		{
 601			get
 602			{
 603				return null;
 604			}
 605		}
 606	}
 607}
 608//$$ HideMembers2a
 609namespace HideMembers2a
 610{
 611	public interface IA
 612	{
 613		int this[int i]
 614		{
 615			get;
 616		}
 617	}
 618	public class A : IA
 619	{
 620		int IA.this[int i]
 621		{
 622			get
 623			{
 624				throw new NotImplementedException();
 625			}
 626		}
 627	}
 628	public class A1 : A
 629	{
 630		public int this[int i]
 631		{
 632			get
 633			{
 634				return 3;
 635			}
 636		}
 637	}
 638}
 639//$$ HideMembers3
 640namespace HideMembers3
 641{
 642	public class G<T>
 643	{
 644		public void M1(T p)
 645		{
 646		}
 647		public int M2(int t)
 648		{
 649			return 3;
 650		}
 651	}
 652	public class G1<T> : G<int>
 653	{
 654		public new int M1(int i)
 655		{
 656			return 0;
 657		}
 658		public int M2(T i)
 659		{
 660			return 2;
 661		}
 662	}
 663	public class G2<T> : G<int>
 664	{
 665		public int M1(T p)
 666		{
 667			return 4;
 668		}
 669	}
 670	public class J
 671	{
 672		public int P
 673		{
 674			get
 675			{
 676				return 2;
 677			}
 678		}
 679	}
 680	public class J2 : J
 681	{
 682#pragma warning disable 0108	// Deliberate bad code for test case
 683		public int get_P;
 684#pragma warning restore 0108
 685	}
 686}
 687//$$ HideMembers4
 688namespace HideMembers4
 689{
 690	public class A
 691	{
 692		public void M<T>(T t)
 693		{
 694		}
 695	}
 696	public class A1 : A
 697	{
 698		public new void M<K>(K t)
 699		{
 700		}
 701		public void M(int t)
 702		{
 703		}
 704	}
 705	public class B
 706	{
 707		public void M<T>()
 708		{
 709		}
 710		public void M1<T>()
 711		{
 712		}
 713		public void M2<T>(T t)
 714		{
 715		}
 716	}
 717	public class B1 : B
 718	{
 719		public void M<T1, T2>()
 720		{
 721		}
 722		public new void M1<R>()
 723		{
 724		}
 725		public new void M2<R>(R r)
 726		{
 727		}
 728	}
 729	public class C<T>
 730	{
 731		public void M<TT>(T t)
 732		{
 733		}
 734	}
 735	public class C1<K> : C<K>
 736	{
 737		public void M<TT>(TT t)
 738		{
 739		}
 740	}
 741}
 742//$$ HideMembers5
 743namespace HideMembers5
 744{
 745	public class A
 746	{
 747		public void M(int t)
 748		{
 749		}
 750	}
 751	public class A1 : A
 752	{
 753		public void M(ref int t)
 754		{
 755		}
 756	}
 757	public class B
 758	{
 759		public void M(ref int l)
 760		{
 761		}
 762	}
 763	public class B1 : B
 764	{
 765		public void M(out int l)
 766		{
 767			l = 2;
 768		}
 769		public void M(ref long l)
 770		{
 771		}
 772	}
 773}
 774//$$ HideMemberSkipNotVisible
 775namespace HideMemberSkipNotVisible
 776{
 777	public class A
 778	{
 779		protected int F;
 780		protected string P
 781		{
 782			get
 783			{
 784				return null;
 785			}
 786		}
 787	}
 788	public class B : A
 789	{
 790		private new string F;
 791		private new int P
 792		{
 793			set
 794			{
 795			}
 796		}
 797	}
 798}
 799//$$ HideNestedClass
 800namespace HideNestedClass
 801{
 802	public class A
 803	{
 804		public class N1
 805		{
 806		}
 807		protected class N2
 808		{
 809		}
 810		private class N3
 811		{
 812		}
 813		internal class N4
 814		{
 815		}
 816		protected internal class N5
 817		{
 818		}
 819	}
 820	public class B : A
 821	{
 822		public new int N1;
 823		public new int N2;
 824		public int N3;
 825		public new int N4;
 826		public new int N5;
 827	}
 828}
 829//$$ HidePropertyReservedMethod
 830namespace HidePropertyReservedMethod
 831{
 832	public class A
 833	{
 834		public int P
 835		{
 836			get
 837			{
 838				return 1;
 839			}
 840		}
 841	}
 842	public class B : A
 843	{
 844		public int get_P()
 845		{
 846			return 2;
 847		}
 848		public void set_P(int value)
 849		{
 850		}
 851	}
 852}
 853//$$ HideIndexerDiffAccessor
 854namespace HideIndexerDiffAccessor
 855{
 856	public class A
 857	{
 858		public int this[int i]
 859		{
 860			get
 861			{
 862				return 2;
 863			}
 864		}
 865	}
 866	public class B : A
 867	{
 868		public new int this[int j]
 869		{
 870			set
 871			{
 872			}
 873		}
 874	}
 875}
 876//$$ HideIndexerGeneric
 877namespace HideIndexerGeneric
 878{
 879	public class A<T>
 880	{
 881		public virtual int this[T r]
 882		{
 883			get
 884			{
 885				return 0;
 886			}
 887			set
 888			{
 889			}
 890		}
 891	}
 892	public class B : A<int>
 893	{
 894		private new int this[int k]
 895		{
 896			get
 897			{
 898				return 0;
 899			}
 900			set
 901			{
 902			}
 903		}
 904	}
 905	public class C<T> : A<T>
 906	{
 907		public override int this[T s]
 908		{
 909			set
 910			{
 911			}
 912		}
 913	}
 914	public class D<T> : C<T>
 915	{
 916		public new virtual int this[T s]
 917		{
 918			set
 919			{
 920			}
 921		}
 922	}
 923}
 924//$$ HideMethod
 925namespace HideMethod
 926{
 927	public class A
 928	{
 929		public virtual void F()
 930		{
 931		}
 932	}
 933	public class B : A
 934	{
 935		private new void F()
 936		{
 937			base.F();
 938		}
 939	}
 940	public class C : B
 941	{
 942		public override void F()
 943		{
 944			base.F();
 945		}
 946	}
 947}
 948//$$ HideMethodGeneric
 949namespace HideMethodGeneric
 950{
 951	public class A<T>
 952	{
 953		public virtual void F(T s)
 954		{
 955		}
 956		public new static bool Equals(object o1, object o2)
 957		{
 958			return true;
 959		}
 960	}
 961	public class B : A<string>
 962	{
 963		private new void F(string k)
 964		{
 965		}
 966		public void F(int i)
 967		{
 968		}
 969	}
 970	public class C<T> : A<T>
 971	{
 972		public override void F(T r)
 973		{
 974		}
 975		public void G(T t)
 976		{
 977		}
 978	}
 979	public class D<T1> : C<T1>
 980	{
 981		public new virtual void F(T1 k)
 982		{
 983		}
 984		public virtual void F<T2>(T2 k)
 985		{
 986		}
 987		public virtual void G<T2>(T2 t)
 988		{
 989		}
 990	}
 991}
 992//$$ HideMethodGenericSkipPrivate
 993namespace HideMethodGenericSkipPrivate
 994{
 995	public class A<T>
 996	{
 997		public virtual void F(T t)
 998		{
 999		}
1000	}
1001	public class B<T> : A<T>
1002	{
1003		private new void F(T t)
1004		{
1005		}
1006		private void K()
1007		{
1008		}
1009	}
1010	public class C<T> : B<T>
1011	{
1012		public override void F(T tt)
1013		{
1014		}
1015		public void K()
1016		{
1017		}
1018	}
1019	public class D : B<int>
1020	{
1021		public override void F(int t)
1022		{
1023		}
1024	}
1025}
1026//$$ HideMethodGeneric2
1027namespace HideMethodGeneric2
1028{
1029	public class A
1030	{
1031		public virtual void F(int i)
1032		{
1033		}
1034		public void K()
1035		{
1036		}
1037	}
1038	public class B<T> : A
1039	{
1040		protected virtual void F(T t)
1041		{
1042		}
1043		public void K<T2>()
1044		{
1045		}
1046	}
1047	public class C : B<int>
1048	{
1049		protected override void F(int k)
1050		{
1051		}
1052		public new void K<T3>()
1053		{
1054		}
1055	}
1056	public class D : B<string>
1057	{
1058		public override void F(int k)
1059		{
1060		}
1061		public void L<T4>()
1062		{
1063		}
1064	}
1065	public class E<T>
1066	{
1067		public void M<T2>(T t, T2 t2)
1068		{
1069		}
1070	}
1071	public class F<T> : E<T>
1072	{
1073		public void M(T t1, T t2)
1074		{
1075		}
1076	}
1077}
1078//$$ HideMethodDiffSignatures
1079namespace HideMethodDiffSignatures
1080{
1081	public class C1<T>
1082	{
1083		public virtual void M(T arg)
1084		{
1085		}
1086	}
1087	public class C2<T1, T2> : C1<T2>
1088	{
1089		public new virtual void M(T2 arg)
1090		{
1091		}
1092	}
1093	public class C3 : C2<int, bool>
1094	{
1095		public new virtual void M(bool arg)
1096		{
1097		}
1098	}
1099}
1100//$$ HideMethodStatic
1101namespace HideMethodStatic
1102{
1103	public class A
1104	{
1105		public int N
1106		{
1107			get
1108			{
1109				return 0;
1110			}
1111		}
1112	}
1113	public class B
1114	{
1115		public int N()
1116		{
1117			return 0;
1118		}
1119	}
1120}
1121//$$ HideEvent
1122namespace HideEvent
1123{
1124	public class A
1125	{
1126		public virtual event EventHandler E;
1127		public event EventHandler F;
1128	}
1129	public class B : A
1130	{
1131		public new virtual event EventHandler E;
1132		public new event EventHandler F;
1133	}
1134	public class C : B
1135	{
1136		public override event EventHandler E;
1137	}
1138}