t4

How can I use EnvDTE within a .NET Standard project

◇◆丶佛笑我妖孽 提交于 2019-12-01 22:34:57
I'm porting a .net 4.7 project to .net standard, which uses T4 to generate some code. I iterate over the classes, properties and methods. This use to work perfectly, but now the return types of DTE are of type 'System.__ComObject' and I cannot cast them. Error: Unable to cast COM object of type 'System.__ComObject' to interface type 'EnvDTE.CodeClass'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{B1F42514-91CD-4D3A-8B25-A317D8032B24}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E

what is and where can I find MvcTextTemplateHost

♀尐吖头ヾ 提交于 2019-12-01 19:29:01
I would like to know what this is MvcTextTemplateHost. I have this in my create.tt but I cant find it in my bin folder (searching with object viewer). I read up and found out it's in my VisualStudio.Extensions.web.dll but I cant find this dll I've read this T4 References for 'MvcTextTemplateHost' and 'VisualStudio' . I would just like to know what properties and methods this class has. I would love a t4 text editor. I installed a few but nothing gives me intellisense for this class thank you. MvcTextTemplateHost is "Host" of MVC 3.0 (Add>View and Add>Controller) Dialog and maintain user

T4 Text Template - Is it possible to get compilation symbols from host?

筅森魡賤 提交于 2019-12-01 17:54:12
Background: I have an open source game library written in C# which is highly tuned for performance, using unsafe code, pointer arithmetic etc. I've recently ported the library to Windows Phone. Unfortunately Windows Phone does not support unsafe code at all, so I have had to litter my source code with preprocessor directives such as this: #if WINDOWS || XBOX public unsafe struct Foo #elif WINDOWS_PHONE public struct Foo #endif Due to the amount of these directives the codebase has become quite unreadable and difficult to maintain, so I've been exploring other options - one of which is text

Use class inside a T4 template

拜拜、爱过 提交于 2019-12-01 15:58:47
I need to be able to use a class inside a T4 template, both of which reside in my solution. I have a class named Container in Container.cs . In my text template I want to be able to Access Container class. Any ideas on how can i do this. Basically something like this: <#@ template language="C#" #> <# var container = new Container() #> GarethJ In general, if you need to actually use the Container class's functionality in your template, you'll want to load the assembly that your project is building. This does introduce a circular dependency, as you need a built version of your assembly in order

Code generator (.net)

 ̄綄美尐妖づ 提交于 2019-12-01 12:19:41
Do you have any experience with T4 and T4 Editor ? Can you compare it to CodeSmith or MyGeneration ? What code generators do you use? What do you recommend? I want to use it for generatig of SPs. Is there anything else you find code generation useful? What exactly you are trying to do? I guess it also depends on from where you are trying to generate the code (the model). The advantage with Codesmith and MyGeneration is, they provide multiple options for you to generate your code - for eg, in MyGeneration, you can write your templates in various langs. MyGeneration can provide a meta model of

Cannot reference dependency assemblies in T4 template when using TransformOnBuild

为君一笑 提交于 2019-12-01 12:19:04
We're trying to use T4 with Visual Studio 2010 (SP1) to build scripts for another language that are based upon some of our existing C# classes. I'm hoping for the following: The template needs to load our existing assembly and use objects from a namespace in that assembly. The transformation needs to run on every build on every development machine and build server without any additional installations. (1) and (2) need to work together. (1) was fairly straightforward: <#@ assembly name="$(TargetDir)RequiredProject.dll" #> <#@ import namespace="RequiredProject.RequiredNamespace" #> Using the $

Code generator (.net)

我只是一个虾纸丫 提交于 2019-12-01 11:24:19
问题 Do you have any experience with T4 and T4 Editor? Can you compare it to CodeSmith or MyGeneration? What code generators do you use? What do you recommend? I want to use it for generatig of SPs. Is there anything else you find code generation useful? 回答1: What exactly you are trying to do? I guess it also depends on from where you are trying to generate the code (the model). The advantage with Codesmith and MyGeneration is, they provide multiple options for you to generate your code - for eg,

How can set the `custom tool` property of an xml file to a T4 file?

自作多情 提交于 2019-12-01 08:45:53
we know that asp.net .resx files have an custom tool for generating some c# code ( ResXFileCodeGenerator ). I have an xml file and I want to set the custom tool property of that to a T4 file. how can i bind T4 file to the xml file? You can do that with T4 Toolbox . Select the resx file in Solution Explorer and set the Custom Tool Template in the Properties window. Have a look at http://t4-editor.tangible-engineering.com/t4editor_features.html#Compare . There's a feature called "Add Code Generation Item Command" that might do the trick. 来源: https://stackoverflow.com/questions/14997308/how-can

Aspect Oriented Logging with Unity\\T4\\anything else

孤街醉人 提交于 2019-12-01 04:07:45
In my application we have a trace logger. We have log statements added at the beginning and end of most of the important methods tracing the method name and the parameter values. Now these trace statements are bloating the code and it is a bit of a pain to read through them. I am considering how can I separate this aspect of the code from my business logic. Today I was reading about Unity's interception framework. I had a passing thought if it is possible to intercept my method calls with a generic logger and log the method name and parameter values. I am not sure if it is possible to read

T4 template will not transform with build

前提是你 提交于 2019-12-01 02:40:58
I'm using VisualStudio Ultimate 2012 (Update 1) on Windows 7. I can get my T4 template to generate a file by: right click [tt file] | run Custom tool . That works great! (yay for me). It also works if I run the menu command: Build | Transform All T4 Templates . But I want automation! I run into a problem when I try to get the generated code file to be produced with every build -- which is my goal. I looked at this: T4 transformation and build order in Visual Studio this isn't what I want. It discusses using a pre-build build event. I wanted it to be part of the build. and this: Is there a way