// Authors:
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
//
-// (C) 2003 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2003-2005 Novell, Inc (http://www.novell.com)
//
using System;
using System.Globalization;
using System.Reflection;
using System.Runtime.InteropServices;
+using System.Security.Permissions;
using System.Text;
using System.Xml;
AddAttribute (nclass, "type", classType);
if (type.BaseType != null)
- AddAttribute (nclass, "base", type.BaseType.FullName);
+ AddAttribute (nclass, "base", type.BaseType.ToString ());
if (type.IsSealed)
AddAttribute (nclass, "sealed", "true");
continue;
}
XmlNode iface = document.CreateElement ("interface", null);
- AddAttribute (iface, "name", t.FullName);
+ AddAttribute (iface, "name", t.ToString ());
ifaces.AppendChild (iface);
}
}
FieldData fd = new FieldData (document, nclass, fields);
// Special case for enum fields
if (classType == "enum") {
- string etype = fields [0].GetType ().FullName;
+ string etype = fields [0].GetType ().ToString ();
AddAttribute (nclass, "enumtype", etype);
}
members.Add (fd);
return (FieldInfo[]) list.ToArray (typeof (FieldInfo));
}
- private PropertyInfo[] GetProperties (Type type)
+ internal static PropertyInfo[] GetProperties (Type type)
{
ArrayList list = new ArrayList ();
{
base.AddExtraData (p, member);
FieldInfo field = (FieldInfo) member;
- AddAttribute (p, "fieldtype", field.FieldType.FullName);
+ AddAttribute (p, "fieldtype", field.FieldType.ToString ());
if (field.IsLiteral) {
object value = field.GetValue (null);
{
base.AddExtraData (p, member);
PropertyInfo prop = (PropertyInfo) member;
- AddAttribute (p, "ptype", prop.PropertyType.FullName);
+ Type t = prop.PropertyType;
+ AddAttribute (p, "ptype", prop.PropertyType.ToString ());
MethodInfo _get = prop.GetGetMethod (true);
MethodInfo _set = prop.GetSetMethod (true);
bool haveGet = (_get != null && TypeData.MustDocumentMethod(_get));
{
base.AddExtraData (p, member);
EventInfo evt = (EventInfo) member;
- AddAttribute (p, "eventtype", evt.EventHandlerType.FullName);
+ AddAttribute (p, "eventtype", evt.EventHandlerType.ToString ());
}
public override string ParentTag {
protected override string GetMemberAttributes (MemberInfo member)
{
MethodBase method = (MethodBase) member;
- return ((int) method.Attributes).ToString (CultureInfo.InvariantCulture);
+ return ((int)( method.Attributes & ~MethodAttributes.ReservedMask)).ToString (CultureInfo.InvariantCulture);
}
protected override void AddExtraData (XmlNode p, MemberInfo member)
return;
MethodInfo method = (MethodInfo) member;
- AddAttribute (p, "returntype", method.ReturnType.FullName);
+ AddAttribute (p, "returntype", method.ReturnType.ToString ());
AttributeData.OutputAttributes (document, p,
method.ReturnTypeCustomAttributes.GetCustomAttributes (false));
}
Type t = parameter.ParameterType;
- AddAttribute (paramNode, "type", t.FullName);
+ AddAttribute (paramNode, "type", t.ToString ());
if (parameter.IsOptional) {
AddAttribute (paramNode, "optional", "true");
- if (parameter.DefaultValue != null)
- AddAttribute (paramNode, "defaultValue", parameter.DefaultValue.ToString ());
+ if (parameter.DefaultValue != System.DBNull.Value)
+ AddAttribute (paramNode, "defaultValue", (parameter.DefaultValue == null) ? "NULL" : parameter.DefaultValue.ToString ());
}
if (direction != "in")
parent.AppendChild (natts);
}
- ArrayList typeList = new ArrayList (atts.Length);
- string comment = null;
- for (int i = atts.Length - 1; i >= 0; i--) {
- Type attType = atts [i].GetType ();
- if (!MustDocumentAttribute (attType))
+ for (int i = 0; i < atts.Length; ++i) {
+ Type t = atts [i].GetType ();
+ if (!t.IsPublic && !t.Name.EndsWith ("TODOAttribute"))
+ continue;
+
+ // we ignore attributes that inherit from SecurityAttribute on purpose as they:
+ // * aren't part of GetCustomAttributes in Fx 1.0/1.1;
+ // * are encoded differently and in a different metadata table; and
+ // * won't ever exactly match MS implementation (from a syntax pov)
+ if (t.IsSubclassOf (typeof (SecurityAttribute)))
continue;
- typeList.Add (attType);
- if (attType.Name.EndsWith ("TODOAttribute")) {
- PropertyInfo prop = attType.GetProperty ("Comment");
- if (prop != null)
- comment = (string) prop.GetValue (atts [i], null);
- }
- }
- Type[] types = (Type[]) typeList.ToArray (typeof (Type));
- Array.Sort (types, TypeComparer.Default);
- foreach (Type t in types) {
XmlNode node = document.CreateElement ("attribute");
- AddAttribute (node, "name", t.FullName);
+ AddAttribute (node, "name", t.ToString ());
+
+ XmlNode properties = null;
+ foreach (PropertyInfo pi in TypeData.GetProperties (t)) {
+ if (pi.Name == "TypeId")
+ continue;
+
+ if (properties == null) {
+ properties = node.AppendChild (document.CreateElement ("properties"));
+ }
+
+ try {
+ object o = pi.GetValue (atts [i], null);
+
+ XmlNode n = properties.AppendChild (document.CreateElement ("property"));
+ AddAttribute (n, "name", pi.Name);
+
+ if (o == null) {
+ AddAttribute (n, "null", "true");
+ continue;
+ }
+
+ string value = o.ToString ();
+ if (t == typeof (GuidAttribute))
+ value = value.ToUpper ();
+
+ AddAttribute (n, "value", value);
+ }
+ catch (TargetInvocationException) {
+ continue;
+ }
+ }
+
if (target != null) {
AddAttribute (node, "target", target);
}
- if (comment != null && t.Name.EndsWith ("TODOAttribute"))
- AddAttribute (node, "comment", comment);
natts.AppendChild (node);
}
else
modifier = "";
- string type_name = info.ParameterType.ToString ();
+ string type_name = info.ParameterType.ToString ().Replace ('<', '[').Replace ('>', ']');
sb.AppendFormat ("{0}{1}, ", modifier, type_name);
}