Tuesday, 7 October 2014

How to improve your ReSharper proficiency

Many developers that start working with ReSharper realize that the learning curve is steep. There are many hidden features, many shortcuts that need to be memorized, there are many tricks that one can do in order to improve his/her productivity. So here is what I did to help my colleagues to help them learn ReSharper.

I created a REST API that returns random ReSharper tips or trick. Its source code is available on github:


I used AppHarbor for continuous integration and cloud hosting. So at the end, the REST API is available at the following URL:


It returns random ReSharper tip or trick in JSON format:

Then I incorporated the above REST API in our command-line build process:

So every time we build, we see random ReSharper tip or trick.

Enjoy coding!

How to write to console from Windows Application

When creating a Windows Applicaiton, either WinForms or WPF it does not have console. Converting the application to Console Application seems to solve the problem. If we execute our application from a console, it will be able to print to console and everything seems to be fine. But when we run it not from a console  a new console window will appear in addition to the existing Form or WPF Window. So what we can do?

AttachToConsole will actually attach to the parent console from which the Windows Application was executed. Unfortunately, it does not move the cursor to the next line. Thus the next line is required Console.Writeline.

Sunday, 24 August 2014

Must have tools for Windows

Each one of us uses some tools that makes his/her life easier. In this post I would like to share a list of very essential tools save a lot of time and let us focus on what is really important to us. The tools have a common denominator: they help to get things or get things done. Please note the difference in terminology. Sometimes in the past there was File Manager and we had the feeling that we "manage" files. When the amount of files increased it was replaced by Windows Explorer. So we had the feeling or exploring things. Then a Search button was added that should have help us to find thing. Unfortunately it was pretty slow, so we still go lost among the files. Nowadays in the 2014 we want to "get" instead of search, manage or explore. So the tools you'll see here focus on getting programs from the internet, getting files on your computer, getting programs on your computer, getting you passwords etc.

So here they are:

1. chocolatey.org - is the ultimate installer for every program for Windows. It has an enormous catalog of pro grams for download with a one line command line. So it is the new way to "get" programs to your computer.

2. Everything -  is the fastest and most effective way to "get" files on local computer. Unlike built-in Windows Search, it is extremely fast, it does not interfere with other programs, such as anti-virus software or files written by compilers or test runners. And it can be invoked with a shortcut. I prefer WinKey-N, for the similarity for the ReSharper and IntelliJ Ctrl-N, but it is completely your choice.

3. Launchy - is the fastest and most elegant way to execute eny program on your computer. It can be invoked with a shortcut (I use Alt-Space) and with typing a few characters it finds any program you need. Launchy has also some useful pluigns like: Killy, Tasky

4. Console2 - command-line console has been for many years the way we like to execute things. But the built-in console is poor and lacks of many features. Console2 is the new and must-have console application. Among its features: multiple tabs, copy-paste with keyboard shortcuts, resize. After installing Console2, follow step described by Scot Hanselman here.

5. Dropbox - needless to say how it is important to keep all your files synced between different machines. Dropbox is one of the popular and  convenient ways to do it.

6. Lightshot- this small and non-intrusive application helps to take screenshot. It allows cropping your screen while taking the snapshot, then editing it on the spot and then copying to clipboard or saving to file. By copying to clipboard and then pasting to the desired application (even to Gmail) you can save a lot of time.

7. Keepass - we need to keep track of our passwords and there are plenty of them. Every website, every application require its own authentication. Keepass allows storing all your passwords in a single encrypted file. The file can be protected by master password, external file, Windows User account or any combination of those methods. I suggest saving the Keepass file in Dropbox folder for easy access from different machines.

All the tools listed above are free.

Sunday, 3 August 2014

TeamCityZen - TeamCity communication and socializing extension

Every organization that uses Continuous Integration can admit, that the continuous integration server became much more than just build-machine. It functions as company's central monitor for the healthiness and readiness of the software being developed. It answers many questions raised by developers, analysts, product managers, development managers, operations etc. But more than this, it became the center of communication for those team members. You can often hear conversations like those:

- I am waiting for you to finish this feature, can you let me know when you're done?
- I will commit the interface of service, so you could consume it. I'll send you an email when I do.

