Wednesday, August 25, 2004

Namespace "inheritance" and XmlSerializer

I've taken to writing much of my XML like this:


<foo:bar xmlns:foo="uri">
    <blah ... />
    <blah ... />
</foo:bar>


Which is to say, with an outermost element that's namespace qualified, but with all other elements belonging to no namespace. This is primarily laziness - I type a lot of XML by hand, and write a lot of XPath, and both are slightly easier with this sort of XML.


Where I got burned today was in trying to write a set of types that deserialize this XML. I started with this:


[XmlRoot("foo", Namespace="uri")]
public class Foo {
  private BlahCollection blahs = new BlahCollection(); 
 
  [XmlElement("blah")]
  public BlahCollection Blahs {
    get { return blahs; }
  }
}


And I expected it would work just fine. But I was surprised to find that when I did the deserialization, I got zero blahs in the resulting collection, even though there were two in the file. After banging my head against this problem for quite some time, I finally realized I needed to do something like this:


[XmlRoot("foo", Namespace="uri")]
public class Foo {
  private BlahCollection blahs = new BlahCollection(); 
 
  [XmlElement("blah", Namespace="")]
  public BlahCollection Blahs {
    get { return blahs; }
  }
}


Note that I'm explicitly setting the namespace to the empty string. Apparently, what was happening was that without this explicit command, the [XmlElement("blah")] attribute was assuming the Namespace value of the [XmlRoot] attribute above it. So at deserialization time, it was looking for an element called "blah" from the "uri" namespace, but finding one called "blah" that was from no namespace.


Although I know I'm nothing like the first person to come across this, it isn't called out in the docs in a way that was obvious to me, so I thought I'd mention it here.

Sunday, August 22, 2004

FlexWikiPad 0.93.1 Released - EnableVisualStyles Suspect

Ah, I have so much sympathy for Microsoft right now. I had just released version 0.93 of FlexWikiPad when I got email from several users complaining of some rather serious problems. Sure enough, I was able to verify them. D'oh!


Well, like any responsible software vendor, I committed to getting a patch out ASAP. And I did, just today: FlexWikiPad version 0.93.1 is available here. I think I got all the bad bugs that I know about. I certainly did a better job of testing this time.


There were about three different bugs that I had to address, but the worst one by far was a bit subtle. You see, users were experiencing actual crashes of the application when creating a new namespace. This was surprising to me because I had used this technique to catch unhandled exceptions. In my handler, I display a dialog box giving the user a chance to email me an exception report, and once they have, I let them go back to the application. In all the months I've been developing FlexWikiPad, this has always worked well enough to let me save my work whenever I hit some sort of unexpected problem. In other words, this was the first real “Oh *&%$ I lost work“ crash I'd seen.


The symptoms looked something like this: an unhandled exception would be thrown, after which the dialog would be displayed. The dialog would work fine (i.e. I could email myself an exception report), and then boom! The application would go down hard, with Application.Run() throwing an SEHException. This happens when someone in unmanaged code receives the dreaded COM HRESULT 0x80004005 (E_FAIL). This is a number I know well, but had hoped never to see again in my life.


I took a look at the code I've added to the application recently. On a whim, I tried removing from my Main the innocuous-looking line:


Application.EnableVisualStyles();


And sure enough, the problems went away. Which is to say, exceptions caused by bugs would still be thrown, but now they could be handled by my handler without an SEHException ensuing.


Needless to say, that line now looks like this:


// Application.EnableVisualStyles();


I can't say I understand why this change would fix the problem. EnableVisualStyles is the call you issue to ensure that you get support for Windows XP-style visual styles. Personally, I think they should have called it EnableUselessVisualFluff, but that's just me. A user requested it, so I wanted to try to support it. Of course, choosing between this and application stability was a pretty easy call.


What's really weird is that I just now compiled the source for version 0.93 to try to play around with this a bit, to see if I could maybe move the call around in Main to see what it would do. And now I can't get it to fail again. Sigh. Don't you just love software?


Either way, FlexWikiPad appears to be stable again. Download and enjoy.

Thursday, August 19, 2004

FlexWikiPad 0.93 Released

