Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,37 @@ IEnumerable<string> ParseArguments (string args)
yield return x;
}
}

public override string ToString ()
{
var s = new System.Text.StringBuilder ();
foreach (var a in Annotations) {
s.Append ("@").Append (a.Name);
if (a.Values.Count > 0) {
s.Append ("(");
AppendAnnotationValue (a.Values [0]);
for (int i = 1; i < a.Values.Count; ++i) {
s.Append (", ");
AppendAnnotationValue (a.Values [i]);
}
s.Append (")");
}
s.Append (" ");
}
s.Append (TypeName).Append (".").Append (MemberName);
if (Arguments?.Length > 0) {
s.Append ("(").Append (Arguments [0]);
for (int i = 1; i < Arguments.Length; ++i) {
s.Append (", ").Append (Arguments [i]);
}
s.Append (")");
}
return s.ToString ();

void AppendAnnotationValue (AnnotationValue d)
{
s.Append (d.Name).Append("=").Append (d.ValueAsArray);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,20 @@ namespace Xamarin.AndroidTools.AnnotationSupport
{
public class AnnotationData : AnnotationObject
{
static readonly string[] Prefixes = new[] {
"android.support.annotation.",
"androidx.annotation.",
};
public AnnotationData (XElement e)
{
var a = e.Attribute ("name");
Name = a == null ? null : a.Value;
string predef = "android.support.annotation.";
if (Name.StartsWith (predef, StringComparison.Ordinal))
foreach (var predef in Prefixes) {
if (!Name.StartsWith (predef, StringComparison.Ordinal))
continue;
Name = Name.Substring (predef.Length);
break;
}
Values = e.Elements ("val").Select (c => new AnnotationValue (c)).ToArray ();
}

Expand Down