Skip to content

Exception when renaming cshtml file in latest VS Windows #11720

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

Closed
ToddGrun opened this issue Jun 30, 2019 · 3 comments
Closed

Exception when renaming cshtml file in latest VS Windows #11720

ToddGrun opened this issue Jun 30, 2019 · 3 comments
Assignees
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates bug This issue describes a behavior which is not expected - a bug. Done This issue has been fixed

Comments

@ToddGrun
Copy link
Contributor

ToddGrun commented Jun 30, 2019

     mscorlib.dll!System.IO.__Error.WinIOError(int errorCode, string maybeFullPath) Line 145    C#
     mscorlib.dll!System.IO.FileInfo.Length.get() Line 168    C#
     Microsoft.CodeAnalysis.Workspaces.dll!Roslyn.Utilities.FileUtilities.GetFileLength(string fullPath)    Unknown
     Microsoft.CodeAnalysis.Workspaces.dll!Microsoft.CodeAnalysis.FileTextLoader.ValidateFileLength(Microsoft.CodeAnalysis.Workspace workspace, string path)    Unknown
     Microsoft.CodeAnalysis.Workspaces.dll!Microsoft.CodeAnalysis.FileTextLoader.LoadTextAndVersionAsync(Microsoft.CodeAnalysis.Workspace workspace, Microsoft.CodeAnalysis.DocumentId documentId, System.Threading.CancellationToken cancellationToken)    Unknown
>    Microsoft.CodeAnalysis.Razor.Workspaces.dll!Microsoft.CodeAnalysis.Razor.ProjectSystem.DefaultProjectSnapshotManager.DocumentClosed.AnonymousMethod__0() Line 273    C#
     mscorlib.dll!System.Runtime.CompilerServices.AsyncTaskMethodBuilder<System.__Canon>.Start<Microsoft.CodeAnalysis.Razor.ProjectSystem.DefaultProjectSnapshotManager.(ref Microsoft.CodeAnalysis.Razor.ProjectSystem.DefaultProjectSnapshotManager.<>c__DisplayClass20_0.<<DocumentClosed>b__0>d stateMachine) Line 471    C#
     Microsoft.CodeAnalysis.Razor.Workspaces.dll!Microsoft.CodeAnalysis.Razor.ProjectSystem.DefaultProjectSnapshotManager.DocumentClosed.AnonymousMethod__0()    Unknown
     Microsoft.CodeAnalysis.Razor.Workspaces.dll!Microsoft.CodeAnalysis.Razor.ProjectSystem.DocumentState.GetTextVersionAsync() Line 127    C#
     Microsoft.CodeAnalysis.Razor.Workspaces.dll!Microsoft.CodeAnalysis.Razor.ProjectSystem.DefaultDocumentSnapshot.GetTextVersionAsync() Line 56    C#
     Microsoft.CodeAnalysis.Razor.Workspaces.dll!Microsoft.CodeAnalysis.Razor.ProjectSystem.DocumentState.ComputedStateTracker.GetGeneratedOutputAndVersionCoreAsync(Microsoft.CodeAnalysis.Razor.ProjectSystem.DefaultProjectSnapshot project, Microsoft.CodeAnalysis.Razor.ProjectSystem.DocumentSnapshot document) Line 351    C#
     Microsoft.CodeAnalysis.Razor.Workspaces.dll!Microsoft.CodeAnalysis.Razor.ProjectSystem.DocumentState.ComputedStateTracker.GetGeneratedOutputAndVersionAsync(Microsoft.CodeAnalysis.Razor.ProjectSystem.DefaultProjectSnapshot project, Microsoft.CodeAnalysis.Razor.ProjectSystem.DocumentSnapshot document) Line 325    C#
     Microsoft.CodeAnalysis.Razor.Workspaces.dll!Microsoft.CodeAnalysis.Razor.ProjectSystem.DefaultDocumentSnapshot.GetGeneratedOutputAsync()    C#
     Microsoft.VisualStudio.LanguageServices.Razor.dll!Microsoft.CodeAnalysis.Razor.BackgroundDocumentGenerator.ProcessDocument(Microsoft.CodeAnalysis.Razor.ProjectSystem.ProjectSnapshot project, Microsoft.CodeAnalysis.Razor.ProjectSystem.DocumentSnapshot document) Line 129    C#
     Microsoft.VisualStudio.LanguageServices.Razor.dll!Microsoft.CodeAnalysis.Razor.BackgroundDocumentGenerator.TimerTick() Line 204    C#
     Microsoft.VisualStudio.LanguageServices.Razor.dll!Microsoft.CodeAnalysis.Razor.BackgroundDocumentGenerator.StartWorker.AnonymousMethod__41_0(object state) Line 170    C#
