net, vs comments edit

I’m working on a fairly major refactoring project, merging a couple of fairly large libraries together that have some overlapping/similar functionality. I figured this would be the perfect time to try out the reasonably new CodeRush Duplicate Code Detection feature.

The solution I’m working on has eight projects - four unit test projects, four shipping class libraries, and a total of 1248 C# code files.

I didn’t have duplicate code detection running in the background during the initial pass at the merge. Instead, I ran the detection after the initial pass to indicate some pain points where I need to start looking at combining code. (Let me apologize in advance - I wanted to show you the analysis results in a real life project, but because it’s a real project, I can’t actually show you the code in which we’re detecting duplicates. I can only show you the duplicate reports. With that…)

First, I started with the default settings (analysis level 4):

Default Duplicate Code analysis settings - level

Running that pass took about eight seconds. I found a few duplicate blocks in unit tests, which weren’t unexpected. Things having to do with similar tests (specifically validating some operator overload functionality):

Level 4 analysis

I wanted to do a little more, so I turned it up a notch to analysis level 3 and ran another pass. This time the pass took about 12 seconds and I found a lot more duplicates. This time the duplicates got into the actual shipping code and started pointing out some great places to start refactoring and merging code. This pass also grabbed more duplicates across classes (whereas the previous pass only caught duplicates within a single class/file).

Level 3 analysis

Well, since one notch on the analysis level settings was good, two must be better, right? Let’s crank it up to analysis level 2!

Duplicate Code settings at analysis level

Once you get to level 2 and below, you get a warning: Analysis might require significant CPU power and memory. I’m not too concerned with this right now since I’m running the analysis manually, but if you turn on the background analysis mechanism you’d probably want to verify that’s really what you want.

Anyway, the third pass using analysis level 2 still only took about 12 seconds… and re-running it, to verify that time, only took around 5 seconds so I’m guessing there is some sort of caching in place. (But don’t hold me to that.)

Analysis level 2

Now we’re talking! Tons of duplicates found on the level 2 run. However, while the code is very similar, there aren’t as many “automatic fixes” that the system can suggest.

Message - no automatic fix for duplicate

I don’t fault CodeRush for this - the duplicates will require a bit of non-automated thought to combine, which is why they pay us (programmers). (If they could replace us with scripts, they’d do it, right?) I’m sure the geniuses at DevExpress will shortly replace me with a keystroke in CodeRush so they can hire my cat in my place, but until then, I can use this as a checklist of things to look at.

Out of curiosity, I decided to do another run, this time at level 0 - the tightest analysis level available. This run took ~50 seconds and found so many duplicates it’s insane. Some are actionable, some are what I’d call “false positives” (like argument validation blocks - I want the validation to take place in the method being called so the stack trace is correct if there’s an exception thrown). Still, this is good stuff.

Analysis results - level

Given the balance between the too-granular detection and the not-granular-enough, I think I’m going to go with the level 2 pass, address those things, and then maybe turn it up from there.

Overall, I was really impressed with the speed of this thing. I mean, 1248 files, thousands of classes… and it takes less than a minute to do super-detailed analysis? That’s akin to magic.

Big props to DevExpress for a super-awesome tool that helps me improve my code. And, hey, some of the automatic fixes that are built in don’t hurt, either. :)

If you want to use this on your project, head over and pick up CodeRush. Honestly, it’s the first thing I install right after Visual Studio, and this sort of feature is exactly why.

I think I’m getting old and starting to fall apart.

For the last year I’ve had this Eustachian tube dysfunction that causes me to hear myself really loud in my left ear. If I’m talking, all I hear is me. When it’s really bad, I can hear my heartbeat or my breathing. Walking around would cause a thump-thump-thump sound with every step.

I ran through five days of prednisone and cipro, then 10 days, with no luck. After a 25-day-run of prednisone, I ended up going in on Monday and gettinga tympanostomy tubein my ear.

When they do it, you lay on your side and they drop some anesthetic in your ear. You lay there for a while letting that soak in, then they pop your eardrum and put the tube in. The tube itself is about the size of a pencil lead. It didn’t hurt going in, but there is still some occasional soreness a couple of days later if I yawn really big or bend over such that the blood rushes to my head.

I still hear myself a little, but in general that whole side of my head feels clearer. I’m waiting for a few days before I test to see if I can clear it.

That same day I noticed the left half of my tongue had gone numb. I let it go for a day, but it was still numb, and that freaked me out a bit, so I called the doctor’s office.

When they puncture your eardrum, some of the anesthetic runs through your Eustachian tube into other areas of your head. Apparently some hit my tongue just right (though I didn’t taste anything) and numbed me up. Today, two days later, I’m better… but that lasts a really long time. What was most freaky was that I could feel things on my tongue, I just couldn’t taste, like half of my taste buds had just died. I’m guessing some nerve got hit or something.

I also got some new glasses because Phoenix got ahold of my old ones and decided to rip the arm off. Since my prescription had expired, I had to get a new one. Upon getting my new glasses, I noticed everything looked like I was looking out a slight fish-eye lens – straight lines weren’t straight anymore. Looking at, say, a brick wall was really trippy because the whole thing looked curved. I tried them for a week and took them back.

The optician said I wasn’t adapting to the lens material, so I went from polycarbonate lenses to some other higher-density material. Same thing – weird curvy vision. Again, I tried for a week and never adapted, so I fell back to plastic lenses. (I did inquire as to whether something in my new prescription might be causing this but I was assured it was the lens material.)

