Ejemplo n.º 1
0
        public PropertyPad()
        {
            frame = new InvisibleFrame();

#if MAC
            isNative = FeatureSwitchService.IsFeatureEnabled("NativePropertyPanel") ?? false;

            if (isNative)
            {
                nativeGrid   = new MacPropertyGrid();
                propertyGrid = nativeGrid;

                gtkWidget           = Components.Mac.GtkMacInterop.NSViewToGtkWidget(nativeGrid);
                gtkWidget.CanFocus  = true;
                gtkWidget.Sensitive = true;
                gtkWidget.Focused  += Widget_Focused;

                nativeGrid.Focused += PropertyGrid_Focused;
                frame.Add(gtkWidget);
            }
            else
            {
#endif
            grid          = new pg.PropertyGrid();
            propertyGrid  = grid;
            grid.Changed += Grid_Changed;
            frame.Add(grid);
#if MAC
        }
#endif
            frame.ShowAll();
        }
 public void CanDisableMultipleWithEnvVar()
 {
     Environment.SetEnvironmentVariable("MD_FEATURES_DISABLED", "Feature1;Feature2;Feature3;Feature4");
     Assert.False(FeatureSwitchService.IsFeatureEnabled("Feature1") ?? true);
     Assert.False(FeatureSwitchService.IsFeatureEnabled("Feature2") ?? true);
     Assert.False(FeatureSwitchService.IsFeatureEnabled("Feature3") ?? true);
     Assert.False(FeatureSwitchService.IsFeatureEnabled("Feature4") ?? true);
 }
Ejemplo n.º 3
0
        void RefreshCombo()
        {
            configs.Clear();
            runtimes.Clear();

            foreach (string conf in IdeApp.Workspace.GetConfigurations())
            {
                DropDownBox.ComboItem item = new DropDownBox.ComboItem(conf, conf);
                configs.Add(item);
                if (conf == IdeApp.Workspace.ActiveConfigurationId)
                {
                    configs.CurrentItem = item.Item;
                }
            }

            var enabled = FeatureSwitchService.IsFeatureEnabled("RUNTIME_SELECTOR");

            if (enabled.GetValueOrDefault())
            {
                foreach (TargetRuntime tr in Runtime.SystemAssemblyService.GetTargetRuntimes())
                {
                    DropDownBox.ComboItem item = new DropDownBox.ComboItem(tr.DisplayName, tr);
                    runtimes.Add(item);
                    if (tr == IdeApp.Workspace.ActiveRuntime)
                    {
                        runtimes.CurrentItem = tr;
                    }
                }

                // If there is only one runtime, there is no need to show it
                if (runtimes.Count == 1)
                {
                    runtimes.Clear();
                }
                else
                {
                    DropDownBox.ComboItem item = new DropDownBox.ComboItem(GettextCatalog.GetString("Default Runtime"), defaultRuntime);
                    runtimes.Insert(0, item);
                    if (IdeApp.Workspace.UseDefaultRuntime)
                    {
                        runtimes.CurrentItem = defaultRuntime;
                    }
                }
            }

            UpdateLabel();
            Combo.ShowAll();

            if (configs.CurrentItem == null && configs.Count > 0)
            {
                IdeApp.Workspace.ActiveConfigurationId = (string)configs [0].Item;
            }

            if (runtimes.CurrentItem == null && runtimes.Count > 0)
            {
                IdeApp.Workspace.ActiveRuntime = Runtime.SystemAssemblyService.CurrentRuntime;
            }
        }
 internal static bool?IsFeatureEnabledIgnoringConfiguration(string featureName)
 {
     try {
         bypass = true;
         return(FeatureSwitchService.IsFeatureEnabled(featureName));
     } finally {
         bypass = false;
     }
 }
        bool IsSupportedDesignerFileName(FilePath fileName, WorkspaceObject ownerProject)
        {
            if (!FeatureSwitchService.IsFeatureEnabled("DesignersNewEditor").GetValueOrDefault())
            {
                return(false);
            }

            return(fileName.HasExtension(".xaml") ||
                   IsSupportedAndroidFileName(fileName, ownerProject));
        }
