Future features for Solution Explorer Tools

Recently both of my two big Visual Studio extension projects (Align by and Solution explorer tools) have started to reach a very nice state. A state where I’m happy with what it does and I can’t really think how to improve it. Especially the Solution explorer tools. There was always this bug in it that I was trying to get rid of and now that I have fixed it (with the help of Noah Richards and Matthew Johnson) I thought that I could be done with it. I don’t like adding features for features sake and everything worked well.

And then someone wrote something in a review which got me really excited. The Reviewer was Jason Schaeffer and here’s what he said…

It used to be a pain to make a specific change to multiple files in one project — every time I’d close a file, the solution explorer would jump to a different spot from where I needed it to be. Using the "Solution Explorer Tools", I can take control, choosing to highlight the active file in the tree only when I want. The "Collapse All" and "Collapse to Item" features are very useful too.
I wonder if it would be possible to have an "undo last collapse" button, so I can use the "Collapse to Item" feature to see where my active file, then put the tree back to being expanded the way it was.

An Undo feature! What a great idea! And the more I thought about it and how to implement it I realised I can extend the idea and make something even cooler. Saved states. How often have you done a lot of work in the Business layer then decided you need to work on your UI layer so you collapse all your business layer projects and open up your UI stuff. By saving state you could simply choose to view the “UI View” and Bam! there everything is as you want it.

And it’s the same logic as the Undo really, you’ve got to serialise the state and deserialise it. The only difference is you have to save that state to file.

As such I have a few new things to add to the Solution Explorer Tools.

– Undo (I’m thinking not just one either maybe 5 levels)

– Save state and load state – It’ll require a screen (which so far in my extensions I’ve managed to avoid) for management, though you shouldn’t need to open a screen to load a state.

 

It’s times like this I’m really glad I shared this project. This is a feature I would never have thought of by myself and I can see myself using it quite a bit. So thanks for the input Jason, expect a basic undo feature fairly soon and lots of exciting improvements in the near future.

Best of 2010

Happy 2011! Been a while since I last blogged but Christmas is over, I’ve celebrated new years and I’ve survived the floods. I still have Australia Day in a couple of days but I’m ready to blog again.

Even though I’m a bit late I thought I’d do a best of 2010 quick list.

Best Movie of 2010 – Scott Pilgrim vs the World

I went into this movie knowing nothing about what it was about. I only knew it had Michael Cera and was directed by the guy who did Shawn of the Dead and Hot Fuzz. So even though I knew it wasn’t British, I was expecting something very British. It wasn’t.

There’s something about this movie that lets you have fun with it. It’s visually interesting, doesn’t take itself too seriously and did I mention it’s just fun?

 

Best TV Show of 2010 – 24 Season 8

There was a lot of great shows in 2010, Community, a very fine season of Doctor Who, but I’m a huge 24 fan and even though it wasn’t the best season it was a great season. We got to see Jack go to a very dark place, and absolutely unleashed, nothing holding him back. We saw the downfall of President Taylor, a president which  had stronger morals than David Palmer, but fall victim to what Jack almost prophesized in the very first episode of 24 ever…

You can look the other way once, and it’s no big deal, except it makes it easier for you to compromise the next time, and pretty soon that’s all your doing; compromising, because that’s the way you think things are done. You know those guys I busted? You think they were the bad guys? Because they weren’t, they weren’t bad guys, they were just like you and me. Except they compromised… Once.

We saw Logan return and at he’s best – manipulative and power hungry.

And we got some brilliant moments my 2 favourite was Taylor’s speech

Peace must prevail, no matter the cost. No matter the cost, no matter the compromises.

While the spilt screen occurred to show Dana being tortured. It was such a powerful scene. (And that scene really reminded my of that Day 1 Episode 1 quote I posted above).

And my favourite Moment – Jack attacking the motor cage single headedly – absolutely heart pumping action.

 

Best New TV Show of 2010 – Sherlock

Community was close (technically it came out in 2009 but not in Australia till 2010) but Sherlock was fantastic. I loved the new Sherlock Holmes movie but this series put it to shame. It was witty, intelligent, true to the original material (despite being set in modern London) and fresh. As someone coming from a family that loved Sherlock Holmes (as well as other Conan Doyle books) the fact that everybody in my family loved it speaks volumes.

 

