Tuesday, November 13, 2007

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...
ImportsSystemData 
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.....

PrinvateAAsInteger

...becomes...Private2Vars

 

 

...becomes...

PrivateManyVars

 

 

 

 

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


Selection-Inversion

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"

..OR..

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.


Sunday, October 28, 2007

BST - Bites me again

I don't know what it is that make this happen every year.

But every single time that the clocks have to be adjusted due to either the start or the end of BST, I inevitably find out about it at around midday on the Sunday on which the change occurs.

I therefore, am either late for some appointment, or alternatively miss that all important extra hour in bed.

Of course I could simply go to bed an hour earlier this evening, but frankly it's been a week since I touched a computer so if you think I'm gonna leave this one early his evening you've got another thing coming.

:)


Friday, October 19, 2007

Holiday???... What's that then?

The trouble with working for yourself (or family in my case) is that you very rarely get to take any official time off.

Not withstanding the birth of my last child Rosie, I haven't taken "official holiday" in about 3 years.

But I'm taking next week off to chill with a few good books.

Money is a bit tight so my wife, my 3 kids and myself are going to visit my in-laws (Just for a few days) who don't really know what the Internet is, much less have a computer.

I'm leaving my laptop behind and I'll probably switch off my mobile phone.

I might take a pen and paper but that's the technological limit.

The pace of life is going to slow to a snail pace and I might finally be able to relax for a bit :)

Of course we'll be staying with the in-laws so there's no guarantees :)

So this is me dutifully giving notice that my DX-Squad presence is going to lapse like never before.

So to anyone who emails me during the next week.... replies will be a little delayed. :P

Tuesday, October 09, 2007

Aliases - The art of readable regular expressions

