Development

How to disable the visual debug toolbar for XAML in Visual Studio

I’ve had the pleasure of working with XAML lately. When running a XAML application from Visual Studio in debug mode, this nifty little toolbar is placed on top of windows:

While I have no doubt this can be useful, I often find it annoying too, so here’s how to remove it:

Open Tools and Options from the menu, and search for “Visual” in the top left corner. Remove the tick from the highlighted checkbox, and hey-presto, no more unwanted elements in your UI!

Resharper templates for unit testing with NUnit

If you’ve ever done test driven development for (TDD) over an extended period of time, you’ll probably agree that writing the same boilerplate test-code over and over can be a hassle. I’m talking specifically about structures like the following:

[TestMethod]
public void SetUp(){ ... }

[TestMethod]
public void Should_Do_Something_Or_Other(){ ... }

[TestCase("input")]
public void Should_Get_Some_Info(string targetPerson){ ... }

 

Writing a large number of tests quickly is perhaps the primary defining characteristic of a TDD process, so being able to generate code like the above quickly is an obvious advantage. If you use Resharper, you can add your own code templates to help you achieve this.

Below you’ll find three templates that I’ve been using for some time now, along with a description of how you can set them up in Visual Studio in under a minute.

Resharper Live Template Editor

Resharper Live Template Editor

Continue reading

“Operation could destabilize the runtime” caused by dynamic invoke.

Dynamically invoking code can sometimes mask errors that actually are pretty simple to fix. If you come across problems like this, it’s probably a good idea to try to reproduce the problem as close to the calling code as possible, in order to see the actual error message, instead of something generic like the title of this post.

Continue reading

How to get up and running with Python in Emacs

I did some programming in Python many years ago (around 2001), but haven’t touched it since, though I always thought I would come back to it at some point. Today, I finally got around to installing and testing it a little.

The python installation on Windows 10 was impressively easy (get it at python.org). I had it up an running in the REPL (or the IDLE, as it is called in the case of Python) almost immediately. Writing a new script is as easy as opening a new file using the standard top menu, and pressing F5 to run it in the REPL. Wonderful. Now to get it working in Emacs.

A little bit of searching indicates there is lots of relatively advanced information available, but all I wanted at this point was a quick and simple way to get a REPL with python running in Emacs. How to do this was not obvious, but in the end this too turned out to be easy.

Running python:

  • Open a Python shell in Emacs: C-c C-z
    Note: When I installed Python, I made sure to add python to the environment variables. I’m assuming this is why this worked so easily. Apparently, support for python mode (python.el) is included from emacs24 and onwards, and once pythons was installed on my system, nothing more was needed for Emacs to find and run it.

  • Run a Python script: C-c C-c
  • This assumes the file is open in Emacs, and that a python shell is running.

  • Run a selected region of a loaded script: C-c C-r

    …And that’s basically it. You should now be able to open a file. write Python code in it, and compile it in the REPL, as well as enter Python commands directly in the REPL.