Best game of 2010 – God of War 3

I love the God of War series and this was the best of them. Brutal, bloody and easily one of the best games of all time.

 

Biggest Programming News of 2010 – Visual Studio 2010

I love Visual Studio 2010, especially how extendable it is. It’s hard to believe it hasn’t even been a year since it came out.

Tabs are evil

I hate tabs in source code. Visual studio contains a untabify command but it sucks. It only untabifies the leading whitespace characters. I was every single tab character removed.

So I wrote an extension which replaces the Visual Studio Untabify command and does it properly. It can be found here – http://visualstudiogallery.msdn.microsoft.com/en-us/f5d2ff29-cf19-4762-b4cc-01cefbbbb471

Line paste fix visual studio extension

Last week I released my third visual studio extension. Again this extension is to solve a very specific problem. This is the smallest extension I’ve written – it only took me about half an hour.

This extension is different to my others. The other two were made to add features, this one is to fix a bug in studio.

One of my favourite visual studio features is line cut copy and paste – if you have nothing selected it will copy the entire line. Paste it and it pastes above your current line.

However this behaviour slightly changed in 2010, before your caret would remain in the same place. In visual studio 2010 it moves to the beginning of the line. This is really annoying and inferior to the old way.

I finally got around to thinking about how to fix it when I was teaching a friend some basics of creating extensions. I quickly released how the extension model made the task very easy.

The model makes it easy to intercept the paste command, figure out where the caret, pass it on to do the normal paste, then afterwards change the caret to the correct position.

As such it was a really easy extension to make, but still very useful. Still this really is a bug that Microsoft should have fixed.

You can download the extension from
http://visualstudiogallery.msdn.microsoft.com/en-us/0bed93d6-2d4b-4661-a426-7071a2b386e7/view/Reviews

New theme