I've just released a new version of my major free-time black hole, FlexWikiPad. You can download version 0.93 here. New features in this, the latest version include:



So it's really coming along! My plans for the future look like this:


 Version 0.94 will probably be oriented toward a complete rewrite of the rendering engine, to make it totally customizable. That is, you'll be able to change a config file to add or alter: fonts, colors, and the regular expressions used to parse the document. I'll probably also take a look at performance, as I'm noticing some lag when typing in longer documents.


Version 0.95 will probably be about adding rudimentary online support, so separate usage of FwSync is not necessary. I'd also like to add a "Preview" function so you can see what your page will look like on the wiki to which you plan to post it.


Version 0.96 will probably be focused on adding hierarchical and historical navigation and fixing the tree view so it actually works.


And then if that's all the major features I can think of, I'll focus on fixing bugs, cleaning up the code, performance, and stability en route to a 1.0 release. If I can get all this done before the baby is born, so much the better.


Of course, for all I know, I'm the only one actually using the thing. But regardless, it's been an interesting experience writing a GUI app, which is not something I usually do. It's been particularly interesting developing it with a TDD approach, as GUIs present some unique challenges.

SHA-1 On the Ropes?

I'm not sure if you've seen this by now or not, but it's potentially devastating news for security pretty much everywhere if it turns out that SHA-1 has serious vulnerabilities.

Tuesday, August 17, 2004

I Need to Learn to RelaxNG

When Tim Ewald says XSD is too complicated, you know that at best the technology might be...a tad overengineered. So perhaps it's time to look into RelaxNG, an alternate schema language that lacks a lot of the weird complexities of XSD.

In truth, I've looked briefly at RelaxNG in the past. I found the basics to be very easy to understand...unlike XSD. But I haven't tried to use it in earnest yet, so my opinion is necessarily unformed. I think I'll make it a goal to use RelaxNG in some real context at the next opportunity where it's practical to do so.

Sunday, August 15, 2004

CruiseControl.NET Configuration

If you haven't checked out CruiseControl.NET yet, you really ought to. Continuous Integration (CI) is, in my opinion, only slightly behind Test Driven Development on the list of “most important software development techniques I've ever encountered,” and that puts it very high indeed. I've found CruiseControl.NET to be far more flexible and reliable than Draco.NET, the other major .NET CI tool.


Recently, I took on the role of buildmaster for FlexWiki. As we make the move to SourceForge, I thought it would be an opportune moment to get a CI system set up, primarily because it would help us avoid the “source code, source code, who's got the source code” hell that we've been in for months now. So as I sat down and set up a CruiseControl instance, I had a chance to think about our needs, and about how we should configure things to allow us to grow the project.


Well, after thinking about it for a while, I came up with something I rather like. Since it differs somewhat from the out-of-the-box CruiseControl experience, I've gone ahead and written up what I did here. Hopefully someone else will find it helpful.

Saturday, August 14, 2004

Conference Envy

There are two conferences I'd really like to go to this year: WinDev and the Applied XML Developer’s Conference 5. The confernces are both in late October, and both look to be awesome...just check the spearker list. I was invited to submit a talk to both of them, but had to refuse in both cases: my wife is pregnant, and her due date is right around then. Technically, she did say I could go, but she told me to buy a one-way ticket if I did. :)

Friday, August 13, 2004

End of an Era

It's been a long time since I've taught a DevelopMentor class: something like 18 months. Well, today I got an email from management that (rightfully, in my opinion) pointed out that it was time to make a decision about whether my name would continue to be associated with their brand. Totally fair: until now I was deriving value from them by appearing on their website, being on their internal mailing lists, and so forth, without delivering any value back to them.

I stopped teaching back in March of 2003 because I was dead tired of it. Some guys can go on teaching the same material month in and month out. I guess they derive their satisfaction from seeing people “get it” for the first time. I think that sort of attitude is fantastic, and that devotion to the educational experience paired with technical excellence in the instructors is what drew me to DM in the first place. My problem was that I simply couldn't face presenting the same 400 slides one more time. I think I'd taught slight variations of their .NET curriculum 25 or 30 times by then. It was hard to get up and be energetic and enthusiastic at that point.

