2015-03-05

My first .gitconfig

I've recently started to use git on an everyday basis. Here's a couple of configurations that you may find useful, if you're just getting started:

[http]
 sslVerify = false
 postBuffer = 104857600
[push]
 default = simple
[user]
 name = James Bond
 email = bond.james@mi6.com
[color]
 ui = auto
[core]
 autocrlf = true
 excludesfile = C:\\Users\\james\\Documents\\gitignore_global.txt
[difftool "sourcetree"]
 cmd = 'C:/Program Files (x86)/WinMerge/WinMergeU.exe' -e -u -dl Mine -wr -dr Theirs $LOCAL $REMOTE $MERGED
[merge]
    tool = kdiff3
[mergetool "kdiff3"]
    cmd = 'C:/Program Files/KDiff3/kdiff3' $BASE $LOCAL $REMOTE -o $MERGED
[credential]
 helper = store

A couple of notes:

  • You set all of this in Git Bash using the git-config command.
  • Your ".gitconfig" file is usually found in the root of your user folder.
  • If you have pluralsight, you can check the Git Fundamentals course.

2015-01-21

Should be or not to be, that is the question

If you are doing a lot of unit or acceptance testing, you've probably have been using FluentAssertions library (if not, give it a try!). This library presents a very good alternative to NUnit's Assert class (or equivalent unit test framework you are using). However, this are some caveats. One of them is that the ShouldBeEquivalent() extension method is case-sensitive when comparing string (and there is no AssertionOptions to do that). However, if you use the Should() extension method, it is case-insensitive. Putting it in simply terms:

        [Test]
        public void ThisWayItsCaseInsenstive()
        {
            var foo = "XPTO";
            var bar = "xpto";

            foo.Should().BeEquivalentTo(bar);
        }

        [Test]
        [ExpectedException(typeof(AssertionException))]
        public void ThisWayItsNot()
        {
            var foo = "XPTO";
            var bar = "xpto";

            foo.ShouldBeEquivalentTo(bar);
        }

Yes, I know it's documented, but it's not obvious, which is a very unfortunate design decision.

2015-01-07

Really resetting IIS

If you are developing ASP.Net web sites with IIS on your local machine it's not very uncommon to update libraries and sometimes IIS just gets messed up, something along the lines of "Could not load file of assembly...".

My recipe for this kind of issues is usually something like:

  • clean + rebuild from Visual Studio
  • iisreset
If that doesn't work, then I might get desperate and do this:
  • iisreset /stop
  • delete the web site from IIS Manager
  • delete the "bin" and "obj" folders for the project
  • restart Visual Studio
  • restart Windows
  • leave the room and start over (!)
But today, I've remembered that somewhere in between, it might be useful to delete the Temporary ASP.NET files, thanks to StackOverflow.

So, why not automatize this in a batch file? Here the prototype for my "really_clean_iis.bat":
@echo off

echo stopping IIS...
iisreset /stop

rem del %TEMP%\Temporary ASP.NET Files\*.*

echo deleting temporary ASP.NET files for .NET 2.0/4.0 32/64 bit...
del C:\Windows\Microsoft.NET\Framework\v2.0.50727\"Temporary ASP.NET Files"\*.* /s /q
del C:\Windows\Microsoft.NET\Framework\v4.0.30319\"Temporary ASP.NET Files"\*.* /s /q
del C:\Windows\Microsoft.NET\Framework64\v2.0.50727\"Temporary ASP.NET Files"\*.* /s /q
del C:\Windows\Microsoft.NET\Framework64\v4.0.30319\"Temporary ASP.NET Files"\*.* /s /q

echo starting IIS..
iisreset /start