private void Solution_Opened() { using (_performanceTracer?.Start("DTE event: Solution opened")) { ReloadSolution(); } }
private void Solution_AfterClosing() { using (PerformanceTracer.Start("DTE event: Solution closed")) { ReloadSolution(); } }
public async Task <IList <ProjectFile> > GetSourceFilesAsync(CancellationToken?cancellationToken) { using (_performanceTracer.Start("Enumerate source files")) { await JoinableTaskFactory.SwitchToMainThreadAsync(); return(await Task.FromResult(_solution.GetProjectFiles(new FileFilter(_configuration)).ToList().AsReadOnly()).ConfigureAwait(false)); } }
private void Solution_ContentChanged([CanBeNull] object item) { using (PerformanceTracer.Start("DTE event: Solution content changed")) { CompositionHost.GetExportedValue <ISourceFilesProvider>().Invalidate(); ReloadSolution(); } }
public async Task <IList <ProjectFile> > GetSourceFilesAsync(CancellationToken?cancellationToken) { using (_performanceTracer.Start("Enumerate source files")) { #pragma warning disable VSTHRD010 // Accessing ... should only be done on the main thread. return(await Task.FromResult(DteSourceFiles.ToList().AsReadOnly()).ConfigureAwait(false)); #pragma warning restore VSTHRD010 // Accessing ... should only be done on the main thread. } }
private void DocumentEvents_DocumentOpened([CanBeNull] EnvDTE.Document document) { using (PerformanceTracer.Start("DTE event: Document opened")) { if (!AffectsResourceFile(document)) { return; } ReloadSolution(); } }
private void Solution_Opened() { using (PerformanceTracer.Start("DTE event: Solution opened")) { ReloadSolution(); var resourceManager = CompositionHost.GetExportedValue <ResourceManager>(); resourceManager.ProjectFileSaved -= ResourceManager_ProjectFileSaved; resourceManager.ProjectFileSaved += ResourceManager_ProjectFileSaved; } }
private void ListBox_CollectionChanged() { var listBox = AssociatedObject; if (!AreAllFilesSelected.GetValueOrDefault()) { return; } _performanceTracer?.Start("ListBox.SelectAll", DispatcherPriority.Input); listBox?.SelectAll(); }
internal void ReloadSolution() { try { using (_performanceTracer.Start("Reload solution")) { _resourceManager.Reload(ResourceLoadOptions.None); } } catch (Exception ex) { _trace.TraceError(ex.ToString()); } }
private void TextEditorContextMenuCommand_BeforeQueryStatus(object sender, EventArgs e) { var menuCommand = sender as OleMenuCommand; if (menuCommand == null) { return; } using (_performanceTracer?.Start("Can move to resource")) { menuCommand.Text = Resources.MoveToResource; menuCommand.Visible = _refactorings?.CanMoveToResource(Dte.ActiveDocument) ?? false; } }
public async Task <IList <ProjectFile> > GetSourceFilesAsync(CancellationToken?cancellationToken) { var folder = SolutionFolder; if (folder.IsNullOrEmpty()) { return(Array.Empty <ProjectFile>()); } using (_performanceTracer.Start("Enumerate source files")) { var fileFilter = new FileFilter(_configuration); var directoryInfo = new DirectoryInfo(folder); return(await Task.Run(() => directoryInfo.GetAllSourceFiles(fileFilter, cancellationToken), cancellationToken ?? new CancellationToken()).ConfigureAwait(false)); } }
private async Task ReloadAsync(bool forceFindCodeReferences) { var cancellationTokenSource = new CancellationTokenSource(); var cancellationToken = cancellationTokenSource.Token; Interlocked.Exchange(ref _loadingCancellationTokenSource, cancellationTokenSource)?.Cancel(); try { IsLoading = true; using (_performanceTracer.Start("ResourceManager.Load")) { var sourceFiles = await _sourceFilesProvider.GetSourceFilesAsync(cancellationToken).ConfigureAwait(true); if (cancellationToken.IsCancellationRequested) { return; } _codeReferenceTracker.StopFind(); if (await ResourceManager.ReloadAsync(sourceFiles, cancellationToken).ConfigureAwait(true) || forceFindCodeReferences) { BeginFindCodeReferences(); } } } catch (OperationCanceledException) { } catch (Exception ex) { _tracer.TraceError(ex.ToString()); } finally { if (Interlocked.CompareExchange(ref _loadingCancellationTokenSource, null, cancellationTokenSource) == cancellationTokenSource) { IsLoading = false; } cancellationTokenSource.Dispose(); } }
private void Reload(bool forceFindCodeReferences) { try { using (_performanceTracer.Start("ResourceManager.Load")) { var sourceFiles = _sourceFilesProvider.SourceFiles; _codeReferenceTracker.StopFind(); if (ResourceManager.Reload(sourceFiles) || forceFindCodeReferences) { BeginFindCodeReferences(); } } } catch (Exception ex) { _tracer.TraceError(ex.ToString()); } }
private void DocumentEvents_DocumentSaved([NotNull] EnvDTE.Document document) { Contract.Requires(document != null); using (PerformanceTracer.Start("DTE event: Document saved")) { if (!AffectsResourceFile(document)) { return; } var resourceManager = CompositionHost.GetExportedValue <ResourceManager>(); if (resourceManager.IsSaving) { return; } // Run custom tool (usually attached to neutral language) even if a localized language changes, // e.g. if custom tool is a text template, we might want not only to generate the designer file but also // extract some localization information. // => find the resource entity that contains the document and run the custom tool on the neutral project file. // ReSharper disable once PossibleNullReferenceException bool Predicate(ResourceEntity e) => e.Languages.Select(lang => lang.ProjectFile) .OfType <DteProjectFile>() .Any(projectFile => projectFile.ProjectItems.Any(p => p.Document == document)); var entity = resourceManager.ResourceEntities.FirstOrDefault(Predicate); var neutralProjectFile = (DteProjectFile)entity?.NeutralProjectFile; // VS will run the custom tool on the project item only. Run the custom tool on any of the descendants, too. var projectItems = neutralProjectFile?.ProjectItems.SelectMany(projectItem => projectItem.Descendants()); _customToolRunner.Enqueue(projectItems); ReloadSolution(); } }
public void Reload(bool forceFindCodeReferences) { try { using (_performanceTracer.Start("ResourceManager.Load")) { var sourceFiles = _sourceFilesProvider.SourceFiles; _codeReferenceTracker.StopFind(); if (_resourceManager.Reload(sourceFiles, _configuration.DuplicateKeyHandling) || forceFindCodeReferences) { _restartFindCodeReferencesThrottle.Tick(); } _configuration.Reload(); } } catch (Exception ex) { _tracer.TraceError(ex.ToString()); } }