dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.5k stars 10.04k forks source link

Cannot resolve @typeparam #5608

Closed kakins closed 5 years ago

kakins commented 6 years ago

I have Blazor 0.6.0 installed, using the VS template. .NET Core SDK 2.1.402. I see this, both with ReSharper enabled and disabled.

The app appears to still compile and run correctly, so perhaps this is an issue with Visual Studio? I have VS 2017 15.8.6.

image

danroth27 commented 6 years ago

Hmm, strange. I'm not able to reproduce this. @rynowak Any ideas?

rynowak commented 6 years ago

I don't have any off the cuff ideas. Can you confirm that other blazor features work in the editor? @layout for instance. Can you confirm the version of the blazor extension in the About... dialog

image

rynowak commented 6 years ago

One other thing to check. Did package restore complete successfully for the project?

kakins commented 6 years ago

@rynowak Yes I can verify that the extension is installed, which mirrors your screenshot. The features work, I get intellisense, @inject works, etc. Packages have restored several times as I've been working with the project.

rynowak commented 6 years ago

Can you please report back about @layout? @inject works the same way in MVC as it does in Blazor. I'm curious if the editor thinks this file is in an MVC project.

kakins commented 6 years ago

I created the project from the Blazor VS template, and opened _ViewImports.cshtml. I see no syntax errors. I also retyped the @layout line and it still appears to be working fine.

image

kakins commented 6 years ago

By the way, just in case, here is my .csproj

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

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <RunCommand>dotnet</RunCommand>
    <RunArguments>blazor serve</RunArguments>
    <LangVersion>7.3</LangVersion>
  </PropertyGroup>

  <ItemGroup>
    <BlazorLinkerDescriptor Include="linker.xml" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Blazor.Browser" Version="0.6.0" />
    <PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="0.6.0" PrivateAssets="all" />

    <DotNetCliToolReference Include="Microsoft.AspNetCore.Blazor.Cli" Version="0.6.0" />
  </ItemGroup>

</Project>

Also, here is the linker.xml I'm using

<linker>
  <assembly fullname="mscorlib">
    <!-- Preserve all methods on WasmRuntime, because these are called by JS-side code
    to implement timers. Fixes https://github.com/aspnet/Blazor/issues/239 -->
    <type fullname="System.Threading.WasmRuntime" />
  </assembly>
  <assembly fullname="System.Core">
    <!-- This is required by JSon.NET and any expression.Compile caller -->
    <type fullname="System.Linq.Expressions*" />
  </assembly>
  <!-- Name of the entry point assembly -->
  <assembly fullname="BlazorTest" />
</linker>
danroth27 commented 6 years ago

@kakins Can you share the project with us?

kakins commented 6 years ago

BlazorTest.zip

I went ahead and zipped everything, hope it helps.

nolisj commented 6 years ago

I'm having the same problem. All other directives are working (@page, @inherits, etc). I've tried creating from various templates just to isolate: a Razor View, Razor Page, Razor Layout. My VS2017 is version 15.9.0 Preview 4.

In my case though, it turns out this is an issue only when I have ReSharper (v2018.2.3) active. If I disable ReSharper, it works properly.

danroth27 commented 6 years ago

@kakins Unfortunately I'm still not able to reproduce this, even with your project:

image

Perhaps the issue is specific to your environment? Maybe try uninstalling resharper?

alexDevBR commented 6 years ago

I had the same issue and was able to resolve it by uninstalling Blazor language services through the VS installer and reinstalling it in Extensions and Updates.

nolisj commented 6 years ago

@alexDevBR, I'm interested to know if your working setup included a ReSharper. Does it?

alexDevBR commented 6 years ago

@nolisj no, I don't have ReSharper. I also upgraded to 15.9.1, maybe that also helped, but what solved it was reinstalling Blazor language services. I reinstalled it after the upgrade, but maybe reinstalling it before would have solved the problem too.

kakins commented 5 years ago

Sorry I haven't responded in some time. I haven't had time to play around with Blazor much.

So as a response to @nolisj, I also tried suspending Resharper again. And to my surprise the error went away. I thought I had tried this before, but who knows. Looks to be a ReSharper thing on my end.

nolisj commented 5 years ago

@kakins , that's interesting. It seems then that Resharper is causing this issue in our cases.

limefrogyank commented 5 years ago

Just for the other dummies that are searching for this issue like me, you can also get this to happen when your "Build Action" is set to None rather than Content. doh!