Fix #1684 - CompletionProvider null ref

The CompletionProvider will be called in cases where the document
doesn't have a FilePath - such as the C# interactive window. This is
causing a null ref.
This commit is contained in:
Ryan Nowak 2017-09-15 11:24:17 -07:00
parent 7cca8618ea
commit e05faf2347
1 changed files with 3 additions and 1 deletions

View File

@ -77,7 +77,9 @@ namespace Microsoft.VisualStudio.LanguageServices.Razor.Editor
throw new ArgumentNullException(nameof(context));
}
if (!context.Document.FilePath.EndsWith(".cshtml", StringComparison.OrdinalIgnoreCase))
// FilePath will be null when the editor is open for cases where we don't have a file on disk (C# interactive window and others).
if (context.Document?.FilePath == null ||
!context.Document.FilePath.EndsWith(".cshtml", StringComparison.OrdinalIgnoreCase))
{
// Not a Razor file.
return Task.CompletedTask;