April 8, 2009

ReSharper 4.5 Released!

Filed under: Development — Tags: — Darrin Maidlow @ 7:09 pm

JetBrains has just released !   Some of the key features of this upgrade are:

  1. 1. performance and memory usage improvements
  2. 2. Solution-wide code inspections (tons of cool tools to find unused params, privates, etc)
  3. 3. VB9 support (too bad I’ve been busy moving to C# =])
  4. 4. Native MSTest Support (I much prefer though)

 

Check it out.  ReSharper is one of the tools I use every day and couldn’t live without…One more day and I’ll be done in Visual Lisp and can actually try out the new release a little more =)

Technorati Tags:

April 6, 2009

Using Relative URLs in CSS with ASP.NET

Filed under: Development — Tags: , — Darrin Maidlow @ 6:42 pm

When we started redoing the I decided that this new site would be all CSS based.  No more nasty tables.   Once the initial xhtml/css template was made I moved it into and ASP.NET master page.  As the site was fleshed out I ran into a problem where some of the images were not loading as the master page was used deeper within the sites structure.   A little inspection of the underlying CSS and I noticed this:

   1: #header {width:100%; height:50px;    background: #7D7D7D url(images/header.gif) left top no-repeat;}

 

When the master page is used from a page deeper than the site root, the paths in the CSS become invalid.  To work around this I made my CSS dynamic!  I added a new page to my project in the CSS folder.  I called this page allcss.aspx.css.   Open up this new aspx file and remove all the html.  Leave only the page header definition:

   1: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="all.css.aspx.cs" Inherits="landorIS.com.css.allcss" ContentType="text/css" %>

image

Note that you may need to update your classnames and stuff depending on how you name the file.  I wanted my file name to reflect the fact that it was a CSS file – but it’s still needed to end with .aspx to ensure the file would be properly parsed by the ASP.NET engine without having to mess with the extension mapping on the web server.  This resulted in Visual Studio making some illegal class names.

Also be sure that you add the ContentType attribute to the @Page definition, and set it to “text/css”, or you will get an error in some browsers stating that the Mime Type “text/html” is not “text/css”.  Nice of Firefox to do a little validation on the content.

At this point you can add your CSS to the file and use <%%> tags or codebehind to manipulate the values.  Now the CSS that was causing problems with the images looks like this:

   1: background:url('<%=ResolveUrl("~/img/header-bg.png")%>') no-repeat 0 0;

 

Now when the CSS is requested by the browser and rendered out, the URL to the image file will be properly displayed as /RootFoolder/img/header-bg.png.  This is a very simple modification, but one could go a little more crazy and do something like  detect browser make/model and send out browser specific css in pre-defined literals, or possibly add authentication checks. 

 

 

Technorati Tags: ,

March 2, 2009

One Click Builds Are A Beautiful Thing – Automated Build Studio

Filed under: Development — Tags: , — Darrin Maidlow @ 7:00 am

I’ve known for a long time that an automated build system is valuable, hey it’s number two on .  Recently the complexity of some of our products made an automated build system a requirement.  It was getting to the point where creating a build of was a four plus hour ordeal.  It had dozens of little steps, and missing even one would result in a defect.   This defect would be a vicious cycle.  We would have to debug to find the problem and fix it.  This would cause ANOTHER four hour rebuilt, and the “cycle of bug” would continue.

This complexity resulted in infrequent builds and as a result the code was not tested as well as it should have been.  Not to mention, I’d get really frustrated and even pissed off on build days.   It took me a while to find a system that really made me happy.  On a whim one night I downloaded (ABS) and gave it a shot.  After installing ABS on a new virtual machine that would become our dedicated build system I fired it up.  I was pretty impressed with the wide range of actions and  tools it supported.  In our environment we had several must have items:

  • 1. SourceGear Vault
  • 2. Visual Studio 2008
  • 3. Oracle/SQL Server
  • 4. Installshield 2009

 

ABS worked with all of them.  In addition to the key requirements I had – it supported a plethora of other operations.

First thing I did was sketch out a rough outline of what was involved in creating a build.  Get latest source code, compile, delete temporary files, etc etc etc.  I started selecting various options from the ABS and fleshing out my macro.  Within a couple of hours, I had a sweet macro in place.  My macro started to look like this:

  • Getting the latest code from Vault
  • Compile all assemblies
  • Delete the temporary files
  • Build the needed release folder structure
  • Move the new files into the needed structure
  • Execute on all assemblies
  • Increment the build version, and set the version on all assemblies
  • Create a label of the build in Vault
  • Build a zip of the release
  • Build the Installshield installer
  • Connect to the build FTP and upload the new build

 

The best part – all of this was occurring in a 100% reliable fashion, oh and it took minutes for a full build to occur.  Over time, this project was tweaked, and copied.  It evolved as I learned more about ABS – or thought up new requirements.  Take for example, it has evolved into three editions, sharing a similar yet different set of source files.  ABS lets me rebuild all three editions with the click of a button – in minutes.   Long long ago, in the before times something like this would have taken days, and years off my life.