So I sort of slipped sideways into consulting. I got lucky and had a bunch of gigs come my way, and they paid well, and for a while I could simply and honestly say I was too busy when DM would call and ask me to teach a class. But as time passed, I realized that I was learning a lot consulting, and that the idea of having to teach a class was something that I didn't look forward to at all. So somewhere in the last 18 months, I left DM mentally.

Today I left it for real. I let them know that - while I consider having taught at DM equivalent in prestige and educational value to my Masters from MIT - I would not be continuing my business relationship with them.

In practical terms, this doesn't mean much beyond that my name comes off their website, candera@develop.com stops working, and I don't get to be on their internal mailing lists any more. And coming as it does after such a long break, it's hardly traumatic. Or even surprising. Still, I can't help but feel a certain sense of...not loss...maybe “transition“ is the right word.

I don't know if I'll teach again in the future or not. I feel like I'm not done learning how to be a “real” developer yet, but I also know that my attention span is short enough that I'll have to do something different at some point. And I could see speaking in some form - classes, conferences, user groups, whatever - being a part of that.

Tuesday, August 10, 2004

Old Site RSS Redirect Added

If you just got a big pile of CraigBlog posts today and are wondering what happened, it's because I finally fixed the redirects for the RSS feed on my old blog. It came to my attention that not only I had forgotten to do so, but that at least a few people were still subscribed to the old, dead feed. Since I'd hate to deprive anyone of my brilliant insights (hah!), the situation has now been remedied.


If you were pointed to the old feed, though, you should really edit your subscriptions to point directly to the new feed.

Saturday, August 7, 2004

Managed Space

Jason Whittington has a blog. Jason's a friend from my DM days; these days he owns the DevelopMentor .NET curriculum. Looks like he's playing with Whidbey these days! Subscribed.

Too Much Fun With Anagrams

Inspired by David Ornstein (Sodden Rat In IV), I've been having some real fun with this site the last few days. It's nothing new: I go there every few years. But I found some good ones this time:


Craig Andera = In A Drag Race = Grand AI Race


I don't have the best name for anagrams, though, so I also tried “Mister Craig Alan Andera” and got “Giant Crania Mars Leader”, “Stir Male Arcadian Anger“, and “Tim's Anger: Canada Rail“.


Of course, my personal favorite from that same set has to be “Incites Real Rad Anagram”. :) So, since it is apparently my destiny to get others to waste time this way, I'm asking you (yes, you) to post your own best picks of your name/name variation. Don't have a blog? Post a comment here! Let see how many good ones we can get!


 

Wednesday, August 4, 2004

Coalesce

Recently, I posted some complaints about XmlSerializer and about Windows Explorer. First of all, thanks to those who posted comments trying to help out - they led to a better understanding, and to a solution, respectively. They also led to me finding out about an interesting tool. Since I know not everyone reads the comments of every post, I thought I'd coalesce the interesting bits here.



  • It turns out the XmlSerializer behavior is expected, and documented. Mostly, it's fallout from the XSD “fixed“ capability, which is basically pure evil: why would you make me go look at a schema to determine what the value of something should be? Yuck.

  • Several people correctly pointed out that files were taking forever to delete because my Recycle Bin had too much crap in it - I had thought I had emptied it recently, but I guess not. Ian Griffiths, however, posts that he uses waste.exe from Tim Tabor's BinManager to automate the process of cleaning out his Recycle Bin. Sounds interesting - I'll definitely have to check it out.

  • While I was poking around trying to figure out my XmlSerializer problems, I came across this little nugget about how to get XmlSerializer to show you the code it generates...now that might come in handy.

  • On top of that, the very cool mvp-xml project just released SGen, which lets you do some pretty serious customization of the XmlSerializer process.

Beatallica

This is too good not to share. Best title? I think it has to be “The Thing That Should Not Let It Be”.

Sunday, August 1, 2004

Please Tell Me Why

Please tell me why, when I delete a file in Windows Explorer (select file, hit the delete key), it takes like 30 seconds. From the command line, it takes no time at all.