Monday, 15 December 2008

Double Click to Open Visual Studio Solutions in Vista/2008

For a while I have been running Visual Studio under Vista (x32) and now I’m using Workstation 2008 (very happily too!).   I have UAC on, but have a policy setting to automatically elevate without showing a prompt.  (I absolutely can’t live with the dialogs…see here and here for more info).

I have also Visual Studio set to run as administrator, and that’s where the problem starts: I have not been able to open solution files by double clicking them. 

I am very grateful to “Sajeev Prasad / Arun Arcot” response to this post for the solution.

Basically, set both IDE and the loader (%programfiles%\Common Files\Microsoft Shared\MSEnv\VSLauncher.exe) to run as administrator and you can then double click to open solutions.

Thanks Sajeev and Arun!

ReSharper Plugins

I’ve been using ReSharper since it’s first EAP release (late 2003 or early 2004, if I am right) and quite simply would not want to code without it.

ReSharper is a platform that can be easily extended and it is worth noting that there are a number of excellent plugins available that to make your ReSharper experience even better.

I mentioned Scout in an earlier post, but there are plugins for NHibernate, Gallio, xUnit and also for stuff like helping extract resources for internationalisation.

Check here for more details.

XML Editor - Liquid XML Studio

I’ve just started using a great XML editor: Liquid XML Studio.  I used it when creating some XSDs the other day.  It’s really easy to use, and has a great graphical interface too. 

The thing I really really like is the feature to generate an instance of the schema.  The only other tool I’m aware of that does this is the BizTalk schema editor – but that’s a bit more of a heavyweight tool than I usually need!

It also has Visual Studio integration (with the visual editor), XPath expression builder, documentation generation and a web service browser.  It’s not cheap, but there is a free feature limited Community Edition.  There’s also the high end Developer Edition that adds a load of muscle for people working with more complex schemas, such as the OASIS schemas.

Joyful Reflections - ReSharper Scout

I’ve just found an excellent ReSharper plugin called Scout.  This lovely little beast will open Reflector when you choose Go to Declaration.  The thing I really love is that Scout also takes care of loading the appropriate assembly in Reflector.  I previously had to load the assembly in Reflector before I could browse it, which took time.  Scout makes this process seamless.

All you have to do is right click and select Go to Declaration:

Selecting the "Go to Declaration" menu item

Then you get taken to the item in Reflector and the correct assembly is loaded:

reflector

Scout will also take you to the Dotnet source code – but I haven’t got around to that yet!  You can find lots of other ReSharper plugin goodness here.

Saturday, 29 November 2008

Update on XPO and One-Way Associations

I stated in a previous post that XPO would be supporting one-way multi associations.  Unfortunately, this is now not the case.  At the time I wrote the previous post, Developer Express had marked my request as accepted, but have now changed that to rejected.

The guys at Developer Express support say that having a two-way association in your object model is fundamental to XPO multiple associations and, as my request was only to simplify code, the feature is now not to be implemented.  The bottom line from them was:
"To sum it up, we think that the current design of one-to-many associations in XPO is reliable and transparent. We are not going to change it, unless we have strong arguments for doing so."
Well, although it's a shame that it's not going to be implemented, you can't argue than that!

You can find the request thread here (but may need to register).  If you still want to keep your XPO code clean, you can use some IL enhancement with PostSharp - details here.

Thursday, 20 November 2008

Why Support One-Way Multiple Associations?

This post is to answer a question from the Developer Express support team as to why I have requested that XPO support one-way multiple associations. The primary reason for my request is to reduce code noise. When you do not want a reverse association in your model, then you should not be forced to put it in. Using the example from my previous post, if all you need is a one-way association you should be able to write:

  public class Customer : XPObject
  {
    public XPCollection Orders { get; }
  }
  public class Order : XPObject
  {
  }

However, as XPO currently requires you to implement a two-way association in your object model. You have to write something like this:

  public class Customer : XPObject
  {
    [Association("CustomerOrders")]
    public XPCollection Orders { get; }
  }
  public class Order : XPObject
  {
    [Association("CustomerOrders")]
    public Customer Customer;
  }

XPO has made me:
  • Add an attribute to my association property.
  • Give that attribute a unique string to identify the association.
  • Add a new property to my linked type.
  • Add an attribute to this new property.
  • Give this attribute the same string so as to identify it is part of the association.
I have no problem with doing that when I need the association to be two-way. Indeed, XPO does some good things for me when I do need this: it maintains the linked states of the linked instances, which is a great help! In other words, when the Association attribute is used as above, adding an order to a customer's orders will automatically set the order's customer; removing the customer from the order's customer property will remove the order from the customer's orders property. Very nice to have and certainly removes code that I would need to write.

You are probably looking at the above example and thinking that you would naturally have an association from order to customer, and I would agree. However, let's say that you have a requirement to show the recently ordered products against the customer. One way of implementing this would be:

  public class Customer : XPObject
  {
    public XPCollection RecentProducts { get; }
  }

In this circumstance, I would not want to have to implement a reverse association:

  public class Customer : XPObject
  {
    [Association("CustomerRecentProducts")]
    public XPCollection RecentProducts { get; }
  }

  public class Product : XPObject
  {
    [Association("CustomerRecentProducts")]
    public XPCollection Customers { get; }
  }

In this case I would consider the reverse association to be worse than code noise - it is structurally worng and simply should not be there! Maybe we should be suspicious of the Customer.RecentProducts association in the first place too, but that's another story!

Another time when being forced to implement a reverse association is when the two classes are in different assemblies. I would have to move the classes to avoind a circular reference. Maybe I should ask for XPO to support persistence by interface too...


Monday, 10 November 2008

Express Persistent Objects (XPO) to Support One-Way Multiple Associations

Update December 2008: this has changed and is no longer to be supported.  See here for details.

I'm happy to say that Developer Express have now accepted my request to support one-way multiple associations in XPO.  See here for more details.