/// <summary> /// If the cached file exists reads the data and returns it /// </summary> private Dictionary <Version, VersionCompatibilityData> GetCompabilityDataFromCacheFile() { try { string data = _versionDataCacheFile?.ReadCacheFile(); if (data != null) { return(VersionCompatibilityData.DeserializeVersionData(data)); } } catch { } return(null); }
public async Task InitializeAsync() { await _threadHandling.Value.SwitchToUIThread(); // Initialize our cache file string appDataFolder = await _shellUtilitiesHelper.Value.GetLocalAppDataFolderAsync(_vsShellService); if (appDataFolder != null) { _versionDataCacheFile = new RemoteCacheFile(Path.Combine(appDataFolder, s_versionDataFilename), s_versionCompatibilityDownloadFwlink, TimeSpan.FromHours(s_cacheFileValidHours), _fileSystem.Value, _httpClient); } VisualStudioVersion = await _shellUtilitiesHelper.Value.GetVSVersionAsync(_vsAppIdService); _vsSolution = await _vsSolutionService.GetValueAsync(); Verify.HResult(_vsSolution.AdviseSolutionEvents(this, out _solutionCookie)); // Check to see if a solution is already open. If so we set _solutionOpened to true so that subsequent projects added to // this solution are processed. if (ErrorHandler.Succeeded(_vsSolution.GetProperty((int)__VSPROPID4.VSPROPID_IsSolutionFullyLoaded, out object isFullyLoaded)) && isFullyLoaded is bool isFullyLoadedBool && isFullyLoadedBool) { SolutionOpen = true; // do not block package initialization on this _threadHandling.Value.RunAndForget(async() => { // First make sure that the cache file exists if (_versionDataCacheFile.ReadCacheFile() is null) { await _versionDataCacheFile.TryToUpdateCacheFileAsync(); } // check if the project is compatible await CheckCompatibilityAsync(); }, unconfiguredProject: null); } }