Tuesday, June 10, 2008

The Resharper cult members already know this, but for those who haven't joined yet, version 4.0 released today with VS 2008 support -- huzzah,  huzzah.  No longer able to resist the chanting and promises of eternal coolness I donned my robe and installed my free copy.

I clearly should have joined sooner.  Resharper has already changed my life.  First it pointed that I had redundant overrides  in the control I was working on, which I had really meant to delete.

Then it reminded me about the new implicit type declaration keyword var, so this...

XmlDocument SomeDoc = new XmlDocument();


var SomeDoc = new XmlDocument();

Granted, that's not too exciting, but if your type declaration is something like...

Dictionary<SomeStrangeType,ANamespace.AnotherLongType> SomeDictionary = new Dictionary<SomeStrangeType,ANamespace.AnotherLongType>();

with var it becomes...

var SomeDictionary = new Dictionary<SomeStrangeType,ANamespace.AnotherLongType>();

Then Resharper pointed out something I didn't realize was available in C#, the object intializer?? VB.NET has long had something similar with the With statement (now with object initializer goodness too).  What's nice about this is that it saves repeating the instance name in front of the properties.  So this...

var MenuBinding = new MenuItemBinding();
MenuBinding.DataMember = MenuItemElementName;
MenuBinding.TextField = DisplayTextAttribute;
MenuBinding.NavigateUrlField = NavigationUrlAttribute;
MenuBinding.Depth = Depth;


var MenuBinding = new MenuItemBinding
     DataMember = MenuItemElementName,
     TextField = DisplayTextAttribute,
     NavigateUrlField = NavigationUrlAttribute,
     Depth = Depth

I was staring at this new construct when I realized that -- it shouldn't work. The project I was working on was a Framework 2.0 project and these things were in 3.0 syntax.  But the darn thing compiles and works.  Not even a single warning.  WTF?  It turns out that since 3.0 and 3.5 are based on 2.0, these are simply compiler tricks -- there is nothing fundamentally different about the types.  Here's a blog post that explores in more detail what is happening under the covers.

Not bad for 15 minutes of tooling around.  Guess I am an official member. Where's the Koolaid?

.NET | 2.0 | 3.0 | 3.5 | Resharper
Tuesday, June 10, 2008 10:24:01 PM (Eastern Standard Time, UTC-05:00)   #     Comments [0]  | 
Monday, May 19, 2008
While crawling around in VS 2008 to work on the P2P presentation for RockNUG and the NOVA Code Camp, I stumbled upon a lovely little feature under Intellisense on the Edit menu called Organize Usings.  A simple click can remove unused using statements, sort the statements or do both.  Cleans up code faster than a life style diva on a nicotine binge.

Visual Studio has default templates for all project items and they frequently includes using statements for namespaces, that well, never get used.  The class template, for example really, really wants you to use the LINQ and the System.Text namespaces. If you haven't gotten around to modifying the default templates, you'll have lots of unneeded using statements cluttering up your code.  The Organize Usings feature can help save other developers (or the future you) from wondering, "Where the heck did he use LINQ in this class?".

And just so you don't strain yourself, it is only available for C#.

Monday, May 19, 2008 11:52:34 AM (Eastern Standard Time, UTC-05:00)   #     Comments [0]  | 
Saturday, May 17, 2008
Nothing like a code camp to get jazzed about all the stuff I could be working on. It is like a revival meeting; everything is new and exciting and possible.

I took in sessions about making DotNetNuke modules and the new ASP.NET Dynamic Data extensions. Very interesting stuff.  The Dynamic Data stuff appears to be a great way to bang out admin pages with minimal effort.

I also presented my little talk about the new Peer-to-Peer Networking goodies in the .NET 3.5 framework.  This is stuff that's been possible to do with the Windows API for a long time, but has finally been exposed through the managed classes for access by mere mortals.  Here is yet another chat application that demonstrates how it all works.

The real exciting namespace is its child the PeerToPeer.Collaboration namespace.  It is a framework for building p2p apps.  Didn't have the time to delve into it fully, as it is only supported in Vista. But it did provide the first compelling reason to upgrade, so I finally succumbed.

Just need to invent the 50 hour day to get to try out all the things I'd like to.

.NET | 3.5 | p2p
Saturday, May 17, 2008 8:30:07 PM (Eastern Standard Time, UTC-05:00)   #     Comments [0]  | 

Theme design by Dean Fiala

Pick a theme: