Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visual Studio error displaying .razor file #11486

Closed
JerryMcMillan opened this issue Jun 24, 2019 · 12 comments · Fixed by dotnet/razor#709
Closed

Visual Studio error displaying .razor file #11486

JerryMcMillan opened this issue Jun 24, 2019 · 12 comments · Fixed by dotnet/razor#709
Assignees
Labels
area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug. Done This issue has been fixed

Comments

@JerryMcMillan
Copy link

JerryMcMillan commented Jun 24, 2019

I get an invalid operation exception in Visual Studio 2019 Preview, .NET Core 3 preview 4 when opening a .razor file. VS renders the text as white only and intellisense does not work.

When I check the error log:

System.InvalidOperationException: The file 'C:/Users/jerry/Desktop/vs/MetroLock/MetroLock/Pages/FetchData.razor' is not a descendent of the base path 'C:/Users/jerry/desktop/vs/MetroLock/MetroLock' ...

In the two paths, one of the "Desktop" is capitalized, the other is not. This is fixed by moving my project to a lower case only directory. I looked really quick at the file DefaultRazorProjectFileSystem.cs and one possible fix would be on line 53

if (!absolutePath.StartsWith(absoluteBasePath))

could be changed to:

if (!absolutePath.StartsWith(absoluteBasePath, StringComparison.OrdinalIgnoreCase))

I hope this helps,

Thanks!

@analogrelay analogrelay added the area-blazor Includes: Blazor, Razor Components label Jun 24, 2019
@analogrelay
Copy link
Contributor

I looked really quick at the file DefaultRazorProjectFileSystem.cs

Since this file is in aspnet/AspNetCore-Tooling, my feeling is this probably should be moved to that repo. Thoughts @NTaylorMullen @mkArtakMSFT ?

@NTaylorMullen NTaylorMullen added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates bug This issue describes a behavior which is not expected - a bug. cost: S and removed area-blazor Includes: Blazor, Razor Components labels Jun 24, 2019
@NTaylorMullen
Copy link
Contributor

NTaylorMullen commented Jun 24, 2019

This is definitely a tooling issue; however, we track issues here in AspNetCore 😄. That being said this is the first public report of this issue that we've had. We have another internal report of this issue tracking the work as well. I've marked the bug with the appropriate labels and will leave it to triage to decide when to tackle this.

@mkArtakMSFT mkArtakMSFT added area-blazor Includes: Blazor, Razor Components and removed area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels Jun 24, 2019
@mkArtakMSFT mkArtakMSFT added this to the 3.0.0-preview8 milestone Jun 25, 2019
@BrennanConroy
Copy link
Member

I am getting this consistently when opening .razor files in Components.sln.

Version 16.2.0 Preview 4.0 [29018.194.d16.2stg]
VisualStudio.16.IntPreview/16.2.0-pre.4.0+29018.194.d16.2stg

SDK: 3.0.100-preview6-012264

@ajaybhargavb
Copy link
Contributor

@BrennanConroy, can you also include the actual error message and stack trace?

@BrennanConroy
Copy link
Member

BrennanConroy commented Jun 26, 2019

Encountered an error during adding a Code Container: Some or all identity references could not be translated.

