From b12575af28eb8f20ff88d9f2f943e7227cc9fc72 Mon Sep 17 00:00:00 2001 From: Atsushi Eno Date: Thu, 16 Feb 2017 02:03:40 +0900 Subject: [PATCH] [generator] add [IntDefinition (JniField = ...)] everywhere. It will be helpful when people read binding dlls and understand the enum conversion, as well as tooling. --- tools/generator/EnumMappings.cs | 8 ++++++-- .../expected.ji/Android.Text.SpanTypes.cs | 1 + .../expected/Android.Text.SpanTypes.cs | 1 + .../SupportFiles/IntDefinitionAttribute.cs | 17 +++++++++++++++++ .../EnumerationFixup/Xamarin.Test.SomeValues.cs | 2 ++ tools/generator/Tests/generator-Tests.csproj | 3 +++ 6 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 tools/generator/Tests/SupportFiles/IntDefinitionAttribute.cs diff --git a/tools/generator/EnumMappings.cs b/tools/generator/EnumMappings.cs index 1858a11a0..25df0c699 100644 --- a/tools/generator/EnumMappings.cs +++ b/tools/generator/EnumMappings.cs @@ -152,8 +152,7 @@ internal List WriteEnumerations (string output_dir, Dictionary WriteEnumerations (string output_dir, Dictionary gens) { if (desc.FieldsRemoved) diff --git a/tools/generator/Tests-Core/expected.ji/Android.Text.SpanTypes.cs b/tools/generator/Tests-Core/expected.ji/Android.Text.SpanTypes.cs index 818146079..a74823e32 100644 --- a/tools/generator/Tests-Core/expected.ji/Android.Text.SpanTypes.cs +++ b/tools/generator/Tests-Core/expected.ji/Android.Text.SpanTypes.cs @@ -1,5 +1,6 @@ namespace Android.Text { public enum SpanTypes { + [global::Android.Runtime.IntDefinition (null, JniField = "android/text/Spanned.SPAN_COMPOSING")] Composing = 256, } } diff --git a/tools/generator/Tests-Core/expected/Android.Text.SpanTypes.cs b/tools/generator/Tests-Core/expected/Android.Text.SpanTypes.cs index 818146079..a74823e32 100644 --- a/tools/generator/Tests-Core/expected/Android.Text.SpanTypes.cs +++ b/tools/generator/Tests-Core/expected/Android.Text.SpanTypes.cs @@ -1,5 +1,6 @@ namespace Android.Text { public enum SpanTypes { + [global::Android.Runtime.IntDefinition (null, JniField = "android/text/Spanned.SPAN_COMPOSING")] Composing = 256, } } diff --git a/tools/generator/Tests/SupportFiles/IntDefinitionAttribute.cs b/tools/generator/Tests/SupportFiles/IntDefinitionAttribute.cs new file mode 100644 index 000000000..8249751a3 --- /dev/null +++ b/tools/generator/Tests/SupportFiles/IntDefinitionAttribute.cs @@ -0,0 +1,17 @@ +using System; + +namespace Android.Runtime +{ + [AttributeUsage (AttributeTargets.Field)] + public class IntDefinitionAttribute : Attribute + { + public IntDefinitionAttribute (string constantMember) + { + ConstantMember = constantMember; + } + + public string ConstantMember { get; set; } + public string JniField { get; set; } + } +} + diff --git a/tools/generator/Tests/expected/EnumerationFixup/Xamarin.Test.SomeValues.cs b/tools/generator/Tests/expected/EnumerationFixup/Xamarin.Test.SomeValues.cs index 338a69870..8e566bedb 100644 --- a/tools/generator/Tests/expected/EnumerationFixup/Xamarin.Test.SomeValues.cs +++ b/tools/generator/Tests/expected/EnumerationFixup/Xamarin.Test.SomeValues.cs @@ -1,6 +1,8 @@ namespace Xamarin.Test { public enum SomeValues { + [global::Android.Runtime.IntDefinition (null, JniField = "xamarin/test/SomeObject.SOME_VALUE")] SomeValue = 0, + [global::Android.Runtime.IntDefinition (null, JniField = "xamarin/test/SomeObject.SOME_VALUE2")] SomeValue2 = 1, } } diff --git a/tools/generator/Tests/generator-Tests.csproj b/tools/generator/Tests/generator-Tests.csproj index ebf6375c5..55385a84a 100644 --- a/tools/generator/Tests/generator-Tests.csproj +++ b/tools/generator/Tests/generator-Tests.csproj @@ -101,6 +101,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest