From c5e172e6456807f10ff24b1c962104bcb4985cbb Mon Sep 17 00:00:00 2001 From: David Poeschl Date: Thu, 21 May 2015 09:04:40 -0700 Subject: [PATCH] Ensure Rename itemid handling is on UI thread --- .../Def/Implementation/VsRefactorNotifyService.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/VisualStudio/Core/Def/Implementation/VsRefactorNotifyService.cs b/src/VisualStudio/Core/Def/Implementation/VsRefactorNotifyService.cs index 8e380e79020..686197c5720 100644 --- a/src/VisualStudio/Core/Def/Implementation/VsRefactorNotifyService.cs +++ b/src/VisualStudio/Core/Def/Implementation/VsRefactorNotifyService.cs @@ -6,6 +6,7 @@ using System.Runtime.InteropServices; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Editor; +using Microsoft.CodeAnalysis.Editor.Shared.Utilities; using Microsoft.VisualStudio; using Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem; using Microsoft.VisualStudio.LanguageServices.Implementation.RQName; @@ -15,10 +16,12 @@ namespace Microsoft.VisualStudio.LanguageServices.Implementation { [Export(typeof(IRefactorNotifyService))] - internal sealed class VsRefactorNotifyService : IRefactorNotifyService + internal sealed class VsRefactorNotifyService : ForegroundThreadAffinitizedObject, IRefactorNotifyService { public bool TryOnBeforeGlobalSymbolRenamed(Workspace workspace, IEnumerable changedDocumentIDs, ISymbol symbol, string newName, bool throwOnFailure) { + AssertIsForeground(); + Dictionary> hierarchyToItemIDsMap; string[] rqnames; @@ -59,6 +62,8 @@ public bool TryOnBeforeGlobalSymbolRenamed(Workspace workspace, IEnumerable changedDocumentIDs, ISymbol symbol, string newName, bool throwOnFailure) { + AssertIsForeground(); + Dictionary> hierarchyToItemIDsMap; string[] rqnames; @@ -103,6 +108,8 @@ public bool TryOnAfterGlobalSymbolRenamed(Workspace workspace, IEnumerable> hierarchyToItemIDsMap, out string[] rqnames) { + AssertIsForeground(); + hierarchyToItemIDsMap = null; rqnames = null; @@ -126,6 +133,8 @@ public bool TryOnAfterGlobalSymbolRenamed(Workspace workspace, IEnumerable> hierarchyToItemIDsMap, out string rqname) { + AssertIsForeground(); + visualStudioWorkspace = null; hierarchyToItemIDsMap = null; rqname = null; @@ -169,6 +178,8 @@ private bool TryGetRenamingRQNameForSymbol(ISymbol symbol, out string rqname) private Dictionary> GetHierarchiesAndItemIDsFromDocumentIDs(VisualStudioWorkspaceImpl visualStudioWorkspace, IEnumerable changedDocumentIDs) { + AssertIsForeground(); + var hierarchyToItemIDsMap = new Dictionary>(); foreach (var docID in changedDocumentIDs) -- GitLab