Wednesday, November 28, 2007

Extension methods and .Net 2 Revisited

It appears that, in VB, you will be unable to create the requisite Attribute unless you have "no root namespace".

Now that's annoying. All my projects have root namespaces.

If I understand things correctly the difference between C# and VB in this respect is....

...In C# this value is copied into each source file as each is created.
...In VB.Net this value is used at compile-time (and background compile-time) and every class in the system is wrapped in said namespace.

This means that a large VB.Net program is very sensitive to any changes to this particular value.

If I keep my default namespaces, then I cannot create this attribute in this namespace. I had thought I could declare the Attribute using "Namespace Global.System.Runtime.CompilerServices" but the keyword cannot be used in this way.

It looks like I will have to create a brand new project, to create a brand new dll, just so that I can put a single attribute in it.

It seems that this is another Compiler/Language deficiency for which the only answer is to create another assembly.

Perhaps I will call my new dll "System.Core.Dll" :D

A simple correction

I previously reported here, a method of using "Extension methods" in a .Net 2.0 targeted project. 

Originally I stated that the extension attribute needed to be created within the "System.ComponentModel.CompilerServices" namespace. This was incorrect and has now been corrected. the namespace in which you actually need to create said attribute is in fact "System.Runtime.CompilerServices".

Assuming that there's anybody out there actually reading any of this.......Sorry about that. I'll try to be more careful.

Wednesday, November 21, 2007

SOLVED - Multi-Target .Net 2.0 or Extension Methods

Update:Corrected "System.ComponentModel.CompilerServices" to "System.Runtime.CompilerServices"

Ok so it looks like "I was wrong". (well it's not like that hasn't happened before :))

NOTE: This information was found in an article called Basic Instincts in the November Edition of MSDN Magazine in a subsection entitled "Extension Methods in .NET Framework 2.0 Apps"

It's true that a .Net 2.0 targeted application cannot reference System.Core (The DLL that contains the Extension Attribute) but it turns out that you don't need to do this anyway.

Instead, you can create your own.

Yup with the following code.....
Namespace System.Runtime.CompilerServices
    Public Class ExtensionAttribute
        Inherits Attribute
    End Class
End Namespace
------------------------------------------------------------- addition to the required import where necessary...
Imports System.Runtime.CompilerServices
------------------------------------------------------------- too can fake out the IDE and have it compile your own String.ShowAsMessage Sub thus:
Public Module Ext
    <Extension()> _
    Public Sub ShowAsMessage(ByVal SomeString As String)
    End Sub
End Module
... and now you can do strange stuff like....
Call "Fred".ShowAsMessage()

The article further notes...

...this technique will not work for ASP.NET applications targeting the .NET Framework 2.0 because they have a runtime dependency on the 2.0 command-line compiler. When those apps are deployed to Web servers that only have the .NET Framework 2.0 installed, they will not work because the 2.0 VBC.EXE command-line compiler does not understand extension methods.

So I guess we just have to be careful.

Multi-Target .Net 2.0 or Extension Methods

It seems you have to choose to use VS2008 to target .Net 2.0 OR choose to use extension methods.

But you can't pick both.

ScottGu said in a comment on his blog that

Extension Methods are actually implemented entirely by the compiler - no new IL instructions within the CLR are required to support them.

This means that you can use the VS "Orcas" C# compiler and write code that uses Extension Methods, and use the multi-targetting features to run it on a vanilla .NET 2.0 box.

However the ExtensionAttribute (required to mask a method in a module as being an extension method) is not available to add to a project which targets .Net 2.0

SOLVED - COMException in VS2008 Conversion Wizard

The COMException is caused by a few projects in my solution being bound to IIS rather than to the built in Web Development Server. I Asked on the ASP.Net Forums and you can follow the conversation here.

