1
ļ»æ// Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
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:
9
// The above copyright notice and this permission notice shall be included in all copies or
10
// substantial portions of the Software.
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.
20
using System.Collections.Generic;
21
using System.Runtime.InteropServices;
22
using System.Runtime.CompilerServices;
24
[assembly: ICSharpCode.NRefactory.TypeSystem.TestCase.TypeTestAttribute(
25
42, typeof(System.Action<>), typeof(IDictionary<string, IList<NUnit.Framework.TestAttribute>>))]
27
[assembly: TypeForwardedTo(typeof(Func<,>))]
29
namespace ICSharpCode.NRefactory.TypeSystem.TestCase
31
public delegate S GenericDelegate<in T, out S>(T input) where T : S where S : class;
33
public class SimplePublicClass
35
public void Method() {}
38
public class TypeTestAttribute : Attribute
40
public TypeTestAttribute(int a1, Type a2, Type a3) {}
43
[Params(1, StringComparison.CurrentCulture, null, 4.0, "Test")]
44
public class ParamsAttribute : Attribute
46
public ParamsAttribute(params object[] x) {}
48
[Params(Property = new string[] { "a", "b" })]
49
public string[] Property { get; set; }
53
public class DoubleAttribute : Attribute
55
public DoubleAttribute(double val) {}
58
public unsafe class DynamicTest
60
public dynamic SimpleProperty { get; set; }
62
public List<dynamic> DynamicGenerics1(Action<object, dynamic[], object> param) { return null; }
63
public void DynamicGenerics2(Action<object, dynamic, object> param) { }
64
public void DynamicGenerics3(Action<int, dynamic, object> param) { }
65
public void DynamicGenerics4(Action<int[], dynamic, object> param) { }
66
public void DynamicGenerics5(Action<int*[], dynamic, object> param) { }
67
public void DynamicGenerics6(ref Action<object, dynamic, object> param) { }
68
public void DynamicGenerics7(Action<int[,][], dynamic, object> param) { }
71
public class GenericClass<A, B> where A : B
73
public void TestMethod<K, V>(string param) where V: K where K: IComparable<V> {}
74
public void GetIndex<T>(T element) where T : IEquatable<T> {}
76
public NestedEnum EnumField;
78
public A Property { get; set; }
80
public enum NestedEnum {
85
public class PropertyTest
87
public int PropertyWithProtectedSetter { get; protected set; }
89
public object PropertyWithPrivateSetter { get; private set; }
91
public object PropertyWithoutSetter { get { return null; } }
93
public string this[int index] { get { return "Test"; } set {} }
96
public enum MyEnum : short
102
CombinedFlags = Flag1 | Flag2
107
public class Nested<X> {}
109
public virtual void GenericMethodWithConstraints<X>(T a) where X : IComparer<T>, new() {}
111
public class Derived<A, B> : Base<B>
113
public override void GenericMethodWithConstraints<Y>(B a) { }
116
public struct MyStructWithCtor
118
public MyStructWithCtor(int a) {}
121
public class MyClassWithCtor
123
private MyClassWithCtor(int a) {}
127
public class NonCustomAttributes
130
public readonly int NonSerializedField;
132
[DllImport("unmanaged.dll", CharSet = CharSet.Unicode)]
133
[return: MarshalAs(UnmanagedType.Bool)]
134
public static extern bool DllMethod([In, Out] ref int p);
137
[StructLayout(LayoutKind.Explicit, CharSet = CharSet.Unicode, Pack = 8)]
138
public struct ExplicitFieldLayoutStruct
147
public class ParameterTests
149
public void MethodWithOutParameter(out int x) { x = 0; }
150
public void MethodWithParamsArray(params object[] x) {}
151
public void MethodWithOptionalParameter(int x = 4) {}
152
public void MethodWithExplicitOptionalParameter([Optional] int x) {}
153
public void MethodWithEnumOptionalParameter(StringComparison x = StringComparison.OrdinalIgnoreCase) {}
156
[ComImport(), Guid("21B8916C-F28E-11D2-A473-00C04F8EF448"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
157
public interface IAssemblyEnum
160
int GetNextAssembly(uint dwFlags);
163
public class ConstantTest
165
public const int Answer = 42;
167
public const StringComparison EnumFromAnotherAssembly = StringComparison.OrdinalIgnoreCase;
169
public const string NullString = null;
172
public class OuterGeneric<X>
175
public OuterGeneric<X> referenceToOuter;
176
public Inner(OuterGeneric<X> referenceToOuter) {}
179
public OuterGeneric<X>.Inner Field1;
181
public OuterGeneric<OuterGeneric<X>.Inner>.Inner Field3;
184
public class ExplicitDisposableImplementation : IDisposable
186
void IDisposable.Dispose() {}
189
public interface IGenericInterface<T>
191
void Test<S>(T a, S b) where S : T;
192
void Test<S>(T a, ref S b);
195
public class ExplicitGenericInterfaceImplementation : IGenericInterface<string>
197
void IGenericInterface<string>.Test<T>(string a, T b) {}
198
void IGenericInterface<string>.Test<T>(string a, ref T b) {}
201
public interface IGenericInterfaceWithUnifiableMethods<T, S>
207
public class ImplementationOfUnifiedMethods : IGenericInterfaceWithUnifiableMethods<int, int>
209
public void Test(int a) {}
212
public class ExplicitGenericInterfaceImplementationWithUnifiableMethods<T, S> : IGenericInterfaceWithUnifiableMethods<T, S>
214
void IGenericInterfaceWithUnifiableMethods<T, S>.Test(T a) {}
215
void IGenericInterfaceWithUnifiableMethods<T, S>.Test(S a) {}
218
public partial class PartialClass
220
partial void PartialMethodWithImplementation(int a);
222
partial void PartialMethodWithImplementation(System.Int32 a)
226
partial void PartialMethodWithImplementation(string a);
228
partial void PartialMethodWithImplementation(System.String a)
232
partial void PartialMethodWithoutImplementation();
235
public class ClassWithStaticAndNonStaticMembers
237
public static event System.EventHandler Event1 { add {} remove{} }
238
public event System.EventHandler Event2 { add {} remove{} }
239
#pragma warning disable 67
240
public static event System.EventHandler Event3;
241
public event System.EventHandler Event4;
243
public static int Prop1 { get { return 0; } set {} }
244
public int Prop2 { get { return 0; } set {} }
245
public static int Prop3 { get; set; }
246
public int Prop4 { get; set; }
249
public interface IInterfaceWithProperty {
250
int Prop { get; set; }
253
public class ClassWithVirtualProperty {
254
public virtual int Prop { get; set; }
257
public class ClassThatOverridesAndSealsVirtualProperty : ClassWithVirtualProperty {
258
public sealed override int Prop { get; set; }
261
public class ClassThatImplementsProperty : IInterfaceWithProperty {
262
public int Prop { get; set; }
265
public class ClassThatImplementsPropertyExplicitly : IInterfaceWithProperty {
266
int IInterfaceWithProperty.Prop { get; set; }
269
public interface IInterfaceWithIndexers {
270
int this[int x] { get; set; }
271
int this[string x] { get; set; }
272
int this[int x, int y] { get; set; }
275
public interface IGenericInterfaceWithIndexer<T> {
276
int this[T x] { get; set; }
279
public class ClassThatImplementsIndexers : IInterfaceWithIndexers, IGenericInterfaceWithIndexer<int> {
280
public int this[int x] { get { return 0; } set {} }
281
public int this[string x] { get { return 0; } set {} }
282
public int this[int x, int y] { get { return 0; } set {} }
285
public class ClassThatImplementsIndexersExplicitly : IInterfaceWithIndexers, IGenericInterfaceWithIndexer<int> {
286
int IInterfaceWithIndexers.this[int x] { get { return 0; } set {} }
287
int IGenericInterfaceWithIndexer<int>.this[int x] { get { return 0; } set {} }
288
int IInterfaceWithIndexers.this[string x] { get { return 0; } set {} }
289
int IInterfaceWithIndexers.this[int x, int y] { get { return 0; } set {} }
292
public interface IHasEvent {
293
event EventHandler Event;
296
public class ClassThatImplementsEvent : IHasEvent {
297
public event EventHandler Event;
300
public class ClassThatImplementsEventWithCustomAccessors : IHasEvent {
301
public event EventHandler Event { add {} remove {} }
304
public class ClassThatImplementsEventExplicitly : IHasEvent {
305
event EventHandler IHasEvent.Event { add {} remove {} }
308
public interface IShadowTestBase {
310
int this[int i] { get; set; }
311
int Prop { get; set; }
312
event EventHandler Evt;
315
public interface IShadowTestDerived : IShadowTestBase {
317
new int this[int i] { get; set; }
318
new int Prop { get; set; }
319
new event EventHandler Evt;
322
public static class StaticClass {}
323
public abstract class AbstractClass {}
325
public class IndexerNonDefaultName {
327
public int this[int index] {
332
public class ClassWithMethodThatHasNullableDefaultParameter {
333
public void Foo (int? bar = 42) { }
336
public class AccessibilityTest
338
public void Public() {}
339
internal void Internal() {}
340
protected internal void ProtectedInternal() {}
341
internal protected void InternalProtected() {}
342
protected void Protected() {}
343
private void Private() {}
347
public class ConstantFieldTest
349
public const byte Cb = 42;
350
public const sbyte Csb = 42;
351
public const char Cc = '\x42';
352
public const short Cs = 42;
353
public const ushort Cus = 42;
354
public const int Ci = 42;
355
public const uint Cui = 42;
356
public const long Cl = 42;
357
public const ulong Cul = 42;
358
public const double Cd = 42;
359
public const float Cf = 42;
360
public const decimal Cm = 42;
361
public const string S = "hello, world";
363
public const int SOsb = sizeof(sbyte);
364
public const int SOb = sizeof(byte);
365
public const int SOs = sizeof(short);
366
public const int SOus = sizeof(ushort);
367
public const int SOi = sizeof(int);
368
public const int SOui = sizeof(uint);
369
public const int SOl = sizeof(long);
370
public const int SOul = sizeof(ulong);
371
public const int SOc = sizeof(char);
372
public const int SOf = sizeof(float);
373
public const int SOd = sizeof(double);
374
public const int SObl = sizeof(bool);
375
public static readonly unsafe int SOe = sizeof(MyEnum);