// 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 (nassembly, "version", aname.Version.ToString ());
parent.AppendChild (nassembly);
AttributeData.OutputAttributes (document, nassembly, ass.GetCustomAttributes (false));
- Type [] types = ass.GetTypes ();
+ Type [] types = ass.GetExportedTypes ();
if (types == null || types.Length == 0)
return;
if (type.IsSealed)
AddAttribute (nclass, "sealed", "true");
+ if (type.IsAbstract)
+ AddAttribute (nclass, "abstract", "true");
+
if (type.IsSerializable)
AddAttribute (nclass, "serializable", "true");
return (FieldInfo[]) list.ToArray (typeof (FieldInfo));
}
- private PropertyInfo[] GetProperties (Type type)
+ internal static PropertyInfo[] GetProperties (Type type)
{
ArrayList list = new ArrayList ();
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);
+
+ 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);
}