Ejemplo n.º 6
0
        public void CanChangeWhileRunning()
        {
            string featureName = nameof(CanChangeWhileRunning);

            Assert.IsNull(FeatureSwitchService.IsFeatureEnabled(featureName));
            FeatureSwitchService.SetFeatureSwitchValue(featureName, true);
            Assert.True(FeatureSwitchService.IsFeatureEnabled(featureName) ?? false);

            FeatureSwitchService.SetFeatureSwitchValue(featureName, false);
            Assert.False(FeatureSwitchService.IsFeatureEnabled(featureName) ?? true);
        }
        public Task <bool> AcceptLicenses(IEnumerable <NuGetPackageLicense> licenses)
        {
            if (FeatureSwitchService.IsFeatureEnabled("NuGetLicenseAcceptanceDialog") == false)
            {
                return(Task.FromResult(true));
            }

            if (Runtime.IsMainThread)
            {
                return(ShowLicenseAcceptanceDialog(licenses));
            }

            return(Runtime.RunInMainThread(() => ShowLicenseAcceptanceDialog(licenses)));
        }
Ejemplo n.º 8
0
        protected override IEnumerable <DocumentControllerDescription> GetSupportedControllers(FileDescriptor modelDescriptor)
        {
            var nodes = Mono.Addins.AddinManager.GetExtensionNodes <SupportedFileTypeExtensionNode> ("/MonoDevelop/TextEditor/SupportedFileTypes");

            bool supported =
                (
                    modelDescriptor.FilePath.IsNotNull &&
                    IdeServices.DesktopService.GetFileIsText(modelDescriptor.FilePath, modelDescriptor.MimeType) &&
                    nodes.Any(n => ExtensionMatch(n) && BuildActionAndFeatureFlagMatch(n))
                ) || (
                    !string.IsNullOrEmpty(modelDescriptor.MimeType) &&
                    IdeServices.DesktopService.GetMimeTypeIsText(modelDescriptor.MimeType) &&
                    nodes.Any(n => MimeMatch(n) && BuildActionAndFeatureFlagMatch(n))
                    );

            if (supported)
            {
                yield return(new DocumentControllerDescription(GettextCatalog.GetString("New Source Code Editor"), true, DocumentControllerRole.Source));
            }

            bool ExtensionMatch(SupportedFileTypeExtensionNode node) =>
            node.Extensions != null &&
            node.Extensions.Any(ext => modelDescriptor.FilePath.HasExtension(ext));

            bool MimeMatch(SupportedFileTypeExtensionNode node) =>
            node.MimeTypes != null &&
            node.MimeTypes.Any(
                mime => string.Equals(modelDescriptor.MimeType, mime, StringComparison.OrdinalIgnoreCase)
                );

            bool BuildActionAndFeatureFlagMatch(SupportedFileTypeExtensionNode node)
            {
                if (!string.IsNullOrEmpty(node.FeatureFlag))
                {
                    if (!(FeatureSwitchService.IsFeatureEnabled(node.FeatureFlag) ?? node.FeatureFlagDefault))
                    {
                        return(false);
                    }
                }
                if (!string.IsNullOrEmpty(node.BuildAction))
                {
                    var buildAction = (modelDescriptor.Owner as Project)?.GetProjectFile(modelDescriptor.FilePath)?.BuildAction;
                    if (!string.Equals(buildAction, node.BuildAction, StringComparison.OrdinalIgnoreCase))
                    {
                        return(false);
                    }
                }
                return(true);
            }
        }
Ejemplo n.º 9
0
        protected override void Update(CommandArrayInfo info)
        {
            var enabled = FeatureSwitchService.IsFeatureEnabled(FeatureSwitches.RuntimeSelectorFeatureSwitchName);

            if (enabled.GetValueOrDefault() && IdeApp.Workspace.IsOpen && Runtime.SystemAssemblyService.GetTargetRuntimes().Count() > 1)
            {
                foreach (var tr in Runtime.SystemAssemblyService.GetTargetRuntimes())
                {
                    var item = info.Add(tr.DisplayName, tr);
                    if (tr == IdeApp.Workspace.ActiveRuntime)
                    {
                        item.Checked = true;
                    }
                }
            }
        }
        public VisualStudioMacLSPEditorFeatureDetector(
            AggregateProjectCapabilityResolver projectCapabilityResolver,
            TextBufferProjectService textBufferProjectService)
        {
            _projectCapabilityResolver = projectCapabilityResolver;
            _textBufferProjectService  = textBufferProjectService;

            _useLegacyEditor = new Lazy <bool>(() =>
            {
                // TODO: Pull from preview features collection

                if (FeatureSwitchService.IsFeatureEnabled(RazorLSPEditorFeatureFlag) == true)
                {
                    return(false);
                }

                return(true);
            });
        }
