-
Notifications
You must be signed in to change notification settings - Fork 226
Description
Azure DevOps work item: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1284417
Testcases Affected
[6.0] SimpleWebAppRazorEditingWithVSCode
[6.0] SimpleBlazorRazorEditingWithVSCode
Platform
- Windows
- macOS
- Linux
Repro Steps
- Create an MVC project and open via VS Code:
md MVC
cd MVC
dotnet new mvc
code .
- Go to https://github.com/OmniSharp/omnisharp-vscode/releasesinstall the latest csharp-1.23.10-lsp-beta.vsix.
- Open Pages/Shared/_Layout.cshtml
- Type "@add" and verify the intellisense list. Select "addTagHelper", then type "*, Microsoft.AspNetCore.Mvc.TagsHelpers" following it. Save the change.
- In VS Code, using CTRL + ~ to open up TERMINAL window, type the following code.
'namespace MVC // Or Razor
{
public class CustomTagHelper
{
}
}' | Out-File CustomTagHelper.cs
- In CustomTagHelper.cs, type ": TagHelper" following the class. And then select "using Microsoft.AspNetCore.Razor.TagHelpers" through the Quick Actions
- In _Layout.cshtml, type "@addTagHelper *, MVC
- Open Program.cs, then enter the code:
public interface ICheese {}above public class Program and save - Edit Index.cshtml to include the following at the bottom:
@{ var x = typeof(Program); }
@functions {
public class Cheddar : ICheese {}
}
- Save and close Index.cshtml
- Close all instances of VSCode and re-open this project.
- go to the program.cs file
Note:
- It works well on 5.0 Project
- It works well on 6.0 Preview 1
Actual Result
CodeLens references numbers did not load and the output window contain error "Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object."

Error Log
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at OmniSharp.Helpers.LocationExtensions.<>c__DisplayClass0_0.b__3(Document d) in D:\a\1\s\src\OmniSharp.Roslyn.CSharp\Helpers\LocationExtensions.cs:line 45
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable1 source, Func2 predicate)
at OmniSharp.Helpers.LocationExtensions.g__GetSourceText|0_0(Location location, IEnumerable`1 documents, Boolean hasMappedPath) in D:\a\1\s\src\OmniSharp.Roslyn.CSharp\Helpers\LocationExtensions.cs:line 45
at OmniSharp.Helpers.LocationExtensions.GetQuickFix(Location location, OmniSharpWorkspace workspace) in D:\a\1\s\src\OmniSharp.Roslyn.CSharp\Helpers\LocationExtensions.cs:line 19
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.Enumerable.d__64`1.MoveNext()
at System.Linq.Buffer1..ctor(IEnumerable1 source)
at System.Linq.OrderedEnumerable`1.d__1.MoveNext()
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)
at Newtonsoft.Json.JsonConvert.SerializeObjectInternal(Object value, Type type, JsonSerializer jsonSerializer)
at OmniSharp.Protocol.Packet.ToString() in D:\a\1\s\src\OmniSharp.Host\Protocol\Packet.cs:line 22
at System.IO.TextWriter.WriteLine(Object value)
at System.IO.TextWriter.SyncTextWriter.WriteLine(Object value)
at OmniSharp.Services.SharedTextWriter.ProcessWriteQueue() in D:\a\1\s\src\OmniSharp.Host\Services\SharedTextWriter.cs:line 48
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()