halloween, costumes comments edit

It was raining this year and I think that put a damper on the trick-or-treat count. We also didn’t put out our “Halloween projector” that puts a festive image on our garage, so I think the rain, combined with lack of decor, resulted in quite a bit fewer kids showing up. When it was busy, it was really busy; but when it wasn’t… it was dead.

2014: 176
trick-or-treaters.

The graph is starting to look like a big mess so I will probably start keeping more like “the last five years” on there. I’ll also keep an overall average graph to keep the bigger picture.

Average Trick-or-Treaters by Time Block

The table’s also starting to get pretty wide; might have to switch it so time block goes across the top and year goes down.

Cumulative data:

</tr> </thead> </table> My costume this year was the Tenth Doctor from _Doctor Who_. Jenn was Anna from _Frozen_. We both made our costumes and [I posted a different blog article walking through how I made the suit](/archive/2014/11/05/making-my-tenth-doctor-suit/). Phoenix decided she was going to be Sleeping Beauty this time, which was a time-saver for us since she already has a ton of princess costumes. ![Travis and Jenn](https://hyqi8g-ch3301.files.1drv.com/y2pgj3Dz3hKaw8KDWRL0zpdp7XPEDIB2qX7nLr2W3U7ZB19kvmPql7fHMDWHLIDC5orV7AzK1I2CaGQ1ryZ7J_Q30Wk0E-zt9whfmhcuBzU8Ek/20141103_costumes.jpg?psid=1)
  Year
Time Block 2006 2007</th> 2008</th> 2009 2010 2011 2013 2014
6:00p - 6:30p 52 5 14 17 19 31 28 19
6:30p - 7:00p 59 45 71 51 77 80 72 54
7:00p - 7:30p 35 39 82 72 76 53 113 51
7:30p - 8:00p 16 25 45 82 48 25 80 42
8:00p - 8:30p 0 21 25 21 39 0 5 10
Total 162 139 237 243 259 189 298 176

net, ndepend comments edit

NDepend is awesome and I use it to analyze all sorts of different projects.

One of the nice things in NDepend is you can define queries that help qualify what is your code (JustMyCode) and what isn’t (notmycode).

I’ve seen two challenges lately that make rule analysis a bit tricky.

  • async and await: These generate state machines on the back end and NDepend always flags the generated code as complex (because it is). However, you can’t just exclude the code because basically the generated state machine moves your code in there, so excluding the state machine will exclude some of your code.
  • Anonymous types: I see these a lot in MVC code, for example, where the anonymous type is being used as a dictionary of values to truck around.

I haven’t figured out the async and await thing yet… but here’s how to exclude anonymous types from the JustMyCode set of code:

First, in the “Queries and Rules Explorer” window in your project, go to the “Defining JustMyCode” group.

Defining JustMyCode

In there, create a query like this:

// <Name>Discard anonymous types from JustMyCode</Name>
notmycode
from t in Application.Types where
t.Name.Contains("<>f__AnonymousType")
select new { t, t.NbLinesOfCode }

Save that query.

Now when you run your code analysis, you won’t see anonymous types causing any violations in queries.

windows comments edit

I develop using an account that is not an administrator because I want to make sure the stuff I’m working on will work without extra privileges. I have a separate local machine administrator account I can use when I need to install something or change settings.

To make my experience a little easier, I add my user account to a few items in Local Security Policy to allow me to do things like restart the machine, debug things, and use the performance monitoring tools.

In setting up a new Windows 2012 dev machine, I found that the domain Group Policy had the “Shut down the machine” policy locked down so there was no way to allow my developer account to shut down or restart. Painful.

To work around this, I created a shortcut on my Start menu that prompts me for the local machine administrator password and restarts using elevated credentials.

Here’s how:

Create a small batch file in your Documents folder or some other accessible location. I called mine restart-elevated.bat. Inside it, use the runas and shutdown commands to prompt for credentials and restart the machine:

runas /user:YOURMACHINE\administrator "shutdown -r -f -d up:0:0 -t 5"

The shutdown command I’ve specified there will…

  • Restart the computer.
  • Force running applications to close.
  • Alert the currently logged-in user and wait five seconds before doing the restart.
  • Set the shutdown reason code as “user code, planned shutdown, major reason ‘other,’ minor reason ‘other.’”

Now that you have the batch file, throw it on your Start menu. Open up C:\Users\yourusername\AppData\Roaming\Microsoft\Windows\Start Menu and make a shortcut to the batch file. It’s easy if you just right-drag the script in there and select “Create shortcut.”

Give the shortcut a nice name. I called mine “Restart Computer (Elevated)” so it’s easy to know what’s going to happen.

I also changed the icon so it’s not the default batch file icon:

  • Right-click the shortcut and select “Properties.”
  • On the “Shortcut” tab, select “Change Icon…”
  • Browse to %SystemRoot%\System32\imageres.dll and select an icon. I selected the multi-colored shield icon that indicates an administrative action.

Change the icon to something neat

Finally, hit the Start button and go to the list of applications installed. Right-click on the new shortcut and select “Pin to Start.”

Restart shortcut pinned to Start menu

That’s it - now when you need to restart as a non-admin, click that and enter the password for the local administrator account.

windows comments edit

I was setting up a new dev machine the other day and whilst attempting to install TestDriven I got a popup complaining about a BEX event.

Looking in the event log, I saw this:

Faulting application name: TestDriven.NET-3.8.2860_Enterprise_Beta.exe, version: 0.0.0.0, time stamp: 0x53e4d386
Faulting module name: TestDriven.NET-3.8.2860_Enterprise_Beta.exe, version: 0.0.0.0, time stamp: 0x53e4d386
Exception code: 0xc0000005
Fault offset: 0x003f78ae
Faulting process id: 0xe84
Faulting application start time: 0x01cfe410a15884fe
Faulting application path: E:\Installers\TestDriven.NET-3.8.2860_Enterprise_Beta.exe
Faulting module path: E:\Installers\TestDriven.NET-3.8.2860_Enterprise_Beta.exe
Report Id: df1b87dd-5003-11e4-80cd-3417ebb288e7

Nothing about a BEX error, but… odd.

Doing a little searching yielded this forum post which led me to disable the Data Execution Prevention settings for the installer.

  • Open Control Panel.
  • Go to the “System and Security” section.
  • Open the “System” option.
  • Open “Advanced System Settings.”
  • On the “Advanced” tab, click the “Settings…” button under “Performance.”
  • On the “Data Execution Prevention” tab you can either turn DEP off entirely or specifically exclude the installer using the whitelist box provided. (DEP is there to help protect you so it’s probably better to just exclude the installer unless you’re having other issues.)

vs, sublime comments edit

As developers, we’ve all argued over tabs vs. spaces, indentation size, how line endings should be, and so on.

And, of course, each project you work on has different standards for these things. Because why not.

What really kills me about these different settings, and what probably kills you, is remembering to reconfigure all your editors to match the project settings. Then when you switch, reconfigure again.

The open source project EditorConfig aims to rescue you from this nightmare. Simply place an .editorconfig file in your project and your editor can pick up the settings from there. Move to the next project (which also uses .editorconfig) and everything dynamically updates.

I don’t know why this isn’t the most popular Visual Studio add-in ever.

Here’s the deal:

Here’s the .editorconfig I use. I like tab indentation except in view markup. We’re a Windows shop, so lines end in CRLF. I hate trailing whitespace. I also like to keep the default settings for some project/VS files.

root = true

[*]
end_of_line = CRLF
indent_style = tab
trim_trailing_whitespace = true

[*.ascx]
indent_style = space
indent_size = 4

[*.aspx]
indent_style = space
indent_size = 4

[*.config]
indent_style = space
indent_size = 4

[*.cshtml]
indent_style = space
indent_size = 4

[*.csproj]
indent_style = space
indent_size = 2

[*.html]
indent_style = space
indent_size = 4

[*.resx]
indent_style = space
indent_size = 2

[*.wxi]
indent_style = space
indent_size = 4

[*.wxl]
indent_style = space
indent_size = 4

[*.wxs]
indent_style = space
indent_size = 4

Note there’s a recent update to the EditorConfig format that supports multiple matching, like:

[{*.wxl,*.wxs}]
indent_style = space
indent_size = 4

…but there’s a bug in the Sublime Text plugin around this so I’ve expanded those for now to maintain maximum compatibility.

I’ve added one of these to Autofac to help our contributors and us. It makes it really easy to switch from my (preferred) tab settings to use the spaces Autofac likes. No more debate, no more forgetting.

Now, get out there and standardize your editor settings!