-
Notifications
You must be signed in to change notification settings - Fork 537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Mono.Android] Add pathSuffix
and pathAdvancedPattern
to [IntentFilter]
#8261
Conversation
6add33f
to
028dd6c
Compare
028dd6c
to
789773e
Compare
@@ -13,7 +13,7 @@ | |||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | |||
<OutputPath>$(MicrosoftAndroidSdkOutDir)</OutputPath> | |||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> | |||
<DefineConstants>$(DefineConstants);TRACE;HAVE_CECIL;MSBUILD;ANDROID_24</DefineConstants> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a block above like:
#if ANDROID_25
public string? RoundIcon {get; set;}
#endif
Is it possible RoundIcon
doesn't actually work? Do we need to define all of them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are tests for it, so I assume it works:
https://github.com/xamarin/xamarin-android/blob/789773ec9989e665000ee47793a3910b82891f5f/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/ManifestTest.cs#L936
I think it uses some sort of alternative method, as the value is processed in a local variable since the property isn't available:
https://github.com/xamarin/xamarin-android/blob/789773ec9989e665000ee47793a3910b82891f5f/src/Xamarin.Android.Build.Tasks/Mono.Android/IntentFilterAttribute.Partial.cs#L16
@@ -135,11 +143,13 @@ IEnumerable<XElement> GetData (string packageName) | |||
.Concat ((DataPathPatterns ?? empty).Select (p => toData (toPathPattern, p))) | |||
.Concat ((DataPathPrefixes ?? empty).Select (p => toData (toPathPrefix, p))) | |||
.Concat ((DataPorts ?? empty).Select (p => toData (toPort, p))) | |||
.Concat ((DataSchemes ?? empty).Select (p => toData (toScheme, p))); | |||
.Concat ((DataSchemes ?? empty).Select (p => toData (toScheme, p))) | |||
.Concat ((DataPathSuffixes ?? empty).Select (p => toData (toPathSuffix, p))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't "feel" right to me, in that we're adding both DataPathSuffix
and DataPathSuffixes
, but this code only deals with DataPathSuffixes
, not DataPathSuffix
. Ditto the following line, which appears to deal only with DataPathAdvancedPatterns
, and not DataPathAdvancedPattern
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class felt like maybe the code was trying to be too "clever", hindering readability. It would likely get rewritten to something a little more straightforward if/when we do this: #8272.
@@ -1118,5 +1121,48 @@ public void SupportedOSPlatformVersionErrors (string minSdkVersion, string suppo | |||
} | |||
} | |||
|
|||
[IntentFilter (new [] { "myaction" }, DataPathSuffix = "mysuffix", DataPathAdvancedPattern = "mypattern")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this test is providing a false sense of security, as the "singular" DataPathSuffix
+ DataPathAdvancedPattern
attribute uses the same values as the "plural" DataPathSuffixes
and DataPathAdvancedPatterns
form on the following line.
These should use different values, so that we can more easily verify that both are working.
That said, based on the current expected
, I think my previous feeling is wrong, because the test method uses .First()
, which will be the "singular' data, and that's working. Yay! (But I don't understand how or why it's working…)
Please update this and the following line so that unique values are used, a'la:
[IntentFilter (new [] { "singularAction" },
DataPathSuffix = "singularSuffix",
DataPathAdvancedPattern = "singularPattern")]
[IntentFilter (new [] { "pluralAction" },
DataPathSuffixes = new [] { "pluralSuffix1", "pluralSuffix2" },
DataPathAdvancedPatterns = new [] { "pluralPattern1", "pluralPattern2" })]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, tests are much clearer now.
draft commit message: Fixes: https://github.com/xamarin/xamarin-android/issues/8235
Context: https://github.com/xamarin/xamarin-android/issues/8272
Add the following properties to `IntentFilterAttribute` to allow
the various `AndroidManifest.xml` [`<data/>`][0] attributes to
be generated:
- `IntentFilterAttribute.DataPathSuffix` generates
[`//intent-filter/data/@pathSuffix`][1].
- `IntentFilterAttribute.DataPathSuffixes` generates
[`//intent-filter/data/@pathSuffix`][1].
- `IntentFilterAttribute.DataPathAdvancedPattern` generates
[`//intent-filter/data/@pathAdvancedPattern`][1].
- `IntentFilterAttribute.DataPathAdvancedPatterns` generates
[`//intent-filter/data/@pathAdvancedPattern`][1].
Note that while we have a script to detect new elements added to
`AndroidManifest.xml`, the code must be written manually.
TODO: Issue #8272 to automate this code generation.
[0]: https://developer.android.com/guide/topics/manifest/data-element
[1]: https://developer.android.com/guide/topics/manifest/data-element#path |
Fixes: #8235 Context: #8272 Add the following properties to `IntentFilterAttribute` to allow the various `AndroidManifest.xml` [`<data/>`][0] attributes to be generated: - `IntentFilterAttribute.DataPathSuffix` generates [`//intent-filter/data/@pathSuffix`][1]. - `IntentFilterAttribute.DataPathSuffixes` generates [`//intent-filter/data/@pathSuffix`][1]. - `IntentFilterAttribute.DataPathAdvancedPattern` generates [`//intent-filter/data/@pathAdvancedPattern`][1]. - `IntentFilterAttribute.DataPathAdvancedPatterns` generates [`//intent-filter/data/@pathAdvancedPattern`][1]. Note that while we have a script to detect new elements added to `AndroidManifest.xml`, the code must be written manually. TODO: Issue #8272 to automate this code generation. [0]: https://developer.android.com/guide/topics/manifest/data-element [1]: https://developer.android.com/guide/topics/manifest/data-element#path
* main: (57 commits) Bump to dotnet/installer@2809943e7a 8.0.100-rc.2.23431.5 (dotnet#8317) [build] Use Microsoft OpenJDK 17.0.8 (dotnet#8309) [Mono.Android] Add missing `[Flags]` attribute for generated enums. (dotnet#8310) Bump to dotnet/installer@c5e45fd659 8.0.100-rc.2.23427.4 (dotnet#8305) [xaprepare] Improve dotnet-install script logging (dotnet#8312) [xaprepare] Fix dotnet-install script size check (dotnet#8311) [Xamarin.Android.Build.Tasks] improve net6.0 "out of support" message (dotnet#8307) [monodroid] Fix the EnableNativeAnalyzers build (dotnet#8293) Bump to dotnet/installer@56d8c6497c 8.0.100-rc.2.23422.31 (dotnet#8291) [Xamarin.Android.Build.Tasks] Fix APT2264 error on Windows. (dotnet#8289) [Mono.Android] Marshal .NET stack trace to Throwable.getStackTrace() (dotnet#8185) [tests] Skip sign check when installing MAUI (dotnet#8288) Bump to xamarin/monodroid@057b17fe (dotnet#8286) [Xamarin.Android.Build.Tasks] add $(AndroidStripILAfterAOT) (dotnet#8172) Bump to dotnet/installer@ec2c1ec1b1 8.0.100-rc.2.23420.6 (dotnet#8281) Bump to dotnet/installer@001d8e4465 8.0.100-rc.2.23417.14 (dotnet#8276) [Mono.Android] [IntentFilter] pathSuffix & pathAdvancedPattern (dotnet#8261) $(AndroidPackVersionSuffix)=rc.2; net8 is 34.0.0-rc.2 (dotnet#8278) Bump to xamarin/xamarin-android-tools/main@52f0866 (dotnet#8241) [build] set file extension for common `ToolExe` values (dotnet#8267) ...
* main: (102 commits) Bump to dotnet/installer@2809943e7a 8.0.100-rc.2.23431.5 (dotnet#8317) [build] Use Microsoft OpenJDK 17.0.8 (dotnet#8309) [Mono.Android] Add missing `[Flags]` attribute for generated enums. (dotnet#8310) Bump to dotnet/installer@c5e45fd659 8.0.100-rc.2.23427.4 (dotnet#8305) [xaprepare] Improve dotnet-install script logging (dotnet#8312) [xaprepare] Fix dotnet-install script size check (dotnet#8311) [Xamarin.Android.Build.Tasks] improve net6.0 "out of support" message (dotnet#8307) [monodroid] Fix the EnableNativeAnalyzers build (dotnet#8293) Bump to dotnet/installer@56d8c6497c 8.0.100-rc.2.23422.31 (dotnet#8291) [Xamarin.Android.Build.Tasks] Fix APT2264 error on Windows. (dotnet#8289) [Mono.Android] Marshal .NET stack trace to Throwable.getStackTrace() (dotnet#8185) [tests] Skip sign check when installing MAUI (dotnet#8288) Bump to xamarin/monodroid@057b17fe (dotnet#8286) [Xamarin.Android.Build.Tasks] add $(AndroidStripILAfterAOT) (dotnet#8172) Bump to dotnet/installer@ec2c1ec1b1 8.0.100-rc.2.23420.6 (dotnet#8281) Bump to dotnet/installer@001d8e4465 8.0.100-rc.2.23417.14 (dotnet#8276) [Mono.Android] [IntentFilter] pathSuffix & pathAdvancedPattern (dotnet#8261) $(AndroidPackVersionSuffix)=rc.2; net8 is 34.0.0-rc.2 (dotnet#8278) Bump to xamarin/xamarin-android-tools/main@52f0866 (dotnet#8241) [build] set file extension for common `ToolExe` values (dotnet#8267) ...
* main: (68 commits) Bump to dotnet/installer@2809943e7a 8.0.100-rc.2.23431.5 (dotnet#8317) [build] Use Microsoft OpenJDK 17.0.8 (dotnet#8309) [Mono.Android] Add missing `[Flags]` attribute for generated enums. (dotnet#8310) Bump to dotnet/installer@c5e45fd659 8.0.100-rc.2.23427.4 (dotnet#8305) [xaprepare] Improve dotnet-install script logging (dotnet#8312) [xaprepare] Fix dotnet-install script size check (dotnet#8311) [Xamarin.Android.Build.Tasks] improve net6.0 "out of support" message (dotnet#8307) [monodroid] Fix the EnableNativeAnalyzers build (dotnet#8293) Bump to dotnet/installer@56d8c6497c 8.0.100-rc.2.23422.31 (dotnet#8291) [Xamarin.Android.Build.Tasks] Fix APT2264 error on Windows. (dotnet#8289) [Mono.Android] Marshal .NET stack trace to Throwable.getStackTrace() (dotnet#8185) [tests] Skip sign check when installing MAUI (dotnet#8288) Bump to xamarin/monodroid@057b17fe (dotnet#8286) [Xamarin.Android.Build.Tasks] add $(AndroidStripILAfterAOT) (dotnet#8172) Bump to dotnet/installer@ec2c1ec1b1 8.0.100-rc.2.23420.6 (dotnet#8281) Bump to dotnet/installer@001d8e4465 8.0.100-rc.2.23417.14 (dotnet#8276) [Mono.Android] [IntentFilter] pathSuffix & pathAdvancedPattern (dotnet#8261) $(AndroidPackVersionSuffix)=rc.2; net8 is 34.0.0-rc.2 (dotnet#8278) Bump to xamarin/xamarin-android-tools/main@52f0866 (dotnet#8241) [build] set file extension for common `ToolExe` values (dotnet#8267) ...
* main: (53 commits) Bump to dotnet/installer@2809943e7a 8.0.100-rc.2.23431.5 (dotnet#8317) [build] Use Microsoft OpenJDK 17.0.8 (dotnet#8309) [Mono.Android] Add missing `[Flags]` attribute for generated enums. (dotnet#8310) Bump to dotnet/installer@c5e45fd659 8.0.100-rc.2.23427.4 (dotnet#8305) [xaprepare] Improve dotnet-install script logging (dotnet#8312) [xaprepare] Fix dotnet-install script size check (dotnet#8311) [Xamarin.Android.Build.Tasks] improve net6.0 "out of support" message (dotnet#8307) [monodroid] Fix the EnableNativeAnalyzers build (dotnet#8293) Bump to dotnet/installer@56d8c6497c 8.0.100-rc.2.23422.31 (dotnet#8291) [Xamarin.Android.Build.Tasks] Fix APT2264 error on Windows. (dotnet#8289) [Mono.Android] Marshal .NET stack trace to Throwable.getStackTrace() (dotnet#8185) [tests] Skip sign check when installing MAUI (dotnet#8288) Bump to xamarin/monodroid@057b17fe (dotnet#8286) [Xamarin.Android.Build.Tasks] add $(AndroidStripILAfterAOT) (dotnet#8172) Bump to dotnet/installer@ec2c1ec1b1 8.0.100-rc.2.23420.6 (dotnet#8281) Bump to dotnet/installer@001d8e4465 8.0.100-rc.2.23417.14 (dotnet#8276) [Mono.Android] [IntentFilter] pathSuffix & pathAdvancedPattern (dotnet#8261) $(AndroidPackVersionSuffix)=rc.2; net8 is 34.0.0-rc.2 (dotnet#8278) Bump to xamarin/xamarin-android-tools/main@52f0866 (dotnet#8241) [build] set file extension for common `ToolExe` values (dotnet#8267) ...
* main: (25 commits) Bump to dotnet/installer@2809943e7a 8.0.100-rc.2.23431.5 (dotnet#8317) [build] Use Microsoft OpenJDK 17.0.8 (dotnet#8309) [Mono.Android] Add missing `[Flags]` attribute for generated enums. (dotnet#8310) Bump to dotnet/installer@c5e45fd659 8.0.100-rc.2.23427.4 (dotnet#8305) [xaprepare] Improve dotnet-install script logging (dotnet#8312) [xaprepare] Fix dotnet-install script size check (dotnet#8311) [Xamarin.Android.Build.Tasks] improve net6.0 "out of support" message (dotnet#8307) [monodroid] Fix the EnableNativeAnalyzers build (dotnet#8293) Bump to dotnet/installer@56d8c6497c 8.0.100-rc.2.23422.31 (dotnet#8291) [Xamarin.Android.Build.Tasks] Fix APT2264 error on Windows. (dotnet#8289) [Mono.Android] Marshal .NET stack trace to Throwable.getStackTrace() (dotnet#8185) [tests] Skip sign check when installing MAUI (dotnet#8288) Bump to xamarin/monodroid@057b17fe (dotnet#8286) [Xamarin.Android.Build.Tasks] add $(AndroidStripILAfterAOT) (dotnet#8172) Bump to dotnet/installer@ec2c1ec1b1 8.0.100-rc.2.23420.6 (dotnet#8281) Bump to dotnet/installer@001d8e4465 8.0.100-rc.2.23417.14 (dotnet#8276) [Mono.Android] [IntentFilter] pathSuffix & pathAdvancedPattern (dotnet#8261) $(AndroidPackVersionSuffix)=rc.2; net8 is 34.0.0-rc.2 (dotnet#8278) Bump to xamarin/xamarin-android-tools/main@52f0866 (dotnet#8241) [build] set file extension for common `ToolExe` values (dotnet#8267) ...
* main: (38 commits) Bump to dotnet/installer@2809943e7a 8.0.100-rc.2.23431.5 (dotnet#8317) [build] Use Microsoft OpenJDK 17.0.8 (dotnet#8309) [Mono.Android] Add missing `[Flags]` attribute for generated enums. (dotnet#8310) Bump to dotnet/installer@c5e45fd659 8.0.100-rc.2.23427.4 (dotnet#8305) [xaprepare] Improve dotnet-install script logging (dotnet#8312) [xaprepare] Fix dotnet-install script size check (dotnet#8311) [Xamarin.Android.Build.Tasks] improve net6.0 "out of support" message (dotnet#8307) [monodroid] Fix the EnableNativeAnalyzers build (dotnet#8293) Bump to dotnet/installer@56d8c6497c 8.0.100-rc.2.23422.31 (dotnet#8291) [Xamarin.Android.Build.Tasks] Fix APT2264 error on Windows. (dotnet#8289) [Mono.Android] Marshal .NET stack trace to Throwable.getStackTrace() (dotnet#8185) [tests] Skip sign check when installing MAUI (dotnet#8288) Bump to xamarin/monodroid@057b17fe (dotnet#8286) [Xamarin.Android.Build.Tasks] add $(AndroidStripILAfterAOT) (dotnet#8172) Bump to dotnet/installer@ec2c1ec1b1 8.0.100-rc.2.23420.6 (dotnet#8281) Bump to dotnet/installer@001d8e4465 8.0.100-rc.2.23417.14 (dotnet#8276) [Mono.Android] [IntentFilter] pathSuffix & pathAdvancedPattern (dotnet#8261) $(AndroidPackVersionSuffix)=rc.2; net8 is 34.0.0-rc.2 (dotnet#8278) Bump to xamarin/xamarin-android-tools/main@52f0866 (dotnet#8241) [build] set file extension for common `ToolExe` values (dotnet#8267) ...
Fixes: #8235
Adds the following properties to
[IntentFilter]
to allow the specifiedAndroidManifest.xml
attributes to be generated:DataPathSuffix
->pathSuffix
DataPathSuffixes
->pathSuffix
DataPathAdvancedPattern
->pathAdvancedPattern
DataPathAdvancedPatterns
->pathAdvancedPattern
Note that while we have a script to detect new elements added to
AndroidManifest.xml
, the code must be written manually. Filed #8272 because we really should automate this code generation.