/// <summary> /// Displays the settings for the local settings file. /// </summary> internal void LocalProjectSettings() { // Get the active project. Project project = ProjectUtilities.GetActiveProject(); // Get the path to the local settings file for this project. string localSettingsFileFolder = ProjectUtilities.GetProjectPath(project); if (localSettingsFileFolder == null) { AlertDialog.Show( this.core, null, Strings.CantGetProjectPath, Strings.Title, MessageBoxButtons.OK, MessageBoxIcon.Error); } else { // Show the local settings dialog. string settingsFilePath = Path.Combine(localSettingsFileFolder, Settings.DefaultFileName); if (!File.Exists(settingsFilePath)) { string deprecatedSettingsFile = Path.Combine(localSettingsFileFolder, Settings.AlternateFileName); if (File.Exists(deprecatedSettingsFile)) { settingsFilePath = deprecatedSettingsFile; } else { deprecatedSettingsFile = Path.Combine(localSettingsFileFolder, V101Settings.DefaultFileName); if (File.Exists(deprecatedSettingsFile)) { settingsFilePath = deprecatedSettingsFile; } } } this.core.AddSettingsPages += this.StyleCopCoreAddSettingsPages; this.core.ShowSettings(settingsFilePath); this.core.AddSettingsPages -= this.StyleCopCoreAddSettingsPages; } }
private void StyleCopCoreAddSettingsPages(object sender, AddSettingsPagesEventArgs e) { Param.Ignore(sender); Param.AssertNotNull(e, "e"); Project project = ProjectUtilities.GetActiveProject(); string fullName = ProjectUtilities.GetProjectFullName(project); if (string.IsNullOrEmpty(fullName)) { return; } project.Save(); var proj = new Microsoft.Build.Evaluation.Project( project.FullName, null, null, new Microsoft.Build.Evaluation.ProjectCollection()); e.Add(new BuildIntegrationOptions(proj)); }
private static string MakeCsvFileName(string variableName) { var project = ProjectUtilities.GetActiveProject(); var projectName = project?.FileName; var contentTypeService = VsAppShell.Current.ExportProvider.GetExportedValue <IContentTypeRegistryService>(); var viewTracker = VsAppShell.Current.ExportProvider.GetExportedValue <IActiveWpfTextViewTracker>(); var activeView = viewTracker.GetLastActiveTextView(contentTypeService.GetContentType(RContentTypeDefinition.ContentType)); var filePath = activeView.GetFilePath(); var csvFileName = string.Empty; if (!string.IsNullOrEmpty(projectName)) { csvFileName += Path.GetFileNameWithoutExtension(projectName); csvFileName += "_"; } if (!string.IsNullOrEmpty(filePath)) { csvFileName += Path.GetFileNameWithoutExtension(filePath); csvFileName += "_"; } if (variableName.StartsWith("$", StringComparison.Ordinal)) { variableName = variableName.Substring(1); } int invalidCharIndex = variableName.IndexOfAny(Path.GetInvalidFileNameChars()); variableName = MakeFileSystemCompatible(variableName); if (variableName.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0) { variableName = _variableNameReplacement; } csvFileName += variableName; return(csvFileName); }