I’ve only scratched the surface of what I’ve been able to do with ABS – some other cool features worth mentioning is that builds can be scheduled to run, there is a web application for viewing build history as well as kicking off builds.  It has a scripting language, and the support I’ve received is fantastic.  The price of the product makes the decision to buy ABS a non issue.

Man, now I’m starting to sound like a sales guy. =)  Seriously though, check out if you develop boxed, or even custom software.

July 14, 2008

ReSharper – A Class Creating Machine

Filed under: Development — Tags: — Darrin Maidlow @ 7:43 am

Recently, I purchased a copy of .  I’m not even going to pretend I’ve scratched the surface of what ReSharper can do, but I can assure you it’s a massive time saver when creating classes from scratch.  I’m furiously plugging away, implementing an ORM for RADE, and to do that I needed to create a lot of classes pretty much from scratch (oh, and do I have a few things to say about that, but that’s for another day).  Let’s look at a simple example.  To get things started, create a new class.  Select the folder in the solution explorer, and press Alt+Insert:

ReSharper Class Creation

Press enter and you are prompted for the class name.  So Visual Studio has this of course, but this is a small example of some of the time savings you can achieve.  Enter the class name and you start off with an empty class.  Next, lets define a couple of private members.   Let’s run with the following example.

   1: namespace RADE.BO.Domain
   2: {
   3:     public class SampleClass
   4:     {
   5:         private Int32 _ID;
   6:         private String _Description;
   7:         private Int64 _BiggerInt;
   8:     }
   9: }

 

Simple class.  Three member variables.  Here is where the big time savers come in.  Next, click Alt+Insert again and you will be prompted with the following options:

Some ReSharper Code Generation Tools

Choose Properties.  You will now be given the option to select one or many fields, set the access rights, read only and virtual properties as well a bunch of others. 

ReSharper Properties Generator

Execute that and all of your get/sets are defined.  My one complaint is that ReSharper is not maintaining the type on the properties.  My Int32’s become int, and Int64’s become long’s.  Apparently this is slated to be fixed.  

So yes, this sample class is tiny, but the time savings on larger classes, or projects full of classes are significant.  The last feature I’ve been using extensively in this project is the generate constructor tool.  Again, a form is displayed with the defined properties, select the ones you want and boom.  You can create half a dozen different constructors in seconds.  I’ve created a full object model on, roughly 20 different mildly complex objects in less than an hour, around midnight on a Sunday =)

Some of the other things ReSharper does is suggest code cleanup ideas by removing unused directives, easy execution of , improved code completion.  I encourage you to check it out, .

Technorati Tags:

May 25, 2008

.NET Code Protection – Remotesoft Protector to the Rescue!

Filed under: Development — Tags: — Darrin Maidlow @ 1:53 am

When .NET based assemblies go out the door, it’s incredibly simple for others to get access to your code.   Download and take a look at what some of your assemblies have to say.  The code visible is likely not going to be anywhere near as elegant as the original.  The comments will be gone.  The gist of what you are doing will be there.  If you would prefer that your work be a little tougher to get at, read on.

Obfuscation was one of my first answers to this problem.  An obfuscator ships with Visual Studio Pro, free and there are many available on the market.  Obfuscation just didn’t do it for me.  I once helped a customer troubleshoot problems with one of their software solutions from an unnamed vendor using Reflector and walking through the obfuscated code.  This was really a painful experience, it does make it harder to figure out what is going on – but a friend of mine suggested a product that takes code protection one step further.

Hello .  This product is pretty cool.  If you purchase the protector product you will receive three components.  Salamander .NET Decompiler, .NET Obfuscator, and .NET Protector.  Initially I was processing my assemblies with both the obfuscator and the protector.   Now a days, I pretty much only run my assemblies through the protector.

Once you’ve processed an assembly with the protector and you open it up in reflector things are going to look a little different.  Here is a little before and after action for you:

Code as disassembled by Reflector 

Now lets take a look at the same code, but after being protected:

image

That’s it.  Protector has made all your code go bye bye =)  What’s happened here?  As I understand it, Protector compiles all your managed .NET code into native code.  So, yes, is it possible to disassemble native binaries.  The difference here is the height of the bar – with plain .NET assemblies even my grand mother could get my code.  Reverse engineering a native assembly is a different story.  If someone with the skill to do that wants your code – well you must be writing some damn fine code.  It would probably be easier for that kind of person to write it from scratch =)

I’ve been working on increasing my score lately.  One of my biggies is the one step build for RADE.  That sentence really doesn’t do the task justice.  The first step I’m tackling in the one step build is automating the process of protecting my .NET assemblies.  I could not find any resources on doing with with MSBuild.  Once I get it working, I’ll post some code.

All that said, I highly recommend you check out Protector if code protection is your thing.  The price is a little bit steep at 1899$ for 1-5 developers – but how much money have you invested in that one little DLL or EXE file?

Powered by WordPress