Question

I have been writing an assembly to simplify much of my POCO type generation. I have one core assembly which multiple tt files include and use to generate the code.

The reason I have done this is because no matter which extension I try (Devart T4, Tangible-T4 or Visual T4) none are as good as the intellisense and support offered by Visual Studio's C# editor, so writing the code generation in pure C# improves the experience a lot.

The biggest issue I am facing is the fact that the entity framework helper classes (e.g. Accessibility, CodeGenerationTools, MetadataTools etc) are defined inside a ttinclude file and not an assembly; currently I am having to rewrite a lot of the functionality these classes provide so that it is usable from an assembly.

My question is, why did the entity framework team decide to use a ttinclude file rather than some compiled assemblies? Using the assemblies approach seems like it would have been much more usable in more circumstances and still would not have affected T4 code generation (as instead of using <#@ include #> it would be <#@ assembly #>).

I am wondering what the best approach to resolve this would be, I have contemplated running EF.Utility.CS.ttinclude through TextTransform.exe and then taking the generated C# and compiling this, would this be advisable?

Thanks, Luke

Update

Currently what I did was add EF.Utility.CS.ttinclude to my project, set the custom tool on the file to TextTemplatingFilePreprocessor. This will generate the code containing the classes. I then copied this cs file, removed the class responsible for writing output (it has the method TransformText()) and compiled into an assembly. I can now use the entity framework utility classes in my assembly.

Was it helpful?

Solution

The reason for using ttinclude instead of assembly is the same as using T4 instead of custom tool for class generation (which is what you are actually doing and what most of designer used previously). T4 and ttinclude can be changed. You can copy ttinclude and create small change and include it in the main T4 per project basics.

Btw. do you know that there are tens of thousands of programers who can write a code without any intellisense ;) Worse support of intellisense is not reason to giving up using T4 templates.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top