-
Notifications
You must be signed in to change notification settings - Fork 526
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[generator] Remove fields and methods that have '$' in the name. (#116)
Related: https://bugzilla.xamarin.com/show_bug.cgi?id=46344#c12 class-parse has brought another problem; it generates fields and methods that are compiler-generated and should not have been written to XML in the first place. class-parse has no idea on how to deal with them, so kill them in api-xml-adjuster instead.
- Loading branch information
1 parent
d5989b1
commit 835aaf7
Showing
13 changed files
with
129 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/Xamarin.Android.Tools.ApiXmlAdjuster/JavaApiNonBindableStripper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace Xamarin.Android.Tools.ApiXmlAdjuster | ||
{ | ||
public static class JavaApiNonBindableStripper | ||
{ | ||
public static void StripNonBindables (this JavaApi api) | ||
{ | ||
var invalids = new List<JavaMember> (); | ||
foreach (var member in api.Packages.SelectMany (p => p.Types) | ||
.SelectMany (t => t.Members).Where (m => m.Name != null && m.Name.Contains ('$'))) | ||
invalids.Add (member); | ||
foreach (var invalid in invalids) | ||
invalid.Parent.Members.Remove (invalid); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<api api-source="class-parse"> | ||
<package name="java.lang"> | ||
<class abstract="false" deprecated="not deprecated" final="false" name="Object" static="false" visibility="public"> | ||
</class> | ||
</package> | ||
<package name="xamarin.test.invalidnames"> | ||
<class abstract="false" deprecated="not deprecated" extends="java.lang.Object" extends-generic-aware="java.lang.Object" final="false" name="InvalidNameMembers" static="false" visibility="public"> | ||
<field deprecated="not deprecated" final="true" name="INVALID_$CONSTANT" static="true" transient="false" type="int" type-generic-aware="int" value="1" visibility="public" volatile="false"> | ||
</field> | ||
<field deprecated="not deprecated" final="true" name="INVALID_$FIELD" static="false" transient="false" type="int" type-generic-aware="int" visibility="public" volatile="false"> | ||
</field> | ||
<method abstract="false" deprecated="not deprecated" final="false" name="invalid$name" native="false" return="int" static="false" synchronized="false" visibility="public"> | ||
</method> | ||
</class> | ||
</package> | ||
</api> | ||
|
15 changes: 15 additions & 0 deletions
15
tools/generator/Tests-Core/expected.cp/GeneratedFiles.projitems
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<DefineConstants>$(DefineConstants);ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4;ANDROID_5;ANDROID_6;ANDROID_7;ANDROID_8;ANDROID_9;ANDROID_10;ANDROID_11;ANDROID_12;ANDROID_13;ANDROID_14;ANDROID_15;ANDROID_16;ANDROID_17;ANDROID_18;ANDROID_19;ANDROID_20</DefineConstants> | ||
</PropertyGroup> | ||
<!-- Classes --> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildThisFileDirectory)\Java.Interop.__TypeRegistrations.cs" /> | ||
<Compile Include="$(MSBuildThisFileDirectory)\Java.Lang.Object.cs" /> | ||
<Compile Include="$(MSBuildThisFileDirectory)\Xamarin.Test.Invalidnames.InvalidNameMembers.cs" /> | ||
<Compile Include="$(MSBuildThisFileDirectory)\__NamespaceMapping__.cs" /> | ||
</ItemGroup> | ||
<!-- Enums --> | ||
<ItemGroup /> | ||
</Project> |
34 changes: 34 additions & 0 deletions
34
tools/generator/Tests-Core/expected.cp/Java.Interop.__TypeRegistrations.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Android.Runtime; | ||
|
||
namespace Java.Interop { | ||
|
||
partial class __TypeRegistrations { | ||
|
||
public static void RegisterPackages () | ||
{ | ||
#if MONODROID_TIMING | ||
var start = DateTime.Now; | ||
Android.Util.Log.Info ("MonoDroid-Timing", "RegisterPackages start: " + (start - new DateTime (1970, 1, 1)).TotalMilliseconds); | ||
#endif // def MONODROID_TIMING | ||
Java.Interop.TypeManager.RegisterPackages ( | ||
new string[]{ | ||
}, | ||
new Converter<string, Type>[]{ | ||
}); | ||
#if MONODROID_TIMING | ||
var end = DateTime.Now; | ||
Android.Util.Log.Info ("MonoDroid-Timing", "RegisterPackages time: " + (end - new DateTime (1970, 1, 1)).TotalMilliseconds + " [elapsed: " + (end - start).TotalMilliseconds + " ms]"); | ||
#endif // def MONODROID_TIMING | ||
} | ||
|
||
static Type Lookup (string[] mappings, string javaType) | ||
{ | ||
string managedType = Java.Interop.TypeManager.LookupTypeMapping (mappings, javaType); | ||
if (managedType == null) | ||
return null; | ||
return Type.GetType (managedType); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
tools/generator/Tests-Core/expected.cp/Java.Lang.Object.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Android.Runtime; | ||
|
||
namespace Java.Lang { | ||
|
||
// Metadata.xml XPath class reference: path="/api/package[@name='java.lang']/class[@name='Object']" | ||
[global::Android.Runtime.Register ("java/lang/Object", DoNotGenerateAcw=true)] | ||
public partial class Object { | ||
|
||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
tools/generator/Tests-Core/expected.cp/Xamarin.Test.Invalidnames.InvalidNameMembers.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Android.Runtime; | ||
|
||
namespace Xamarin.Test.Invalidnames { | ||
|
||
// Metadata.xml XPath class reference: path="/api/package[@name='xamarin.test.invalidnames']/class[@name='InvalidNameMembers']" | ||
[global::Android.Runtime.Register ("xamarin/test/invalidnames/InvalidNameMembers", DoNotGenerateAcw=true)] | ||
public partial class InvalidNameMembers : Java.Lang.Object { | ||
|
||
protected InvalidNameMembers (IntPtr javaReference, JniHandleOwnership transfer) : base (javaReference, transfer) {} | ||
|
||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
tools/generator/Tests-Core/expected.cp/__NamespaceMapping__.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[assembly:global::Android.Runtime.NamespaceMapping (Java = "java.lang", Managed="Java.Lang")] | ||
[assembly:global::Android.Runtime.NamespaceMapping (Java = "xamarin.test.invalidnames", Managed="Xamarin.Test.Invalidnames")] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<enum-field-mappings> | ||
</enum-field-mappings> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<enum-method-mappings> | ||
</enum-method-mappings> | ||
|