AnkhSVN 2.0 Released - How’s it look?

11 07 2008

When I first started using Subversion full time for all of my personal projects, I stuck with the VisualSVN server and AnkhSVN as a Visual Studio client.  Both were free, easy to install, and easy to use.

However, after a few weeks, the AnkhSVN client could almost be called “annoying.”  It trampled over the existing SCC plugins for SourceSafe (for work) and made a mess out of several of my project uploads.  I ended up going back to using TortioiseSVN and doing everything through Explorer.

When AnkhSVN 2.0 was released, I figured I’d give it another shot.

The site claims quite a bit—including several unique additions:

  • Pending changes window; subversion status and commands available in one place
  • Full support for Visual Studio 2005 and 2008; AnkhSVN is now a SCC package instead of just an addin
  • Better log viewer
  • Merge support
  • Property editor
  • AnkhSVN now supports most project types previously unsupported via the SCC api
  • All solution explorer actions (rename, copy&paste, drag&drop) keep subversion history now
  • Enhanced build process and setup
  • Automatic check for updates
  • And last but certainly not least end user documentation

All of those look great—especially the SCC package and changes window.  But how does it compare once installed?

After installation and starting up VS2008, everything looks normal.

Brief Look

Pending Changes Window

The new pending changes window is FANTASTIC—much improved over the old 1.x versions.  I did run into a snafu when trying to resize the window where the scrollbars didn’t update on the screen; however, I’m not sure if it’s a VSS or AnkhSVN issue.

SCC Package

Under Options > Source Control, AnkhSVN shows up just like it should.

What does boggle me is that all of the Subversion commands and menus are available no matter what—even when the VSS SCC is enabled.  It still has the stink of VSS and SVN trying to step on one another (“pick me! control your project with me! no, I’m better! pick me!”).

Log/History Viewer

I really like the new history viewer.  It’s clean and easy to read; however, if you change the options at the top—there doesn’t appear to be a way to “change it back” and see the history again, close the view and review.

Annoyances

  • Opening a project from Subversion (File > Subversion > Open from Subversion) will open a project just fine, copy it down, but never opens it.  You have to go back and open the solution after it’s created the local structure.  Not huge, but annoying.
  • When viewing history; you cannot view the history of a single file (that I’ve found) in the Repository Explorer. 

I’m still planning to give it a whirl for the next couple of weeks and see what happens.  Hopefully over a couple weeks I’ll have more time to code—it’s been a busy July so far!





ReSharper 4.0 Beta Released!

22 05 2008

The EAP from Monday (19 May) was elevated from Beta candidate to Beta status later this week—a tremendous step for the tool.  The JetBrains team has been cranking out build after build and the latest few have been great!

If you have been putting off checking out the new ReSharper—don’t wait!  The builds are extremely solid and if you do happen across an issue, submit it up and help the community!





Bubbling up Methods in Composite Controls

9 05 2008

A while back, I wrote a couple of articles (here and here) regarding encapsulating the ModalPopupExtender into a spiffy little template control that you could toss onto a page.  It’s worked GREAT over the past few months, however, I hit a snag today.

I needed to call the base ModalPopupExtender’s .Show() method from code behind; however, I hadn’t bubbled that up to the Composite Control.

At first, I expected to simply add a private instance of the MPE (which is assigned to when the control is built) and then add a method to my composite control that calls the .Show() method.

private ModalPopupExtender _control;

public void Show()

{

       _control.Show();

}

That sounds good, but it never fired and the _control field was always null (even though I could step through and it was assigned).

What it needed was a little reminder—a reminder to EnsureChildControls existed before trying to call Show().  Now, a quick update to the code:

public void Show()

{

       this.EnsureChildControls();

       _control.Show();

}

Now I can call the Show() method of the Composite Control and it works like a charm!  Here’s an example (for what I’m working with at the moment) of dynamically iterating through an IDictionary and returning the values in a Modal Popup.

ASPX:

<tiredstudent:ModalPopupTemplate HeaderText=”ERC” runat=”server”

        ID=”PopupDialogBox” DefaultStyle=”YUI” TargetControlId=”fakeButton” />

<asp:Button ID=”fakeButton” runat=”server” style=”display: none” />

Code-behind:

foreach (var entry in results)

{

       sb.AppendLine(string.Format(“<p>{0} - {1}</p>”,

                     entry.Key, entry.Value));

}

 

PopupDialogBox.BodyText = sb.ToString();

 

PopupDialogBox.Show();

 





Basic Benchmarking in ASP.Net

10 04 2008

I’m not sure why I’ve always rewrote this “simple” code—over and over again, project after project.  I should know better, but perhaps time has gotten the best of me (though I’m betting on lazy).

What code might this be?  The basic “stopwatch” for evaluating page performance and outputing the results to Page.Trace. You can do page speed analysis using Visual Studio 2008, but for quick Trace output, I prefer this method.

