Home Dashboard Directory Help
Search

Entering invalid code into .csx file can crash Visual Studio by drobson


Status: 

Active


1
0
Sign in
to vote
Type: Other
ID: 777917
Opened: 1/30/2013 12:20:58 PM
Access Restriction: Public

Description

I noticed that if I enter certain invalid code into a .csx file in the Visual Studio editor, I can crash Visual Studio. I will copy the offending code below. On the Sept Roslyn CTP, uncommenting the commented line crashes Visual Studio.

Obviously, the offending line makes no sense (can't refer to 'w' until after the method call completes) but still, Visual Studio should handle it gracefully without crashing.

#r "PresentationCore"
#r "PresentationFramework"
#r "System.Xaml"
#r "WindowsBase"

using System.Windows;
using System;

Window CreateWindow(Action action)
{
    var w = new Window();
    if (action != null)
        w.Dispatcher.Invoke(action);
    return w;
}

var w = CreateWindow(() =>
{
    // w.Content = new TextBlock("This code makes no sense");
});
Details
Sign in to post a comment.
Sign in to post a workaround.