private string GetSettingsPath() { string slnFilename = vsHelper.GetSolutionFilename(); return(Path.ChangeExtension(slnFilename, "ArgsCfg.json")); }
public ProjectDataJson ReadDataForProject(IVsHierarchy project) { ProjectDataJson result = null; if (!cmdPackage.IsUseSolutionDirEnabled) { string filePath = FullFilenameForProjectJsonFileFromProject(project); if (File.Exists(filePath)) { try { using (Stream fileStream = File.Open(filePath, FileMode.Open, FileAccess.Read)) { result = Logic.ProjectDataSerializer.Deserialize(fileStream); } Logger.Info($"Read {result?.Items?.Count} commands for project '{project.GetName()}' from json-file '{filePath}'."); } catch (Exception e) { Logger.Warn($"Failed to read file '{filePath}' with error '{e}'."); result = null; } } else { Logger.Info($"Json-file '{filePath}' doesn't exists."); } return(result); } else { Guid projectGui = project.GetGuid(); string slnFilename = vsHelper.GetSolutionFilename(); string jsonFilename = Path.ChangeExtension(slnFilename, "args.json"); if (File.Exists(jsonFilename)) { try { using (Stream fileStream = File.Open(jsonFilename, FileMode.Open, FileAccess.Read)) { SolutionDataJson slnData = SolutionDataSerializer.Deserialize(fileStream); result = slnData.ProjectArguments.FirstOrDefault(p => p.Id == projectGui); } Logger.Info($"Read {result?.Items?.Count} commands for project '{project.GetName()}' from json-file '{jsonFilename}'."); } catch (Exception e) { Logger.Warn($"Failed to read file '{jsonFilename}' with error '{e}'."); result = null; } } else { Logger.Info($"Json-file '{jsonFilename}' doesn't exists."); } return(result); } }