The class is almost totally private, but could be expanded later on to log to console, log to files, whatever.

public class BenchmarkToTrace

{

private TimeSpan ElapsedTime { get; set; }

       private DateTime StartTime { get; set; }

       private DateTime EndTime { get; set; }

       private Page PageToTrace { get; set; }

       private string TraceCategory { get; set; }

 

       public BenchmarkToTrace(Page pageToTrace, string category)

       {

              PageToTrace = pageToTrace;

TraceCategory = category;

PageToTrace.Trace.IsEnabled = true;

}

 

       public void Start()

       {

              StartTime = DateTime.Now;

}

 

       public void Stop()

       { 

EndTime = DateTime.Now;

ElapsedTime = EndTime - StartTime;

PageToTrace.Trace.Write(

TraceCategory,

string.Format(

“Start: {0} “ + Environment.NewLine +

“Stop: {1} “ + Environment.NewLine +

“Elapsed: {2}”,

StartTime, EndTime, ElapsedTime));

}

}

As far as usage, here’s how I am using the benchmarker to evaluate different data retrieval methods (in this example, measuring Oracle performance):

BenchmarkToTrace bench =

new BenchmarkToTrace(this.Page, “Reports-GetAllBy”);

 

bench.Start();

Reports.GetAllBy(123465789, 3, “2007-2008″);

bench.Stop();

           

bench.Start();

Reports.GetAllBy(123456789, 4, “2007-2008″);

bench.Stop();

When I load up the page, I see the trace log:

BenchmarkToTest Results

Cool, and I won’t rewrite this NEXT time.





Verifying Extensions and MIME Types of FileUpload

7 04 2008

The FileUpload control is REALLY handy to upload files from a client, through the web, into a database table or the web server.  The control wraps up the HttpPostedFile object (into .PostedFile); however, there isn’t a way to “filter” on the fly.  This was a recent discussion in the Microsoft newsgroups today, so I figured I’d work out what it’d take to implement a “better” file upload control.

The control, inheriting the FileUpload class as a base class, implements quite quickly.  I’m sure you could go farther, but this works out nicely.

NOTE: In my experience, filtering by MIME type (aka content type) is much more reliable than parsing out the uploaded file’s file name and trying to grok the extension.  Extensions are far too easily changed. ;)

public partial class BetterFileUpload : FileUpload

{

public BetterFileUpload()

       {

              ValidContentTypes = new List<string>();

}

 

public IList<string> ValidContentTypes { get; private set; }

 

public void AddValidContentType(string contentType)

{

              ValidContentTypes.Add(contentType);

}

 

public void AddValidContentType(string[] contentTypes)

{

              foreach (var contentType in contentTypes)

{

ValidContentTypes.Add(contentType);

}

}

 

public bool HasValidContentType()

{

return

ValidContentTypes.Contains(PostedFile.ContentType);

}

}

This partial class simply adds a few methods and a single property to the FileUpload class—ValidContentTypes.

HasValidContentType looks through the ValidContentTypes and tries to match it to the PostedFile’s content type—then returns a boolean.

Using this code is simple.

To setup a few valid content types, you can either pass them one-by-one or as an array (you could also pass in a collection of some sort and use the ToArray() method to convert it back into an array).  You could also store these in the web.config file or another reusable source to keep the code clean.

protected void Page_Load(object sender, EventArgs e)

{

betterFileUpload.AddValidContentType(“text/plain”);

 

betterFileUpload.AddValidContentType(

              new[] {“application/msword”, “application/pdf”});

}

After the valid content types have been added and we’re ready to fetch the stream from the FileUpload object, we now have a tidy boolean method to check.

protected void ReadFileButton_Click(object sender, EventArgs e)

{

if (betterFileUpload.HasValidContentType())

       {

              InfoLabel.Text = “Valid ContentType: “ +

                     betterFileUpload.PostedFile.ContentType;

}

else

       {

              InfoLabel.Text = “Invalid ContentType: “ +

                     betterFileUpload.PostedFile.ContentType;

}

}

Works well and is reusable!





SVNing in Visual Studio 2008

26 03 2008

At work, we’re still a Visual SourceSafe shop.  It works, don’t knock it.

However, at home, I’ve become VERY happy with SVN.  TortoiseSVN is great to drop and pick up repositories, update, and all that jazz, but I really missed the convenience of having those functionalities in Visual Studio.

I remember Will mentioning that having the VS plugins “dirtied” up the environment with junk.  Maybe, but damn it… a hot key to sync to SVN, apply patches, see differences, etc., to me, is a productivity boost.  Maybe I’m not as hardcore as Will—or I’m just more lazy.

So, after looking around, I found two rather attractive plugins for SVN.

VisualSVN

