Archives for category: Uncategorized

I know its a little obscure, but I recently needed to find out how to enable Typescript in a Visual Studio 2013 Class Library project, because per default this is not enabled. (probably a bug)

Vanilla way of enabling TypeScript:

  1. Create a “Class Library” project
  2. Add a Typescript file (.ts)

This is were the bug occurs, normally the TypeScript file should compile on save.  However it does not. So after searching around and looking at the csproj file and comparing it to a MvcApplication csproj file I found out what the problem is:

Visual Studio correctly adds the TypeScript props file at the top of your csproj. file:

<?xml version="1.0" encoding="utf-8"?>
  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props" />
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />

(see first project import)

This allows your csproj file to use the <TypeScriptCompile> tag


<TypeScriptCompile Include="Angular\Accounting\AccountingTestDirective.ts" />

Enabling compile on save is done by adding the missing

<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets" />


  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

at the end of the csproj file, before your own custom build tasks.

I believe this should have been done automatically. But now I know how to do it manually >D

A 40 minute timelapse deep in the night

While doing some filesystem work I encountered alot of AccessViolationExceptions because a file is being opened to write multiple times.  Even after closing the file explicitly a short timeframe exists in which the file could not be opened again.  The simplest approach for me was to retry openening the file until it worked.  To allow a more easy and more general way to handle exceptions I developed a small extensible try-repeat-framework which allows me to configure waiting and repeating strategies and also to only react to specific exceptions.  I have written it with a fluent interface which allows easy usage:

New: I created a Repository on Github :
Even newer: you can now install it via nuget:  PM> Install-Package Core.Trying

Example 1:

var configuration = new Try()
        // do not throw exceptions 
        // when action continouosly fails
        // only expectAccessViolationExceptions
        // repeat at most 5 times or until 
        // 1s of waiting time has passed
      .Repeat(5, 1000)
        // when actions fails backoff exponentially
        // e.g. first wait 10 ms then 100 ms then 1000ms
      //configuration is reusable
      var result = configuration.Execute(() =>
        /*something which potentially throws */

      if (result)
        // success
        Console.Write("number of retries: ");
        // failure
        Console.Write("time spent waiting [ms]: ");
        Console.Write("number of retries: ");
        Console.Write("last throw exception message: ");

Example 2:

// default configuration handles any exception
  // repeats 4 times at most and exponentially backs off
  Try.Default.Execute(() => {
    /*some action which potentially throws*/

let me know if you think it is useful…  Be warned that this type of repeat on exception strategy should not be applied blindly …

I developed the library because I needed it but some terminology was researched.  consulted sources:

To parse versioned web asset filenames ala
I wrote a simple class 

/// <summary>
/// simple class for describing a file library like 
/// jquery-1.4.min.js
/// bootstrap.min.css
/// libname-
/// ... etc
/// contains methods for parsing these kind of filenames
/// </summary>
public class FileLib
  /// <summary>
  /// regular expression for parsing the filename
  /// </summary>
  public static readonly string libRegex = @"((?<libname>[^\.-]*)-?)((?<major>\d+))?(\.(?<minor>\d+)(\.(?<revision>\d+)(\.(?<build>\d+))?)?)?(\.(?<tags>.+))*";
  /// <summary>
  /// parses a path as a lib
  /// </summary>
  /// <param name="path"></param>
  /// <returns></returns>
  public static FileLib ParsePath(string path)
    var filename = Path.GetFileName(path);
    return Parse(filename);
  /// <summary>
  /// parses a filename as a file lib 
  /// </summary>
  /// <param name="filename"></param>
  /// <returns></returns>
  public static FileLib Parse(string filename)
    var match = Regex.Match(filename, libRegex);
    var lib = match.Groups["libname"].Value ?? "";
    var major = match.Groups["major"].Value ?? "";
    var minor = match.Groups["minor"].Value ?? "";
    var revision = match.Groups["revision"].Value ?? "";
    var build = match.Groups["build"].Value ?? "";
    var tags = match.Groups["tags"].Value.Split('.');
    var extension = tags.LastOrDefault() ?? "";
    tags = tags.Reverse().Skip(1).Reverse().ToArray();
    var result = new FileLib()
      Extension = extension,
      LibName = lib,
      Major = major,
      Minor = minor,
      Revision = revision,
      Build = build,
      Tags = tags

    return result;
  /// <summary>
  /// Major version number
  /// </summary>
  public string Major { getset; }
  /// <summary>
  /// Minor version number
  /// </summary>
  public string Minor { getset; }
  /// <summary>
  /// Revision Number
  /// </summary>
  public string Revision { getset; }

  /// <summary>
  /// Build number
  /// </summary>
  public string Build { getset; }

  /// <summary>
  /// Creates a version object for the Filelib. returns null if this is not possible
  /// </summary>
  /// <returns></returns>
  public Version GetVersion()

    Version parsedVersion = null;
      var version = Major + "." + Minor + "." + Revision + "." + Build;
      while (version.EndsWith(".")) version = version.Substring(0, version.Length - 1);
      if (version == ""return parsedVersion;
      parsedVersion = new Version(version);
    catch (Exception exception) { }
    return parsedVersion;

  /// <summary>
  /// the name of the lib
  /// </summary>
  public string LibName { getset; }
  /// <summary>
  /// the tags of the lib.  e.g. min, intellisense, etc
  /// </summary>
  public IEnumerable<string> Tags { getset; }
  /// <summary>
  /// the extension of the lib
  /// </summary>
  public string Extension { getset; }


Table set for two




Tracks of the tram in bessungen at night

DSC00991Mushrooms on a rotting log.


Tower of old Lincoln Village Baracks