-
Jonathan Pobst authored
Fixes: https://github.com/xamarin/xamarin-android/issues/8272 Context: https://github.com/xamarin/xamarin-android/issues/8235 Context: https://github.com/xamarin/xamarin-android/issues/8729 Context: e790874a Previously, we did not have an established process for detecting new XML elements and attributes allowed in `AndroidManifest.xml` and surfacing them to users via our manifest attributes like `[ActivityAttribute]`. This leads to users having to use manual workarounds until our attributes can be updated. Additionally, whenever we do add new properties to these attributes, it requires manually updating multiple files by hand that must remain in sync, eg: * [src/Mono.Android/Android.App/IntentFilterAttribute.cs](https://github.com/xamarin/xamarin-android/blob/180dd5205ab270bb74bb853754665db9cb5d65f1/src/Mono.Android/Android.App/IntentFilterAttribute.cs#L9) * [src/Xamarin.Android.Build.Tasks/Mono.Android/IntentFilterAttribute.Partial.cs](https://github.com/xamarin/xamarin-android/blob/180dd5205ab270bb74bb853754665db9cb5d65f1/src/Xamarin.Android.Build.Tasks/Mono.Android/IntentFilterAttribute.Partial.cs#L14) The `build-tools/manifest-attribute-codegen` utility (e790874a) has support to parse Android SDK `attrs_manifest.xml` files, which specifies what elements and attributes are valid within `AndroidManifest.xml`. Update `manifest-attribute-codegen` to do what it's name already implied: generate code! It now reads a `metadata.xml` file which controls which custom attributes to emit, where to emit them, and what members those custom attributes should have (among other things). This makes it easier to ensure that code shared by `src/Mono.Android` and `src/Xamarin.Android.Build.Tasks` are consistent, meaking it easier to correctly add support for new attributes and/or attribute members. Generated file semantics and naming conventions: consider the C# type `Android.App.ActivityAttribute`. * `src\Xamarin.Android.NamingCustomAttributes\Android.App\ActivityAttribute.cs` contains the C# `partial` class declaration that can be shared by both `src\Mono.Android` and `src\Xamarin.Android.Build.Tasks`. This file also contains a `#if XABT_MANIFEST_EXTENSIONS` block which is only used by `src\Xamarin.Android.Build.Tasks`. * `src/Xamarin.Android.Build.Tasks/Mono.Android/ActivityAttribute.Partial.cs` contains the C# `partial` class declaration with code specific to `Xamarin.Android.Build.Tasks.dll`. * `src/Xamarin.Android.NamingCustomAttributes/Android.App/ActivityAttribute.Partial.cs` contains the C# `partial` class declaration with code specific to `Mono.Android.dll`. `metadata.xml` contents and the update process is documented in `build-tools/manifest-attribute-codegen/README.md`. Also removed the `ANDROID_*` values from `$(DefineConstants)` for `Xamarin.Android.Build.Tasks.csproj` as we no longer build separate assemblies for old Android API levels. Note this commit does not change any existing manifest attributes or the properties they expose. It merely generates what we expose today. We will determine additional properties to expose in a future commit.