Friday, March 18, 2011

Automatic Upgrade from .NET 2 to .NET 3.5

Our core application suite is currently based on .NET 2, C# 2, VS2005, with a few dependencies on libraries from 3.0 and 3.5. I decided to perform a trial upgrade of the solution into VS2010, as I am using it for all new work and hate to revert back to 2005.

To start, I simply created a branch of the source, and then loaded the solution into VS2010. I waited for some time, and then eventually the import wizard completed – the result was a set of fully loaded .NET 2.0 projects within VS2010 – That seemed too easy! Of course, getting everything to compile was a different story. As stated above, several of the projects had taken some dependencies on 3.0 libraries – specifically WCF and WPF, and these projects longer compiled. Unfortunately they represented some core libraries within our project suit so this meant the solution was broken.

Instead of spending too much time finding out why, I converted these projects to the 3.5 framework via the project properties dialog and proceeded to compile – it soon became apparent however that I would be better off upgrading all projects in the same way, yet I didn’t have the time to upgrade 120 projects within the solution via the properties window..

Of course I knew that there had to be a better way, and having read about other attempts to do the same, II decided to write a macro to do the upgrade. Avner Kashtan provided a method here to process the projects within the solution like this:

For Each proj As Project In DTE.Solution.Projects

   Try

       proj.Properties.Item("TargetFramework").Value = 196613

       Debug.Print("Upgraded {0} to 3.5", proj.Name)

   Catch ex As Exception

       Debug.Print("Failed to upgrade {0} to 3.5", proj.Name)

   End Try

Next proj



I tried this but it didn’t do much – it turns out that Solution.Projects returns only the child nodes of the solution, which from my solution was simply 7 solution folders – so this didn’t work. Of course, I realised that I could rewrite this macro to be recursive so that I could traverse the hierarchy and process it that way.

This is what I came up with:

Sub Upgrade()
    For Each project As EnvDTE.Project In DTE.Solution.Projects
        UpgradeProject(project)
    Next
End Sub
 
Sub UpgradeProject(ByVal Project)
    For Each projectItem As EnvDTE.ProjectItem In Project.ProjectItems
        Dim childProject = TryCast(projectItem.Object, EnvDTE.Project)
        If childProject IsNot Nothing Then
            UpgradeProject(childProject)
        End If
    Next
 
    If Project.Kind = PrjKind.prjKindCSharpProject Then
        Project.Properties.Item("TargetFramework").Value = 196613
    End If
End Sub


This macro ran reasonably quickly and did the upgrade with the visible effect of changing all the project files to refer to the new framework version.

I then recompiled everything successfully.

Nice!

Monday, October 25, 2010

Windows Phone 7 First Impressions


I'm not a usual candidate to be the first kid on the block with the new toys - I usually like to let things settle down first - but this time I took a punt.. Not 100% sure why, but I've been telling myself that this time I could write some code to run on the phone, so that would make it worth the trouble. Since Windows Phone 7 is silverlight based, and developed in C#, I couldn't resist.

I've been developing in .NET and C# so it was a natural fit - my first thoughts though have nothing to do with the developer experience however, since I soon discovered that even 'sideloading' and app on to the phone from my local Visual Studio wouldn't be possible without purchasing a developer unlock for $100. Although something I'll consider if/when I get an app worth depolying, I was still a little surprised. I had expected to deploy locally for free - naively I realise now, in retrospect, given that MS has decided to control deployment ostensibly to maintain standards via the marketplace..

As for the phone itself, I was an early buyer - early on the 22nd of October. Telstra, the most prominent Australian telco shipped the phone the day before and I received a text late that afternoon telling me to hurry to avoid disappointment. As it turns out, I have heard that others did get disappointed with limited stock, but at least from the Rundle Mall Testra Store, there was at least a few left when I arrive 9am Friday morning (so much for going to work!)

Price

At the end of the day, I care about the price, it's not purely about function, it has to meet the features/dollar ratio in my mind - and in this case, I actually thought Telstra had this one totally sorted in my favour. $49 cap, with $400 worth of calls and 500MB data on the NextG network? Rediculous. I was expecting to pay $79 for this at least, and thought I would thus need some convincing. My old Nokia plan was the same price and was on Vodafone, slow data and old (N95) handset.. In the end tt was a simple swap actually, for no real outlay.. Awesome! now you know why I was an early adopter!

Physical Appearance

I bought the HTC Mozart and my initial response was very good - I like the weight, size, shape and overall appearance - granted it's not quite as single chassis iPhone style, but it feels well built and comfortable to hold - it fits well in my pocket without feeling either bulky or heavy. The screen repsonsive to touch too. The soft buttons do have to be avoided though, but this was sorted out after a few hours of use.