Studio apparently needs some rights (that it doesn't get by default) to read some info from IIS.

The work around is to launch Studio with "Run as Administrator" permission and all should work as expected.

I still consider it a bug that studio doesn't explain itself properly, but this workaround will do for now.

Tuesday, November 20, 2007

COMException in VS2008 Conversion Wizard

The first serious project I am undertaking in VS2008 has stalled at the first hurdle.

I am attempting to upgrade a VS2005 Solution to VS2008.

This particular solution has approximately 15 projects, with 5 being WebApps.

When I open this solution in VS2008 and allow the Wizard to do it's thing, It fails on 3 of the 5 WebProjects with COMException. and nothing else.

Not the best error information.

Any thoughts?

[Update: I just realized that I had no pointer to my eventual solution.]

Monday, November 19, 2007

Whatever you do DON'T Download VS2008 PRO!..

...for at least the next 4 hours. I needs to get me a copy of this and I don't need the rest of you hogging all the bandwidth :P

VS2008 - Available to MSDN now!?

Well Daniel Moth thinks it is in his post here.

I can't see it though :(

Must mean it won't be long though :D

Beta 2 of VS2008 no longer available.

That's right Beta2 of VS2008 seems to have mysteriously disappeared from MSDN subscriptions :)

Sunday, November 18, 2007

Refactoring vs Simple Code Transformation

After conversing with Trevor about the inner working of duplicate line, and a retelling of my understanding of said feature here, I have found myself wondering about a potential new feature.

Duplicate line is an interesting feature which takes advantage of RegEx to match expressions to code and then create further code based on the original code.

The self-defined purpose of "Duplicate Line" is to duplicate the line on which the caret resides.
Side-Note: I have a suggestion, registered here, which suggests that it would be useful to invoke duplicate line retroactively, when one's caret resided already on a blank line and one wished to insert a duplicate of the line above.
To this end, the 'create' pattern (RegEx) is largely the same as the 'match' pattern.

But is there any reason that they should be?

Well yes... for 'duplicate line'.... they should be, but what about some other function (from here referred to as 'code-transform') which we could activate manually in the same way and have the system match the preceding line of code and transform it into something else.

Perhaps said feature could even popup a list of named patterns which it was felt matched the current situation so that the user could pick the most appropriate one.

Does this sound familiar? Yes of course it does. It's RefactorPro isn't it?.

So why re-invent the (extremely streamlined, dead flashy and effective) wheel?

Well to be honest, I'm really not sure. My mind, like this post, started from 'Duplicate Line' and wandered away with itself from there.

I guess the difference is in how you create new "Code-Transforms" vs "Refactorings"

Refactorings are probably way more sophisticated and clever due to having a rather clever understanding of the code upon which they operate. But then again you do need to write a new piece of code for each one you create. There's the hassle of creating a new project, a new plugin, a new Refactoring and handling various events.

On the other hand, one might create a more basic type of code-transformation simply by setting up a few RegEx expressions.

This is theoretically made even easier by the existence of the DXCore's RegEx Aliasing System

So now Imagine that we have this new Code-Transform Action. We've hijacked the Ctrl+T keystroke and bound it to "Code-Transform" and we come across the following minor code...
Dim SC As New SomeClass
...which for reasons of taste and style (or lack thereof) we decide we would like to rewrite as...
Dim SC As SomeClass = New SomeClass
Well in exactly the same way as 'Duplicate line' works, you can create a match pattern...
%Dim1%%Identifier1%%mws1%%Initialization1%? %EndOfLineComment1%?
...and a replace pattern...
%Dim1%%Identifier1%%mws1%%As1%%Type1%%Initialization1%? %EndOfLineComment1%?
... and this when triggered, would introduce the extra code needed to Refactor our simple example.

Of course the reverse could easily be performed as well by simply reversing the RegEx's in another "code-transform"

There are limitations to this simplistic system. Off the top of my head I can think of "single line only Refactoring", (and therefore) transformations cannot affect code-blocks (Loops).

but there might be some merit to this idea.

What do you think? All comments/thoughts appreciated

Cheatsheet 1 - RegEx Expressions

This post is more for myself than for anything else. It is to remind me of the location of a good cheatsheet for Regular expressions

Held at

Duplicate line - How does it work?

Note: Information in this post is based entirely on observation. It contains no insider knowledge whatsoever.

So how does it work? Well..."Duplicate line" doesn't strictly duplicate the line. It creates a transformation of a copy of the line and then expands the transformation into a new line underneath the original.

So why does it do that? Wouldn't it be simpler to just copy the line of code?

Well yes but then again, how useful would that really be?

You'd have an exact copy of the line you already had. But then typically you don't want an exact copy of the code. You typically want a version which is slightly different.

For example you might want to duplicate a variable declaration but then change the name of the variable which is being declared. Or perhaps duplicate a method call but then alter the parameters that are passed.

In these cases it is better for CodeRush to help you out by setting up which part of the new code is selected and placing field wrappers around other selected bits.

And this is what it does.

It can do this because of several pre-setup rules each comprising a pattern to match code and another to construct code.

Thus a match pattern of...
%SubOrFunction1%%Identifier1% \( %ParamsDec1%? \) (%As1%%Type1%)? %EndOfLineComment1%?
...together with a Create pattern of ...
%SubOrFunction1%«BlockAnchor»%Identifier1%«Cursor» ( %ParamsDec1% ) %As1%%Type1% %EndOfLineComment1%
...allows us to duplicate...
Dim SomeVar as Integer
... and have CodeRush immediately highlight "SomeVar" in the duplicate ready for replacement.

Tuesday, November 13, 2007

Behavior in Vista Newsgroup

Sometimes I discuss (have a blazing row with) my father about all sorts of things. We each explain (at great volume) our points of view to the other hoping to persuade them (by beating any given point to death) that our view is the more accurate.

Observers of this behavior will wonder if they shouldn't move the sharp objects out of the room. Just to be on the safe side.

But the truth is that my father and I have the greatest respect for one another.
We can just be very bad at listening to one another. :)

