Bill McCarthy is Blogging - Greg Low is moving . . .

26 06 2004

Bill McCarthy joined the blogosphere at the beginning of the month and didn’t notice. It took FrankArr and Greg Low to point it out. Greg has also moved his blog over to msmvps.com from theSpoke.





Expansions Cont’d - How To

26 06 2004

Well, it turns out building an expansion couldn’t be easier, the directory I mentioned in the previous post (C:\Program Files\Microsoft Visual Studio 8\VC#\Expansions\1033\Expansions) are a set of XML files. In each of these XML files is a snippet of code inside some XML markup with some tokens (like $this$). These tokens match literal declarations which you can use to provide tooltip information and defaults. The shortcut element is used to define what keyword can be used to trigger the TAB-TAB trick.

Here is my first expansion. I’m almost certain there is more to this file - it looks like quite a bit of functionality could be dug away in here. Interestingly - if you define more than one expansion with the same shortcut you get a drop down list after pressing TAB twice. I could imagine this would be useful for doing “families” of expansions.

Update: The $end$ token seems to be where the editor will put the caret when finished editing. Also, there seems to be a $selected$ token which can be used for inserting your selected text. Nice.





Whidbey C#: Expansions Rock!

26 06 2004

Looks like I am going for a Whidbey theme tonight. One of the nice features in Whidbey is expansions. An expansion is a simple string preceded by a magic keystroke (CTRL-T,X) which is a shortcut for writing more complex code. In the example below I am using the shortcut for defining a read-write property.

Once you select the expansion, you can press enter and some code will be injected into the source file at the cursor location. This code is templated with the modifyable fields highlighted in yellow (by default I guess). You can press tab to navigate around the fields and change the text. Related source in the template can be configured to change.

I’m currently investigating how this can be extended, there are a few ones that I use for diagnostics which could replace a few of the macros that I have written.

Update: In the course of my investigations I have learnt that there is an even better shortcut than typing CTRL-T,X, in the case of the property, just type in “prop” and hit TAB twice. I’ve found the definitions for the built in expansions in the following directory.

C:\Program Files\Microsoft Visual Studio 8\VC#\Expansions\1033\Expansions

The XML file structure is fairly easy to understand - I’ll follow up with a more indepth analysis based on what I see.





Whidbey: Snapping to Edges

26 06 2004

I’ve got to say that despite the bug here and there I am really been enjoying using Whidbey as my everyday development environment. One of the neat features that caught my eye this week was the snapping to edges that the Windows Forms designer now does.

Notice the fine dotted lines between the top and left borders of the button and containing form. It actually goes a little bit further than that allowing text baseline alignment of windows controls using the mouse.

One thing that seems to be missing is the ability to do this snapping on all sides. It seems once it is snapped into one position you can snap on the opposite corner or side. It would also make sense to me for this snapping to lead to anchoring - maybe some kind of smart tag which is context sensitive. There are smart tags on many of the controls already.





Luke on Flying Qantas

26 06 2004

Can you tell Luke doesn’t have kids? People with kids at home exchange understanding smiles with people with kids on planes and airport lounges. I’d also like to point out that on Saturday last week, if Luke was in the Virgin Blue “blue room” he would definitely have been “soothed” by my daughters dulcet tones. I’m pretty sure the lady sitting in the seats near us at Melbourne airport was muttering “I wish I had flown Qantas”.

So Luke, since you were so nice to come down to Canberra and relieve me I’ll share with you this advice re: Qantas and Canberra - this applies to everyone coming down for TechEd too.

  • Pick flights carefully, if available take the DASH-8 flights. The staff seem to be friendlier and the seats have about two inches more room and because they reach their cruising altitude easier you can get some laptop time in.
  • If you do manage to get a DASH-8 flight, never take the front seats - especially the ones that face backwards. They are weirdly uncomfortable, an facing other passengers during take off is just weird man. I think it would be more fun if we played a game of celebrity heads or something.
  • If you are prone to concocting fantasies about propeller blades breaking off then do sit mid-plane.
  • If self-checkin is available take it. Sydney airport is fantastic, I have no idea why those dodos queue, it takes me about 2 minutes flat to check-in - including wait time. To assist in this process, I find it handy to copy and paste the booking ref from the PDF itenary I get into my Smartphone for quick access (you need to key it in at the kiosk). Self-checkin also means you can select your seats instead of relying on Qantas staff to “choose” for you.

P.S. I put that link in there to the celebrity head game not only for comic relief, but because if the Internet is just the beginnings of a big brain as my friend Paul Murphy once suggested, then these little random links are what is going to make it interesting. Or atleast give the brain a few issues that it is going to need to see a shrink about.





FirewallPermission: For the XP SP2 enabled!

26 06 2004

I just finished building version 1.0.0.0 of my FirewallPermission implementation it is a custom permission and associated declaritive security attribute which uses the Windows Firewall COM interfaces to check whether a program has inbound access on a port enabled.

The implementation is pretty basic right now, but if there is an interest in this then I will rev it with some more enumerations for allowing more fine grained definition of the access required. At the moment you use it like this:

[FirewallPermission(SecurityAction.Demand, Port = 1234)]

public void SomeCode()

{

}

If the demand fails then you get a SecurityException. It will only run on machines that have Windows XP SP2 installed - maybe this is enough of an incentive for you to get off your butt and test out your applications on it!

There are a few things you need to be aware of. First - the interop library has been hacked - its what VS.NET generates, except it has been disassembled and strongly signed. Second, if you get in there and tweak the code remember that VS.NET runs the C# compiler in-proc so it will always use the old version of the permission to emit the XML into the IL stream. I worked around this by doing the editing in VS.NET but then defering to the command-line to do a build and test.

Hope it works, if you have any questions, problems or feedback just leave some comments on this post or e-mail me at mitch.denny@notgartner.com.