UI

The interface is different, and overall I don't mind it. The tile concept is well put together especially the live data within each tile - even the simple colour scheme is ok to me, I'm not really sure why so many iFreaks are hating on in, I'm yet to see why a standard icon is that much more effective.., and I don't mind the hubs concept either.

The graphics looks great - smooth hardware based transitions looks slick, the way you move around the page feels very natural. The metaphor of panorama or pivot style pages works well. I didn't see too many apps that got thi
s too wrong.. a few did, but that's not surprising!

As for the secondary app list, I don't know.. Can't say I'm convinced. I will wait to see how many apps I settle on before passing judgement. Although I'm not a huge fan of the iPhone app array as a great UI metaphor (kind or reminds me of Windows Explorer View Lists), on the other the idea has some merit, since it doesn't take long for the app list of WP7 to get a bit long. I wouldn't mind if this is swappable with a 3rd party but at this stage I haven't seen anything like this - I suspect this will change in a latter OS upgrade (at least, I *hope* it will!) though, as the volume of apps goes up.

Apps

I was pleasant'y surprised at the number of apps in the market place on day 2 - There was something in every problem space I enquired about. Not bad for such early days. Obviously the quality varies, but I only had to download an try a few apps for various things to get a good 'base' collection. I did have to remove the Yellow Pages app after a while when I realised it was based on old data, and wasn't Australian enough to be useful. It is listed as a beta product though, so I hope to try it again later once the issues are ironed out. I actually bought a few apps too, a few games and some baby pleasers too - my toddler loves to press the screen, so why not touch the animal to hear some noises. Just a little fun at a $1.30!!

Facebook, Twitter, YouTube are all there and provide some decent 'basic' coverage of those sites capabilities. Not bad for free.

Quibbles

I had some initial difficulty getting some games to load in the app store (err. marketplace), but in the end I discovered that the games were installing, but don't appear in the app list itself - *only* in the game hub.. obviously it makes sense but since I didn't read the manual (dude RTFM..) I had to discover it myself.

There have been a few other quibbles too - It's hard to apportion blame at this stage so I'll just detail what I discovered. Hopefully others have more insight.

  • Outlook Integration - fails when the company certificate is self signed. Usually apps just ask for you to accept it anyway - but there is no setting for this that I could see. Obviously the company needs to get there exchange server act together, but I am told iPhone and Android phones within the office all accept the certificate as is.
  • Google Calendar Sync - my wife and I run our whole 'eLife' via google apps, and have a calendar for each of us as well as our daughter. 90% of my app events exist on my wife's calendar, so having them all sync into the phone is critical, but alas, no. Not only does my calendar not sync correctly (it does allow me to write from phone to gCal, ) my 'other' shared calendars don't appear at all. I read somewhere that others have claimed the same problem, and that WP7 only syncs to gCal when there is only one calendar and this is a known issue. Wish I had read that one earlier!
  • IE7 - not the most polished app I've ever used. sometimes the zoom rendering is a little laggy catching up with the resizing. overall though, I expected it to be much worse. Didn't try using a site with some modern CSS or HTML though so no doubt things go a bit funky on that end - I hope this changes soon though.. Perhaps an IE9 Mobile version is pending?
  • Predicitive texting - is actually awesome, but is a quibble because not all text entry uses it. Don't know why not.. surely this is a device level function?? strange, such an excellent feature, wish it was everywhere.
  • Copy/Paste - I know I know, you know and I know it's coming. I don't really need it much anyway (so far) but I would have thought it wasn't too hard to include up front
Overall

I don't think I want to speculate about the success of WP7 too much, but suffice to say I like it, and will definitely consider writing an app for this OS soon. I think once the quibbles are ironed out it will be a good platform. I only hope that the anti-MS types don't get too much mindshare.. I really don't see a problem with more competition in the mobile space, and hope that MS can push the envelop and then the entire industry (including general software development) will benefit.

Lastly, I was showing the phone of to my father-n-law yesterday, and I learnt he bought the same one on the same plan this morning.. Nice!

Wednesday, July 21, 2010

Powershell Scripting Book - first thoughts


As part of my endeavour to learn a new language this year (and hopefully every year), I decided to improve my .NET and general Windows development workflow with Powershell. It's not only a great scripting tool, but a complete language, and actually quite handy as a REPL too, when working with .NET types.

In order to maximize my learning time, I turned to Manning and bought the 'early access program' book for Windows Powershell In Action. I am a huge fan of the early access program, and have bought more than 10 books now.. Again I wasn't disappointed, as it is a good entry level book to the syntax and idioms that make Powershell so, well.. powerful.