Whilst looking for a suitable newsgroup in order to post about my Vista problem I came across

I posted about my problem and went about my business. I had naturally added this newsgroup to my newsreader Omea Pro, so when I was informed by said reader that an absolute torrent of posts had appeared in said newsgroup, my interest was of course piqued.

I clicked the folder and started to read the titles of the posts hoping for some response to mine.

I'm afraid that I have to report, to those of you lucky enough not to already know, that the 5 year olds have taken over this newsgroup.

There are some valid informative posts in this newsgroup, but they are largely hidden, for the moment at least, by the relative avalanche of "alternative" posts wherein the correspondents have long forgotten any actual facts that their arguments might have been based on, and settled instead upon the time honored strategy of name-calling.

The signal:noise ratio is approx 10-15:1

Wow that's a lot of Crap. Do these people really have nothing better to do that to "virtually" shout names at one another across the ether can they really maintain this constant level of bickering about nothing.

My 2 eldest children are rather adept at fighting in that way that siblings will do about almost anything. But even they eventually get bored and give up.

I hope that I never reach the stage where reasoned argument is forsaken and personal flaming rapidly becomes the default strategy.

I think I'm going to start listening to my father a little more.

Vista Ultimate, 64-bit, VS2005, "Run as Administrator"

As the title suggests I run Vista 64-bit (at least at work). I have a core2duo something or other and a whopping 4Gig of RAM.

I run VS2005 (although I think I may be switching very soon :P). and it runs very well apart from one thing.

I can't switch to it.

Well that may be over-exaggerating things a little.

I can switch to it...using Alt tab
I can switch to it...using the task-bar
I can switch to clicking on it when it's in the background.

but I can't switch to it when I click on it in the background and I'm not already running a UAC elevated process.

Yes that's right, it's as if the Elevated  processes all run in a different desktop all the time.   There's no grayed out background. there's no prompt asking me if I want to allow this action.

But none the less I cannot switch from notepad to VS2005 by clicking on VS2005 in the background of Notepad.

Now I do run VS2005 elevated as Administrator, because encourages me to every time it loads by showing me this screenimage

Why I continue to have it show the message, I don't know. I thought it might go away once I told the .exe to "Run as Administrator" every time it loads. But no, this does not appear to be the case.

I have installed VS2005 SP1 and I have applied the Vista update for same.

However... I'm not yet been 100% totally forthcoming with the full facts.... You see... It's not just VS2005 that is doing this to me.

There's another culprit and It's none other than IIS7.

So with this baffling combination of circumstances, can someone somewhere tell me what's going on here and how I can fix it.

I would love to imagine that this will be fixed in a matter of weeks when I install VS2008, but I doubt it.


So how's about it... anyone... anyone at all?

The time has come.... VS2003... you're fired.

Ok sure that was cheesy, but come on..... Just read the title again. it said "VS2003". This is a product whose name at least is soon to be out of date by 5 years. (ok nobody say XP)

I'm just sick of maintaining code that's just that old. (ok nobody say VB6)

The time has come. I am mere days now from the rollout of the last of our products to be upgraded from using version 1.1 of the .Net framework to version 2.0.

And not a minute too soon because version 3.0 is already out and version 3.5 is due out before the end of this month.

It is my sad (ecstatically happy really) duty to inform you that VS2003 is finally on it's way out. And to that end I must further inform the populace at large (or small in the case of the readership of this blog) that I will no longer be allowing said framework to hold back any of my plugins either.

