diff --git a/src/Xamarin.Android.Tools.Bytecode/ClassFile.cs b/src/Xamarin.Android.Tools.Bytecode/ClassFile.cs index 1e50293e8..6968509e7 100644 --- a/src/Xamarin.Android.Tools.Bytecode/ClassFile.cs +++ b/src/Xamarin.Android.Tools.Bytecode/ClassFile.cs @@ -115,8 +115,8 @@ public bool TryGetEnclosingMethodInfo (out string declaringClass, out string dec } declaringClass = enclosingMethod.Class.Name.Value; - declaringMethod = enclosingMethod.Method.Name.Value; - declaringDescriptor = enclosingMethod.Method.Descriptor.Value; + declaringMethod = enclosingMethod.Method?.Name.Value; + declaringDescriptor = enclosingMethod.Method?.Descriptor.Value; return true; } diff --git a/src/Xamarin.Android.Tools.Bytecode/XmlClassDeclarationBuilder.cs b/src/Xamarin.Android.Tools.Bytecode/XmlClassDeclarationBuilder.cs index a9626a5ea..4d41072a2 100644 --- a/src/Xamarin.Android.Tools.Bytecode/XmlClassDeclarationBuilder.cs +++ b/src/Xamarin.Android.Tools.Bytecode/XmlClassDeclarationBuilder.cs @@ -65,17 +65,18 @@ static string GetDeprecatedValue (AttributeCollection attributes) return "deprecated"; } - XAttribute[] GetEnclosingMethod () + IEnumerable GetEnclosingMethod () { string declaringClass, declaringMethod, declaringDescriptor; if (!classFile.TryGetEnclosingMethodInfo (out declaringClass, out declaringMethod, out declaringDescriptor)) { - return null; + yield break; } - return new []{ - new XAttribute ("enclosing-method-jni-type", "L" + declaringClass + ";"), - new XAttribute ("enclosing-method-name", declaringMethod), - new XAttribute ("enclosing-method-signature", declaringDescriptor), - }; + if (declaringClass != null) + yield return new XAttribute ("enclosing-method-jni-type", "L" + declaringClass + ";"); + if (declaringMethod != null) + yield return new XAttribute ("enclosing-method-name", declaringMethod); + if (declaringDescriptor != null) + yield return new XAttribute ("enclosing-method-signature", declaringDescriptor); } XAttribute[] GetExtends ()