question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Intellisense is not working for View Template file. Yes I am inheriting from TemplatePage

See original GitHub issue

Describe the bug Intellisense is not working for View Template file. Yes I am inheriting from TemplatePage

image

To Reproduce Create a Project with the following

Project file

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.1</TargetFramework>
    <PreserveCompilationContext>true</PreserveCompilationContext>
  </PropertyGroup>

  <ItemGroup>
    <None Remove="TestView.cshtml" />
  </ItemGroup>

  <ItemGroup>
    <Content Include="TestView.cshtml">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="RazorLight" Version="2.0.0-beta1" />
  </ItemGroup>

</Project>

TestView.cshtml

@using QuestionRazorLight
@using RazorLight
@inherits TemplatePage<TestViewModel>

<table id="myTable" class="table" cellspacing="0">
    <thead>
        <tr>
            item1
        </tr>
        <tr>
            item2
        </tr>
    </thead>
    <tbody>
        @foreach (var item in Model.listOfStuff)
        {
            <tr>
                item.item1
            </tr>
            <tr>
                item.item2
            </tr>
        }
    </tbody>
</table>

TestViewModel.cs

using System;
using System.Collections.Generic;
using System.Text;

Program.cs

using System.Collections.Generic;
using System.IO;
using System.Reflection;
using RazorLight;

namespace QuestionRazorLight
{
    class Program
    {
        static void Main(string[] args)
        {
            var viewmodel = new TestViewModel
            {
               listOfStuff = new List<(string, string)>() { ("Blah1","blah1"), ("Blah2", "blah2") }
            };


            var engine = new RazorLightEngineBuilder()
              .UseFilesystemProject(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location))
              .UseMemoryCachingProvider()
              .Build();

            string reportAsHTML = engine.CompileRenderAsync($"{Path.DirectorySeparatorChar}TestView.cshtml", viewmodel).Result;
        }
    }
}
namespace QuestionRazorLight
{
    public class TestViewModel
    {
        public IList<(string,string)> listOfStuff { get; set; }
    }
}

Expected behavior I expect there not to be any syntax errors about missing AspNetCore assemblies

Information:

  • OS: Windows 10 1809
  • Visual Studio Community 2017 (15.9.4)
  • Platform .NET Core 2.1
  • RazorLight version 2.0-beta1

Additional Information This will compile and run but I can’t figure out how to make the syntax errors go away.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
MNFcommented, May 15, 2019

You can try to add PackageReferences to your Project file ```

<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor" Version="2.1.0" />
2reactions
billrobcommented, Nov 14, 2019

@TheColonel2688

Add ‘Web’ to the end of your project sdk, that wakes the intellisense up.

<Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <TargetFramework>netstandard2.0</TargetFramework> <ApplicationIcon /> <OutputType>Library</OutputType> <StartupObject />
Read more comments on GitHub >

github_iconTop Results From Across the Web

c++ - Visual Studio Intellisense not working when inheriting ...
Visual Studio Intellisense not working when inheriting from template class. The code compiles and runs. But in void C<T>::test() , when I tried ......
Read more >
Live templates not shown while using VS intellisense - YouTrack
Resharper Live Templates does not show up using the Visual Studio intellisense, the Live templates indeed work, but to invoke a Live template...
Read more >
Intellisense Not working - Developer Community
Tried to continue working on my ARM Templates and create a new resource. Intellisense was SO SLOW that VS was not responding for...
Read more >
EPiServer Web Controls
Template class used by FileTree to display files. FileTree. Displays a file tree from ... a seven level deep inheritance chain: (not shown...
Read more >
Flare Touring the Workspace Guide
Non -Topic File Type. Recommended Default Folder in Content Explorer. Table Stylesheet. Resources > TableStyles. Template Page. Resources > TemplatePages.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found