Roslyn: InvalidCastException in Microsoft.CodeAnalysis.Options.OptionSet.GetOption

Created on 14 Nov 2016  Â·  5Comments  Â·  Source: dotnet/roslyn

Version Used:
D15Rel 25901.00 or d15prerel 25823.02

Steps to Reproduce:
Install below workloads:
UWP + Web Development + Cordova workload(All optional)

  1. Create one JS/TS APP
  2. Open one js/ts file
  3. Paste any info in js/ts file or press "Ctrl+V".

Expected Behavior:
No crash

Actual Behavior:
VS crashes

Parent Bug:
Bug 280468 VS crash when pasting code to index.js in cordova project

Call Stacks:

Description: The application requested process termination through System.Environment.FailFast(string message).
Message: System.InvalidCastException: Specified cast is not valid.
   at Microsoft.CodeAnalysis.Options.OptionSet.GetOption[T](PerLanguageOption`1 option, String language)
   at Microsoft.CodeAnalysis.Editor.Shared.Extensions.ITextBufferExtensions.GetFeatureOnOffOption(ITextBuffer buffer, PerLanguageOption`1 option)
Stack:
   at System.Environment.FailFast(System.String, System.Exception)
   at Microsoft.CodeAnalysis.FailFast.OnFatalException(System.Exception)
   at Microsoft.CodeAnalysis.ErrorReporting.FatalError.Report(System.Exception, System.Action`1<System.Exception>)
   at Microsoft.CodeAnalysis.Editor.Shared.Extensions.ITextBufferExtensions.GetFeatureOnOffOption(Microsoft.VisualStudio.Text.ITextBuffer, Microsoft.CodeAnalysis.Options.PerLanguageOption`1<Boolean>)
   at Microsoft.CodeAnalysis.Options.OptionSet.GetOption[[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](Microsoft.CodeAnalysis.Options.PerLanguageOption`1<Boolean>, System.String)
   at Microsoft.CodeAnalysis.Editor.Shared.Extensions.ITextBufferExtensions.GetFeatureOnOffOption(Microsoft.VisualStudio.Text.ITextBuffer, Microsoft.CodeAnalysis.Options.PerLanguageOption`1<Boolean>)
   at Microsoft.CodeAnalysis.Editor.Implementation.Formatting.FormatCommandHandler.ExecuteCommandWorker(Microsoft.CodeAnalysis.Editor.Commands.PasteCommandArgs, System.Action, System.Threading.CancellationToken)
   at Microsoft.CodeAnalysis.Editor.Implementation.Formatting.FormatCommandHandler+<>c__DisplayClass15_0.<ExecuteCommand>b__0(Microsoft.CodeAnalysis.Editor.Host.IWaitContext)
   at Microsoft.VisualStudio.LanguageServices.Implementation.Utilities.VisualStudioWaitIndicator.Wait(System.String, System.String, Boolean, Boolean, System.Action`1<Microsoft.CodeAnalysis.Editor.Host.IWaitContext>)
   at Microsoft.CodeAnalysis.Editor.Implementation.Formatting.FormatCommandHandler.ExecuteCommand(Microsoft.CodeAnalysis.Editor.Commands.PasteCommandArgs, System.Action)
   at Microsoft.CodeAnalysis.Editor.Implementation.Commands.CommandHandlerService+<>c__DisplayClass6_1`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].<ExecuteHandlers>b__1()
   at Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.RenameCommandHandler.HandlePossibleTypingCommand(Microsoft.CodeAnalysis.Editor.CommandArgs, System.Action, System.Action`1<Microsoft.VisualStudio.Text.SnapshotSpan>)
   at Microsoft.CodeAnalysis.Editor.Implementation.InlineRename.RenameCommandHandler.ExecuteCommand(Microsoft.CodeAnalysis.Editor.Commands.PasteCommandArgs, System.Action)
   at Microsoft.CodeAnalysis.Editor.Implementation.Commands.CommandHandlerService.ExecuteHandlers[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.Collections.Generic.IList`1<Microsoft.CodeAnalysis.Editor.ICommandHandler`1<System.__Canon>>, System.__Canon, System.Action)
   at Microsoft.CodeAnalysis.Editor.Implementation.Commands.CommandHandlerService.Microsoft.CodeAnalysis.Editor.ICommandHandlerService.Execute[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](Microsoft.VisualStudio.Utilities.IContentType, System.__Canon, System.Action)
   at Microsoft.VisualStudio.LanguageServices.Implementation.AbstractOleCommandTarget.ExecutePaste(Microsoft.VisualStudio.Text.ITextBuffer, Microsoft.VisualStudio.Utilities.IContentType, System.Action)
   at Microsoft.VisualStudio.LanguageServices.Implementation.AbstractOleCommandTarget.ExecuteVisualStudio97(System.Guid ByRef, UInt32, UInt32, IntPtr, IntPtr, Microsoft.VisualStudio.Text.ITextBuffer, Microsoft.VisualStudio.Utilities.IContentType)
   at Microsoft.VisualStudio.LanguageServices.Implementation.AbstractOleCommandTarget.Exec(System.Guid ByRef, UInt32, UInt32, IntPtr, IntPtr)
   at Microsoft.VisualStudio.Editor.Implementation.CommandChainNode.InnerExec(System.Guid ByRef, UInt32, UInt32, IntPtr, IntPtr)
   at Microsoft.VisualStudio.Editor.Implementation.CommandChainNode.InnerExec(System.Guid ByRef, UInt32, UInt32, IntPtr, IntPtr)
   at Microsoft.VisualStudio.Editor.Implementation.SimpleTextViewWindow.Exec(System.Guid ByRef, UInt32, UInt32, IntPtr, IntPtr)
   at Microsoft.VisualStudio.Editor.Implementation.CompoundTextViewWindow.Exec(System.Guid ByRef, UInt32, UInt32, IntPtr, IntPtr)
   at Microsoft.VisualStudio.Platform.WindowManagement.DocumentObjectSite.Exec(System.Guid ByRef, UInt32, UInt32, IntPtr, IntPtr)
   at Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.Exec(System.Guid ByRef, UInt32, UInt32, IntPtr, IntPtr)
Area-IDE Bug Tenet-Reliability

Most helpful comment

JavaScript and TypeScript are getting a lot of feedback about this problem. Please address with quickness.

All 5 comments

Is this really as simple as pasting any code in a js file crashes?

Tagging @paulvanbrenk @minestarks

So the dump I saw in the internal bug shows that we tried fetching a bool from the synced profile and got back an Int64 instead. Turns out we've never (for a very long time) had any protections about type checks.

@IlyaBiryukov It's hard to know how that got into the profile. Any idea if the machine / user account is still available to take a look at?

@Pilchie, @paulvanbrenk: I just tested this in d15prerel 25928.00 with & without signing in to VS with my user account — I'm unable to repro so not as simple as cut & paste any code in a JS file. That said we've had a number of customers report the same issue so other users are hitting this.

Here is the repro:

  1. Launch VS and sign in with [email protected]
  2. Create one JS/TS APP
  3. Open one js/ts file
  4. Paste any info in js/ts file or press "Ctrl+V"

JavaScript and TypeScript are getting a lot of feedback about this problem. Please address with quickness.

Was this page helpful?
0 / 5 - 0 ratings