Ejemplo n.º 11
0
        public void CanRegisterAndUnregisterFeatureSwitches()
        {
            string featureName = nameof(CanRegisterAndUnregisterFeatureSwitches);

            for (int i = 1; i <= 10; i++)
            {
                FeatureSwitchService.RegisterFeatureSwitch($"{featureName}{i}", "Test feature", i % 2 == 0);

                var switches = FeatureSwitchService.DescribeFeatures()
                               .Where(x => x.Name.StartsWith(featureName, StringComparison.OrdinalIgnoreCase))
                               .ToList();

                foreach (var feature in switches)
                {
                    Assert.That(FeatureSwitchService.IsFeatureEnabled(feature.Name).GetValueOrDefault(), Is.EqualTo(feature.DefaultValue));
                    Assert.That(switches.Count(x => x.Name == feature.Name), Is.EqualTo(1));

                    // Check we can bypass the controller with the environment variables
                    if (feature.DefaultValue)
                    {
                        Environment.SetEnvironmentVariable("MD_FEATURES_DISABLED", feature.Name);
                        Assert.False(FeatureSwitchService.IsFeatureEnabled(feature.Name).GetValueOrDefault(true));
                    }
                    else
                    {
                        Environment.SetEnvironmentVariable("MD_FEATURES_ENABLED", feature.Name);
                        Assert.True(FeatureSwitchService.IsFeatureEnabled(feature.Name).GetValueOrDefault(false));
                    }

                    Environment.SetEnvironmentVariable("MD_FEATURES_ENABLED", null);
                    Environment.SetEnvironmentVariable("MD_FEATURES_DISABLED", null);
                }

                FeatureSwitchService.UnregisterFeatureSwitch($"{featureName}{i}");
            }
        }
 public void CanDisableWithEnvVar()
 {
     Environment.SetEnvironmentVariable("MD_FEATURES_DISABLED", "MonoDevelop.Core.FeatureSwitchTests");
     Assert.False(FeatureSwitchService.IsFeatureEnabled("MonoDevelop.Core.FeatureSwitchTests") ?? true);
 }
 public void IgnoresUnknownFeatures()
 {
     Assert.IsNull(FeatureSwitchService.IsFeatureEnabled("FakeFeature"));
 }
Ejemplo n.º 14
0
        public IEnumerable <TargetRuntime> CreateRuntimes()
        {
            MonoRuntimeInfo currentRuntime = MonoRuntimeInfo.FromCurrentRuntime();

            if (currentRuntime != null)
            {
                yield return(new MonoTargetRuntime(currentRuntime));
            }

            if (!FeatureSwitchService.IsFeatureEnabled("RUNTIME_SELECTOR").GetValueOrDefault())
            {
                yield break;
            }

            if (Platform.IsWindows)
            {
                string progs = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
                foreach (string dir in Directory.EnumerateDirectories(progs, "Mono*"))
                {
                    MonoRuntimeInfo info = new MonoRuntimeInfo(dir);
                    if (info.IsValidRuntime)
                    {
                        yield return(new MonoTargetRuntime(info));
                    }
                }
            }
            else if (Platform.IsMac)
            {
                if (!Directory.Exists(MAC_FRAMEWORK_DIR))
                {
                    yield break;
                }
                foreach (string dir in Directory.EnumerateDirectories(MAC_FRAMEWORK_DIR))
                {
                    if (dir.EndsWith("/Current", StringComparison.Ordinal) || currentRuntime.Prefix == dir)
                    {
                        continue;
                    }
                    MonoRuntimeInfo info = new MonoRuntimeInfo(dir);
                    if (info.IsValidRuntime)
                    {
                        yield return(new MonoTargetRuntime(info));
                    }
                }
            }
            else
            {
                foreach (string pref in commonLinuxPrefixes)
                {
                    if (currentRuntime != null && currentRuntime.Prefix == pref)
                    {
                        continue;
                    }
                    MonoRuntimeInfo info = new MonoRuntimeInfo(pref);
                    if (info.IsValidRuntime)
                    {
                        // Clean up old registered runtimes
                        foreach (MonoRuntimeInfo ei in customRuntimes)
                        {
                            if (ei.Prefix == info.Prefix)
                            {
                                customRuntimes.Remove(ei);
                                break;
                            }
                        }
                        yield return(new MonoTargetRuntime(info));
                    }
                }
            }
            foreach (MonoRuntimeInfo info in customRuntimes)
            {
                MonoTargetRuntime rt = new MonoTargetRuntime(info);
                rt.UserDefined = true;
                yield return(rt);
            }
        }