-
Notifications
You must be signed in to change notification settings - Fork 533
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
Annotate attributes with resource category hint for the IDE #2866
Merged
Conversation
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
The code completion experience can be improved if the editor knew which string properties typically come from resources so a completion suggestion can be provided that is filtered to the type of resource the property should be pointing to (i.e. `@(string)` vs `@(drawable)`). Fixes dotnet#2862
The macOS PR Release Pipeline Build is failing:
Looks like |
dellis1972
approved these changes
Mar 23, 2019
jonpryor
pushed a commit
that referenced
this pull request
Apr 3, 2019
Fixes: #2862 The code completion experience within Visual Studio can be improved if the editor knows which string properties typically come from resources so a completion suggestion can be provided that is filtered to the type of resource the property should be pointing to (i.e. `@(string)` vs `@(drawable)`). Add a [`CategoryAttribute`][0] to various string properties, providing a `;`-separated list of Android `@resource` types that the Visual Studio IDE can key completion suggestions off of. [0]: https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.categoryattribute?view=netframework-4.7.2
jonathanpeppers
added a commit
to jonathanpeppers/xamarin-android
that referenced
this pull request
Dec 4, 2020
…ops (dotnet#2866)" Fixes: dotnet#5373 This reverts commit d548ec9. Decoration of `ApplicationAttribute.Label` with: [System.ComponentModel.Category ("@string")] public string? Label {get; set;} Allowed an experimental feature in Visual Studio to offer `@string` `AndroidResource` completion when changing the `Label` property in C#. Unfortunately, the presence of this attribute causes the linker to preserve various dependencies of `System.ComponentModel` in .NET 6. It appears that this completion feature never shipped in the IDE, so we can completely remove this. If we ever want to bring the feature back, we should create a new `internal` attribute to be used instead.
jonathanpeppers
added a commit
to jonathanpeppers/xamarin-android
that referenced
this pull request
Dec 7, 2020
…ops (dotnet#2866)" Fixes: dotnet#5373 This reverts commit d548ec9. Decoration of `ApplicationAttribute.Label` with: [System.ComponentModel.Category ("@string")] public string? Label {get; set;} Allowed an experimental feature in Visual Studio to offer `@string` `AndroidResource` completion when changing the `Label` property in C#. Unfortunately, the presence of this attribute causes the linker to preserve various dependencies of `System.ComponentModel` in .NET 6. It appears that this completion feature never shipped in the IDE, so we can completely remove this. If we ever want to bring the feature back, we should create a new `internal` attribute to be used instead. Results of this change: > 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)
jonathanpeppers
added a commit
to jonathanpeppers/xamarin-android
that referenced
this pull request
Dec 8, 2020
…ops (dotnet#2866)" Fixes: dotnet#5373 This reverts commit d548ec9. Decoration of `ApplicationAttribute.Label` with: [System.ComponentModel.Category ("@string")] public string? Label {get; set;} Allowed an experimental feature in Visual Studio to offer `@string` `AndroidResource` completion when changing the `Label` property in C#. Unfortunately, the presence of this attribute causes the linker to preserve various dependencies of `System.ComponentModel` in .NET 6. It appears that this completion feature never shipped in the IDE, so we can completely remove this. If we ever want to bring the feature back, we should create a new `internal` attribute to be used instead. Results of this change: > 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)
jonathanpeppers
added a commit
to jonathanpeppers/xamarin-android
that referenced
this pull request
Dec 8, 2020
…ops (dotnet#2866)" Fixes: dotnet#5373 Reverts: d548ec9 Decoration of `ApplicationAttribute.Label` with: [System.ComponentModel.Category ("@string")] public string? Label {get; set;} Allowed an experimental feature in Visual Studio to offer `@string` `AndroidResource` completion when changing the `Label` property in C#. Unfortunately, the presence of this attribute causes the linker to preserve various dependencies of `System.ComponentModel` in .NET 6. It appears that this completion feature never shipped in the IDE, so we can completely remove this. If we ever want to bring the feature back, we should create a new `internal` attribute to be used instead. Results of this change: > 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)
jonpryor
pushed a commit
that referenced
this pull request
Dec 9, 2020
…ops (#2866)" (#5375) Fixes: #5373 Reverts: d548ec9 Reverts: #2862 The idea in Issue #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
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The code completion experience can be improved if the editor knew
which string properties typically come from resources so a completion
suggestion can be provided that is filtered to the type of resource
the property should be pointing to (i.e.
@(string)
vs@(drawable)
).Fixes #2862