resharper-devguide icon indicating copy to clipboard operation
resharper-devguide copied to clipboard

ZoneFlags.AutoEnable

Open derigel23 opened this issue 11 years ago • 9 comments

For most plugins zone should be auto-enabled, otherwise no one enabled plugins' zone.

derigel23 avatar Dec 09 '14 11:12 derigel23

But I still didn't get plugin's item on the options page for disable/enable features.

derigel23 avatar Dec 09 '14 12:12 derigel23

I finally got appeared plugins' zone at options page, but due some bug in wave01, AutoEnabled zone is not possible to disable. image

derigel23 avatar Dec 09 '14 13:12 derigel23

Yay! First pull request!

So, in that screenshot, is the ReSpeller checkbox disabled? Does it work if you create an activator that requires/activates the respeller feature zone?

citizenmatt avatar Dec 09 '14 14:12 citizenmatt

Yep, it's checked, but disabled. Trying with explicit activator.

derigel23 avatar Dec 09 '14 14:12 derigel23

Yeah, finally works as supposed. image

But explicit use of ZoneActivator requires a lot of boilerplate code:

namespace R
{
  [ZoneActivator]
  public class ReSpellerActivator : IActivate<IReSpellerZone>
  {
    public bool ActivatorEnabled()
    {
      return true;
    }
  }

  [ZoneMarker]
  public class ZoneMarker
  {
  }
}

namespace ReSpeller
{
  [ZoneDefinition]
  [ZoneDefinitionConfigurableFeature("ReSpeller", "Spell Checker for Resharper based on NHunspell library.", isInProductSection: false)]
  public interface IReSpellerZone : IZone, IRequire<PsiFeaturesImplZone>
  {
  }

  [ZoneMarker]
  public class ZoneMarker : IRequire<IReSpellerZone>
  {
  }
}

Take into account that activator should be in separate namespace with own ZoneMarker. I am not sure - should we publish that workaround? Or, may be, just wait until bug with AutoEnable will be fixed.

derigel23 avatar Dec 09 '14 16:12 derigel23

Or, a little less code

namespace R
{
  [ZoneMarker, ZoneActivator]
  public class ReSpellerActivator : IActivate<IReSpellerZone>
  {
    public bool ActivatorEnabled()
    {
      return true;
    }
  }
}

namespace ReSpeller
{
  [ZoneDefinition]
  [ZoneDefinitionConfigurableFeature("ReSpeller", "Spell Checker for Resharper based on NHunspell library.", isInProductSection: false)]
  public interface IReSpellerZone : IZone, IRequire<PsiFeaturesImplZone>
  {
  }

  [ZoneMarker]
  public class ZoneMarker : IRequire<IReSpellerZone>
  {
  }
}

derigel23 avatar Dec 09 '14 16:12 derigel23

Bleurgh. This is only required if we're setting up a feature, though, isn't it? If we don't add a feature, we don't need to define a zone definition. That said, I'm up for adding the workaround. We can always remove it when the bug's fixed.

citizenmatt avatar Dec 09 '14 17:12 citizenmatt

In theory, each plugin should have own feature, if we want to disable them.

derigel23 avatar Dec 09 '14 17:12 derigel23

What about implicit zones created automatically by R# for each plugin, with an options page to disable them? It's a shame plugins have to implement a zone explicitly to be disabled, especially since installing/uninstalling them is much longer in v9.0.

MrJul avatar Dec 10 '14 18:12 MrJul