@Eilon Eilon added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Jul 1, 2019
@mkArtakMSFT mkArtakMSFT added PRI: 1 - Required investigate bug This issue describes a behavior which is not expected - a bug. and removed investigate labels Jul 1, 2019
@mkArtakMSFT mkArtakMSFT added this to the 3.0.0-preview8 milestone Jul 1, 2019
@mkArtakMSFT
Copy link
Contributor

Thanks @ToddGrun.

@NTaylorMullen this is your to handle.

@NTaylorMullen
Copy link

Investigated this and have a few findings.

  1. It doesn't crash VS 👍
  2. It's unavoidable because our project manager can't guarantee that an underlying file won't disappear before processing it.
  3. In VS' case renaming a Blazor file doesn't result in the project system detecting its removal until after we've attempted to parse the deleted file.
  4. This exception is reported to the activity log as an error.

I'm going to take the approach of fixing 4 because this is a pretty common case that can't always be avoided. I wish I could mitigate it by dequeuing background parsing work; however, we aren't notified that it's actually gone until we've already thrown an exception.

NTaylorMullen pushed a commit to dotnet/razor that referenced this issue Jul 17, 2019
- This reduces the noise when a user renames a .razor file in VS.
- Added tests to validate that we properly swallow FileNotFoundExceptions.

During the fix of this I found:
1. It doesn't crash VS
2. It's unavoidable because our project manager can't guarantee that an underlying file won't disappear before processing it.
3. In VS' case renaming a Razor file doesn't result in the project system detecting its removal until after we've attempted to parse the deleted file.
4. This exception is reported to the activity log as an error.

I took the approach of fixing 4 because this is a pretty common case that can't always be avoided. I wish I could mitigate it by dequeuing background parsing work; however, we aren't notified that it's actually gone until we've already thrown an exception.

dotnet/aspnetcore#11720
@rynowak
Copy link
Member

rynowak commented Jul 17, 2019

It's unavoidable because our project manager can't guarantee that an underlying file won't disappear before processing it.

Agreed, it's fundamentally a race condition.

NTaylorMullen pushed a commit to dotnet/razor that referenced this issue Jul 18, 2019
…d in ActivityLog.

- This reduces the noise when a user renames a .razor file in VS.
- Added tests to validate that we properly swallow IOExceptions and UnauthorizedAccessException.

During the fix of this I found:
1. It doesn't crash VS
2. It's unavoidable because our project manager can't guarantee that an underlying file won't disappear before processing it.
3. In VS' case renaming a Razor file doesn't result in the project system detecting its removal until after we've attempted to parse the deleted file.
4. This exception is reported to the activity log as an error.

I took the approach of fixing 4 because this is a pretty common case that can't always be avoided. I wish I could mitigate it by dequeuing background parsing work; however, we aren't notified that it's actually gone until we've already thrown an exception.

dotnet/aspnetcore#11720
NTaylorMullen pushed a commit to dotnet/razor that referenced this issue Jul 18, 2019
…d in ActivityLog.

- This reduces the noise when a user renames a .razor file in VS.
- Added tests to validate that we properly swallow IOExceptions and UnauthorizedAccessException.

During the fix of this I found:
1. It doesn't crash VS
2. It's unavoidable because our project manager can't guarantee that an underlying file won't disappear before processing it.
3. In VS' case renaming a Razor file doesn't result in the project system detecting its removal until after we've attempted to parse the deleted file.
4. This exception is reported to the activity log as an error.

I took the approach of fixing 4 because this is a pretty common case that can't always be avoided. I wish I could mitigate it by dequeuing background parsing work; however, we aren't notified that it's actually gone until we've already thrown an exception.

dotnet/aspnetcore#11720
@NTaylorMullen NTaylorMullen added the Done This issue has been fixed label Jul 18, 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-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates bug This issue describes a behavior which is not expected - a bug. Done This issue has been fixed
Projects
None yet
Development

No branches or pull requests

5 participants