Skip to content

Commit 8c65fa3

Browse files
committed
[generator] strip fields and methods that have '$' in the name.
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.
1 parent 39f1744 commit 8c65fa3

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
5+
namespace Xamarin.Android.Tools.ApiXmlAdjuster
6+
{
7+
public static class JavaApiNonBindableStripper
8+
{
9+
public static void StripNonBindables (this JavaApi api)
10+
{
11+
var invalids = new List<JavaMember> ();
12+
foreach (var member in api.Packages.SelectMany (p => p.Types)
13+
.SelectMany (t => t.Members).Where (m => m.Name != null && m.Name.Contains ('$')))
14+
invalids.Add (member);
15+
foreach (var invalid in invalids)
16+
invalid.Parent.Members.Remove (invalid);
17+
}
18+
}
19+
}

src/Xamarin.Android.Tools.ApiXmlAdjuster/Xamarin.Android.Tools.ApiXmlAdjuster.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
<Compile Include="JavaTypeResolutionUtil.cs" />
5151
<Compile Include="JavaApiFixVisibilityExtensions.cs" />
5252
<Compile Include="Log.cs" />
53+
<Compile Include="JavaApiNonBindableStripper.cs" />
5354
</ItemGroup>
5455
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
5556
</Project>

tools/generator/ApiXmlAdjuster.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public void Process (string inputXmlFile, GenBase [] gens, string outputXmlFile,
2323
var api = new JavaApi ();
2424
api.LoadReferences (gens);
2525
api.Load (inputXmlFile);
26+
api.StripNonBindables ();
2627
api.Resolve ();
2728
api.CreateGenericInheritanceMapping ();
2829
api.MarkOverrides ();

0 commit comments

Comments
 (0)