Once I had mastered the syntax, using the canned examples within the book, I decided to take the plunge and write a few 'real world' scripts. It didn't take me too long until I had started incorporating Powershell into my everyday development cycle.

My 'new work' script looks something like this:

param
(
[string]$name = $(throw "a branch name is required")
)

. .\Scripts\Utilities.ps1

Stop-
Servers

Invoke-Expression .\Create-Branch.ps1 "BUG_$name"
Invoke-Expression .\Setup-Config.ps1
Invoke-Expression .\Build-Source.ps1
Invoke-Expression .\Build-Database.ps1

Start-Servers

The whole process automates a lot of the drudgery of creating a branch, switching to it, patching the many config files (via XPath), doing a full build, rebuilding the database, etc. Fantastic!

What is more surprising is that these processes were done each and every time by each developer manually until I suggested we script them.. What's more, each had their own special way to achieve the end result, which made things difficult when we integrate branches and get a consistent working environment.

I am still trialling these scripts, and the many others that I have written to manage random files and processes on the fly, however I am having lots of fun and have even managed to remove some drudgery from a home-centric file operation ritual I do all the time.. This will have to wait for another post however..

HINT: I'm downloading and transferring podcasts to my phone.. (I use RSS via google reader and DownThemAll currently - it's very manual..)

Thursday, March 25, 2010

Media Center Goes Win 7 - Finally

It's hard to believe that I first built my media center back in 2007. When I initially set it up, my plan was to use Windows XP and run Media Portal. After a few abortive attempts and getting everything running with my hardware, I gave up and moved to Media Center 2005 (XP). After further configuration woes (due to dodgy hardware and/or drivers), it has worked basically flawlessly since.

I was happy with this configuration, and it remained unchanged, until I bought Windows Vista.. MY tuner cards didn't work any more, and the interface ran too slow for my wife to accept. Needless to say, that copy of Vista still sits in a box somewhere, never to see the light of day again.

With the recent release of Windows 7, I knew the time was right to try again - I knew there were lots of good features for MC, and I was keen - only problem was that my hardward (tuner cards) *still* didn't work. This time though, I was feeling a bit more keen on spending some money, so I discarded my tuner card (actually I gave it to my brother-n-law, who has made it work in Win 7!), and I bought two dual-tuner cards and a 1TB hard drive for TV only.

These cards are Hauppauge 2200 and they 'just worked'. Now the only problem was that the interface was a bit sluggish on a busy screen (e.g. Recorded TV - we have a lot of recorded shows).

I looked at everything obvious (or so I thought), and eventually I realised, much to my own embarrassment, that the HTPC only had 1GB of ram! I don't really recall way back there in 2007, but 1GB was probably not too bad.. As my wife pointed out, even her netbook has more ram. Too true.

A quick trip to MSY (great prices, worst web site ever) and 4 GB, for a lousy $105 and now the Win7 Media Center is looking awesome.

One last thing - having visited my place several times and viewed the beast that is my HTPC, my stepfather has decided he wanted one too - despite my encouragement to get a TiVo. I beg you.. But no.. He bought one anyway, and a big screen TV, and a nice new stereo. It will be a good setup, when he gets it working.. :-)

Given that he's not technical, I've committed a few hours to the cause so far, but as of last night, we are not quite there yet.. I think we're close though, with only the channels tuning to be done. Somewhat poorly, I think, the supplier (in a different city), left the channels configured when he shipped it - thus, when we booted it, it listed all the 'correct' channels, but no guide listings, and no reception. It took me a while to realise that these were for Melbourne (or perhaps Brisbane?), but the bub had had enough so we went home with the problem unresolved..

Ahh.. Why didn't he just buy TiVo?

EDIT: After a little tweaking (faulty tuner, wrong city config) it is all working a treat, and the supplier was good about replacing the faulty tuner too

Wednesday, February 17, 2010

Open Source RTS Engine


I had a brief window of opportunity to play a game a few weeks ago - the first I've played on my computer for a few years. I used to be a hard-core real time strategy (RTS) player, but with work, house, wife and child, their is never enough time!

The game itself is called Spring, and is an open source RTS engine. The implementation is inspired from Total Annihilation (1997) and more recently, from it's modern equivalent Supreme Commander (2007). The basic idea is a classic RTS paradigm, with base building, resource collecting and domination being the primary methods of success.

