Get flash to fully experience Pearltrees
I’m a bit quicker off the mark than I was with our Beta as this is my first day back from vacation after our Release Candidate has launched . We have one final significant T4 feature to add for Visual Studio 2012 in addition to all of the stuff from out beta and developer previews , and it’s a doozy! T4 template debugging In past releases of Visual Studio, debugging T4 templates has been a little more work than we’d like, so we’ve addressed that in this release with a simple to use but full-featured debugging experience: You’ll see the ‘Debug T4 Template’ menu item above on the context menu for the template in the Solution Explorer.
From time to time it happens that people want to use the async programming model in WCF based on the IAsyncResult approach - either on the client or the service side. Writing all the asynchronous operation contract signatures is quite a tedious and error-prone task. Given this fact, design-time code generation with a T4 template may come in very handy for this purpose. The following is my first try to create such a T4 template and it seems to work for the scenarios I need it for.
It’s been a while since I’ve blogged since things have been crazy busy. I finally decided to kick myself and do a post so without further ado, the problem at hand: A co-worker of mine asked me whether its possible to dynamically create a type from some data he is receiving from a WCF service (over HTTP). My natural response was, why would you need to do that since Visual Studio creates a proxy from the metadata exposed by the service and the return types would typically be DataContracts. Well, it turns out that instead of returning a strongly typed domain specific object, the service is returning a Dictionary<string,string> where the Key represents an attribute and the Value represents the value of the attribute. This has obvious problems:
My multiple outputs from t4 made easy post contained a class making it easy to produce multiple files from Visual Studio’s text templating engine (T4). While useful it had a few issues: Getting start/end blocks mixed up resulted in unpredictable behaviour Files were rewritten even when content did not change Did not play well with source control Files not always deleted in VS Failed in Visual Studio’s project-less Web Sites This helper class forms the basis of multiple file output for Entity Framework templates in .NET 4.0 and the LINQ to SQL templates on CodePlex so we (Jeff Reed, Andrew Peters and myself) made the following changes. Improvements Simpler block handling
For example, you could create a template to define an HTML page: <html><body> The date and time now is: <#= DateTime.Now #></body></html> Notice that the template resembles the generated output.
Watch Overview on Channel 9 Text Template Transformation Toolkit (T4) is a template-based code generation engine. It is included with Visual Studio 2008 and available as a download for Visual Studio 2005 in DSL and GAT toolkits. You can use T4 templates to generate Visual Basic, C#, T-SQL, XML or any other text files.