Sponsored Link •
|
Summary
A pointless rant
Advertisement
|
In my upcoming new job I have to write C# code on Windows. This was a choice of mine and the reasons for the choice are outside of the context of public disclosure. I am happy to say I haven't used a Microsoft product for much of anything for about 10 years or so. I write code for a living and my position remains that developing the sorts of plumbing code I write on Windows is like going to a gunfight with a knife. It's just the wrong tool.
Anyway, when I get some time at night I've been futzing about with a little program to add an XML element to Visual Studio project files. Because I have to use Visual Studio and it's doing something I don't like and to tell it not to do that something I'd have to modify 57 project files using a GUI. Which is stupid in many dimensions. I'm ok with stupid at some level. Wild cards with java generics for example. But I digress.
These project files have an extension of .csproj. If you happen to be on Windows and have one of these lying around open it up in some random editor. I used both notepad and textpad. Looks like normal XML right? As you'd expect. I mean it's either XML or some obviously non-XML thing. Right? How else would you do it? One or the other. Either, or.
Now do something like this (warning: C# code ahead):
XMLDocument document = new XMLDocument();
document.LoadXML("SomeProject.csproj");
watch in surprise as LoadXML() throws an exception telling you that the content is illegal at line 1, position 1. Look at the file in the editors. See XML? Yup. Go back and futz with the program. Try e.g.
document.Load(someStreamYouCreated)
Same exception. Be confused and frustrated.
In a fit of frustrated inspiration at 5:30AM fire up the machine, open CMD.EXE (truly an abortion of a CLI) and do this:
more SomeProject.csproj
Marvel at the 3 squiggly little characters at the beginning of the file. Indeed at line 1, position 1. WTF? In your program read past those 3 bytes and then do
document.Load(someStreamAfterReadingThreeBytes);
and see your program start to function.
Of the many reasons I truly detest Microsoft this is probably one of the largest. What absolute arrogance, in my mind, to jam 3 bytes at the front of this XML like file. Because it's not XML is it? So why make it look like it is? Is this an example of the vaunted Microsoft "innovation"? There may be some better way of loading these files. Some Microsoft approved way like VisualStudioProjectFileParser or whatever. I didn't find one when looking casually and, honestly, I don't think I should have to.
Hey, fellas! There's a whole world out here. You're not special or cool anymore. At all. Believe it.
C# is a rocking language though. I think I might prefer it to Java.
Have an opinion? Readers have already posted 13 comments about this weblog entry. Why not add yours?
If you'd like to be notified whenever Rick Kitts adds a new entry to his weblog, subscribe to his RSS feed.
Rick Kitts has been making a living writing software for a little while. He's started a company or two, worked at bigger companies, but mostly at startups. Constantly on the look out for things to help him build better systems he's a bit of a tool and process slut, though he can't bring himself to try C# or get serious about UML. Go figure. He's convinced being invited to have a weblog on Artima is the result of some glitch in the matrix. He's keeping quiet about it though. |
Sponsored Links
|