aspnet / Razor

[Archived] Parser and code generator for CSHTML files used in view pages for MVC web apps. Project moved to https://github.com/aspnet/AspNetCore

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How can I configure the Razor Language Service in Visual Studio 2017?

daiplusplus opened this issue · comments

commented

(Alternative title: "Bug report: No documentation available regarding configuring Razor Language Services in Visual Studio 2017".)

Steps:

  1. Open Visual Studio 2017 (I'm running Enterprise 15.8.5)
  2. Create a new C# .NET Framework 4.7.2 Class Library project (not .NET Core or .NET Standard)
  3. Open the Project Properties and specify C# language version 7.3.
  4. Create a new .cshtml file in the project root.
    • As there isn't an item-template for Razor files I used the HTML Page template and renamed the file extension to .cshtml.
  5. Open the file and the Text Editor with the Razor Language Service runs.
  6. Observe that IntelliSense and design-time build errors indicate and with no custom assembly references, not even System.Core.dll so Linq isn't available.
  7. Add a new C# class MyProject.TestClass to the project in its own .cs file.

Observations:

  1. The Razor Language Service is using the C# 4.0 compiler, not the C# 7.0 compiler.
  2. Classes in my project like TestClass are acessible in the Razor file, but not types defined in other assemblies referenced by my project (e.g. System.Linq.Enumerable in System.Core.dll)
  3. There doesn't seem to be any way to configure the Razor Language Service.

Hi, the best place for for bug reports and feedback about Visual Studio is https://developercommunity.visualstudio.com/spaces/8/index.html

This repo is the .NET Core Razor support.

commented

@rynowak But this is the repo that also contains the Razor Language Service, used by both .NET Core and non-.NET Core projects, right?

I'm not sure that class library projects support the Razor tooling.

The code and internal work item tracking for the .NET core implementation for Razor is in the repo. The best place to report issues with Visual Studio is https://developercommunity.visualstudio.com/spaces/8/index.html