forked from dotnet/android
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "[Mono.Android] Add [Category] for IDE completion of string pr…
…ops (dotnet#2866)" (dotnet#5375) Fixes: dotnet#5373 Reverts: d548ec9 Reverts: dotnet#2862 The idea in Issue dotnet#2862 and commit d548ec9 was to to improve code completion for Android Resources within Visual Studio: ![Android Resource completion in Visual Studio][0] This was achieved by adding [`CategoryAttribute`][1] to various properties so that Visual Studio could know what completions to show: partial class ActivityAttribute { [System.ComponentModel.Category ("@string")] public string? Label {get; set;} } Unfortunately, the presence of `CategoryAttribute` causes the .NET 6 linker to preserve various dependencies of `System.ComponentModel`, causing `.apk` files to be larger than desired. Furthermore, the feature was *experimental*, and never shipped in a stable Visual Studio release. For now, revert commit d548ec9, removing the `[Category]` custom attributes. This will allow `.apk` files to be smaller for .NET 6. Should we want to bring this feature back, we'll either need to see if the linker can be improved to remove `CategoryAttribute`, or instead introduce a set of `internal` attributes for this purpose. Results of this change in a .NET 6 `.apk`: > apkdiff before.apk after.apk Size difference in bytes ([*1] apk1 only, [*2] apk2 only): - 56 lib/armeabi-v7a/libxamarin-app.so Section size difference - 8 .rel.dyn - 12 .data - 6,144 .bss - 77 assemblies/Mono.Android.dll - 3,194 assemblies/System.ComponentModel.Primitives.dll *1 Summary: + 0 Other entries 0.00% (of 6,484) + 0 Dalvik executables 0.00% (of 317,508) - 3,271 Assemblies -0.15% (of 2,139,234) - 56 Shared libraries -0.00% (of 20,674,428) - 3,468 Package size difference -0.04% (of 9,485,287) [0]: https://user-images.githubusercontent.com/169707/54777844-f9b37500-4bf1-11e9-8e52-63982b8b362f.gif [1]: https://docs.microsoft.com/dotnet/api/system.componentmodel.categoryattribute?view=netframework-4.7.2
- Loading branch information
1 parent
143f662
commit e5a4bee
Showing
8 changed files
with
49 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
### Application size improvements | ||
|
||
* [GitHub PR 5375](https://github.com/xamarin/xamarin-android/pull/5375): | ||
Removed decoration of `System.ComponentModel.CategoryAttribute` to | ||
improve linker behavior. This reduced the .NET assembly size of a | ||
.NET 6 application by 3,271 bytes. | ||
|
||
`CategoryAttribute` was removed from properties on types such as | ||
`Android.App.ActivityAttribute`: | ||
|
||
```diff | ||
-[Category ("@drawable;@mipmap")] | ||
public string? Icon { get; set; } | ||
-[Category ("@string")] | ||
public string? Label { get; set; } | ||
``` | ||
|
||
A full list of types changed: | ||
|
||
* `Android.App.ActivityAttribute` | ||
* `Android.App.ApplicationAttribute` | ||
* `Android.App.InstrumentationAttribute` | ||
* `Android.App.ServiceAttribute` | ||
* `Android.Content.BroadcastReceiverAttribute` | ||
* `Android.Content.ContentProviderAttribute` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Compat issues with assembly Mono.Android: | ||
CannotRemoveAttribute : Attribute 'System.ComponentModel.CategoryAttribute' exists on 'Android.App.ActivityAttribute.Icon' in the contract but not the implementation. | ||
CannotRemoveAttribute : Attribute 'System.ComponentModel.CategoryAttribute' exists on 'Android.App.ActivityAttribute.Label' in the contract but not the implementation. | ||
CannotRemoveAttribute : Attribute 'System.ComponentModel.CategoryAttribute' exists on 'Android.App.ActivityAttribute.RoundIcon' in the contract but not the implementation. | ||
CannotRemoveAttribute : Attribute 'System.ComponentModel.CategoryAttribute' exists on 'Android.App.ActivityAttribute.Theme' in the contract but not the implementation. | ||
CannotRemoveAttribute : Attribute 'System.ComponentModel.CategoryAttribute' exists on 'Android.App.ApplicationAttribute.Description' in the contract but not the implementation. | ||
CannotRemoveAttribute : Attribute 'System.ComponentModel.CategoryAttribute' exists on 'Android.App.ApplicationAttribute.Icon' in the contract but not the implementation. | ||
CannotRemoveAttribute : Attribute 'System.ComponentModel.CategoryAttribute' exists on 'Android.App.ApplicationAttribute.Label' in the contract but not the implementation. | ||
CannotRemoveAttribute : Attribute 'System.ComponentModel.CategoryAttribute' exists on 'Android.App.ApplicationAttribute.Logo' in the contract but not the implementation. | ||
CannotRemoveAttribute : Attribute 'System.ComponentModel.CategoryAttribute' exists on 'Android.App.ApplicationAttribute.RoundIcon' in the contract but not the implementation. | ||
CannotRemoveAttribute : Attribute 'System.ComponentModel.CategoryAttribute' exists on 'Android.App.ApplicationAttribute.Theme' in the contract but not the implementation. | ||
CannotRemoveAttribute : Attribute 'System.ComponentModel.CategoryAttribute' exists on 'Android.App.InstrumentationAttribute.Icon' in the contract but not the implementation. | ||
CannotRemoveAttribute : Attribute 'System.ComponentModel.CategoryAttribute' exists on 'Android.App.InstrumentationAttribute.Label' in the contract but not the implementation. | ||
CannotRemoveAttribute : Attribute 'System.ComponentModel.CategoryAttribute' exists on 'Android.App.InstrumentationAttribute.RoundIcon' in the contract but not the implementation. | ||
CannotRemoveAttribute : Attribute 'System.ComponentModel.CategoryAttribute' exists on 'Android.App.ServiceAttribute.Icon' in the contract but not the implementation. | ||
CannotRemoveAttribute : Attribute 'System.ComponentModel.CategoryAttribute' exists on 'Android.App.ServiceAttribute.Label' in the contract but not the implementation. | ||
CannotRemoveAttribute : Attribute 'System.ComponentModel.CategoryAttribute' exists on 'Android.App.ServiceAttribute.RoundIcon' in the contract but not the implementation. | ||
CannotRemoveAttribute : Attribute 'System.ComponentModel.CategoryAttribute' exists on 'Android.Content.BroadcastReceiverAttribute.Description' in the contract but not the implementation. | ||
CannotRemoveAttribute : Attribute 'System.ComponentModel.CategoryAttribute' exists on 'Android.Content.BroadcastReceiverAttribute.Icon' in the contract but not the implementation. | ||
CannotRemoveAttribute : Attribute 'System.ComponentModel.CategoryAttribute' exists on 'Android.Content.BroadcastReceiverAttribute.Label' in the contract but not the implementation. | ||
CannotRemoveAttribute : Attribute 'System.ComponentModel.CategoryAttribute' exists on 'Android.Content.BroadcastReceiverAttribute.RoundIcon' in the contract but not the implementation. | ||
CannotRemoveAttribute : Attribute 'System.ComponentModel.CategoryAttribute' exists on 'Android.Content.ContentProviderAttribute.Icon' in the contract but not the implementation. | ||
CannotRemoveAttribute : Attribute 'System.ComponentModel.CategoryAttribute' exists on 'Android.Content.ContentProviderAttribute.Label' in the contract but not the implementation. | ||
CannotRemoveAttribute : Attribute 'System.ComponentModel.CategoryAttribute' exists on 'Android.Content.ContentProviderAttribute.RoundIcon' in the contract but not the implementation. |