Category: Uncategorized

Three times I have received Order of Lenin…

I just came back from pre-premiere screening of Indiana Jones and the Kingdom of the Crystal Skull. To make it short: I haven’t had such fun in cinema for a long time. If you liked the old movies – you’ll love this one – it certainly is not the worst of them. Despite of the fact that the whole movie is just one giant product placement of refrigerators 😉 Even Shia LaBeouf is tolerable.

The movie is very well balanced, with lots of action, without long boring-ish moments like “and the Temple of Doom”, and without cheap jokes, like “and the Holy Grail”. It has lots of references to previous movies though, so it might be a good idea to see them once again to get the most out of this one.

To sum it up – I highly recommend it.

Technorati Tags: ,

Simplifying Rhino.Mocks; Round II

Just a small idea before I go to work. As follow up to my yesterdays post about Rhino.Mocks. I figured, that instead of supplying arrays of object for constructor parameters, which is error prone and doesn’t give you the safety of compiler checks, we can actually insert the call to constructor using Expressions (notice that this is solution that will work only in .NET >= 3.5).

Here’s quick and dirty sketch of remade method:

public TTypeToMock Mock<TTypeToMock>(Kind mockKind, Expression<Func<TTypeToMock>> ctorCall, params Type[] extraTypes)
    if (extraTypes == null) throw new ArgumentNullException("extraTypes");
    if (ctorCall == null) throw new ArgumentNullException("ctorCall");
    if (mockKind == Kind.WithRemoting)
        mockKind &= Kind.Strict;
    else if (!_mockMethods.ContainsKey(mockKind))
        if ((mockKind & Kind.WithRemoting) != 0)
            throw new ArgumentException("This kind of mock does not support remoting.");
        throw new ArgumentException("Invalid mock kind.", "mockKind");
    var newCall = ctorCall.Body as NewExpression;
    if (newCall == null)
        throw new ArgumentException("Not a constructor call.", "ctorCall");
    var ctorArgs = new object[newCall.Arguments.Count];
    for (int i = 0; i < ctorArgs.Length; i++)
        var param = newCall.Arguments[i] as ConstantExpression;
        if (param == null)
            throw new ArgumentException("You may only place constant values in calls to the constructor.");
        ctorArgs[i] = param.Value;
    return CreateMock<TTypeToMock>(mockKind, extraTypes, ctorArgs);
private TTypeToMock CreateMock<TTypeToMock>(Kind mockKind, Type[] extraTypes, object[] ctorArgs)
    //NOTE: possibly with lock in this call
    var mock = (TTypeToMock) _mockMethods[mockKind](_repo, typeof (TTypeToMock), ctorArgs, extraTypes);
    return mock;

And with that you get in return this:


Notice that you no longer need to specify <MyClass> (it’s grayed out) since compiler can infer that from the Expression.

Technorati Tags: ,

Agile Toolkit Podcast

I love reading blogs. I gain so much knowledge from people far smarter than myself. In my previous job it was taking me about 40 minutes to get there, and another 40 to return home. It’s quite a lot I guess, wasting over an hour in public communication.

Then to make my commute a little bit more productive (ok, I lie here, it was just boring) I decided to use my old Creative Zen Micro mp3 player, and listen to podcasts. That’s how it started, and now I have yet another source of knowledge about technology, and what’s great about it, is that I don’t have to be in front of the computer, or even at home to use it. I’m hooked.

Anyway, when I ran out of Hanselminutes, Dot Net Rocks, Polymorphic Podcast and Plumbers at Work episodes I started to look for some other great podcasts out there and I just found out (via great XP group) about Agile Toolkit Podcast.

It seems to be the best agile-centric podcast around, and it’s been published for roughly 3 years, so I have quite a few episodes to get up to speed with. At the moment I’m listening to an episode with James Shore, author of one of the books I bought last week. Great stuff, highly recommended.

Dr. Venkat Subramaniam on Agile Practices

There’s a great talk (video and slides) up on InfoQ, by Dr. Venkat Subramaniam on Agile Practices. Be sure to check it out. Great stuff, great speaker, great author.

Technorati Tags: , ,

My favorite ReSharper’ 4.0 feature

sshot-1Camel humps intellisense. Start using it, and you’ll be wondering how you could ever have lived without it.




ReSharper 4.0 – at last


Go get it here, and while you’re downloading, read release notes.


And suddenly I’m much less happy… 🙁



Well, maybe not that much less happy 😉

Ilya Ryzhenkov said…

We will renew evaluation period regulary, so all you need is use latest nightly build all the time 😉

Technorati Tags: ,