Here's a simple question.. Which of these is more readable?

  • (\.?((\[(([A-Z]|[a-z]|([À-Ö]|[Ø-ö]|[ø-ə]))|_)
    ((([A-Z]|[a-z]|([À-Ö]|[Ø-ö]|[ø-ə]))|_)|[0-9])*
    (\u0025|&|@|!|#|\$)?\])|(([A-Z]|[a-z]|([À-Ö]|[Ø-ö]
    |[ø-ə]))|_)((([A-Z]|[a-z]|([À-Ö]|[Ø-ö]|[ø-ə]))|_)
    |[0-9])*(\u0025|&|@|!|#|\$)?)((\s*)\.(\s*)((\[(([A-Z]|[a-z]|([À-Ö]
    |[Ø-ö]|[ø-ə]))|_)((([A-Z]|[a-z]|([À-Ö]|[Ø-ö]
    |[ø-ə]))|_)|[0-9])*(\u0025|&|@|!|#|\$)?\])|(([A-Z]|[a-z]|([À-Ö]
    |[Ø-ö]|[ø-ə]))|_)((([A-Z]|[a-z]|([À-Ö]|[Ø-ö]
    |[ø-ə]))|_)|[0-9])*(\u0025|&|@|!|#|\$)?))*)


  • %Identifier%


I'll give you a minute to let that sink in......


The 2 expressions above are both valid and equivalent in DXCore's 'Alias' subsystem. The 'alias' subsystem backs the 'Duplicate Line', 'Selection Inversion" and "Intelligent Paste" functions of CodeRush.


Which would you rather type?


The 'Alias' subsystem is a very simple but very powerful recursive substitution system which starts with a simple phrase. (In this case %Identifier%) and then expands it according to 1 or more rules. The resultant phrase is then analyzed and, if capable, expanded again... and again ... and again.


%Identifier%

...becomes...

(\.?%SimpleIdentifier% (%ws%\.%ws%%SimpleIdentifier%)*)

...becomes...

(\.?(%EscapedIdentifier%|%NonEscapedIdentifier%) (%ws%\.%ws%(%EscapedIdentifier%|%NonEscapedIdentifier%))*)

...becomes...

(\.?((\[%AlphaOrUnderline%%PartialIdentifier%%TypeCharacter%?\]) |%AlphaOrUnderline%%PartialIdentifier%%TypeCharacter%?) (%ws%\.%ws%((\[%AlphaOrUnderline%%PartialIdentifier%%TypeCharacter%?\]) |%AlphaOrUnderline%%PartialIdentifier%%TypeCharacter%?))*)

A few rounds later and we have our full expansion....


(\.?((\[(([A-Z]|[a-z]|([À-Ö]|[Ø-ö]|[ø-ə]))|_)
((([A-Z]|[a-z]|([À-Ö]|[Ø-ö]|[ø-ə]))|_)|[0-9])*
(\u0025|&|@|!|#|\$)?\])|(([A-Z]|[a-z]|([À-Ö]|[Ø-ö]
|[ø-ə]))|_)((([A-Z]|[a-z]|([À-Ö]|[Ø-ö]|[ø-ə]))|_)
|[0-9])*(\u0025|&|@|!|#|\$)?)((\s*)\.(\s*)((\[(([A-Z]|[a-z]|([À-Ö]
|[Ø-ö]|[ø-ə]))|_)((([A-Z]|[a-z]|([À-Ö]|[Ø-ö]
|[ø-ə]))|_)|[0-9])*(\u0025|&|@|!|#|\$)?\])|(([A-Z]|[a-z]|([À-Ö]
|[Ø-ö]|[ø-ə]))|_)((([A-Z]|[a-z]|([À-Ö]|[Ø-ö]
|[ø-ə]))|_)|[0-9])*(\u0025|&|@|!|#|\$)?))*)


At each round of the substitution you can see the power of  Aliasing (not to mention the pre-built list of aliases) at work.


And what a list it is..... 93 separate pre-built aliases found in the "Core\Aliases\Regular Expressions\System" section of the DXCore options.


If  you find, somehow, that these aren't enough you can create you own. DevExpress have even allocated a place for you to do just this in "Core\Aliases\Regular Expressions\User"


But it doesn't stop there. Each defined alias can be referenced either on it's own, or with a numeral suffix from 1 to 9. Thus you can have %Identifier%, %Identifier1%, %Identifier2% .. all the way through to .. %Identifier9% all used in the same expression.


This paves the way for some pretty powerful features


In my next couple of posts I'll show you how we take advantage of aliases in our use of "Duplicate Line", "Smart Paste" and "Selection Inversion".


Thursday, September 27, 2007

Trevor is unlocked

Trevor W is blogging. Take a look over at http://trevorunlocked.blogspot.com
Trevor W has unlocked his brain and will shortly be pouring forth the cream of the content from within. Available at http://trevorw.blogspot.com, Trevor is well versed in many technologies available from DeveloperExpress and is particularly keen on their XPO and XAF technologies and we should begin to see the gems of information pour forth soon.

Well done Trevor....

I have a feeling I'll be reading your blog for some time to come.

Friday, September 14, 2007

DX_Contrib, MoveIt, PaintIt and UnusedVariables all added to DXCorePlugins

The sourcecode to DX_Contrib, MoveIt, PaintIt and UnusedVariables has now been uploaded to http://DXCoreplugins.GoogleCode.com
These projects (DX_Contrib, MoveIt, PaintIt and UnusedVariables) are all still somewhat in flux.

I'm trying to get around to making sure that the cache employed by each of them for paint purposes is kept up to date.

This seemed originally to have some performance issues and I am trying to move towards a background threaded mechanism for keeping said cache up to date.

The problem seems to be that each time I approach this system looking to see if I Can improve it, it takes almost all my spare time to analyse what I have done to date. so that I seem to have very little time left to actually improve it.

This of course smacks of poor documentation/commenting. Therefore I have checked the entire set of projects into GoogleCode.com.

At least this way everyone can see where things have reached.

I am by no means giving up on these projects though. I intend to start going through the code making damn sure that I comment things as I go this time ;)

New project: DX_Sample

I have added DX_Samples to http://dxcoreplugins.googlecode.com.

DX_Samples was created in response to a question on the DX_Plugin newsgroup asking for
"a quick example of how I might go making an action that auto-creates regions around any properties that are not already in a region."

DX_Samples contains a plugin called RegionWrapProperties which wraps *all* properties in a class in a region. This is clearly not *exactly* what the original poster asked but we'll get there.

In the mean time we now have a suitable project for creating reference examples about how things can be done, without necessarily needing to create *full* examples.

Wednesday, September 12, 2007

Coderush EmbedParenthesis Tip

Idea by Neal Culiner... Configuration workaround by Mark Miller....
Coderush contains a feature called "Embed Parenthesis". this feature allows a user to select a portion of their code and to then type either '(' or ')'.

At 19:20 this evening (According to my newsreader) Neal Culiner suggested on the Coderush forum that it would be good if the existing EmbedParenthesis feature could be made somewhat more intelligent. He suggested that the caret should be placed either left or right of the final expression dependant on which of the 2 keys had been pressed in order to activate said function.
-------------------------------------------------------------
Note:
This is particularly useful as, Neal pointed out, for vb programmers who regularly highlight small expressions and wrap parenthesis around them so that we might CInt, CStr or CType.