Finally decided to change the theme of my website. I’m a fan of dark themes, they’re much easier on your eyes. My Visual Studio theme is dark and I use the firefox plugin “Stylish” (http://userstyles.org/) to restyle common websites (Facebook, gmail) with dark themes

It looks like more of the same to me…

I don’t know how many times I’ve seen people in comments on articles about Windows Phone make the statement “It looks like more of the same to me”. Let’s have compare Windows Mobile and Windows Phone…

Are people really going to claim they “look the same”? They’re completely different. Windows mobile is just ugly. Look at those “Contacts” and “Set” buttons. What the hell does “set” even do? and why is contacts displayed differently than the items in the list? Do I need to the time displayed on the screen twice?

Windows Phone 7 has launched

I’m a bit surprised I haven’t seen more advertising for it. Telstra has it fairly hidden on there website, but they’re the only carrier who has at least updated their website to have some information on it.

Then there’s been virtually no word from Microsoft itself.

The amazing thing is Microsoft has some great ideas for ads. I think their “Really?” and “Season of the witch” ads are great. They speak to people who like the idea of smart phones, but are annoyed by how often people are always on their phones. It’s not overstating it that you can be having a conversation with someone and all of a sudden, while talking to you pull out their phones to check facebook. Also “Season of the witch” is just a great song to use.

Add to that great idea in getting the old spice guy to come to Australia. But the thing is, we’ve seen so little of all this.

I’m convinced that Windows Phone 7 is a brilliant device. I’m a Windows Phone man, and I’m a Metro UI fan. I can only hope it really takes off. And I think that, although better marketing would help, the biggest thing to drive sales will be social – I show mine to friends, they get impressed and want one, and it increases exponentially from there.

 

 

Windows 7 Taskbar tips

Ok, there’s 2 really cool things about the taskbar that isn’t immediately obvious.

First, I’ve heard many people complain that you can’t quickly open up a second instance. You have to right click and select the option. Very slow.

The solution came to me quickly, it’s like a browser. Middle click and BAM! new instance!

Second one only came to me today. Let’s say you have a lot of instances of a program open. But you just want to go to the last one you were on. You have to open up the list and look through each one for it. There’s nothing that indicates which one was used last.

The solution – Ctrl + click. BAM! Last active window opens. Even better keep doing it and it cycles through them, from most recent to least. My only problem with this is you need the keyboard. Currently double click does nothing. It should do this as well.

Removing if statements

We all us if statements. They are one of the simplest constructs, but they can be really verbose, and repetitive.

The easiest construct to replace it with is the switch statement. Everyone knows it, but it only works for a very small subset of cases (no pun intended). So I won’t bother mentioning it.

My first example, I once had to use I library which sent XML off to a web service. Each method would return a string which if null, it worked, if not an error occurred and the string was the error message.

var result = xmlSender.Verify(input);

if (result != null)
    throw new Exception(result);

result = xmlSender.Encrypt(input, out input);

if (result != null)
    throw new Exception(result);

result = xmlSender.Send(input);
if (result != null)
    throw new Exception(result);

This might not seem too bad, but imagine you had 10 of them, 20 of them. It quickly becomes very verbose and the majority of the code is redundant – throw the exception and stop continuing.

Now the best way to refactor this is the null coalesce operator. All that above magically becomes…

var result = xmlSender.Verify (input)
          ?? xmlSender.Encrypt(input, out input)
          ?? xmlSender.Send   (input);

if (result != null)
    throw new Exception(result);

Seriously how much nicer is that? Clean, and the process is together, you look at it and instantly see I Verify, Encrypt, then send. You can’t beat it.

 

Next is to use a ternary. Let’s say we want to return something based on type…

if (ctl is TextBox)
    return TextBox.TextProperty

if (ctl is CheckBox)
    return CheckBox.IsCheckedProperty;

if (ctl is Slider)
    return Slider.ValueProperty;
 
return ContentControl.ContentProperty;

Simple. but it’s something we’d like a switch statement for. Unfortunately you can’t do a switch on it. However, you can get close…

return ctl is TextBox   ? TextBox  .TextProperty
     : ctl is TextBlock ? TextBlock.TextProperty
     : ctl is CheckBox  ? CheckBox .IsCheckedProperty
     : ctl is Slider    ? Slider   .ValueProperty
     : ContentControl.ContentProperty;
 
nice, simple, and very table like, so it’s easy to process.
 
The final example is using Functional programming. The best example is linq. Instead of
foreach (var record in Records)
{
    if (record.IsMarkedForDelete())
        record.Delete();
}

now we can say…

foreach (var record in Records.Where(x => x.IsMarkedForDelete())
{
    record.Delete();
}

.NET Reflector

.NET reflector is one of those great free tools every .NET developer should have. A while back it was bought by red gate. Red gate understandable wanted to make money off of .NET reflector. This lead them to an interesting decision. They could make us pay for a tool we always had for free or the could keep it free and make a pro version with more features. They chose the latter, and I think it was the right choice. Personally the Pro version doesn’t interest me much.

But this lead to a problem. Red gate wanted to make the pro version as compelling as possible, so it’s where they’ve spent their development time. The problem is, the core of the program is it converts CIL into c# (or VB), and it should do it as cleanly as possible. Everything else is secondary. And this core is pretty much what the free version is.

As such they haven’t kept it up to date enough. One annoyance is auto implemented properties. When you look at them in reflector they look like…

[CompilerGenerated]
private MyObj <MyObj>k__BackingField;

public MyObj Prop1
{
    [CompilerGenerated]
    get
    {
        return <MyObj>k__BackingField;
    }
    [CompilerGenerated]
    set
    {
        this.<MyObj>k__BackingField = value;
    }
}

when all we want to see is…

public MyObj1 Prop1 { get; set; }

This one is sort of forgivable, we can understand it, but it’s not valid c#, copy it into a class and it won’t work.

 

To their credit they have fixed a lambdas, I’m pretty sure they use to create gibberish for them but now they create delegates. It would be nice if they they could use lambdas if they determined them to be simple – They are so much more cleaner.

They should also work on inferred generic parameters. it makes the code much cleaner.

There are a few other problems. I understand why they’re focusing on the pro features, but the core of reflector, which everyone, paying or not, care about the most, is clean correct code.

Return top

INFORMATION

The occasionally interesting thoughts & insights of a software developer