Skip to content

Commit

Permalink
[Mono.Android] Add [Category] for IDE completion of string props (#2866)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kzu authored and jonpryor committed Apr 3, 2019
1 parent bb0469a commit a3d4ade
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 0 deletions.
@@ -1,4 +1,5 @@
using System;
using System.ComponentModel;

using Android.Content.PM;
using Android.Views;
Expand Down Expand Up @@ -52,7 +53,9 @@ public ActivityAttribute ()
#if ANDROID_11
public bool HardwareAccelerated {get; set;}
#endif
[Category ("@drawable;@mipmap")]
public string Icon {get; set;}
[Category ("@string")]
public string Label {get; set;}
public LaunchMode LaunchMode {get; set;}
#if ANDROID_23
Expand Down Expand Up @@ -99,6 +102,7 @@ public ActivityAttribute ()
public WindowRotationAnimation RotationAnimation {get; set;}
#endif
#if ANDROID_25
[Category ("@drawable;@mipmap")]
public string RoundIcon {get; set;}
#endif
#if ANDROID_23
Expand All @@ -120,6 +124,7 @@ public ActivityAttribute ()
#endif
public bool StateNotNeeded {get; set;}
public string TaskAffinity {get; set;}
[Category ("@style")]
public string Theme {get; set;}
#if ANDROID_27
public bool TurnScreenOn {get; set;}
Expand Down
@@ -1,4 +1,5 @@
using System;
using System.ComponentModel;

using Android.Content.PM;
using Android.Views;
Expand Down Expand Up @@ -30,6 +31,7 @@ public ApplicationAttribute ()
public string Banner {get; set;}
#endif
public bool Debuggable {get; set;}
[Category ("@string")]
public string Description {get; set;}
#if ANDROID_24
public bool DirectBootAware {get; set;}
Expand All @@ -46,13 +48,16 @@ public ApplicationAttribute ()
public bool HardwareAccelerated {get; set;}
#endif
public bool HasCode {get; set;}
[Category ("@drawable;@mipmap")]
public string Icon {get; set;}
public bool KillAfterRestore {get; set;}
#if ANDROID_11
public bool LargeHeap {get; set;}
#endif
[Category ("@string")]
public string Label {get; set;}
#if ANDROID_11
[Category ("@drawable;@mipmap")]
public string Logo {get; set;}
#endif
public Type ManageSpaceActivity {get; set;}
Expand All @@ -70,12 +75,14 @@ public ApplicationAttribute ()
public string RestrictedAccountType {get; set;}
#endif
#if ANDROID_25
[Category ("@drawable;@mipmap")]
public string RoundIcon {get; set;}
#endif
#if ANDROID_17
public bool SupportsRtl {get; set;}
#endif
public string TaskAffinity {get; set;}
[Category ("@style")]
public string Theme {get; set;}
#if ANDROID_14
public UiOptions UiOptions {get; set;}
Expand Down
@@ -1,4 +1,5 @@
using System;
using System.ComponentModel;

namespace Android.App {

Expand All @@ -14,10 +15,13 @@ public InstrumentationAttribute ()

public bool FunctionalTest {get; set;}
public bool HandleProfiling {get; set;}
[Category ("@drawable;@mipmap")]
public string Icon {get; set;}
[Category ("@string")]
public string Label {get; set;}
public string Name {get; set;}
#if ANDROID_25
[Category ("@drawable;@mipmap")]
public string RoundIcon {get; set;}
#endif
public string TargetPackage {get; set;}
Expand Down
@@ -1,4 +1,5 @@
using System;
using System.ComponentModel;

using Android.Content.PM;
using Android.Views;
Expand All @@ -22,14 +23,17 @@ public ServiceAttribute ()
#endif
public bool Enabled {get; set;}
public bool Exported {get; set;}
[Category ("@drawable;@mipmap")]
public string Icon {get; set;}
#if ANDROID_16
public bool IsolatedProcess {get; set;}
#endif
[Category ("@string")]
public string Label {get; set;}
public string Permission {get; set;}
public string Process {get; set;}
#if ANDROID_25
[Category ("@drawable;@mipmap")]
public string RoundIcon {get; set;}
#endif
}
Expand Down
@@ -1,4 +1,5 @@
using System;
using System.ComponentModel;

namespace Android.Content {

Expand All @@ -15,13 +16,17 @@ public BroadcastReceiverAttribute ()
public bool DirectBootAware {get; set;}
public bool Enabled {get; set;}
public bool Exported {get; set;}
[Category ("@string")]
public string Description {get; set;}
[Category ("@drawable;@mipmap")]
public string Icon {get; set;}
[Category ("@string")]
public string Label {get; set;}
public string Name {get; set;}
public string Permission {get; set;}
public string Process {get; set;}
#if ANDROID_25
[Category ("@drawable;@mipmap")]
public string RoundIcon {get; set;}
#endif
}
Expand Down
@@ -1,4 +1,5 @@
using System;
using System.ComponentModel;

namespace Android.Content {

Expand All @@ -24,15 +25,18 @@ public ContentProviderAttribute (string[] authorities)
public bool Enabled {get; set;}
public bool Exported {get; set;}
public bool GrantUriPermissions {get; set;}
[Category ("@drawable;@mipmap")]
public string Icon {get; set;}
public int InitOrder {get; set;}
[Category ("@string")]
public string Label {get; set;}
public bool MultiProcess {get; set;}
public string Name {get; set;}
public string Permission {get; set;}
public string Process {get; set;}
public string ReadPermission {get; set;}
#if ANDROID_25
[Category ("@drawable;@mipmap")]
public string RoundIcon {get; set;}
#endif
public bool Syncable {get; set;}
Expand Down

0 comments on commit a3d4ade

Please sign in to comment.