gaming, playstation comments edit

Had a bit of a PS3 weekend this weekend. Realized I had the PS3 but really hadn’t played any games on it, using it primarily as a Blu-ray player, so thought it might be time to see how it went.

The first game I picked up was Echochrome. It’s sort of like “MC Escher: The Game.” The idea is that you’ve got this little mannequin that walks around on a sort of wireframe-looking level that obeys certain “laws of perspective” like “perspective existence” - if you can’t see an obstacle, it doesn’t exist. It’s sort of hard to explain - watch the video.

What I like about it is that it makes you think in a different way. A level that looks impossible to traverse is actually pretty simple if you think in perspective. It’s definitely worth the $10 I paid for it.

Darth Vader in Soul Calibur
IVThe second game I got was Soul Calibur IV. I debated whether I should get this on Xbox 360, where the “special character” included is Yoda, but decided that the PS3’s special character, Darth Vader, would just be cooler to fight with. Yoda’s neat and all, but I don’t really think “bad ass” when I see Yoda. It’s more… novelty value. Darth Vader, though, I’m thinkin’ that boy’s gonna put the beat down on someone.

Jenn and I put a few rounds in here and, while I was pretty decent at Soul Calibur III, Jenn kicked my ass like nine out of ten rounds just by button mashing. (She’s really good at button mashing.) I’ll have to bust out the guide and practice up again. It’s been a couple of years since I played SC3 so I’ve gotta get back in the groove. Still, tons of fun, and totally great graphics and sound. A total step up from SC3 and a good way to get myself into the PS3 game world.

One thing Jenn and I noticed while playing SC4: On PS3, when you turn it on, you can “sign in” to the Playstation Network with an account you create, which then associates purchases, etc., with your “profile.” This seems very similar to the Xbox Live account sort of thing, where you sign in and then play games and achievements get associated with your profile. On Xbox, though, when you play two people at the same time, both of you are signed in - I get signed in on my control, Jenn gets signed in on hers, and when we play, each of us can unlock achievements.  PS3 doesn’t have achievements (there’s a notion of “trophies” that’s still pretty new) and it turns out you can’t sign multiple people in at the same time, so we ended up playing with only me signed in even though Jenn has her own account. We both thought that was sort of weird. Hopefully they’ll fix that in the future.

gists, dotnet comments edit

I’m working on some custom FxCop rules and one that I want to do is to catch people who try to call Dispose() on objects deriving from System.ServiceModel.ClientBase<T> because they didn’t implement IDisposable in a safe manner.

So you have ClientBase<T> which looks, in a very abbreviated fashion, like this:

public abstract class ClientBase<TChannel> : ICommunicationObject,
          IDisposable where TChannel : class
{
  // Other stuff... and then
  void System.IDisposable.Dispose()
  {
    this.Close();
  }
}

Later, I might have a class that derives from that. Maybe a special type of client, and I might implement my own safe IDisposable version:

public class CustomClient : ClientBase<IMyService>,
          IDisposable where TChannel : class
{
  // Other stuff... and then
  void System.IDisposable.Dispose()
  {
    try
    {
      this.Close();
    }
    catch
    {
      this.Abort();
    }
  }
}

Try not to get hung up on the hokey implementation there, just stick with me - you have a sort of “overridden” Dispose() call. The thing is, if I put my CustomClient in a using statement, it’s the “overridden” Dispose() that executes, not the one in ClientBase<T>.

I want my FxCop rule to catch people who put something deriving from ClientBase<T> in a using block, but if you’ve got an override like in the CustomClient class there, I want it to let it go.

How do you detect that?

I’ve been all over the System.Reflection namespace and I can’t find anything. If you do Type.GetInterfaces() or Type.GetInterface() it shows that you implemented IDisposable either way because it gets all of the interfaces you implement all the way through the inheritance chain. Type.GetInterfaceMap() only returns the base implementation - the one from ClientBase<T> - in all cases. It ignores the derived class’s “override.” The only thing I can figure out that seems to work, but feels really bad, is this:

public static bool OverridesDispose(Type runtimeType)
{
  // For brevity, we're assuming the incoming Type isn't null and
  // implements IDisposable. I've omitted those checks here.
  MethodInfo info = runtimeType.GetMethod(
    "Dispose",
    BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic,
    null,
    new Type[] { },
    null);
  if (info == null)
  {
    info = runtimeType.GetMethod(
      "System.IDisposable.Dispose",
      BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic,
      null,
      new Type[] { },
      null);
  }
  if (info == null)
  {
    return false;
  }

  Type declaringType = info.DeclaringType;
  if (
    declaringType.IsGenericType &&
    declaringType.GetGenericTypeDefinition() == typeof(ClientBase<>)
  )
  {
    return false;
  }
  return true;
}

See what I’m doing? I basically query for an implicit interface implementation, then if that’s not found, I get the explicit interface implementation. If neither are found, I figure there’s no override. If one is found, then I ask what the declaring type of the method is, and if it’s the ClientBase<T> type, it’s not overridden, otherwise it is.

But the code smell! Ugh!

Am I missing some easier way to do it?

Last week was #32 for me. I had a great time the weekend before last, checking out The Dark Knight and hitting the driving range.

On the day of my birthday my parents came over and brought dinner - Mom made this super-tasty Mexican meal. I ate far too much of that and had some cheesecake when it was all done. They also got to visit the new kittens, who are starting to get big but no less wild. Jenn got me a red and black Nintendo DS with Guitar Hero: On Tour. My parents got me a case for all that and Mario Kart DS.

This past weekend, we went to the Washington County Fair on both Friday night and Saturday. I rode one of the rides called “El Niño” with Jenn and our friends Angela and K. It was pretty crazy and probably one of the better traveling fair rides I’ve been on. We also saw The Pirate’s Parrot show and it was great as usual, even though I got a pretty decent sunburn out of it. I hope they come back again next year.

In the end, it was a pretty great birthday. It’s going to be a while before I reach my next power of 2, so I’m going to have to savor this one.

dotnet, vs comments edit

Just got word from the folks over at Typemock

  • if you have an open source project and you want to use Typemock Isolator, they’re going to be coming out with a new (free) license type that allows your open source project to use it. Here’s the new licensing structure I’ve seen:

  • Commercial - $449 (same as today)
  • Personal - $200 (will include one year maintenance)
  • Open Source Project - Free
  • 21-Day Trial - Free

And, of course, discounts for upgrades, etc., on the paid licenses.

This is huge. I’ve been wanting to add tests to CR_Documentor, but it’s almost impossible to do that because of the tight coupling DXCore plugins have with the DXCore engine. For example, I’d love to be able to create a fake language element and unit test the syntax generator… but I don’t want to have to write wrapper interfaces and services for everything in DXCore that I interact with. Now I can!

Big side benefit - the folks who are unfamiliar with Isolator can see how open source projects use it and see the benefits. Sweet!

downloads, vs, coderush comments edit

I just posted the new version of CR_Documentor, version 2.1.0.0, over at Google Code. This new one hosts a tiny internal web server (instead of manually poking things into the IE DOM) so as long as you can get to localhost, you should be able to see the preview without that nasty warning. I also fixed the focus issue so it shouldn’t steal focus when the preview refreshes.

If you upgraded before and are ready for a fix, go get it!