I have a reasonably new core2duo 64-bit machine with 4 Gigs of ram running vista ultimate 64-bit. and I don't mean to sully (no Mulder or X-Files jokes allowed) it with any of that .Net 1.1 crap (ok no Vista cracks either).

I will be moving all plugins that are deemed worthy, to version 2.0 or better of the framework just as soon as I can find the time. (yeah I know... that could lengthen their lives by years)

I will attempt to mark their source in Subversion in such a way as to allow the 1.1 versions to live on in some sense but that's about it.

VS2005... My mate multi-targeting says your days are seriously numbered.

But VS2003 and  .Net 1.1...... You're fired.

A nice stress-free holiday.

Yup that was the plan..

And to be fair it was quite a stress-free holiday. The journey home and the subsequent few days were a little more tense.

You see the idea was that given our tight financial situation we would not be going abroad or holidaying in any official location. We would instead holiday by taking a break from the norm. We would put ourselves beyond the reach of the Internet.

This is a big step as, for my wife (Anne) and I, the computers have largely replaced the television as our primary indoor (non adult-themmed) entertainment.

We live on the south coast of England and so we don't get to see my Anne's family very much. (Like all families it should be understood that for some members this is a good thing and for others it is not so good.) So we planned to spend the first few days of our break, visiting with her family "Up North" in Halifax.

This is a journey of some 286 miles which Google maps informs me should have taken roughly 5 hours. The route I took was about 20 miles more than this but took about the same time. All told, including numerous toilet and food breaks, we took about 6.5 hours to do this trip in the northward direction.

Once arrived we spent a pleasant couple of days in the company of Anne's Parents, Sister, Niece and their respective families. A good time was had and we managed to get off pretty lightly when it came to holiday junk acquired. I even managed to get the car's M.O.T (Mandatory, once yearly, minimum roadworthiness check here in the UK) renewed whilst everyone else generally wandered around the shops looking for holiday junk to fill the car with.

And so came the time of the return journey.

The car was packed, the kids were packed and some holiday junk was packed. We drove around the area passing at each family home to say goodbye and then we were off.

