提交 1cdbef97 编写于 作者: R Ravi Chande 提交者: GitHub

Merge pull request #20076 from rchande/debuggerIntellisenseContentTYpes

Don't crash and send an NFW if debugger contenttype does not match
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
using Microsoft.CodeAnalysis.Editor;
using Microsoft.CodeAnalysis.ErrorReporting;
using Microsoft.VisualStudio.Editor;
using Microsoft.VisualStudio.LanguageServices.Implementation.DebuggerIntelliSense;
using Microsoft.VisualStudio.OLE.Interop;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.TextManager.Interop;
using Roslyn.Utilities;
namespace Microsoft.VisualStudio.LanguageServices.Implementation.LanguageService
{
......@@ -81,6 +84,16 @@ int IVsImmediateStatementCompletion2.InstallStatementCompletion(int install, IVs
if (buffer != null)
{
var contextBuffer = EditorAdaptersFactoryService.GetDataBuffer(buffer);
if (!contextBuffer.ContentType.IsOfType(this.ContentTypeName))
{
FatalError.ReportWithoutCrash(
new ArgumentException($"Expected content type {this.ContentTypeName} " +
$"but got buffer of content type {contextBuffer.ContentType}"));
return VSConstants.E_FAIL;
}
var context = CreateContext(view, textView, debuggerBuffer, contextBuffer, currentStatementSpan);
if (context.TryInitialize())
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册