System.InvalidOperationException: The file 'C:/GitHub/aspnetcore/src/Components/test/testassets/BasicTestApp/EventPreventDefaultComponent.razor' is not a descendent of the base path 'C:/github/aspnetcore/src/Components/test/testassets/BasicTestApp'.
at Microsoft.AspNetCore.Razor.Language.DefaultRazorProjectFileSystem.GetItem(String path, String fileKind)at Microsoft.VisualStudio.Editor.Razor.DefaultImportDocumentManager.GetImportItems(VisualStudioDocumentTracker tracker)
at Microsoft.VisualStudio.Editor.Razor.DefaultImportDocumentManager.OnSubscribed(VisualStudioDocumentTracker tracker)
at Microsoft.VisualStudio.Editor.Razor.DefaultVisualStudioDocumentTracker.Subscribe()
at Microsoft.VisualStudio.Editor.Razor.DefaultRazorDocumentManager.OnTextViewOpened(ITextView textView, IEnumerable`1 subjectBuffers)
at Microsoft.VisualStudio.Editor.Razor.RazorTextViewConnectionListener.SubjectBuffersConnected(ITextView textView, ConnectionReason reason, IReadOnlyCollection`1 subjectBuffers)
at Microsoft.VisualStudio.Text.Editor.Implementation.ConnectionManager.NonWpfListener.SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection`1 subjectBuffers)
at Microsoft.VisualStudio.Text.Editor.Implementation.ConnectionManager.<>c__DisplayClass7_3.<.ctor>b__3()
at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.CallExtensionPoint(Object errorSource, Action call)
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)

@NTaylorMullen
Copy link
Contributor

NTaylorMullen commented Jun 26, 2019

System.InvalidOperationException: The file 'C:/GitHub/aspnetcore/src/Components/test/testassets/BasicTestApp/EventPreventDefaultComponent.razor' is not a descendent of the base path 'C:/github/aspnetcore/src/Components/test/testassets/BasicTestApp'.

Interesting, so your casing is busted (notice how first part starts with C:/GitHub and second starts with C:/github). How are you opening the solution so I can try and dial down on a more concrete repro?

@BrennanConroy
Copy link
Member

From the command line (in the . .\activate.ps1 environment), cd to Components folder, then "./Components.sln"

@NTaylorMullen
Copy link
Contributor

Ah, so if you do pwd do you see a lower case github at the start of your path?

@BrennanConroy
Copy link
Member

Yeah

@ajaybhargavb
Copy link
Contributor

Yeah

Wait pwd shows you github? When we spoke offline I thought you said your actual casing for the folder in disk was GitHub.

@BrennanConroy
Copy link
Member

Yes, those are both true

@jekawo
Copy link

jekawo commented Jun 28, 2019

I have the same problem, Stack trace:

System.InvalidOperationException: 
The file 'C:/Users/jwo/source/repos/Workmodel/Workmodel/Workmodel.Client/Pages/sales.razor'
is not a descendent of the base path 
C:/Users/jwo/Source/Repos/Workmodel/Workmodel/Workmodel.Client'. at 
Microsoft.AspNetCore.Razor.Language.DefaultRazorProjectFileSystem.GetItem(String path, String fileKind)   at 
Microsoft.VisualStudio.Editor.Razor.DefaultImportDocumentManager.GetImportItems(VisualStudioDocumentTracker tracker)   at 
Microsoft.VisualStudio.Editor.Razor.DefaultImportDocumentManager.OnSubscribed(VisualStudioDocumentTracker tracker)   at 
Microsoft.VisualStudio.Editor.Razor.DefaultVisualStudioDocumentTracker.Subscribe()  at 
Microsoft.VisualStudio.Editor.Razor.DefaultRazorDocumentManager.OnTextViewOpened(ITextView textView, IEnumerable`1 subjectBuffers)   at Microsoft.VisualStudio.Editor.Razor.RazorTextViewConnectionListener.SubjectBuffersConnected(ITextView textView, ConnectionReason reason, IReadOnlyCollection`1 subjectBuffers)   at
Microsoft.VisualStudio.Text.Editor.Implementation.ConnectionManager.NonWpfListener.SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection`1 subjectBuffers)   at 
Microsoft.VisualStudio.Text.Editor.Implementation.ConnectionManager.<>c__DisplayClass7_3.<.ctor>b__3()   at 
Microsoft.VisualStudio.Text.Utilities.GuardedOperations.CallExtensionPoint(Object errorSource, Action call) 
--- End of stack trace from previous location where exception was thrown ---    
at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)

I see the case difference on the source folder

@ajaybhargavb ajaybhargavb added the Done This issue has been fixed label Jun 28, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Dec 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug. Done This issue has been fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants