Category Archives:Microsoft

Suppress warning “Field is never assigned to, and will always have its default value null” when fields are populated by MEF

By

MEF is a great framework for doing all kinds of cool things in .NET. However one thing that gets me quite often is that fields in classes that are composed by MEF using the [Import] label often generate warnings like the following:

Field 'field name' is never assigned to, and will always have its default value null

This is a warning that is safe to ignore but looks bad on your automated builds when warnings come up. So it is easy to get rid of with the SuppressMessage decoration on the field, but it is nearly impossible to find the right documentation for it (Visual Studio helpfully does not include the identifying code in the error message when rendered in the UI, thanks guys). To suppress this particular message, use the decoration:

[SuppressMessage("Microsoft.Performance", "CA1823")]

I also discovered a wonderful resource on MSDN (after literally hours of searching) which describes all the warnings and their codes so you can use them in such suppressions later on. Here is the whole list of warning identifiers, and here is the specific one for CA1823.

The unused event one is equally hard to find:

[SuppressMessage("Microsoft.Performance", "CS0219")]

Hope this saves someone a few hours looking for the docs and the correct code.

Controlling MotorHawk with C#

By

For the robot project I am using a MotorHawk board, which essentially provides motor control over USB.

Unfortunately the code that comes with it isn’t that great. I knew it was Windows only from the start, but when I had a closer look, it comes with a DLL, and sample applications in managed VB and managed C++.

If you’ve ever looked at managed C++ coming from a non-managed C++ background, you will know how ugly it is. I was not even able to get the project to build. So I set out with a couple of hours to get something nicer sorted out so I can hook it all into ROS eventually and get some real automation going on.

Where were you?

By

I was reading this interesting (and bravely-titled) post on cross-browser testing earlier and scrolling down this memory-jogging infographic detailing the history of modern web browsers when I got to the bottom where Chrome came into existence and thought back to that day in early September 2008 when Chrome was first leaked then announced and the internet went wild. Now where was I that day?

I was deep inside the heart of Microsoft UK. And the reaction was priceless.

Week of Windows Phone 7: Day 5

By

That’s it! I’ve spent the last 5 days using my HTC Trophy running Windows Phone 7 24/7.

But what’s the final verdict? Find out in the video below.

This isn’t the end of my experience with WP7; watch out for blog posts, tweets and more videos in the coming weeks when I get to use it even more.

Week of Windows Phone 7: Day 4

By

So we’ve all heard how popular the iOS App Store is. But what about Windows Phone 7′s offering? Today I’ve been having a go with the Marketplace and various apps, and giving the camera on my HTC Trophy a go.

Check out the video below.