Search

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

Active

1
0
Sign in
to vote
Type: Other
ID: 777917
Opened: 1/30/2013 12:20:58 PM
Access Restriction: Public
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 (expand)

Visual Studio Tooling version

Microsoft Roslyn CTP

Steps to reproduce

Enter the following code into an open .csx file in the Visual Studio editor and then uncomment the commented line.

#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");
});

Product Language

English

Operating System

Windows 7

Operating System Language

English

Actual results

Visual Studio will crash (at least on CTP3).

Expected results

Editor should highlight syntax/compilation error, but Visual Studio should not crash.
File Attachments
0 attachments
Sign in to post a comment.
Sign in to post a workaround.