I would also be sensible to use this to wrap an expression in any function call which passes such an expression.
-------------------------------------------------------------

"Great" said I "Add that to the support center and I'll track it too".

By 20:20 Mark Miller had spotted the conversation and posted a solution which required no new distribution of Coderush as all could be done with the existing version.

For those not willing to click through and read Mark's version, the solution is simple and elegant.
Simply create 2 'Selection\Embedding' entries. One for ParensCaretOnLeft and another for ParensCaretOnRight. Each should be the 5th type of SelectionEmbedding

For ParensCaretOnLeft, the Top line should be...
-------------------------------------------------------------
«Caret»(
-------------------------------------------------------------
...and the bottom line should be...
-------------------------------------------------------------
)
-------------------------------------------------------------

This should be suitably changed for ParensCaretOnRight

Then just change the existing bindings for Shift+9 and Shift+0 in "IDE\Shortcuts" to trigger the "Embed" rather than "EmbedParenthesis" and give each a parameter of either
'ParensCaretOnLeft' or 'ParensCaretOnRight'

You should now be good to go.



Tuesday, September 11, 2007

Write your own Dynamic Template

How do you write your own custom Dynamic-Template for CodeRush?
CodeRush 2.0 introduced the concept of Dynamic-Templates which I blogged about some time ago here. However I don't think I ever went into any detail about how you make your own.

Well the process is fairly simple.

To show you how this is done I will give an example.

Lets create a new template that will spit out code like...
-------------------------------------------------------------
Throw New ApplicationException
-------------------------------------------------------------
OR
-------------------------------------------------------------
Throw New System.InvalidCastException
-------------------------------------------------------------
OR
-------------------------------------------------------------
Throw New System.IO.FileNotFoundException
-------------------------------------------------------------

...based the specifics of your mneumonic.

The first step is to create a Dynamic List.

Follow these steps to get to the Dynamic Lists options page:

-------------------------------------------------------------
1. From the DevExpress menu, select "Options...".
2. In the tree view on the left, navigate to this folder:

Core

3. Select the "Dynamic Lists" options page.
-------------------------------------------------------------

Now we would like to create a "neutral" list, because this list should be available to all language types.

(Note: This is not technically true. I would prefer to make this list available to only VB.net and C#, but for now there is no way to do this other than to duplicate the list for these types. This will not matter too much as we will only be creating templates that use this list in VB.Net and C# anyway)

To do this we must ensure that the language dropdown reads "neutral".

Next we will right click the "Lists" list in the center column of the options screen and select "New".

You will next have to fill out 3 boxes with values for Name, Variable and a Comment.

Name should mean something to you, and it is what will appear in the previously mentioned "Lists" list once you save. I typed "Exception Types" in this box.
Variable is the suitable variable name in which DXCore will store the user/developer's selected item. I typed "Exception" here.

...and Comment is just a comment. I guess you should write a comment here :)

Once saved, your list is ready to be filled. This is accomplished by adding items on the right-hand side of the options dialog.

Each item added requires a mnemonic and a value.
We will add the following items

a - ApplicationException
ic - InvalidCastException
fnf - FileNotFoundException

Then we can push "apply" and our list is saved.

So how do we use this list in a sensible way?

This is the easy part.

Navigate to the "Editor\Templates" options page and create a new template. I'm going to do the VB one for now so I'll select VB.Net from the language dropdown first.

This template will need a special name. You need to use a special syntax within the name to indicate where DXCore should allow the user to substitute one of the mneumonics we created earlier.

We will call our Template "tn?Exception?".

What this means is that our Template will be triggered by the letters 't' , 'n' and any mneumonic from the Dynamic-List.

The expansion of our template will be:-
-------------------------------------------------------------
Throw New «?Get(Exception)»
-------------------------------------------------------------
The '«?Get»' is a StringProvider. StringProviders are available to insert from the right-click context menu in the expansion box. The '(Exception)' is the parameter for the StringProvider. In this case the phrase '«?Get(Exception)»' retrieves the string held in the "Exception" variable placed there by the trigger mneumonic.

Once this little gem is saved, you should be able to trigger your 3 expansions with any of the 3 phrases 'tna', 'tnfnf' or 'tnic'

The great thing is that you can add additional exception types to the "Exception Types" Dynamic-List at any time and they will also work with the template we have defined.