Those conversation led me to writing a TeamCity extension named TeamCityZen, since we are sort of citizens of the city named TeamCity. The extension enables mentioning somebody's username in commit comments. User who was mentioned in the comments will be notified by email. Support any kind of Source Control: Git, TFS, Subversion, etc.

Screenshot from TFS:

Feel free to download, use and extend.

More details: https://github.com/borismod/TeamCityZen

Clean Code Alliance second meeting summary

If you are a constant reader of this blog, you must noticed that my friend Itzik Saban and I organized a meetup group: Clean Code Alliance. Recently its second meeting took place at Kenshoo offices. We were really excited to see the growing interest to clean code in general and to our group in particular. Except of the sessions itself there is vital networking that takes place between the sessions.

On group's second meeting there were two sessions, which can be watched on group's YouTube channel:

Clean Code Principles - part II by Itzik Saban

Continuous Delivery in Practice by Tzach Zohar

In order to keep in touch between the meetings, feel free to follow the group on twitter: @CleanCodeAll
and join discussions on LinkedIn group:  http://www.linkedin.com/groups/Clean-Code-Alliance-8104602

See you on the coming meetup!

Thursday, 17 April 2014

BizArk.Core 2.0.14 was pushed to NuGet

Bizark.Core 2.0.14 was pushed to NuGet

Release notes:
9290   Not parse array of string


[CmdLineOptions(ArgumentPrefix = "-", AssignmentDelimiter = ':', ArraySeparator = ";")]
public class CmdLineObjectWithStringArray : CmdLineObject
    public string[] Names { get; set; }
You can invoke the console application from command line:

MyConsoleApplication -Names:1;2

Bizark.Core will parse the values into string array of Names: { "1", "2"}


Tuesday, 1 April 2014

TeamCity hidden shortcuts

My colleague says, that he hates JetBrains as a company. He cannot find anything wrong or ineffective in their products. He is surprised that they just work. Work as expected and even better. They foresee our needs and our requirements and have already implemented them.

In this post I would like to share you the keyboard shortcuts I found in TeamCity:

p is a shortcut for searching among project names. Strike "p" and then start typing a project name Available in TeamCity 7.0

j is a shortcut for searching projects and build configurations in the same root project. Strike "j" and then start typing a project name or a build configuration name. Available from TeamCity 8.0

And the most powerful:
q is a shortcut for searching both projects and build configurations. Strike "j" and then start typing a project name or a build configuration name. Available from TeamCity 8.0

P.S. Thanks to JetBrains and Pluralsignt for supporting CleanCodeAlliance group.

UPDATE: I've got a reply from JetBrains employee on twitter that there are even more keyboard shortcuts in TeamCity's Changes page in version 8.1:

up/down to navigate, right/left to expand changes.  And 'f', 'b', 't' to open specific tabs of the selected change

Thanks to Kirill Maximov @maxkir

According to Kirill there is no official documentation about the shortcuts. So I will maintain this post as a sporadic one.

Monday, 17 March 2014

Clean Code Alliance group on Meetup

My friend Itzik Saban and I opened a new group on Meetup: Clean Code Alliance. You may ask, who needs another group and more meetings when there are a lot of them talking about almost every technical aspect of software engineering. Most of the groups are focused on specific technology or domain. The purpose of Clean Code Alliance is to return to the basics - to quality and clean code. We would like to talk about clean code principles, TDD issues, domain driven design concepts, applicative information security principles, anti-patterns in programming and testing, quality code metrics.

Feel free to join the group on meetup: Clean Code Alliance

Thursday, 20 February 2014

How to follow best practices of NHibernate with WCF integration?

If you work with NHibernate, you are probably familiar with its best practices. When working with WCF we need to maintain UnitOfWork and transactions. There is a library that makes this integration seamless: NHJump by James Lanng and Richard Penrose.

Marking your service class with an attribute will do the magic:
  • will create a unit of work per request
  • will open a transaction
  • will commit it at the end of the request or rollback it if an exception was thrown
public interface IPersistenceService  {  ...  }  
public class PersistenceService : IPersistenceService  {  ...  }

Sounds nice? It has also ASP.NET MVC integration.

Samples can be found on SVN repository:

