10 March, 2013

TypeLITE - TypeScript interfaces from .NET classes

In the last few weeks I was doing some client-side development in TypeScript. It is amazing tool, that increased my productivity in client-side development dramatically.

To streamline the integration between TypeScript and C# code on the server I wrote a simple utility that generates TypeScript interfaces from our POCO classes. It help us a lot in keeping our client-side code in sync with the server side-code - when a server-side class changes, TypeScript interface is automatically updated and if the TypeScript code isn't compatible with the updated interface, TypeScript compilation fails with nice, descriptive message - a huge difference form previous experience with pure JavaScript.

I think this utility might be useful for other developers, so I made it available under MIT license. It's called TypeLITE.


POCO classes
public class Person {
    public string Name { get; set; }
    public int YearOfBirth { get; set; }

    public Address PrimaryAddress { get; set; }
    public List<address> Addresses { get; set; }

public class Employee : Person {
    public decimal Salary { get; set; }

public class Address {
    public string Street { get; set; }
    public string Town { get; set; }

Generated TypeScript interfaces
interface Person {
  Name: string;
  YearOfBirth: number;
  PrimaryAddress: Address;
  Addresses: Address[];

interface Employee extends Person {
  Salary: number;

interface Address {
  Street: string;
  Town: string;

Usage instructions are available on Bitbucket on the project page. Any comments or suggestions are welcome.

28 January, 2013

Linking BitBucket with JIRA

Last week we started using the issue tracking system JIRA. To take full advantage of all features we wanted to integrate our repositories on BitBucket with JIRA - it should be easy, there is an official  DVCS Connector plugin for this task.

Installation of the plugin was really smooth, after couple minutes spend on configuration, we were able to push changesets to our repository and they immediately appeared in the activity stream of the project. At the first glance it seemed that everything is working just fine, but as we tried more advanced features a problem appeared - smart tags weren't working. (Smart tags is a nice feature, that allows you to edit issues in JIRA with the commit message - e.g. LS-15 #time 15m #close)

We checked and rechecked configuration of JIRA / Bitbucket and everything seemed exactly as in the installation guide. After some tests we tracked down the problem to user accounts - the user accounts on BitBucket weren't linked to the user accounts in JIRA, since issue changes in our JIRA can be made only by authorized users, smart tags couldn't work. Both JIRA and Bitbucket accounts have the same usernames and the same emails, but it isn't enough. 

After couple tries we finally found the solution - to successfully link the author of the commit with the JIRA user (and thus enable smart tags), the commit has to been made with the correct username. Is seems that BitBucket credentials are irrelevant for this case - they are necessary to push changes to BitBucket, but they aren't used by JIRA.

The username can be set in the mercurial.ini file or in UI, if you are using TortoiseHg

The correct format of the username is

Username <UserEmailInJIRA>

e.g. Lukas Kabrt <lukas@kabrt.cz>

I hope this might save somebody few minutes, because this detail isn't mentioned in the documentation (or it is well hidden :-) )