Monday, May 24, 2010

Template Driven Assembly References


In comments on my previous post @BlackMael asked about doing something similar to DX_NewItem, only with assembly references instead of Project Items.

That sounds like a challenge to me :D

My answer to this is that there already exists an AddAssemblyReference TextCommand in CodeRush. But that ‘s only useful if you know what to do with it.

So here’s a quick guide on setting up a “Dynamic List” of Assemblies

  • First Create a new Dynamic list (DevExpress\Options  Core\Dynamic Lists)

DynamicList0   

  • Then populate it with Assembly names and suitable mnemonics

DynamicList3DynamicList1

  • Finally create a template that references the variable used in the list.

DynamicList2

You’re done!

You can now use ‘ar’ in combination with any Assembly added to the assembly list and CodeRush will add your assembly reference without ever needing to go near the dreaded “Add Reference” Dialog


4 comments:

Unknown said...

What happens where there are multiple versions of the same assembly, such as Microsoft.Office.Interop.Outlook?

Rory said...

I haven't tried this, but the system should be able to use whatever information you can give it.

For example: "System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" (sans quotes) should be enough to find the 2.0 version of this assembly.

Likewise I imagine that it's possible to use a similar string, to indicate the particular version of outlook interop dll that you'd prefer.

Rory said...

I would appreciate any feedback on how well this works

Unknown said...

That works great, Rory, thanks.