Monthly Archives: June 2013

xUnit in Action

I’ve not really seen any major purpose to use anything other than NUnit for unit testing in .NET since I switched 100% to it from a combination of mbUnit and NUnit a fair few years back. But recently I’ve had that urge we developers get, to try something different. So here’s a very brief post on using xUnit.

First off, if you need a VS2012 test runner for xUnit check out http://visualstudiogallery.msdn.microsoft.com/463c5987-f82b-46c8-a97e-b1cde42b9099.

So with NUnit we marked are test classes with [TestFixture]. xUnit doesn’t use anything to mark the class itself as a test class, it solely relies on the use of attributes on the test methods themselves (see http://xunit.codeplex.com/wikipage?title=Comparisons for a comparison of all the features between NUnit and xUnit).

The SetUp and TearDown of NUnit have been replaced with the ctor and IDisposable.Dispose on a test class and the TestFixtureSetUp and TestFixtureTearDown require you to implement IUseFixture on your test class.

So a simple example of a test is

[Fact]
public void Clear_MultipleBits_ShouldClearAllBits()
{
   Binary b = new Binary(4);
   b.Set(2, 4);
   b.Clear(2, 4);
   Assert.Equal(0, b.ToNumber());
}

So we use the Fact attribute to declare a test and Assert to verify the test. The Fact attribute also allows us to assign a DisplayName, test Name, a way to ignore (in this case Skip) a test and assign a string to this to tell everyone why the test was skipped and a timeout. So a Fact is pretty comprehensive.

On top of Fact the xUnit extensions library (available through NuGet) also adds some useful additions such as the Theory attribute which allows us to supply data to the test, for example

[
Theory, 
InlineData("1", 1),
InlineData("10", 2),
InlineData("11", 3),
InlineData("100", 4),
]
public void ToNumeric_TestVariousNumbers_BinaryStringShouldMatchDecimalValue(string s, int value)
{
   Assert.Equal(value, Binary.Parse(s).ToNumber());
}

In the above case we’ve marked the test as a Theory (which is also a Fact, hence no need for the Fact attribute). The InlineData attribute allows us to specify the arguments that will be passed into our method as arguments. So obviously you need the same number of values in the InLineData attribute as you have arguments on the method.

The Trait attribute is useful for grouping our tests (particularly if you’re using the xUnit test runner). So for example

[Fact, Trait("Bug", "1234")]
public void SomeTest()
{
}

In the above we create a new trait named Bug. In xUnit’s test runner this will create a new group within the Traits: window named Bug and add the item 1234.

The xUnit extensions project add a whole load of more attributes for use with xUnit tests, including various methods for bringing data into the test from different sources, such as from a separate class, a property on the test class, OleDb data, Excel and more.

One of the key difference with writing tests in xUnit comes with the way it handles exceptions. In NUnit we use the ExpectedException attribute. In xUnit the Assert.Throws wraps a specific method expecting an exception. For example

[Fact]
public void Divide_ExpectDivideByZeroException()
{
   Calculator c = new Calculator();
   Assert.Throws<ArgumentException>(() => c.Divide(4, 0));
}

xUnit also supports testing of async await code in the following manner

[Fact]
public async Task SomeAsyncAwaitTest()
{
   MyObject o = new MyObject();
   await o.Run();   
   Assert.True(MyObject.Completed);
}

Operator Overloading in C#

I don’t use operator overloading as much in C# as I did in my C++ days. Part of this might simply be down to the types of application I write nowadays where using operating overloading is less useful. Anyway, every time I need to overload an operator I seem to have forgotten the format/syntax. So this post is my memory dump on this subject.

Not all operators can be overloaded. To save myself some typing, check this link for a full list of the operators and what may or may not be overloaded, http://msdn.microsoft.com/en-us/library/8edha89s(v=vs.80).aspx.

Unary Operators

Unary operators, such as +, -, !, ~, ++, –, true, false (yes even true and false) can be overloaded. The syntax is as follows:

public static ReturnType operator Operator(ContainingType)
{
}

For +, -, ++ and — The ReturnType might be the actual object that the code is associated with on another valid type which makes sense for the operation (for example an int).

For the !, ~, true, false the return type must be a boolean.

The Operator is obviously the operator +, -, !, ~, ++, –, true, false and finally the ContainingType must be, well the containing type. You must overload both true and false if you want to overload either of these.

Binary Operators

Binary operators, such as +, -, *, /, %, |, &, ^, << and >> can be overloaded. The syntax is as follows:

public static ReturnType operator Operator(ContainingType, Type)
{
}

The difference being that two arguments are supplied, the two arguments may both be the ContaingType or the second argument might be a different type, for example when using a + b, a might be a complex number and b an int. In the case of the << and >> bit shift operators the second argument must be an int.

Comparison Operators

Comparison operators, such as ==, != <, <=, >, >= can be overloaded. The syntax is as per the binary operator’s syntax. The == and != must both be implemented as pairs of operators as must the > and < operators and the >= and <= operators. Implicit and Explicit operators

If you want to implement cast operators, you can implement an implicit cast should be used if the operation is guaranteed to not lose information and explicit should be used for scenarios where a loss of information is possible and/or where you want to ensure the user is aware of the possible cast.

The syntax for both implicit and explicit cast is the same

public static CastOperator operator CastType(ContainingType)
{
}

The CastOperator is either implicit or explicit, the CastType is the returning type that you’re casting to and the ContainingType is the type that contains the overloaded operator.

For a full, if somewhat pointless example, here’s a Number class that wraps and int

public class Number
{
   private int number;

   public Number(int value)
   {
      number = value;
   }

   public int Value
   {
      get { return number; }
   }

   // format for implicit cast but disabled to ensure it doesn't 
   // affect other operators, i.e. casting to in int automatically.
   //public static implicit operator int(Number n)
   //{
   //	return n.number;
   //}

   public static explicit operator int(Number n)
   {
      return n.number;
   }

   // unary operators
   public static Number operator +(Number n)
   {
      n.number = +n.number;
      return n;
   }

   public static Number operator -(Number n)
   {
      n.number = -n.number;
      return n;
   }

   public static bool operator !(Number n)
   {
      return n.number == 0;
   }

   public static bool operator ~(Number n)
   {
      return !n;
   }

   public static Number operator ++(Number n)
   {
      n.number++;
      return n;
   }

   public static Number operator --(Number n)
   {
      n.number--;
      return n;
   }

   public static bool operator true(Number n)
   {
      return n.number != 0;
   }

   public static bool operator false(Number n)
   {
      return n.number != 0;
   }

   // binary operators
   public static Number operator +(Number a, Number b)
   {
      return new Number(a.number + b.number);
   }

   public static Number operator -(Number a, Number b)
   {
      return new Number(a.number - b.number);
   }

   public static Number operator *(Number a, Number b)
   {
      return new Number(a.number * b.number);
   }

   public static Number operator /(Number a, Number b)
   {
      return new Number(a.number / b.number);
   }

   public static Number operator %(Number a, Number b)
   {
      return new Number(a.number % b.number);
   }

   public static Number operator &(Number a, Number b)
   {
      return new Number(a.number & b.number);
   }

   public static Number operator |(Number a, Number b)
   {
      return new Number(a.number | b.number);
   }

   public static Number operator ^(Number a, int b)
   {
      return new Number(a.number ^ b);
   }

   public static Number operator <<(Number a, int shiftBy)
   {
      return new Number(a.number << shiftBy);
   }

   public static Number operator >>(Number a, int shiftBy)
   {
      return new Number(a.number >> shiftBy);
   }

   // comparison operators
   public static bool operator ==(Number a, Number b)
   {
      return a.Value == b.Value;
   }

   public static bool operator !=(Number a, Number b)
   {
      return a.Value != b.Value;
   }

   public static bool operator <(Number a, Number b)
   {
      return a.Value < b.Value;
   }

   public static bool operator <=(Number a, Number b)
   {
      return a.Value <= b.Value;
   }

   public static bool operator >(Number a, Number b)
   {
      return a.Value > b.Value;
   }

   public static bool operator >=(Number a, Number b)
   {
      return a.Value >= b.Value;
   }
}

Basics of async and await

In .NET 4.5 Microsoft added the async and await keywords.

Important: By prefixing a method with the async keyword we’re telling the .NET compiler that you want to use the await keyword. The async keyword does NOT mean your method is automatically asynchronous, i.e. the compiler will not automatically assign a thread to it or a task. It simple indicates that the compiler to compile the code so that it can be suspended and resumes at await points.

If you wrote a simple async method which carried out some long running calculation the method would still be synchronous. Even if we await the result (you can have a async method without an await but this is equivalent to any other type of synchronous method and will result in compiler warnings).

So what’s the point of async and await ?

We basically use async on a method to allow us to use await. If there’s no async then we cannot use await. So the await is really where the magic happens.

The await keyword can be thought of as a continuation on a Task. It allows us to break a method into parts where we can suspend and resume a method. Below is an example of a call to some LongRunningTask

// simulation of a method running on another thread
private Task LongRunningTask()
{
   return Task.Delay(10000);
}

private async void Button_Click(object sender, RoutedEventArgs e)
{
   textBox.Text = "";
   await LongRunningTask();
   textBox.Text = "Completed";
}

What happens with the above is that a button click event takes place and the textbox is set to an empty string, then a LongRunningTask occurs on a different task. The await keyword suspends operation of this method now until the LongRunningTask completes but the UI in this case remains responsive. When the LongRunningTask ends the text is set to “Completed”. As the button was called from the UI thread the code after the await line is run on the UI thread, i.e. the synchronization context for the code after the await line is the same as the synchronization context used before the await line.

An async method may have one of three types of return, a Task (non-generic) and Task<> (generic) and a void. The return should be either of the Task objects to allow for a calling method to await the method. Void should only be used for things like event handlers.

We can implement code similar to await using Task ContinueWith, but one neat feature of async/await is in WinForms/WPF The code after the await is executed on the same thread as the async method was called on. ContinueWith, by default, is executed on another thread. Obviously this feature of async/await is very useful with the likes of WinForms as a button click might await a webservice call or the likes, then return onto the GUI thread upon return.

Self hosting SignalR

I’ve covered the steps needed to host SignalR within a web application, but we’ve also seen we can connect to SignalR through a .NET client (in my case a simple Console app.). So next we’ll cover self-hosting SignalR.

Requirements

At the time of writing you’ll need to install the following NuGet packages from Package Manager Console in Visual Studio

Install-Package Microsoft.AspNet.SignalR
Install-Package Microsoft.Owin.Hosting -Pre
Install-Package Microsoft.Owin.Host.HttpListener -Pre

You can delete the scripts folder added by SignalR, we’re really just after the assemblies

Microsoft.AspNet.SignalR.Core
Microsoft.AspNet.SignalR.Owin
Microsoft.Owin.Host.HttpListener
Microsoft.Owin.Hosting
Owin

So if you feel like only deploying the minimal assemblies you can remove anything else installed from those packages.

Edit: Since writing the above a couple of things seems to have changed on those packages, you’ll now need Microsoft.Owin assembly and WebApplication (in the below code) is now WebApp.

The Server

public class MyHub : Hub
{
   public void Send(string message)
   {
      Clients.All.sendMessage(message);
   }
}

internal class MyStartUp
{
   public void Configuration(IAppBuilder app)
   {
      // the line below works fine with the console client but not the browser client
      // app.MapHubs();
      // use the following to enable the browser client to work with the server
      HubConfiguration config = new HubConfiguration();
      config.EnableCrossDomain = true;
      config.EnableDetailedErrors = true;
      app.MapHubs(config);   
   }
}

class Program
{
   // just for demo purposes, will "beep" every 5 seconds
   private static Timer timer = new Timer(o =>
   {
      var context = GlobalHost.ConnectionManager.GetHubContext<MyHub>();
      context.Clients.All.sendMessage(DateTime.Now.ToLongTimeString() + " beep");
   });

   static void Main(string[] args)
   {
      using (WebApplication.Start<MyStartUp>("http://localhost:9100"))
      {
         // just for this demo
         TimeSpan ts = TimeSpan.FromSeconds(5);
 	 timer.Change(ts, ts);

	 Console.WriteLine("Server is running, Press <Enter> to stop");
	 Console.ReadLine();
      }
   }
}

I’ve listed all the code above, it’s all pretty self-explanatory. The URL in the start method is the URL for the server and port etc. The timer is solely used to send out a message every 5 seconds for out client to see. I’ve listed the code for a simple client below (see my post on creating a .NET client for SignalR if you need more info. on this).

Client

A simple .NET Console client…

static void Main(string[] args)
{
   HubConnection connection = new HubConnection("http://localhost:9100");
   IHubProxy proxy = connection.CreateHubProxy("myHub");
   connection.Start().ContinueWith(task =>
   {
      proxy.Invoke("Send", ".NET Client Connected");

      proxy.On<string>("sendMessage", (message) =>
      {
         Console.WriteLine(message);
      });
   });
   Console.Read();
}

If, you wish to access the server hub via JavaScript then the following is a simple example of the required JavaScript, note we create the proxy to the hub in the same way to the way we do this in the console client.

<script>
   $(function () {
      var connection = $.hubConnection("http://localhost:9100");
      var proxy = connection.createHubProxy('myHub');

      proxy.on("sendMessage", function (message) {
         $('#discussion').append('<li><strong>' + message + '</strong></li>');
      });

      connection.start().done(function () {
         proxy.invoke("Send", "Webpage client");
      }).fail(function () {
         $('#discussion').append('<li><strong>Failed to start</strong></li>')
      });
   });
</script>

Note: The at least one proxy.on event handler must be set before the connection.start or you will be able to send messages but not receive them (see http://www.asp.net/signalr/overview/hubs-api/hubs-api-guide-javascript-client#establishconnection for more information).

SignalR Minimal Server

Here’s the minimal steps required to create a SignalR server.

  • Create a new ASP.NET Empty Web Applications
  • Use NuGet to add Microsoft ASP.NET SignalR to the project
  • Right mouse click on the project select Add | Global Application Class
  • Edit the Global.asax.cs file to look like the following
    public class Global : System.Web.HttpApplication
    {
       protected void Application_Start(object sender, EventArgs e)
       {
          RouteTable.Routes.MapHubs();
       }
    }
    
  • A a new class file named MyHub and edited it to look like this
    public class MyHub : Hub
    {
       public void Send(string message)
       {
          Clients.All.sendMessage(message);
       }
    }
    
  • Finally we need an index.html pages so right mouse click on the project and select Add | HTMLPage – name it index and press ok. Then edit the file as follows
    <!DOCTYPE html>
    <html>
    <head>
        <title>Minimal SignalR</title>
    
        <script src="../Scripts/jquery-1.6.4.js"></script>
        <script src="../Scripts/jquery.signalR-1.1.2.js"></script>
        <script src="../signalr/hubs"></script>
    
        <script>
            $(function () {
               var monitor = $.connection.myHub;
               monitor.client.sendMessage = function (message) {
                  $('#discussion').append('<li><strong>' + message + '</strong></li>');
              }
              $.connection.hub.start().done(function () {
                  monitor.server.send("Starting...");
              });
            });
        </script>
    </head>
    <body>
        <h2>Minimal SignalR</h2>
    
        <div class="container">
           <ul id="discussion"></ul>
       </div>
    </body>
    
    </html>
    

The above has all the parts required to create a SignalR capable server and script in the HTML file but it doesn’t do anything, that’s for the user to implement, but just as an example to give something to see, let’s edit Global.asax.cs again and change the code to the following

private Timer timer = new Timer(o =>
{
   var context = GlobalHost.ConnectionManager.GetHubContext<MyHub>();
   context.Clients.All.sendMessage(DateTime.Now.ToLongTimeString() + " beep");
});

protected void Application_Start(object sender, EventArgs e)
{
   RouteTable.Routes.MapHubs();

   TimeSpan ts = TimeSpan.FromSeconds(5);
   timer.Change(ts, ts);
}

The code above will simply send a message every 5 seconds to any listening clients.

Note: You’ll notice how the JavaScript has the MyHub methods etc. in camel case, the proxy automatically does this for us. Also notice the JavaScript call, monitor.server.send uses the Hub method to push a message out when the script starts whereas we subscribe our function to a “known” name, one used in the MyHub (Clients.All.sendMessage). As this is dynamic there’s no compile time check on this, so make sure you get the name and case correct.

SignalR .NET client

I’ve been using SignalR from a browser but decided I wanted to try the .SignalR .NET Client code as well to see how to implement such an app. I’m not going to cover the server exception to show the Hub

public class MonitorServiceHub : Hub
{
   public void ProjectUpdate(string message)
   {
      Clients.All.projectUpdated(message);
   }
}

It’s very simple as you see. This pushed messages out to anything subscribed to the “projectUpdated” function.

So in JavaScript we have the following for the browser

<script>
var monitor = $.connection.monitorServiceHub;
monitor.client.projectUpdated = function (message) {
   $('#latest').append('<li>' + message + '</li>');
}
$.connection.hub.start().done(function () {
   monitor.server.projectUpdate("Starting Monitor");
});
</script>

So how to we create a SignalR client ?

  • Create a new Console application in Visual Studio 2012
  • Use NuGet to add the Microsoft ASP.NET SignaalR Client
  • Now, simple add the following code
    static void Main(string[] args)
    {
       HubConnection connection = new HubConnection("http://localhost/test/");
       IHubProxy proxy = connection.CreateHubProxy("monitorServiceHub");
       connection.Start().ContinueWith(task =>
       {
          proxy.Invoke("ProjectUpdate", ".NET Client Connected");
    
          proxy.On<string>("projectUpdated", (message) =>
          {
             Console.WriteLine(message);
          });
       });
       Console.Read();
    }
    

Obviously replace the http://localhost/test/ with the location of your server. This line creates the connection (as the name suggests) and then we create the proxy. Notice we use the camel case name as created by the proxy. Next we start the connection and set up a ContinueWith where the communications takes place. I’ve added code to send a message out (just to demonstrate how) using Invoke, so all clients will see when the .NET client connects. Notice this uses the method name on the class not the camel case naming. Finally we in essence subscribe to the projectUpdated messages/function and simply output whatever message we get to the Console.

Publishing an ASP.NET site to Windows 7 and IIS 7.5

I’ve just started developing a new ASP.NET MVC application on Windows 7 using IIS 7.5 and wanted to publish it to IIS. The steps are simple.

  • Right mouse click on your project and select Publish.. or select the Build menu and select Publish Selection.
  • If you do not have a profile select <New..> from the drop down and create one
  • Select Next and in my case I was deploying to a file system, so selected Publish Method: File System.
  • Browse to the target path (for example C:\inetpub\wwwroot\MyApp)
  • Set Destination URL to localhost
  • Select Next, I set this to Release configuration and delete all existing files prior to publish (obviously you choose what options you wish)
  • Select Next, the n Publish

The files and folders are copied and ready to access.

Now I was using a machine not yet set up correctly for hosting IIS and the first thing I got when trying to view http://localhost/MyApp was HTTP Error 403.14 – Forbidden. I needed to set Internet Information Services (IIS) Manager up to see the MyApp folder as an application.

  • So open IIS Manager and right mouse click on MyApp (under Sites/Default Web Site in my case).
  • Right mouse click on MyApp and select Convert to Application
  • Accept the defaults and press OK

Now reload the web page. If you get the following error in your browser Handler “ExtensionlessUrlHandler-Integrated-4.0” has a bad module “ManagedPipelineHandler” in its module list. Try opening a Visual Studio command  prompt as Administrator and type/paste

aspnet_regiis -i

(this should be available from C:\Windows\Microsoft.NET\Framework\v4.0.30319)

or to check if this is installed select the Application Pools in IIS Manager and you should see ASP.NET v4.0 (probably along with ASP.NET v4.0 Classic, Classic .NET AppPool and DefaultAppPool).

Now reload the web page and all should be working.

Note: For deploying ASP.NET MVC, make sure you set System.Web.Routing, System.Web.Mvc and System.Web.Abstractions to Copy Local = True as per documentation on http://msdn.microsoft.com/en-us/library/dd410407(v=vs.90).aspx

SQL Server creating a readonly user

I created a database in SQL Server (previously created in the post on Entity Framework – Code First). I decided I wanted to limit the access to the db to a readonly user.

So in SQL Server Management Studio I carried out the following

  • In the Server/Security/Logins right mouse click and create a new login. Login name “readonly” and set as SQL Server authentication, assign the password “readonly” for this example. Press OK.
  • Under the Databases section select the database we want to apply this user to, so in this case StorePlanDatabase
  • In the Security/Users section, right mouse click and select New User…
  • Click the ellipse (…) button next tot he Login name textbox
  • Check the [readonly] user
  • Next select the Securables item on the left of the dialog and press the Search button
  • Select specific objects…, press OK
  • Select Object Types…
  • Check the Tables option
  • Select Browse.. and check the tables you want to alter permissions for (in my case the three tables I added)
  • Now Grant Select permission to each table and press OK

Now to test this, I’m going to change the connection string in the client application from the Code First post to something this

Server=MyServer;Database=StorePlanDatabase;User Id=readonly;Password=readonly

and with the following simply code to test this

using(StorePlanDatabase context = new StorePlanDatabase())
{
   foreach(var p in context.Products)
   {
      Console.WriteLine(p.Name);
   }
}

This should now list the names of all our products stored in the database, but it doesn’t prove the permissioning worked, so if we replace the foreach loop above with

Product peas = new Product
{
   Name = "Peas",
   UPC = "9999"
};

context.Products.Add(peas);
context.SaveChanges();

We’ll get an exception due to not having valid INSERT permissions.

Writing a Windows Service

Creating

The steps for creating a Windows Services are pretty simple.

Open Visual Studio and create a new Windows Service Project. This will create a Program.cs with the relevant code to instantiate the service and then run it. The defaults service files (Service1.cs) contains an object derived from the ServiceBase. Here we implement our code. So when the Service starts the Onstart method is called, here we run whatever code we require to run the service and the OnStop (as the name suggests) we stop the code. There’s also OnPause and OnContinue overrides if needed.

Next we need to create an installer to allow the service to be installed in the Services control app.

Open the Service1.cs (or whatever the service is now called) designer and right mouse click on the background. Select Add Installer. An installer has been added which has the service name of your service and is set-up by default to install on the user’s account and in Manual startup mode. Obviously changes these to suit, plus add a description of the service which will be displayed in the Service control app.

If, on the other hand, you don’t have a Service1 designer or you wish to add an installer by hand, simple create a new C# class and add the following (bare minimum) code

[RunInstaller(true)]
public partial class MyInstaller : Installer
{
   private ServiceProcessInstaller serviceProcessInstaller;
   private ServiceInstaller serviceInstaller;

   public MyInstaller()
   {
      serviceProcessInstaller = new ServiceProcessInstaller();
      serviceInstaller = new ServiceInstaller();

      serviceProcessInstaller.Password = null;
      serviceProcessInstaller.Username = null;
			
      serviceInstaller.ServiceName = "Orchestator.Service";

      Installers.AddRange(new Installer[] { serviceProcessInstaller, serviceInstaller });
   }
}

Note: The username and password are set to null, hence when you try to install this service it will ask you for the username and password to login with. Alternatively you can set the Account on the serviceInstaller to ServiceAccount.LocalService which will not require the username/password dialog to be displayed as per the following code

serviceProcessInstaller.Account = ServiceAccount.LocalService;

Installing

To install the service without creating a fully fledged setup application simply run

installutil.exe

and to uninstall

installutil.exe /u

If you have no supplied the username and password you’ll be prompted to supply it, you will need to supply the fully qualified username, including domain or for a local user account use .\username (where .\ indicates the local machine). .\ on it’s own can be used to indicate the local machine but in the Services applet it will display .\ as Log On As, whereas you might notice other local service logins show Local Service. We can easily alter out Installer class to allow for this as outlined previously.

Debugging

Due to the time limit for startup (30 seconds) it can be difficult to debug a service as it starts. The best solution to this is to create a console app which mimics the startup process. Once the service is running we can attach to it’s instance like any other app.

Using jQuery in TypeScript

As somebody who mainly develops in C# I do miss strong typing when using JavaScript. So I’ve started to use TypeScript which solves this. But let’s face it, this would be of little use without jQuery (and other frameworks). So here’s the steps to get jQuery running with TypeScript.

  1. If you have already installed TypeScript, grab the latest VS2012 integration from http://www.typescriptlang.org/
  2. Next up, create a new project, navigate to Other Languages | TypeScript and create a new TypeScript project
  3. From the References section in the solution explorer, right mouse click and select Manage NuGet Packages and search for jquery.TypeScript.DefinitelyType and install – this will install a .ts file which includes the jQuery TypeScript definition to allows us to work with code completion
  4. Now either from NuGet, install jQuery or download from http://jquery.com/
  5. To reference the jQuery TypeScript file put /// at the top of the app.ts file, this will allow VS2012 to reference the types in the .ts file
  6. You’ll need to add a script to the default.htm file

Now we’ve got jQuery up and running in TypeScript.

Note: One problem I found on one of my machines was the code complete didn’t work for TypeScript, reading up on this on it appeared (as suggested in one of the posts) that MySQL Connector Net 6.6.5 was causing the problem. Open Control Panel | Programs | Programs and Features, location My SQL Connector 6.6.5 if its installed. Right mouse click on it and select Change and remove the Visual Studio Integration.