t4

Get all methods that are decorated with a specific attribute using T4/EnvDTE

陌路散爱 提交于 2019-12-18 04:02:59
问题 I'd like to get a list of all public methods in my project that are decorated using MyAttribute using T4/EnvDTE. I know this can be done with reflection, but I don't want to load the assembly and reflect over it in a T4 template, rather, I want to use the existing code files as the source. The following is boilerplate code I found on the internet that gets a reference to the current project <#@ template debug="true" hostspecific="true" language="C#" #> <#@ assembly name="EnvDTE" #> <#@

Determine solution configuration (debug/release) when running a T4 template

坚强是说给别人听的谎言 提交于 2019-12-18 01:53:11
问题 I have a T4 template that can output either optimized content or standard content based on a flag. Currently I'm manually changing the flag based on my needs. What I'd love to do is set the flag based on the Configuration of the Solution in Visual Studio. If set to build in Debug mode, I would output standard content. If set to build in Release mode, I would optimize the content instead. I found another T4 question that looks promising: T4 Text Template - Is it possible to get compilation

Accessing Projects via DTE in C# T4 Template

浪尽此生 提交于 2019-12-17 18:56:15
问题 I'm currently trying to iterate over all of my projects (sharepoint) to get all feature guids into an file. there i want to prefix them with the projects name. My problem is DTE.Solution.Item and DTE.Solution.Projects.Item (or the enumerators for foreach) will not take an integer as parameter and foreach returns an object which is not castable to Project. Here is my code snippet: var hostServiceProvider = (IServiceProvider) Host; var dte = (DTE) hostServiceProvider.GetService(typeof(DTE));

What T4 file is used to generate an EDMX from database via “Update Model From Database”?

十年热恋 提交于 2019-12-13 18:06:47
问题 When working with an EF4 (edmx) model, we frequently need to process an "Update Model From Database". Commonly, we need to just delete table(s) and let them fully regenerate from the database. The issue at hand is that we have multiple recursive relationships/properties. By default, the "update Model From Database" process creates the property with the object's name and then adds a 1, 2, 3, etc. for each additional relationship. So if I have a table of "companies" where it points to itself

Mono refuses to resolve relative paths in T4 template includes

空扰寡人 提交于 2019-12-13 05:26:13
问题 Ok so I'm trying to hack together something to make SubSonic3 work with Postgres, on Mono. I almost have the templates generating but have ran into one small problem. <#@ include file="PostgreSQL.ttinclude" #> will give a "cannot resolve include file" error. However, specifying a full path will work(though cumbersome) <#@ include file="/home/earlz/Projects/SubSonicPostgres/SubSonicPostgres/SubSonic/PostgreSQL.ttinclude" #> Is there any kind of fix to this issue? Is it even a known bug? 回答1:

How to generate Visual Studio Project using T4 using XML?

北战南征 提交于 2019-12-13 05:18:51
问题 Hi all! In earlier days it is possible using Code-Dom , I came to know that using T4 is much easier than Code-Dom. I have gone through many articles but still I am not in a situation to draft-out the code which will meet my requirements. I need to generate a code on the basis of an auto-generated XML document [ I am able to generate the XML document as per my requirements ]. It seems like this : <?xml version="1.0" encoding="utf-8" ?> <GeneratedSolution Name ="name of Solution">

How do you access publish information in a T4 Text Template?

[亡魂溺海] 提交于 2019-12-13 04:20:51
问题 How do you access publish information for use in a T4 Text Template? For example, I want to create a text template that generates an xml file that will be published with an ASP.Net Core MVC website. The generated file should be different depending on where I publish the website; Production or Test environment. So I would have something like this in the .tt file such that when it is generated it varies depending on the selected publish profile or the publish path: <# if(publishing to A) { #>

Adding POCO Entities

旧城冷巷雨未停 提交于 2019-12-13 03:56:52
问题 I have an EDMX file with context.tt and .tt file. I have POCO classes under .tt file. I have one more EDMX with POCO files. I want to copy some POCO classes from 2nd EDMX to 1st EDMX. Please keep in mind that the tables are different in both the EDMX. Just wanted to find out if its possible to copy one POCO class from EDMX and .tt file to another. Any help would be appreciated. 回答1: Solution was easy. Change the connectionstring of EDMX file. In my case I had to create a 2 Function imports

How can we get the T4 template to generate code based on a .cs file that the user is editing?

自闭症网瘾萝莉.ら 提交于 2019-12-13 03:38:29
问题 I'm trying to create a T4 template that will save our developers from creating a lot of boilerplate code that's necessary in our framework. Let's say the developer creates an interface and marks it with our custom attribute. I would like it so that any interface marked with that custom attribute is enhanced by additional methods, which means my T4 template would have to generate partial classes on the fly. However, I would like it so that this automatic generation happens on the fly and

Complex Object won't return when using 'include' syntax in WCF with Entity Version 6

守給你的承諾、 提交于 2019-12-12 20:17:46
问题 Okay so this one has got me stumped as I just see that my client basically disconnects and terminates when returning an object with 'include'. However it works fine without that across a WCF SERVICE. The problem is that I really want those connected objects set up through navigation. Basically the code is a complex object return: public teCIF getCif(int aCifId) { using (CIFContainer context = GetCifContext()) { var thing = context.teCIFs .Include("Product_TYPE") .FirstOrDefault(i => i.CIF_ID