razor icon indicating copy to clipboard operation
razor copied to clipboard

VS Code complaining that Routes element is not a component, but it totally is

Open DamianEdwards opened this issue 2 years ago • 5 comments

See this image: image

The editor is complaining that <Routes /> looks like a component but isn't, but the Routes.razor file is right there in the directory. Note that the <HeadOutlet> is detected as a component just fine.

project.razor.vscode.bin.zip

Repro is at https://github.com/dotnet/aspire/tree/main/samples/eShopLite

DamianEdwards avatar Nov 22 '23 22:11 DamianEdwards

Adding Razor Log razorlog.log

DamianEdwards avatar Nov 22 '23 22:11 DamianEdwards

From the logs it looks like this was actually reproing for https://github.com/dotnet/aspire-samples/tree/main/samples/eShopLite

Crux of the issue is this:

[Client - 2:00:38 PM] (Warning) razor.provideDynamicFileInfo failed with CodeExpectedError: cannot open virtualCSharp-razor:/d%3A/src/GitHub/dotnet/aspire-samples/samples/eShopLite/eShopLite.Frontend/Components/Routes.razor__virtual.cs. Detail: Unable to resolve resource virtualCSharp-razor:/d%3A/src/GitHub/dotnet/aspire-samples/samples/eShopLite/eShopLite.Frontend/Components/Routes.razor__virtual.cs

Fowler hit that once, and I reproed it once too, but it went away after I bumped up the logging and reloaded, sadly. Not sure why, but VS Code doesn't want to open our generated file. That means we can't update Roslyn with the generated code, and therefore means components aren't discovered - they don't exist in the Roslyn compilation, it just has empty files. I can't see any issues with file paths or anything that would cause issues though.

Opening https://github.com/dotnet/aspire/tree/main/samples/eShopLite fails for me because the build system puts the obj folder in artifacts in the repo root, which is not part of the VS Code workspace. https://github.com/dotnet/roslyn/pull/70913 might fix that, unintentionally, but makes me think thats not what you were doing. Nothing works if you do that :)

davidwengier avatar Nov 23 '23 05:11 davidwengier

Hah, it's likely I just got confused when pointing at which instance of the sample I was using. Are you able to repro if opening https://github.com/dotnet/aspire-samples/tree/main/samples/eShopLite?

DamianEdwards avatar Nov 27 '23 16:11 DamianEdwards

I hit it once, but then couldn't hit it again, sadly. Could be a startup issue, perhaps a race condition around when we register the handler for the virtualCSharp-razor:/ scheme.

davidwengier avatar Dec 04 '23 01:12 davidwengier

I did a git clean -xdf and it went away so it seems related to transient files created during the inner-loop? Perhaps got out of sync somehow?

DamianEdwards avatar Dec 04 '23 01:12 DamianEdwards

This is a stale issue. We fixed a few things in this around how we sync code to Roslyn + how we synchronize tag helper information. I wasn't able to reproduce this using aspire examples. Feel free to reopen or open a new issue if you're still seeing problems

ryzngard avatar Jan 08 '25 23:01 ryzngard