未验证 提交 214df40e 编写于 作者: H Heejae Chang 提交者: GitHub

fixed issue where analyzer run after project is already removed from VS. (#35383)

上级 05665eda
......@@ -213,11 +213,8 @@ private async Task RegisterDesignerAttributeAsync(Document document, string desi
var updateService = await GetUpdateServiceIfCpsProjectAsync(document.Project, cancellationToken).ConfigureAwait(false);
if (updateService != null)
{
// we track work by async token but doesn't explicitly wait for it. and update service is free-thread service,
// no need to switch to UI thread to use it
var asyncToken = _listener.BeginAsyncOperation("RegisterDesignerAttribute");
_ = updateService.SetProjectItemDesignerTypeAsync(document.FilePath, designerAttributeArgument)
.ReportNonFatalErrorAsync().CompletesAsyncOperation(asyncToken);
// fire and forget designer attribute notification to CPS
_ = NotifyCpsDesignerAttributeAsync(document, designerAttributeArgument, updateService).ReportNonFatalErrorAsync();
}
else
{
......@@ -267,6 +264,23 @@ private async Task RegisterDesignerAttributeAsync(Document document, string desi
}
}
private async Task NotifyCpsDesignerAttributeAsync(Document document, string designerAttributeArgument, IProjectItemDesignerTypeUpdateService updateService)
{
using (_listener.BeginAsyncOperation("RegisterDesignerAttribute"))
{
try
{
await updateService.SetProjectItemDesignerTypeAsync(document.FilePath, designerAttributeArgument).ConfigureAwait(false);
}
catch (ObjectDisposedException)
{
// we might call update service after project is already removed and get object disposed exception.
// we will catch the exception and ignore.
// see this PR for more detail - https://github.com/dotnet/roslyn/pull/35383
}
}
}
private IVSMDDesignerService GetDesignerFromForegroundThread()
{
if (_dotNotAccessDirectlyDesigner != null)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册