1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
5
using System.Collections.Generic;
7
namespace ICSharpCode.SharpDevelop.Dom
9
public class SystemTypes
11
public readonly IReturnType Void;
12
public readonly IReturnType Object;
13
public readonly IReturnType Delegate;
14
public readonly IReturnType MulticastDelegate;
15
public readonly IReturnType ValueType;
16
public readonly IReturnType Enum;
18
public readonly IReturnType Boolean;
19
public readonly IReturnType Int32;
20
public readonly IReturnType String;
22
public readonly IReturnType Array;
23
public readonly IReturnType Attribute;
24
public readonly IReturnType Type;
26
public readonly IReturnType Exception;
27
public readonly IReturnType AsyncCallback;
28
public readonly IReturnType IAsyncResult;
29
public readonly IReturnType IDisposable;
33
public SystemTypes(IProjectContent pc)
36
Void = new VoidReturnType(pc);
37
Object = CreateFromName("System.Object");
38
Delegate = CreateFromName("System.Delegate");
39
MulticastDelegate = CreateFromName("System.MulticastDelegate");
40
ValueType = CreateFromName("System.ValueType");
41
Enum = CreateFromName("System.Enum");
43
Boolean = CreateFromName("System.Boolean");
44
Int32 = CreateFromName("System.Int32");
45
String = CreateFromName("System.String");
47
Array = CreateFromName("System.Array");
48
Attribute = CreateFromName("System.Attribute");
49
Type = CreateFromName("System.Type");
51
Exception = CreateFromName("System.Exception");
52
AsyncCallback = CreateFromName("System.AsyncCallback");
53
IAsyncResult = CreateFromName("System.IAsyncResult");
54
IDisposable = CreateFromName("System.IDisposable");
57
IReturnType CreateFromName(string name)
59
IClass c = pc.GetClass(name, 0);
61
return c.DefaultReturnType;
63
LoggingService.Warn("SystemTypes.CreateFromName could not find " + name);
69
/// Creates the return type for a primitive system type.
71
public IReturnType CreatePrimitive(Type type)
73
if (type.HasElementType || type.ContainsGenericParameters) {
74
throw new ArgumentException("Only primitive types are supported.");
76
return CreateFromName(type.FullName);
80
public sealed class VoidClass : DefaultClass
82
internal static readonly string VoidName = typeof(void).FullName;
84
public VoidClass(IProjectContent pc)
85
: base(new DefaultCompilationUnit(pc), VoidName)
87
this.ClassType = ClassType.Struct;
88
this.Modifiers = ModifierEnum.Public | ModifierEnum.Sealed;
92
protected override IReturnType CreateDefaultReturnType()
94
return ProjectContent.SystemTypes.Void;
98
public sealed class VoidReturnType : AbstractReturnType
102
public VoidReturnType(IProjectContent pc)
105
throw new ArgumentNullException("pc");
107
FullyQualifiedName = VoidClass.VoidName;
110
public override IClass GetUnderlyingClass()
112
return pc.GetClass("System.Void", 0, LanguageProperties.CSharp, GetClassOptions.LookInReferences);
115
public override List<IMethod> GetMethods()
117
return new List<IMethod>();
120
public override List<IProperty> GetProperties()
122
return new List<IProperty>();
125
public override List<IField> GetFields()
127
return new List<IField>();
130
public override List<IEvent> GetEvents()
132
return new List<IEvent>();