oleg-shilo / cs-script.npp

CS-Script (C# Intellisense) plugin for Notepad++ (x86/x64)
MIT License
246 stars 52 forks source link

"Open in VS" button is not shown #25

Closed mosxl closed 6 years ago

mosxl commented 6 years ago

Environment: Visual studio 2017 Professional, and notepad++ 7.5.7, and using cs-script plugin 1.7.14.0.

Steps to reproduce:

  1. Open a C# code file from notepad++
  2. Open project panel of cs-script

Result: Cannot see the button "Open in VS" even "+openInVsBtn" is set in config file

oleg-shilo commented 6 years ago

I have checked ind now can confirm that the visibility of the button is not based on the config value but is computed at runtime according this algorithm:

public static bool IsVS2010PlusAvailable
{
    get
    {
        using (var vs2010 = Registry.ClassesRoot.OpenSubKey("VisualStudio.DTE.10.0", false))
        using (var vs2012 = Registry.ClassesRoot.OpenSubKey("VisualStudio.DTE.11.0", false))
        using (var vs2013 = Registry.ClassesRoot.OpenSubKey("VisualStudio.DTE.12.0", false))
        {
            return (vs2010 != null || vs2012 != null || vs2013 != null);
        }
    }
}

Thus if you don't have VS2010-2013 installed then the button will not be visible.

Though I do think that the algorithm will need to be updated and also dedicated config value introduced. Starting from the next release the feature will be implemented as following:

public static bool IsVS2010PlusAvailable
{
    get
    {
        using (var vs2010 = Registry.ClassesRoot.OpenSubKey("VisualStudio.DTE.10.0", false))
        using (var vs2012 = Registry.ClassesRoot.OpenSubKey("VisualStudio.DTE.11.0", false))
        using (var vs2013 = Registry.ClassesRoot.OpenSubKey("VisualStudio.DTE.12.0", false))
        using (var vs2015 = Registry.ClassesRoot.OpenSubKey("VisualStudio.DTE.14.0", false))
        using (var vs2017 = Registry.ClassesRoot.OpenSubKey("VisualStudio.DTE.15.0", false))
        {
            return (
                Config.Instance.ShowOpenInVsAlways ||
                vs2010 != null || 
                vs2012 != null || 
                vs2013 != null || 
                vs2015 != null || 
                vs2017 != null);
        }
    }
}
mosxl commented 6 years ago

Thanks Oleg. I'll close the issue after it's released and tested. Looking forward to it.

mosxl commented 6 years ago

Tested in 1.7.15.0, perfect : ) Close issue, thank you Oleg.