Available on nuget:

PM> Install-Package NhJump.Persistence

Wednesday, 29 January 2014

How to merge multiple .NET assemblies into one

Sometimes we need to deliver our code as a single assembly for different reasons. There are a few techniques for doing that.

The first one and maybe the most obvious is ILMerge. A command line tool that disassembles multiple assemblies into IL code and then reassembles them to a single one.

When to use ILMerge:
 - When all the assemblies are from the same provider. If the assemblies have strong name, they will be re-signed with the snk file of the first of them (or executable if exists).
- ILMerge works well on Microsoft.NET framework only. Supported version is only 2.0 and higher

When we cannot use ILMerge:
- When merging assemblies from different providers. For example, one assembly written by our company which references a few 3rd party assemblies.
- When merging WPF assemblies, because they use embedded resources, that needs to be serialized
- ILMerge won't work on other .NET frameworks, such as Mono or Rotor.
- ILMerge won't merge assemblies from .NET Framework 1.1

Another technique makes use of embedding assemblies as resources within the main assembly. So here are the steps:
1. Add referenced assembly as embedded resource to the main assembly.
2. Don't forget to select "Embedded Resource" in Build Action on File Properties
3. Add a code that loads assembly from the resources (see below)

When to use loading assemblies from resources:
- When we need to load multiple strong named assemblies from different providers.
- Any case that is not supported by ILMerge

Here is a sample code that loads assemblies from resources. It started from Jeffrey Richter's blog post and enhanced to support loading multiple assemblies. When I used the code as is in his post I got an exception saying "Method not found". So here is the modified piece of code. It needs to be initialized in a static constructor of your "main" class, i.e. the first class user would access before accessing other classes.


public class AssemblyResolver
    private readonly Dictionary<string,Assembly> m_LoadedAssemblies = new Dictionary<string,Assembly>();

    public Assembly CurrentDomainAssemblyResolve(object sender, ResolveEventArgs args)
        var assemblyResource = BuildAssemblyResourceName(args.Name);

        return m_LoadedAssemblies.ContainsKey(assemblyResource)
            ? m_LoadedAssemblies[assemblyResource]
            : LoadAssembly(assemblyResource);

    private static string BuildAssemblyResourceName(string requestedAssemblyFullName)
        var containingAssemblyName = Assembly.GetExecutingAssembly().GetName().Name;
        var indexOfComma = requestedAssemblyFullName.IndexOf(",", StringComparison.Ordinal);
        var requestedAssemblyName = indexOfComma > 0
            ? requestedAssemblyFullName.Substring(0, indexOfComma)
            : requestedAssemblyFullName;
        var assemblyFullName = String.Format("{0}.Resources.{1}.dll", containingAssemblyName, requestedAssemblyName);
        return assemblyFullName;

    private Assembly LoadAssembly(string assemblyName)
        using (var assemblyStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(assemblyName))
            if (assemblyStream == null) return null;

            using (var reader = new BinaryReader(assemblyStream))
                var readBytes = reader.ReadBytes((int) assemblyStream.Length);
                var assembly = Assembly.Load(readBytes);
                m_LoadedAssemblies.Add(assemblyName, assembly);
                return assembly;

    public AssemblyResolver Attach()
        AppDomain.CurrentDomain.AssemblyResolve += CurrentDomainAssemblyResolve;
        return this;

    public void Dettach()
        AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomainAssemblyResolve;
Yes, I know there is a lot of code, but let's try to understand it one by one.

AssemblyResolver class holds list of already loaded assemblies. If an AssemblyResolve event occurs, the resolver looks up in the m_LoadedAssemblies and return the already preloaded instance from it. If the requested assembly is not loaded yet, LoadAssembly method will load it from the embedded resources and add it to m_LoadedAssemblies. BuildAssemblyResourceName method concatenates resource name assuming that dependend assemblies reside in Resources folder in the main assembly.

Please note that it ignores the version of the requested assembly and its public key. It assumes that the correct assembly was added to the embedded resources.

Here is the usage from another class:

public class MainClass : IDisposable
    static readonly AssemblyResolver Resolver = new AssemblyResolver();

    static MainClass()

    public void Dispose()
That's all! Hope it helps