I’m wearing the plastic lenses right now and still seeing curvy. Keeping in mind it takes about a week to get my glasses fixed up every time I take them back, we’re going on well over a month now since I first tried to get new glasses. I’ll give these two weeks before taking them back, but right now I hate these stupid glasses with every fiber of my being. I hate that nothing looks right. I really just want my old glasses with my old prescription even if I wasn’t seeing 20/20.

So that’s three of my five senses that have gone out on me recently and I have to say, it’s stressing me out.

I won’t even get into the pressure cooker work has become, or my lack of time to do anything at home, or the bathroom caulk I’ve replaced twice now because I can’t get it to set.

Basically I’m just tired all the time now. I’m hoping things pick up soon because I’m really just falling apart.

net, gists, build comments edit

I’m working on building a bunch of projects that all follow a specific convention for naming, NuGet packaging, and so on. As part of that, I want to run the build for each component – from clean to package – all at once rather than clean everything, then build everything, then package everything. (For the sake of the article, let’s ignore whether that’s a good idea or not and just stick with me.)

MSBuild has batching, which sort of works like “for-each,” but in examples you see you can really only “batch” on tasks. Targets (groups of tasks) allow you to specify inputs and outputs, but the “outputs” list is assumed to be files, so if it finds the outputs are up to date, it won’t run that input.

Anyway, I found this article that explains how to sort of abuse the inputs and outputs on targets so you can effectively do for-each over a target.

First, create an item list with your inputs and metadata. It doesn’t have to be files. For your inputs, pass the list of parameters. For the outputs, put a dummy value that always evaluates to empty/null – that way it’s never seen as up to date and will always run.

Here’s a sample script:

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Start"
    <SomeValues Include="First">
    <SomeValues Include="Second">
  <Target Name="Start">
    <CallTarget Targets="Parameterized" />
  <Target Name="Parameterized" Inputs="@(SomeValues)" Outputs="%(Identity).Dummy">
    <Message Text="Item = %(SomeValues.Identity)" />
    <Message Text="Meta = %(SomeValues.Meta)" />
    <Message Text="---" />

The output, as you’ll see, is that the “Parameterized” target gets called once for each item in the group.

Build output window

My 15-month-old daughter, Phoenix, is a kick in the pants. This kid has got more energy in her than I can keep up with. Of course, when she gets home from day care, she runs rampant and really wants to play, so we do.

I envision a typical play session with a different little girl going something like, “Oh, look, Cookie Monster is going into Hooper’s Store. See how he’s in there? He’s looking for cookies. Cookie starts with ‘C.’ Here comes Elmo, he’s bringing Cookie Monster some cookies. Yum!”

That’s not quite how it goes at our house. Phoenix is into Sesame Street, so we do have the Sesame Street Neighborhood Playset and figures, but she’s also into Little People, so Daddy ended up getting some figures that he could better relate to… like Batman and Joker.

Little People - Batman and

We’ve also got some Little People vehicles, like the school bus. That means a play session goes more like this for us:

Travis: Hey, Phoenix, can you find Batman? Where’s Batman?

Phoenix: <holding up the Batman figure> BAPMO!

Travis: Yes, that’s Batman! Great! I’ll play Joker, because Daddy is always the bad guy anyway. Here’s Joker, he’s getting into the bus with this little kid. Do you see how Joker is in the bus? Now Joker has a hostage. Hostage starts with ‘H’ – can you say ‘hostage?’”

Phoenix: <dancing the Batman figure around on the floor> BAPMO! BAPMO!

Travis: Right, Batman has to come stop the Joker. Joker is going to drive the bus away from Batman. Vroom! Vroom!

Phoenix: <grabbing the school bus> pbbbbbbbbbtttttt! <making raspberry/spitting noises and driving the bus around>

Travis: Perfect! Now Batman’s going to try to stop Joker… but the Joker has a secret weapon. The shark! Watch out, the shark is going to get you!

At this point, I grab this giant stuffed shark we bought at Ikea for $15. It’s the best $15 I’ve ever spent. Phoenix wrestles this shark and screams and runs and then comes back to wrestle it some more. I attack her with the shark, and she screams and giggles.

Phoenix attacking the giant

Travis: Hey, Jenn, where’s the Wonder Woman figure?

Jenn: I don’t know, have you looked in the toy box?

Travis: Yeah, but I don’t see her. Phoe, where’s Wonder Woman?

Phoenix: <ignoring me, still wrestling the shark>

Travis: Well, crap. How am I supposed to set up the Hall of Justice in Hooper’s Store if I can’t find Wonder Woman?

…and so on. I’m not sure if that’s typical of everyone or if it’s just me. I’m thinking it’s just me. (Phoenix also accompanies me on occasion to the local Things From Another World comic store. Gotta start her early.)

net comments edit

Typemock has released Isolator v7, and this is pretty much the release you’ve been waiting for.

Let’s ignore the visual test coverage, the test autocompletion, or even the automated test runner that runs your tests in the background so you instantly know when you write something that breaks a test. That stuff all rocks and you’ll love it.

This is the version that lets you run tests against different versions of Isolator without having to uninstall/reinstall different versions. A long-running issue, you’ve previously always had to build your tests and run your tests against the exact same version of Isolator. Not a huge deal if it was a product you could check in alongside your code… but you have to install it and you can only have one version installed at a time. No longer! They’ve finally fixed my #1 complaint and I am stoked.

Oh, and they added mocking for the filesystem (System.IO.File) and environment (System.Environment). Nice.

Go check it out.