VisualSVN is pretty darn slick.  The Server itself works very well, adds a beautiful MMC console for managing repositories, and just makes sense.  The VS integration plugin works great and it works hand-in-hand with TortoiseSVN.

I liked the interface for logging messages, checking in, and looking at differences the best.

The downfall—it costs a bit of money, but just a bit.

A personal license (well, and a corporate too, haha) is 49$US per individual.  If you are part of an active open source project, you’re in luck because it’s free (I’m assuming they appreciate the free advertising).

The advantage—while the connector for Visual Studio costs 49$US, the VisualSVN SERVER license is FREE.  That keeps us out of the command prompt for creating and managing the basics.  Good deal.

AnkhSVN

AnkhSVN is a free, open source solution for using SVN with Visual Studio.  Rather than relying on Tortoise, AnkhSVN actually fully integrates into Visual Studio—for Diffs, logging, snap-ins for the repositories, additional Solution explorer windows, and more.

It has the snazzy icons as well.

Unlike VisualSVN, it feels a bit rough. 

The menus are all over the place (the AnkhSVN menu is actually hidden in Tools and then adding the repositories is under File).  It also doesn’t register as a Source Control plug-in with Visual Studio (I’m assuming it’s working AROUND Visual Studio, not through it), so the File > Source Control menu never appears and cannot be used.

So what am I using?

Both.  The VisualSVN server is great and saves me some headaches for setting up repositories—I also love the web interface.  AnkhSVN, while a bit rough, works very well.  I’m using the 1.0.3 Preview release for VS2008, so I’m assuming it’ll continue to improve and I look forward to contributing where I can to that process.  The Server is running on Windows Server 2003 R2 and AnkhSVN works like a champ under both Windows Vista SP1 and Windows Server 2003 R2.

 





Visual SourceSafe 2005 - “HotFixes”

11 03 2008

I’ve apparently been out of the SourceSafe bit for a while now (now that I’m happy wiht SVN), but had to reinstall it today to touch a few old projects (from back in 2004).  After I installed, I tried to move a few files around and the SourceSafe Administrator kept locking up. 

Angry and frustrated, I hit up Google and found that a “hotfix” was published for SourceSafe back in December 2007 that summed up over 64 updates to the program—including fixes with Visual Studio 2008.

It notes:

This update is a rollup of hotfixes for Visual SourceSafe 2005. This update includes many stability improvements, performance improvements, data improvements, integrity improvements, and usability improvements. This update also improves compatibility with Microsoft Visual Studio 2008 and with Windows Vista.

After installing the updates, SourceSafe is working better than it ever has.  Cool.

 





.NET Tip of the Day

28 02 2008

I stumbled upon the site earlier today while watching my system Ghost—and it’s pretty cool.

If you haven’t checked it out, they provide a single “tip” or trick to using .NET (from using Visual Studio to performance considerations oc concatenation) and is available ala RSS (just the way I like it).  The site is clean, which is an added bonus.

Check it out.

 





LOLCode - Implementing “Fuzzy” Logic on Domain Driven Design

14 01 2008

Yeah, it’s still a Monday.  A week or so ago, a friend and I spent far too much time laughing at the LOLCats page—one of the most popular blogs here on WordPress (I’m not quite sure what that says about humanity, but none-the-less).

Earlier in 2007, a few developers coded up a compiler for the “leet” language of LOLCats called LOLCode.  I remember Scott Hanselman doing an article on it, but glossed over it.  I came across the site again today and, while’s totally insane, it did get me laughing.

Here’s an example of a try/catch block.

HAI
CAN HAS STDIO?
PLZ OPEN FILE "LOLCATS.TXT"?
	AWSUM THX
		VISIBLE FILE
	O NOES
		INVISIBLE "ERROR!"
KTHXBYE

What’s scary is that this isn’t much more difficult to read than some code I’ve inherited from others.  Heh.  If you’re totally bored, I suggest giving it a shot.  Scott’s article explains a .NET version of LOLCode, with compiler, for lots of coding fun!

CODIN IZ FUN!





Visual Studio 2008 "Consolas" Theme

16 11 2007

A few readers have emailed in asking what my Visual Studio font was–and how I had my development environment setup based on the screen shots I’ve posted up.

I’m a big fan of the Consolas font for development.  Consolas is part of Office 2007 and Vista, so you can grab it from those packs.  To me, it’s clean and crisp while still being very easy to read hundreds of lines of code.  I blogged and have an example about the font and it’s history here.

Here’s a link to download the font without needing Office 2007 and Vista (it’s from Microsoft, so no theft involved as long as you’re putting it into use in Visual Studio).

Finally, here’s a link to my Visual Studio environment settings; to save you some time.  Right now, I have the font size set to 11 (I use a 24″ or 30″ wide screen monitor depending where I am, so a bit larger size.  Changing the size is pretty easy.

To import the settings, open up Visual Studio, go to Tools | Import and Export Settings…