Visual Studio/ReSharper syntax coloring issue

I use custom color theme in Visual Studio. Black background and light-colored fonts. After installing new ReSharper nightly build I noticed however, that something is not right. ReSharper adds additional coloring to your syntax, but it seemed to be disabled. I checked ReSharper’s settings, and it looked OK. It turned out to be Visual Studio issue. Looks like it didn’t pick additional colors from ReSharper. To fix this you need to open Tools –> Options, then navigate to Environment–> Fonts and Colors, and wait for Visual Studio to reload its colors. You can close the window now. All should be back to normal.


Framework tips III: DateTime.ToString() explained

There seems to be much confusion around how DateTime’s ToString method actually works. Let me try to clear it out for you:

First, there are several ways of converting DateTime to String:

   1: public String ToLongDateString() {...}

   2: public String ToLongTimeString() {...}

   3: public String ToShortDateString() {...}

   4: public String ToShortTimeString() {...}

   5: public override String ToString() {...}

   6: public String ToString(String format) {...}

   7: public String ToString(IFormatProvider provider) {...}

   8: public String ToString(String format, IFormatProvider provider) {...}

Every of this methods calls internal method giving it reference to itself, format string and DateTimeFormatInfo instance.

Calling methods 1 – 7 is like calling method 8, with given parameters:

Method (and its parameters)

8th method’s parameters

ToLongDateString() (“D”, DateTimeFormatInfo.CurrentInfo)
ToLongTimeString() (“T”, DateTimeFormatInfo.CurrentInfo)
ToShortDateString() (“d”, DateTimeFormatInfo.CurrentInfo)
ToShortTimeString() (“t”, DateTimeFormatInfo.CurrentInfo)
ToString() (null, DateTimeFormatInfo.CurrentInfo)
ToString(String format) (format, DateTimeFormatInfo.CurrentInfo)
ToString(IFormatProvider provider) (null, DateTimeFormatInfo.GetInstance(provider))

If you don’t specify IFormatProvider, DateTimeFormatInfo.CurrentInfo is used, that is basically:

   1: System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat;

So although you may be very specific about your format, Current culture will be still take into account, which may result in unexpected strings in some cultures. Notice that there are basically three kinds of format you may provide:

  1. null (or string.Empty)
  2. one-character long predefined format
  3. multi-character long custom format

If you provide null (or empty string), in almost every occasion this will result in General date/long time formatting (same as providing “G” as format).

There is a list of all predefined formats here. Notice however that for ‘o’, “O”, “r”, “R”, “s” and “u”, invariant DateTimeFormatInfo, will always be used. Next, predefined format will be expanded according to given DateTimeFormatInfo’ properties (or their combinations), and ultimately, in all three above cases will end up with fully expanded formatting string, that will get translated to date-time string according to rules specified in second table on this site.

Notice however that ‘:’ and ‘/’ have special meaning and are not treated like literals. If you do need to use them (or any other formatting character) as literal, you have to precede it with ‘\’. If you want to embed longer literal string in the format you have to put it within ” or ‘ characters.


.NET Framework does its best to display date and time according to user’s settings, but if you need to make sure that date and time will always be displayed the same way despite of user’s settings, use the last overload, and pass some DateTimeFormatInfo instace. Otherwise, even if you use specific format strings like “yyyy-MM-dd HH:mm”, you may end up with strings like: תשס”ח-ה’-י”א 10:06

Technorati Tags: , , ,

To continue installation close the installer

dotbetthreefiveinstaller The title says it all. I’ve uninstalled beta2, and currently I’m trying to install the final version of Visual Studio 2008.

As many people had problems with .NET 3.5 installer, while installing VS, I wanted to install it before installing Studio. While installing it, I received one of the most bizarre notifications I’ve ever seen. Oh, and clicking ‘ignore’ causes the installer to exit with an error. Any ideas?

Technorati Tags: ,

Go way back in time.

I recently found this great website called Internet Archive:Wayback Machine. Basically it lets you see snapshots of different websites starting from 1996 to present day. I found this fascinating for at least two reasons.

  1. It’s fun. To see how Microsoft’s site looked back in 1996, or alpha version of Google.
  2. The other (more important aspect to me) is – this site is a great learning tool. Like in movies you can go back in time and jump between eras, see how the world changed. How sites we visit every day looked like few years ago. It may be eye-opening, especially for people designing web interfaces. It’s almost like archeology, it shows you how fashions changed, people went from dial-up to broadband, and I must say – all web sites I looked at, look now better that anywhere else in the past. I think it’s a good sign, that despite of fashions, being all webtwozeroish – usability improves.


Technorati Tags: , , ,