... Home Contact

Krzysztof Koźmic's blog

You're doing it wrong.


Show appreciation: My Amazon.com Wish List

Me@Twitter

    Currently reading

    Article Categories

    Archives

    Post Categories

    MyPersonal

    Syndication:

    January 2008 Entries

    Hello World: the 'new' keyword

    Everyone knows what the new keyword is for in C# - you use it to call constructor of an object, right? What can be simpler? Actually, that's true, but not the whole truth. That's the most common way to use it. However, new is one of contextual keywords, which means, it can have different meaning, depending on the context where it's being used. The new keyword can be used in three scenarios: the one presented above, everyone immediately thinks of - creating objects. as modifier, to hide members of a base class. as generic constraint. Creating objects is pretty...

    Cheating an application

    I have contact with lots of different software. However yesterday I came across an application, that completely blew my mind... in a negative sense. This particular application uses its own custom file format, that is basically zip, with special files and folders inside, much like Open XML and Open Office file formats work. What's different however, is that it requires you to have WinZip installed in order for it to work. And by WinZip, I mean WinZip, not just some generic compressing/decompressing program that supports zip format. This thing is so ridiculous that I just don't know what to say....

    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...

    Framework Tips V: Extension Methods and nulls

    You can call extension methods on null elements. It's obvious when you think about it: its a normal static method where you specify its first parameter with this. using System;namespace ExtensionMethods2{ class Program { static void Main(string[] args) { string isNull = null; Console.WriteLine(isNull.IsNullOrEmpty()); string isNotNull =...

    XCopy deployment of MbUnit

    Yesterday I blogged about advantages and disadvantages of XCopy deployment. I didn't say however, about one important scenario, where you may need not to use any installers in order to deploy software to a new machine, and that is, setting up project on a new developer's machine. J.P. blogged about it a few times, so I won't repeat his words, and get straight to the point. One piece of software that you certainly will need is Unit Testing framework. My favorite one - MbUnit, can be however downloaded only as installable package, so you will need to perform few additional...

    To install, or not to install: that is the question

    While most applications come with installer, there are many, that don't. They are usually a single .zip, .rar or .7z file, that you can extract to some directory on your hard drive, and that's it. They just work. One such example is NDepend, which comes only in this form. Many other applications, like Notepad++ give you choice: you can either get installation package, or a .zip file. Each approach comes with its own set of advantages, and disadvantages. Zip/rar packages, are usually smaller downloads, and it definitely maters for people with dial-up connections. All depends on the particular application, but...

    Framework Tips IV: Check if character exists for given Encoding (CodePage)

    In a project I'm currently working on, I needed to check if particular character is a part of given CodePage. Problem with .NET's Encoding class, is that although it maintains a table mapping Unicode characters to codes in particular CodePage, it keeps it as private field. Moreover it does its best to replace characters it does not contain, with some fallback character. One might use this fact, and compare character received this way from Encoding' instance, with original character, assuming, that if they are different, this character is not a part of that CodePage, but this is not an elegant...

    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:...

    Upgrading Visual Studio trial to full version

    Today I finally downloaded my MSDN version of Visual Studio 2008. Up 'till now I've been using trial version and I wanted to upgrade it before my trial period ends. So I burned downloaded ISO to DVD, started the disc, ran the installer, and saw this: Apparently something went wrong with the burning, so I mounted the ISO as virtual drive, ran the installer and saw the same message box again. Hmmm could I have downloaded corrupted ISO? I decided to give it last one shot, and unpack ISO with 7-zip. Surprisingly, when I opened the ISO with 7-zip...

    Framework Tips II: How to get default ANSI Encoding for given culture

    It's sometimes useful to know what is the default ANSI CodePage, for some given culture. It's quite easy to achieve, thanks to System.Globalization namespace. CultureInfo cultureInfo = CultureInfo.GetCultureInfo(1252); Encoding encoding = Encoding.GetEncoding(cultureInfo.TextInfo.ANSICodePage); However this code will not always work correctly. The problem is, not every culture has default ANSI CodePage, and therefore, for them you'd have to have plan B, like using UTF-8. CultureInfo cultureInfo = CultureInfo.CurrentUICulture; ...

    Linkz: Continuous Integration - how to...

    Carel Lotz has published updated version of his great "Continuous Integration: From Theory to Practice" guide. Updates include: Updated to use VS 2008, .NET 3.5 and MSBuild 3.5 (including new MSBuild features like parallel builds and multi-targeting). All tools (NUnit, NDepend, NCover etc.) are now stored in a separate Tools folder and kept under source control. The only development tools a developer needs to install are VS 2008, SQL Server 2005 and Subversion. The rest of the tools are retrieved form the mainline along with the latest version of the source code. Added the CruiseControl.NET configuration (custom...

    Framework Tips I: Clear StringBuilder

    StringBuilder is a class that allows you to manipulate strings in mutable manner. It has many methods allowing you to Append, Insert and Replace, portions of the string. However it does not contain Clear() method, that would allow you to clear the content of a StringBuilder.There is Remove(int,int) method, that allows you to do this, but it requires you to pass two parameters to achieve this. int startIndex = 0; stringBuilder.Remove(startIndex, stringBuilder.Length); There is however easier, and more elegant way to do this. Other than in case of most classes in the framework, StringBuilder's Length...

    Get free Introducing Microsoft LINQ e-book

    As Paulo Morgado brought to my attention, Microsoft published absolutely for free, full pdf e-book version of new Introducing Microsoft LINQ book, by Paolo Pialorsi and Marco Russo. Its got average Amazon rating, but hey - don't look a gift horse in the mouth. You can get the book (and some free chapters of two other) here. Technorati Tags: ebook, linq, Microsoft