The feature which I enjoy the most is the use of metal as salvageable resource from the remnants of the battle field. A favourite strategy is to allow the enemy near to your base to allow easy access when picking over the carcasses of the dead (it's only robots, no blood!!).

Also, I really appreciated (in the original TA), that the command system is entirely queued. Simply hold down shift, and initiate a sequence of commands. It is essentially fire-n-forget. Back in 97, this concept was revolutionary.. It is still awesome today.

What I particularly like - besides being open source - is that the game play is very similar to my recollections of TA, but with better graphics and sound.

The game is separated into the engine, modifications (mods), and maps, such that there are various mods available, some ostensibly require a licence to the original TA (it uses its units model and rule data), and others are complete fabrications of new rules, units, AIs, and scenarios. There are both open source and paid mods, such as a futuristic (Sci-Fi), WW2, and Star Wars themed mods.

I have been playing the Balanced Annihilation (BA) mod only at this stage, since it has the familiar units and rules of the original Total Annihilation game.

After approx. 20 hours of gaming, I can now give a fair review of the engine, the AIs, the mod, and the lobby:

The lobby is the weakest link in this suite, although it does work, I have found it crashes, has a lot of 'nag' dialogs when failing to connect to a server (even when playing single player), and in general is a bit dull (it appears to be a standard windows form application, nothing special..). It is functional, and provides some good mechanisms for downloading content as required.

The engine is very good, but requires a better graphics card than I have to fully appreciate the feature set it offers. I found the game is responsive with medium unit volumes, but since I prefer high response times to great graphics, I generally played with these settings on low.

Since I needed a lot of practice before I could commit to the multi-player game, I spent all my time with the bundled AIs. Some are definitely better than others, E323AI and RAI I beleive the ones I competed against. One is easy ot beat, as soon as the game's mechanics are mastered, but the other one (I think it was E323AI), is a difficult one to handle, especially early game! I suspect that these AI processes are reducing the performance of the game overall, but still performed admirably.

The BA mod is a faithful recreation of the game I remember, and has been so good that I am yet to entertain the thought of loading up any other mods at this time! I will do this at some time though - Time permitting, of course!

For some screenshots, see here.

Well done to the guys over at Spring RTS, this is a worthwhile project, and I hope to get some time in the future to peruse the source for my self.

Wednesday, October 21, 2009

SQL Formatter Released!

Although, not finished by any stretch, I have released my first draft of the Laan.Sql.Formatter to 'production'.

I have provided 3 deliverables - each providing access to SQL Formatting for different purposes:
  • Sql Server Management Studio 2008 (SSMS) Plugin
  • Ad-hoc Sql Formatter Web Page
  • Sql Formatter Log4Net Appender (for use with NHibernate)
Further, the SSMS plugin provides a second feature - code template expansions. I've 'borrowed' the idea shamelessly from DevExpress' CodeRush (awesome tool), but without all the trappings. In my version, you can only expand a template that you know and remember (no visual clues - sorry, this *may* come some day), Also, the template list can't be edited/added/removed (yet).

For more information, and to obtain an installer for the plugin, go to the project site, or directly to the download page. There is also a download for the NHibernate Appender, with some simple documentation on it's use still to come. To play with the formatter, you can go to my web site as per my last blog entry.

If you find an issue, or have a feature request, you can add it here - but don't bother to log an issue regarding missing formatting options - I know I need to add some, eventually, but my plan is to get the core functionality done first.

Also, I would appreciate it if someone could provide a code review of my work so far. There is no doubt some of it needs more work, especially within the formatter assembly.. All code is available via svn hosted on google code, so it's easy to get access to a read only file set, or on the download page on the above link. If you are interested, let me know, or just send me an email of your review or blog it.

I hope you find these tools useful, I know I have..



Thursday, May 28, 2009

Laan SQL Formatter (alpha) is online!

Finally, after much wailing and nashing of teeth, I've delivered my first draft (alpha) of my SQL code formatter. There's not much too it, simply enter (or copy) your SQL into the top, hit convert, and the bottom will (should!) supply the formatted result!

code.laanfamily.com


Also, I will soon be releasing an NHibernate Appender which raps this functionality into a FormattedSqlFileAppender, once I get the appender subclassing working correctly.

Currently, the formatter (and even the parser, behind the scenes) is quite limited. It only supports SELECT statements, without UNION and SELECT..INTO modifiers. I believe there is full expression syntax parsing, but some aspects of expressions are still not formatted - e.g., bracketed sub expressions.

I will keep modifying it over time, as time permits (baby is now 6 weeks away!), but hopefully I can quickly implement INSERT, UPDATE and DELETE, CREATE TABLE and CREATE VIEW statements fairly rapidly. Then I'll work towards doing batched SQL instead of single statements, which will open the door for stored procedures.


Stay tuned!

P.S. Interested in the code? check it: http://code.google.com/p/sqlformat/