public void Update(ScriptAnalysisSettings settings, string workspaceRootPath)
        {
            if (settings != null)
            {
                this.Enable = settings.Enable;

                string settingsPath = settings.SettingsPath;

                if (string.IsNullOrWhiteSpace(settingsPath))
                {
                    settingsPath = null;
                }
                else if (!Path.IsPathRooted(settingsPath))
                {
                    if (string.IsNullOrEmpty(workspaceRootPath))
                    {
                        // The workspace root path could be an empty string
                        // when the user has opened a PowerShell script file
                        // without opening an entire folder (workspace) first.
                        // In this case we should just log an error and let
                        // the specified settings path go through even though
                        // it will fail to load.
                        Logger.Write(
                            LogLevel.Error,
                            "Could not resolve Script Analyzer settings path due to null or empty workspaceRootPath.");
                    }
                    else
                    {
                        settingsPath = Path.GetFullPath(Path.Combine(workspaceRootPath, settingsPath));
                    }
                }

                this.SettingsPath = settingsPath;
            }
        }
        public void Update(
            ScriptAnalysisSettings settings,
            string workspaceRootPath,
            ILogger logger)
        {
            if (settings != null)
            {
                this.Enable = settings.Enable;

                string settingsPath = settings.SettingsPath;

                try
                {
                    if (string.IsNullOrWhiteSpace(settingsPath))
                    {
                        settingsPath = null;
                    }
                    else if (!Path.IsPathRooted(settingsPath))
                    {
                        if (string.IsNullOrEmpty(workspaceRootPath))
                        {
                            // The workspace root path could be an empty string
                            // when the user has opened a PowerShell script file
                            // without opening an entire folder (workspace) first.
                            // In this case we should just log an error and let
                            // the specified settings path go through even though
                            // it will fail to load.
                            logger.Write(
                                LogLevel.Error,
                                "Could not resolve Script Analyzer settings path due to null or empty workspaceRootPath.");
                        }
                        else
                        {
                            settingsPath = Path.GetFullPath(Path.Combine(workspaceRootPath, settingsPath));
                        }
                    }

                    this.SettingsPath = settingsPath;
                    logger.Write(LogLevel.Verbose, $"Using Script Analyzer settings path - '{settingsPath ?? ""}'.");
                }
                catch (Exception ex) when(
                    ex is NotSupportedException ||
                    ex is PathTooLongException ||
                    ex is SecurityException)
                {
                    // Invalid chars in path like ${env:HOME} can cause Path.GetFullPath() to throw, catch such errors here
                    logger.WriteException(
                        $"Invalid Script Analyzer settings path - '{settingsPath}'.",
                        ex);

                    this.SettingsPath = null;
                }
            }
        }
 public LanguageServerSettings()
 {
     this.ScriptAnalysis = new ScriptAnalysisSettings();
 }