c#
Archived Posts from this Category
Archived Posts from this Category
I think anonymous methods are a great feature, and I use them where I can to improve code readability. I thought they would be especially useful in Windows Forms controls, if you want to execute a small piece of code on the UI thread using the Control.Invoke method.
The Control.Invoke method takes a Delegate parameter, so I figured I could just do something like:
this.Invoke( delegate { this.Text = "x"; } );
Well, I was wrong, it seems that a conversion from an anonymous method (a delegate) to a Delegate is not something trivial and I got this compiler error:
Argument '1': cannot convert from 'anonymous method' to 'System.Delegate'
So, I tried to help a bit by explicitly casting the thing…
this.Invoke( (Delegate) delegate { this.Text = "x"; } );
21 comments Wednesday 15 Nov 2006 | Guy Mahieu | .net(t) , c#(t)
Ever needed to search a bunch of files to see if they contain a certain text fragment? Well I did, and now I needed to do this from a build script so the Windows Explorer was no option. At first I looked into using a windows port of grep, but since I preferred to have XML output I decided to write a small custom task for NAnt to do this.
4 comments Saturday 28 Oct 2006 | Guy Mahieu | .net(t) , c#(t) , nant(t) , regex(t)
I’m not big on advertising for commercial products, but the people at JetBrains have always managed to release exquisite software at very reasonable prices. I have been a fan since I first used their Java IDE IntelliJ IDEA (that’s already 4 years ago), and their Visual Studio add-in ReSharper made the switch from Java to .Net a lot easier for me.
This is why I’m glad that they have decided to release the unit test runner from ReSharper for free as a separate add-in called UnitRun.
From their early access program newsgroup:
We are glad to announce opening of Early Access Program for our new product — ReSharper UnitRun. This product is basically ReSharper’s unit testing functionality released separately that will be available for free. At JetBrains we believe that developers should have free tools supporting their basic needs and recent development of TDD makes unit test runners a part of the basic package. The software is free, you only will be asked to register on the first use. You may cancel the registration in which case you will be able to use the add-in for 30 days without registration prompt. ReSharper UnitRun is based on new ReSharper core which will be available as part of the next ReSharper release. Note that UnitRun cannot be installed on machines with ReSharper 2.0 installed (but you probably don’t need it in the case because ReSharper already has UnitRun inside).
You can download an early access version of the unit test runner from their EAP site.
Note that this is a pre-beta version and is bound to have some issues.
Alternatively, you can use this direct download link to the msi installer: http://download.jetbrains.com/resharper/unitrun.msi.
2 comments Monday 23 Oct 2006 | Guy Mahieu | .net(t) , c#(t) , resharper(t) , tdd(t)