So now you have some simple mneumonics to help throw exceptions.

Sunday, September 09, 2007

Minor CR_WorkBench update.

CR_Workbench now Autoloads and Autosaves.
Yes CR_WorkBench now has an option "AutoLoad and AutoSave" vailable from "DevExpress\Options\ToolWindows\WorkBench".
This will cause your WorkBench to save each time you close your solution.
It will (kinda obviously) attempt to load a WorkBench each time you open a solution.

This new functionality added in revision 18 of DXCorePlugins

Wednesday, September 05, 2007

URL Mistake

It seems I have been quoting the wrong Urls in my previous DXCorePlugin posts.
I have now corrected the posts themselves but if you use an rss reader to view this then you might have already downloaded an earlier version.

Essentially I published Urls which required a login in order to gain access the the resources.

The correct Urls are
http://dxcoreplugins.googlecode.com/svn/trunk/CR_Contexts
http://dxcoreplugins.googlecode.com/svn/trunk/QuickTemplates
http://dxcoreplugins.googlecode.com/svn/trunk/CR_WorkBench
http://dxcoreplugins.googlecode.com/svn/trunk/Common

CR_Contexts added to DXCorePlugins

I have added a new plugin (CR_Contexts) to DXCorePlugins to add a few new contexts to DevExpress's IDE Tools

The new plugin provides 3 new Clipboard contexts called 'Clipboard Contains (Literal)', 'isMultiLine' and 'Clipboard Contains (RegEx)'

All found underneath 'Editor\Clipboard'

Enjoy.

This source available via GoogleCode and Subversion.
CR_Contexts available from http://dxcoreplugins.googlecode.com/svn/trunk/CR_Contexts
Common code available from http://dxcoreplugins.googlecode.com/svn/trunk/Common

QuickTemplates added to DXCorePlugins

Just a quick note to tell those who are interested that I have added my QuickTemplates plugin to DXCorePlugins
Yup, QuickTemplates is now available as a part of DXCorePlugins.

This source available via GoogleCode and Subversion.
QuickTemplates available from http://dxcoreplugins.googlecode.com/svn/trunk/QuickTemplates
Common code available from http://dxcoreplugins.googlecode.com/svn/trunk/Common

CR_WorkBench

CR_Workbench is a DXCore plugin which provides you with a toolwindow to store references to commonly used files.

CR_workBench gives you a toolwindow into which you can drag/drop files from either Solution Explorer or Windows Explorer.

All files placed on the WorkBench can be Double-Clicked to load them into the editor

The WorkBench has a context menu which allows loading and saving it's list to and from a file called [Docs and Settings]\[You user name]\Local Settings\Application Data\WorkBenches\[Solution Name].sln.wrk"

The only real point is to allow you a window which does not contain the whole breadth of files in your solution. If you save your workspace (I'm thinking of adding Autoload/Autosave) then you can close all documents prior to saving your solution and thus receive a much faster start-up next time studio loads this solution.

This source available via GoogleCode and Subversion.
WorkBench available from http://dxcoreplugins.googlecode.com/svn/trunk/CR_WorkBench
Common code available from http://dxcoreplugins.googlecode.com/svn/trunk/Common

Tuesday, September 04, 2007

GoogleCode - DXCorePlugins

And so I have created a GoogleCode repository for an open source project called 'DXCorePlugins'.

I created 'DXCorePlugins' because I wanted a better way to manage my open source plugins for DXCore, CR and R!.

I irks me that I don't do as much work on said plugins as I would like to. I came to the conclusion that it was all the management that was becoming awkward.

i.e.
Creating versioned code...
... to make versioned assemblies...
... and building versioned zip files with both source code and binaries.
... updating web pages to reference said zip files and explain the purpose of each.

... trying to keep track of 'issues', 'bugs' and 'feature requests'

It's all management which distracts from the fun part.... making a cool plugin which does something to help people in their daily coding lives.

So I decided that I had to move the source code off my machine and into a repository of some kind. We use CVS at work but are thinking of moving to SubVersion. so ideally this would be a good chance to get to know said source control software on something less mission critical.

So I needed hosting of an open source project which ideally allowed SubVersion access to the repository of code.

2 obvious candidates: SourceForge and GoogleCode. This does not make a definitive set but this is a hobby project after all. I didn't want the research to take over my life.

It should be noted that I did consider Codeplex but decided against it because of what appeared to be a bias toward MS SCC API. To me MS SCC API shouts SourceSafe and I've been stung there before. Now I know that this is an unfair judgement, but ours is a small company and we cannot afford to spend too much time on micro-management so the fewer pieces involved, the better. I simply saw Subversion as a natural evolution of CVS and therefore when I saw that I would need to introduce additional pieces( some kind of SSC - Subversion bridge) I basically ruled out Codeplex then and there.

Now... to say that I was then left with SourceForge and GoogleCode is also something of an unfair statement. A more accurate statement would have been..."I was left with GoogleCode and, if I really had to, SourceForge".

You see, SourceForge has, for me, been the slowest of experiences. Accessing a SourceForge has always been like returning to the days of dial-up connections. It makes me wonder if this isn't the method they use to connect their servers to the internet. Now in fairness, I have been led to believe that this is not the case for everyone. many people apparently find SourceForge a very reasonable resource. however I am apparently not in that position. So from day one, If I could run without SourceForge, I was going to...

And therein lies my one regret. If not for this one issue I would simply have added my code to the CRPlugin project on SourceForge. I would recommend that these projects definitely be checked out.

And so unless GoogleCode was to provide and major stumbling blocks, I was going to use it.

So how does one create a project on GoogleCode?

Well it turns out it's really easy. Just show up at http://code.google.com/hosting/ and declare the Name and Licence of your project. That's essentially all there is to it. True you'll need an account with google, but who doesn't have a GMail account these days anyway.

The hard part was choosing a Licence for the project.

Now originally I wanted to specify do anything you like with the code except sell it (I wanted to encourage giving back to the community) but I realised I was spending way too much time considering the licence when... In truth, I didn't really care what people did with the code as long as they don't blame me for something it might do by mistake.

I stared at the list and their definitions for ages before I finally gave in and asked for help.

Trevor Westerdahl rescued me and pointed me in the direction of the MIT licence. Indicating "An MIT license is about as "open" as a license gets. It essentially protects the writer form any harm...as in there are no warranties of any kind, but allows for selling, copying, redistributing, etc."

It sounded good to me, and so there you have it. http://dxcoreplugins.googlecode.com/ is up and running with it's first project 'CR_WorkBench'.

Friday, August 10, 2007

Quick templates Example: Contact XML

A simple example of using "Quick Templates" with a simple piece of XML.
This is a very quick post to show an example of using "Quick Templates" to aid you
in the creation of a repetitive piece of XML
Imagine you have the following XML.
-------------------------------------------------------------
<Contact fname="Rory" lname="Becker"/>
-------------------------------------------------------------
You would like to have many more of these.
What to do?

- Highlight the XML to duplicate.
- Trigger my plugin. (I suggest attaching the "Create Quick Template" action to the "Alt-Q")
- Enter a few keys to trigger your template (In this case perhaps "con")
- Add some choice (crlf separated) keywords to the "Field list". (I think Rory and Becker would work well here. )
- Optionally: Setup a suitable context for you new template.
- Click Ok

Now whenever you activate the template by typing con and hitting space, you will find that the XML is repeated back
to you but that Coderush has wrapped my name (in this case) using it's nice glowing field markers. and you can
effectively type the following
-------------------------------------------------------------
con Mark Miller<enter>
con Carl Franklin<enter>
con Dustin Campbell<enter>
con Richard Campbell<enter>
-------------------------------------------------------------
...and create the following XML...
-------------------------------------------------------------
<Contact fname="Mark" lname="Miller" />
<Contact fname="Carl" lname="Franklin" />
<Contact fname="Dustin" lname="Campbell" />
<Contact fname="Richard" lname="Campbell" />
-------------------------------------------------------------

I'm sure there are many other uses for this.
Feel free to suggest some.

Thursday, August 09, 2007

QuickTemplates v0.5

Here's a sneak peek at my new QuickTemplates plugin.
QuickTemplates is a DXCore plugin which provides a new action to complement CodeRush Templates.

Available here(Updated to 0.51), it provides a quick method to create a template from text selected in the editor.

Setup:
1. Place QuickTemplates.Dll (Extract from obj folder or compile your own from the source) to your plugins folder and start VS.
2. Assign a key to the "Create Quick Template" action. I use "Alt-Q"

Usage:
1. Select some text
2. Activate the action (Alt-Q)
3. Assign a Name to the template.
4. Enter some words/phrases (CRLF separated) in the box labelled "Fields".
5. Configure any context you require.
6. Click 'Ok'

You will now have created a template complete with fields in place of appropriate phrases.

Here are some screenshots: