Phil posted on October 14, 2009 19:37

Paul Thurrott posted something that I had missed on Channel 9: A documentary on the evolution of Visual Studio. I took the time on a Sunday night to watch both parts (Part 1 and Part 2)

Part One

The first part was a look back at the early-mid 80's: MS-DOS, green-screen, OS/2 + IBM, and the arch of Visual Basic from version 1.0 through 5.0. One thing I did NOT know was that Alan Cooper's prototype of VB was called Tripod, and later Ruby. Cooper talks about the presentation of Tripod to Microsoft reps., "Gates-clones" as he calls them.

cooperRuby-Tripod

It was interesting to me that he scoffed "… like Microsoft would care about something like this."

Some of most interesting bits were around the culture or atmosphere at Microsoft - "pulling more all-nighters at Microsoft than I did at University" was telling. It makes sense - the stakes are much higher, and the environment more professional. It reminded me slightly of Barbarians Led By Bill Gates by Edstrom and Eller. (great read!)

Microsoft was incredibly focused on building a developer community. I feel they've done an amazing job at this, and they really are unparalleled in this respect. I've seen it first-hand at various DevDays.

They traced the evolution of Visual Basic from VB3 to VB5. One interesting part for me was the comment that "you could compile an application as an executable, which was a really big deal at the time." 

Part Two

hotjava   

The second part was a tracing of the genesis or development of C#. The impetus for the new language was due to Java. In 1996/1997, Java was the hot new kid on the block with the promise of 'write once, run anywhere' on other computing platforms.

 csharp

C# was then conceived from the lawsuit and forced failure of Microsoft's implementation of their own Java VM and Visual J++. The fact that Microsoft had the market-leading Java dev toolset at the time, and then extended further with C# is amazing.

 anders

guthrie

C# is inarguably the tool that helped win more developers over to the .NET platform from the Java space. Some great shots of the 2000 PDC with Scott Guthrie presenting. It really highlighted the war with Java in the early 2000s, and how Sun just got crushed. I say: "Thank goodness!" I loved the time-to-market and LOC graphs around Microsoft's copy of the prototypical Java app PetStore.

petstore

 

The video led into some self-criticism about some Visual Studio attributes like performance, the help system, the Ladybug defect/feature website, etc. Lots of talk about how Microsoft wants to connect with its customers, and wants to be more transparent to its customers.

Part 2 then devolved, in my mind, into a sales pitch for VS2010, Team Suite, and Azure. I guess I am not too surprised :)

Some of my favorite lines (Alan Cooper is full of them!):

  • "It (Visual Basic) a very different thing from what I had originally set it out to be. It's like sending your son to college, and he comes back graduating with honors and a sex-change." says Alan Cooper.
  • "I think Basic is a terrible language. Nothing more than FORTRAN with a dress on it. It's a language that should be dragged outside and shot." says Alan Cooper.
  • "C++ - a terrible, terrible language. An awful language… basically un-learnable… not a tool for the masses." says Alan Cooper.
  • "C# - is most of the magic of C++, with a lot of the simplicity of Visual Basic combined" says Dave Mendlen
  • "You don't have to be a genius to be an application developer." - Tim Huckaby

Overall it wasn't as much a "history" of Visual Studio as I had expected. I had expected to hear more fine-grained details about how the product was built/merged. It's definitely a worthwhile watch. Check it out for yourself!

Part 1 and Part 2 of The Visual Studio Documentary at Channel 9.


Posted in: visual studio , microsoft  Tags:
Actions: E-mail | Permalink | Comments (0) |

Today's Dreaded Exception: Data at the root level is invalid.

Found a problem recently when serializing a custom object.  Here's what I was working with. Warning: this is the bathroom wall of code version. Do not copy/paste this into production.

public static XmlDocument SerializeToXmlDoc(Object obj) 
{ 
 try 
    { 
        XmlDocument xmlDoc = new XmlDocument(); 
        string xmlString =  SerializeIt(obj);             
        xmlDoc.LoadXml(xmlString); 
        return xmlDoc; 
    } 
    catch (Exception e) {   return null; } 
} 
 
public static string SerializeIt(Object obj) 
{ 
    try 
    {     
        MemoryStream memoryStream = new MemoryStream(); 
        XmlSerializer xs = new XmlSerializer(obj.GetType()); 
        XmlTextWriter xmlTextWriter = new XmlTextWriter(memoryStream, Encoding.UTF8); 
        xs.Serialize(xmlTextWriter, obj); 
 
        memoryStream = (MemoryStream)xmlTextWriter.BaseStream; 
 
        string xmlString = UTF8ByteArrayToString(memoryStream.ToArray()); 
        return xmlString; 
    } 
    catch (Exception e) { return null; } 
} 
 
private static string UTF8ByteArrayToString(byte[] characters) 
{ 
    UTF8Encoding encoding = new UTF8Encoding(); 
    String constructedString = encoding.GetString(characters); 
    return (constructedString); 
} 

The problem that was that as I passed one of my custom objects to it, I'd get this exception:
Data at the root level is invalid. Line 1, position 1.

Fine, root level… got it. Let's take a peek at what's actually trying to be loaded.

Wait, What The…?

Here's the kicker: there was a funny null/something character at the beginning of the string, and therefore, my XmlDoc couldn't successfully execute the LoadXml method. Confessional: I scraped this method from the interwebs and its bathroom wall of code. I tweaked it to suit my needs. I figured it was ready for ANY kind of POCO object. Guess not. I have hit the 10% case where it didn't work well. Well, let's fire up the Text Visualizer and figure out why that string isn't loading into an XmlDocument properly.


Text Visualizer Visual Studio xml string

Hmm. That's funny. What is that?! Turning to the Immediate Window didn't give any real answers as to the value of that unknown/bad character.

immediate window Visual Studio 2008
Hmm. Looks blank. I then copied that value right from the Immediate Window, pasted into Notepad, it comes out as a question mark. Nice! Here's the direct paste:

?xmlString.Substring(0,1)
"?"

Solved!

You could go down all kinds of kludgey roads and try to replace the first character if it's not angle bracket "<", or try and trim null chars, etc.

Turns out that a StringWriter will do the job well in this case. No more null character leading to a failed load of the string.
(via the bathroom wall of code at http://asp.net2.aspfaq.com/xml-serialization/simple-serialization.html)

public static string SerializeIt(Object obj) 
{ 
    try 
    {               
        XmlSerializer serializer = new XmlSerializer(obj.GetType()); 
        StringWriter sw = new StringWriter(); 
        serializer.Serialize(sw, obj); 
        sw.Close(); 
 
        // get the Xml as a string 
        string xmlString = sw.GetStringBuilder().ToString(); 
 
        return xmlString; 
    } 
    catch (Exception e) { return null; } 
}

 

 

 

The MemoryStream algorithm worked well for some of my POCO objects, but not for another.


Posted in: c# , visual studio , xml , serialization  Tags:
Actions: E-mail | Permalink | Comments (0) |

When hammering away at a unit test, I often found myself wanting to test the current unit test and its associated code. I of course wanted to use the debugger, break points, inspect values, use the Watch tool, etc.

The First Iteration

  • Put the cursor in the test method.
  • Go to Visual Studio IDE’s menu 
  • Click Tools - Run - Tests in Current Context
  • Debug as per normal

ide

Uh, Do It Smarter

Then I remembered that you could put the shortcuts in the right click context menu. Ah ha!

rightclick

You can see where this is going if you paid attention to the first iteration, as well as the title of this blog post. Taking your hands off the keyboard to move to the mouse adds so much more wasted time in development. File this under “what were you thinking?”.

Smartest

Now it’s all keyboard goodness:

  • Cursor in the test method
  • use a cute mnemonic in your head when you're typing in this combo. Re Test
  • Ctrl-R, Ctrl-T

What is YOUR favorite Visual Studio keyboard shortcut?


Posted in: development , shortcuts , visual studio  Tags:
Actions: E-mail | Permalink | Comments (0) |