WCF & useless ProtocolException

Imagine we have a program which uses WCF services. Sometimes your WCF service stops to work and you are getting such exception on a client. I find this exception absolutely useless. ‘The first 1024 bytes’… There are no useful information in this 1024 bytes at all. Now I have to spend additional time to figure …

T4 Runtime Template and code-behind logic

By default T4 runtime template adds to the project corresponding generated cs file But what if we want to have some custom logic in separate C# file? We create a partial class and put that logic there. But default project structure is not very friendly with that. How would we name this file? Where would …

T4 Design-Time templates base class

Let’s discuss how to provide a custom base class for design-time T4 templates. If we can do that it will open us a way to extend T4 templates and add as many features as you wish. First of all let’s find how the generated code looks like For that let’s add new design-time template Save …

T4 Templates and Null in Expression block

Another annoying issue with T4 templates is its support for nulls. If you have template Both design-time and runtime templates will fail with And this is very annoying because sometime you are calling external functions and you don’t want to check for nulls all the time. It is unacceptable. So I decided to change base …

T4 Runtime Templates Base Class

Unfortunately out of the box T4 Runtime templates in Visual Studio have some issues Let’s discuss these issues one by one. Issue with base classes When we create RuntimeTextTemplate1.tt Visual Studio automatically generates nested C# file which contains RuntimeTextTemplate1 and RuntimeTextTemplate1Base classes. RuntimeTextTemplate1 class contains actual generation logic generated from tt file. But RuntimeTextTemplate1Base class …

T4 Syntax

MSDN has an article which describes T4 syntax with details. I will quickly describe it Visual Studio 2012 supports two types of project items: Text Template aka Design-time Text Template Runtime Text Template aka Preprocessed Text Template T4 template can contain directives, text blocks, standard control blocks, expression control blocks and class feature control blocks …

[PowerShell] Built-in support for -Debug and -Verbose for your scripts

Here is very good article about adding support for so-called Common Parameters such as -Verbose or -Debug Short overview of the article above To enable support for Common Parameters you need to add the following snippet on top of your script So now you can invoke If you don’t like the fact that your script …