Skip to content

Commit aa0349d

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 aa0349d

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
@@ -42,6 +42,7 @@
4242
<Compile Include="JavaApiTypeResolverExtensions.cs" />
4343
<Compile Include="JavaApiOverrideMarkerExtensions.cs" />
4444
<Compile Include="JavaApiGeneralExtensions.cs" />
45+
<Compile Include="JavaApiNonBindablStripper.cs" />
4546
<Compile Include="JavaApi.RelationAnalysisModel.cs" />
4647
<Compile Include="JavaTypeReference.cs" />
4748
<Compile Include="JavaApiGenericInheritanceMapperExtensions.cs" />

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)