//
// (C) 2006 Jb Evain
// (C) 2007 Novell, Inc.
+// Copyright 2013 Xamarin Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
_document = document;
}
- public override void Process (LinkContext context)
+ protected override void Process ()
{
XPathNavigator nav = _document.CreateNavigator ();
nav.MoveToFirstChild ();
- ProcessAssemblies (context, nav.SelectChildren ("assembly", _ns));
+ ProcessAssemblies (Context, nav.SelectChildren ("assembly", _ns));
}
void ProcessAssemblies (LinkContext context, XPathNodeIterator iterator)
}
}
- static void MarkAndPreserveAll (TypeDefinition type)
+ void MarkAndPreserveAll (TypeDefinition type)
{
Annotations.Mark (type);
Annotations.SetPreserve (type, TypePreserve.All);
continue;
}
- TypeDefinition type = assembly.MainModule.Types [fullname];
+ TypeDefinition type = assembly.MainModule.GetType (fullname);
if (type == null)
continue;
switch (preserve) {
case TypePreserve.Nothing:
- if (nav.HasChildren) {
- MarkSelectedFields (nav, type);
- MarkSelectedMethods (nav, type);
- } else
+ if (!nav.HasChildren)
Annotations.SetPreserve (type, TypePreserve.All);
break;
default:
Annotations.SetPreserve (type, preserve);
break;
}
+
+ if (nav.HasChildren) {
+ MarkSelectedFields (nav, type);
+ MarkSelectedMethods (nav, type);
+ }
}
void MarkSelectedFields (XPathNavigator nav, TypeDefinition type)
void ProcessFields (TypeDefinition type, XPathNodeIterator iterator)
{
while (iterator.MoveNext ()) {
- string signature = GetSignature (iterator.Current);
- FieldDefinition field = GetField (type, signature);
- if (field != null)
- Annotations.Mark (field);
- else
- AddUnresolveMarker (string.Format ("T: {0}; F: {1}", type, signature));
+ string value = GetSignature (iterator.Current);
+ if (!String.IsNullOrEmpty (value))
+ ProcessFieldSignature (type, value);
+
+ value = GetAttribute (iterator.Current, "name");
+ if (!String.IsNullOrEmpty (value))
+ ProcessFieldName (type, value);
}
}
+ void ProcessFieldSignature (TypeDefinition type, string signature)
+ {
+ FieldDefinition field = GetField (type, signature);
+ MarkField (type, field, signature);
+ }
+
+ void MarkField (TypeDefinition type, FieldDefinition field, string signature)
+ {
+ if (field != null)
+ Annotations.Mark (field);
+ else
+ AddUnresolveMarker (string.Format ("T: {0}; F: {1}", type, signature));
+ }
+
+ void ProcessFieldName (TypeDefinition type, string name)
+ {
+ if (!type.HasFields)
+ return;
+
+ foreach (FieldDefinition field in type.Fields)
+ if (field.Name == name)
+ MarkField (type, field, name);
+ }
+
static FieldDefinition GetField (TypeDefinition type, string signature)
{
if (!type.HasFields)
void ProcessMethods (TypeDefinition type, XPathNodeIterator iterator)
{
while (iterator.MoveNext()) {
- string signature = GetSignature (iterator.Current);
- MethodDefinition meth = GetMethod (type, signature);
- if (meth != null) {
- Annotations.Mark (meth);
- Annotations.SetAction (meth, MethodAction.Parse);
- } else
- AddUnresolveMarker (string.Format ("T: {0}; M: {1}", type, signature));
+ string value = GetSignature (iterator.Current);
+ if (!String.IsNullOrEmpty (value))
+ ProcessMethodSignature (type, value);
+
+ value = GetAttribute (iterator.Current, "name");
+ if (!String.IsNullOrEmpty (value))
+ ProcessMethodName (type, value);
}
}
- static MethodDefinition GetMethod (TypeDefinition type, string signature)
+ void ProcessMethodSignature (TypeDefinition type, string signature)
+ {
+ MethodDefinition meth = GetMethod (type, signature);
+ MarkMethod (type, meth, signature);
+ }
+
+ void MarkMethod (TypeDefinition type, MethodDefinition method, string signature)
+ {
+ if (method != null) {
+ Annotations.Mark (method);
+ Annotations.SetAction (method, MethodAction.Parse);
+ } else
+ AddUnresolveMarker (string.Format ("T: {0}; M: {1}", type, signature));
+ }
+
+ void ProcessMethodName (TypeDefinition type, string name)
{
if (!type.HasMethods)
- return null;
+ return;
- foreach (MethodDefinition meth in type.Methods)
- if (signature == GetMethodSignature (meth))
- return meth;
+ foreach (MethodDefinition method in type.Methods)
+ if (name == method.Name)
+ MarkMethod (type, method, name);
+ }
- foreach (MethodDefinition ctor in type.Constructors)
- if (signature == GetMethodSignature (ctor))
- return ctor;
+ static MethodDefinition GetMethod (TypeDefinition type, string signature)
+ {
+ if (type.HasMethods)
+ foreach (MethodDefinition meth in type.Methods)
+ if (signature == GetMethodSignature (meth))
+ return meth;
return null;
}
static string GetMethodSignature (MethodDefinition meth)
{
StringBuilder sb = new StringBuilder ();
- sb.Append (meth.ReturnType.ReturnType.FullName);
+ sb.Append (meth.ReturnType.FullName);
sb.Append (" ");
sb.Append (meth.Name);
sb.Append ("(");