I think it was around 7pm on Tuesday evening. [This time was chosen, in theory to be good for getting the kids to sleep at given that it is their usual bed time. And even those of you with no kids whatsoever should appreciate that it is far less stressful to travel with kids who are unconscious than with kids who are constantly talking: I'm hungry", "I'm Thirsty", " I need the toilet", "Are we nearly there yet?". And this can all be in the first 10 minutes.] We set of at a fair pace (Breaking no speed limits or other sensible driving guidelines at all. Honest) and covered what I thought to be a fair distance. Google says it was about 112 miles in 2 hours. [I dispute this and suggest it was more like 100 but who am I to argue with the great Google :)]

It was at this point that things started to take a turn for the worse. We suddenly noticed a suspicious-looking light on the dashboard. It looked like an engine with little lightning strike through it. Then it disappeared. A minute later it was back again. A minute late it was gone again.

We got a little worried and stopped the car at the nearest service station to have a look. We stopped the car opened the bonnet (That's what we call the hood for any Americans out there:) ) and I used my considerable "mechanical engineering skillz" to confirm for my wife that yes indeed, we still had an engine and no it did not appear to have been struck by lightning.

Happy with my conclusion I suggested that not would be a good time to get everyone out of the car and feed and water the family. This seemed good because it would be a break on my terms rather than on those of my children. So we trooped into the service station (Kids in PJs and everything) for some food.

Food was (for a change) not bad and everybody felt better. Everybody got back in the car and we noted with optimism that the warning light was now out and all seemed normal.

Back on the road and a few miles further on we saw a different warning light come on. You should have figured out by now that I know diddly about cars and so this time we looked in the manual to find out what was happening.

The light said the manual indicates the failure of the automatic transmission. (Auto-Gearbox for those, like me, who would have had to ask their wives what this meant).

It then went on to say that since the automatic gears we're knackered, that we should shift manually instead. Well that seemed fair enough. I assumed (and you know what they say about assumptions) that we could get away with this until we could call a mechanic at home.

So instead of leaving the car in D(Drive) we now have to switch from 1 through 3 appropriately. Fine we can do that. I learned and am licensed in a manual so these concepts are now new to me even if doing so in an automatic is a little strange for me.

So we continue a little further.... and then Anne points out that although this light is still on, the rest of the dashboard has gone dark.... a moment later a seatbelt warning light had come on. Suddenly Anne, who is driving, says she thinks the car is loosing power. Literally she is having to push the accelerator further to get any kind of momentum from the engine.

The car is indeed losing power so we decided (rather quickly that the car was about to die on us and perhaps the middle lane (out of a possible 3) on the M1 (major motorway/Highway running North-South) was not the best place for this to happen. Especially at about 21:30 at night in reasonably high traffic.

So as quick as we can we get into the left-most lane (the slow lane) where we noticed signs indicating that we were just about to hit the off ramp to another service station. This would be a very good place to stop so we indicated and drifted left in to what we thought was the off ramp but turned out to be just the hard-shoulder (no idea if those outside the UK have another term for this but it's a lane to the left of the slow lane used in case of emergency) we quickly realized our mistake as it seemed that if we continued in this lane we were going to hit a bridge. Not good. We indicated and drove back out onto the slow lane, drove another 10 yards or so and my wife declared that all power seemed to have disappeared. Having already passed the bridge, we steered left again onto the hard shoulder and to our relief saw that this was indeed the off-ramp. However, having no power save for the momentum already ours, we saw that we would not reach the service station and so steered (For by not it's not really driving, there being no drive) onto the true hard shoulder where the car was brought (more from lack of power than from applied brakes) to a halt.

So 21:30ish at night, it's dark and it's cold but there's a service station within sight. My 3 kids Molly(5), Daniel(4) and Rosie(1) year old are asleep on the back seat of the car but we're still technically on a motorway. This is not a safe position to be in. It is not a happy position to be in. I could carry the elder 2 kids if need be and Anne could carry Rosie easily enough but I wasn't happy about the idea of walking any length of road in the dark under those conditions.

We quickly decided that we couldn't stay here as it was possible we could get hit by some fool driver at any moment. Then we noticed that the Hazard lights (emergency lights on the car) which we had remembered to turn on, were not working any more. The headlights had also failed. At this point I was not thinking much of that M.O.T I had had done.

So that did it. It's bad enough being in a broken down car at the side of the motorway at night in the rain (Did I mention the rain).

But now the car has lost all electrical power including anything that might power the Hazard lights. We had to get out.

Just then we noticed some blue flashing lights ahead. It seems that some police had just driven past on patrol and had seen the car. The offered to give us a lift to the service station. It took some doing to rouse my 2 eldest but once their subconscious minds were vaguely aware of getting to ride in a police car, the woke up with amazing speed. The Police dropped us off at the service Station and said they would call Highway maintenance or some such group who would help me get my car towed off the motorway. I booked the family into a room for the night after all who knew how long it might take to get this all sorted. Then I resolved to go back to the car to get some blankets and nappies (diapers) and anything else which might have been considered essential.

I took a safe(ish) route going outside of the barriers that a car might potentially have hit, thus affording me some protection. I reached the car and opened it up. I realized that since nothing was functioning anyway, I might as well turn everything off. Off went the headlights, the hazards and the heater. I shut the car and went to the boot (trunk for my American friends) to retrieve the bits for Rosie. Having got these I decided it would be good since I was here already to pick something up to occupy my kids, as sleep was not going to be foremost in their little heads after something like a ride in a police car. So I went to open the car up (meaning to retrieve some picture books or toys or something) and discovered that now the central locking mechanism of the car had decided to give out.In and of itself I could understand this as I can see where electrical power would help this subsystem in it's duties. but what I don't understand is why I couldn't even turn the key to unlock the passenger door itself. Strange. I resolved to figure this out later. I had already got my hands on the vitals necessary for looking after my Rosie.

On the way back I my mobile phone began to ring. It was the Highway guys. they informed me that I could not leave the car where it was and that I would have to move it or they have the police do it for me at a probable cost of over £100. This, I thought, was a little steep and resolved to find a way to do it myself.

Since I had to yet phoned and kind of rescue service, being of mind to sort my family out first I realized that no rescue service would arrive in time to move the car before the highway guys got the police to do it. So I asked the guy on the phone (James  I think his name was) Where exactly was the car felt to be safe?

James indicated that basically it was unsafe as long as it was on the motorway so as long as I got it off there, it would be ok. I looked at where the car was and wondered if I could push it off. however as I looked closer, I realized that in order to get the car into the car park I would have to cross back on to the exit ramp from the hard shoulder. this would be like pushing the car into traffic, and without any lights of any kind this was really not going to be a valid option.

Then I spotted the "End of motorway regulations" sign. It stood a full car length from one end of the Hard shoulder providing the perfect place where the car could reside without being either in the car park or technically on the motorway. I solicited help from a guy playing the slots in the service station, and together we approached the car, the battery of which, had now managed to store enough energy to allow reentry into the ca. I disengaged the gears putting the car in neutral, removed the handbrake and we managed to push the car the length of the hard shoulder to it's new "safe" location. I never did ask the name of the guy who helped me push the car but I slipped him the close to £5 loose change I had in hopes that it might help him to his fortune on the slots.

A short while after this, I got a call from the highway guys saying that the police had seen the car and were prepared to tow it around the corner into the car park for me (at no charge). I was very glad to hear this as I was still very unsure if where I had left the car would be acceptable.

The towing complete, I was off back to the room I'd booked for the family where I found mum looking ragged. This is not a reflection on here, but more on the behavior of my elder kids who seemed to have picked up the same levels of energy as they might have gained from several energy drinks mixed with some sort of neat sugar IV and they were using this burst of energy to pound on one another. This coupled with cries of Rosie who apparently needed changing meant that my arrival was greeted with much anticipation.

A little while later we had managed to get all 3 children to sleep the 2 eldest had fought so much that they now had each a bed of their own, and Rosie had a makeshift bed made out of a much folded blanket. I was preparing to sleep on the floor but Anne convinced me that we could now move Molly back into the same bed as Daniel. After this we both collapsed into bed where we slept very soundly until morning.

In the morning we called the AA who showed up very quickly and told us that our alternator was shot and a replacement would cost us about £90. Well we paid up and the car was fixed up right there in the car park.

A day later the fan belt fell apart. It was literally shredded.

We got that replaced and now the Power steering pump is leaking. We have a replacement for that and it's being fitted tomorrow morning by a friend of ours.

I think the car is fast earning a nickname of "The money pit"

I'm glad I cycle to work :)

Monday, November 12, 2007

Duplicate Line - Simple Examples

'Duplicate Line' is a simple enough concept....

  • Type a qualifying line of code.
  • Hit <Shift>+<Enter> instead of <Enter>

CodeRush will intelligently duplicate the line of code.

What do I mean by 'intelligently duplicate'.

Well I assume you know what I mean by 'duplicate'. What I mean by 'intelligently' is probably best demonstrated rather than explained.

Suppose I have the VB.Net line...
Position your caret at the end of this line and hit <Shift>+<Enter>.
CodeRush duplicates the line in question.....
ImportsSystemDataSelected ...and then positions the selection block cleverly around the namespace itself so that you can over-type with an alternative.

Similarly you can use this to create a whole slew of variables of the same type.....











I think you'll agree, this is quite the handy function.


Selection-Inversion (CTRL-SHIFT-I) is a mechanism for transforming one simple code structure into another or back again.
For example:

From .... "X = True" ....into.... "X = False"


From .... "A = B" ....into.... "B = A"

So how does this work?

We it's all down to pattern matching and the wonderful alias engine provided by DevExpress.

Each Selection-Inversion requires a pattern to match and another pattern to replace.

The expressions that allow the above Inversions are simple in nature and, unlike most regular expressions, quite readable.

For example, the first Selection-Inversion above matches using...
%Identifier1% = %BooleanValue1% %EndOfLineComment1%?
...and replaces with...
%Identifier1% = «?InvertBoolean(%BooleanValue1%)» %EndOfLineComment1%
This shows an additional strength of Selection-Inversion. That of the StringProviders. I'll cover StringProviders in another post but as you can see from this small example. a StringProvider is essentially like a function which takes 0 or more parameters and returns a string. A very simple idea but one which allows for a lot of customization.

The example here uses an "InvertBoolean" StringProvider which, as it's name suggests, inverts the passed boolean and passes out the text which represents it's opposing value.

The second example matches using...
%Identifier1% = %Identifier2% %EndOfLineComment1%?
...and replaces with...
%Identifier2% = %Identifier1% %EndOfLineComment1%

Note the subtle change here. Only the numerals 1 and 2 have switched positions. The numerals can be tacked on to any alias and allow each alias type to be used multiple times in the match string and then placed in arbitrary positions in the replacement string.

As you can see the Selection-Inversion is quite powerful.

There are also a few more Inversions in the shipping version of CodeRush which deal with inverting loops so that they progress in the opposite direction from which they started but I'll leave these for you to investigate.