code-generation

Given a type instance, how to get generic type name in C#?

蓝咒 提交于 2019-11-28 22:38:16
Given a generic type, including List<string> Nullable<Int32> how do i get a generic name for C#? var t = typeof(Nullable<DateTime>); var s = t.GetGenericTypeDefinition().Name + "<" + t.GetGenericArguments()[0].Name + ">"; This yields "Nullable`1<DateTime>" , but i need "Nullable<DateTime>" . I see you already accepted an answer, but honestly, that answer isn't going to be enough to do this reliably if you just combine what's in there with what you already wrote. It's on the right track, but your code will only work for generic types with exactly one generic parameter, and it will only work

How to output namespace in T4 templates?

大城市里の小女人 提交于 2019-11-28 22:15:37
问题 I have a T4 template for a class set up with TextTemplatingFileGenerator Custom Tool in Visual Studio: <#@ template language="C#v3.5" hostspecific="True" debug="True" #> <# var className = System.IO.Path.GetFileNameWithoutExtension(Host.TemplateFile); var namespaceName = "MyNamespace"; #> namespace <#= namespaceName #> { public static class <#= className #> { // some generated code } } How can I get the value of the "Custom Tool Namespace" property in Visual Studio, so I don't have to

How to generate DELETE statements in PL/SQL, based on the tables FK relations?

北慕城南 提交于 2019-11-28 22:01:25
Is it possible via script/tool to generate authomatically many delete statements based on the tables fk relations, using Oracle PL/SQL? In example: I have the table: CHICKEN (CHICKEN_CODE NUMBER) and there are 30 tables with fk references to its CHICKEN_CODE that I need to delete; there are also other 150 tables foreign-key-linked to that 30 tables that I need to delete first. Is there some tool/script PL/SQL that I can run in order to generate all the necessary delete statements based on the FK relations for me? (by the way, I know about cascade delete on the relations, but please pay

Using types in a T4 template that exist in the same project as the template

爷,独闯天下 提交于 2019-11-28 21:54:47
问题 I'm working on my first T4 code generation tool to add some Stored Procedure helper code to my project. I've created custom types (e.g. StoredProcedure and StoredProcedureParameter to help with my code generation and have included the assembly and namespace references in my code: <#@ template debug="false" hostspecific="false" language="VB" #> <#@ output extension=".generated.vb" #> <#@ assembly name="$(TargetPath)" #> <#@ import namespace="StoredProcCodeGenerator" #> This allows me to use my

Is there an Emacs Lisp library for generating HTML?

时光怂恿深爱的人放手 提交于 2019-11-28 21:19:51
问题 I'm looking for a solution that allows me to write native Emacs Lisp code and at compile time turns it into HTML, like Franz's htmlgen: (html ((:div class "post") (:h1 "Title") (:p "Hello, World!"))) Of course I can write my own macros, but I'm interested if there are any projects around this problem. 回答1: As you found out, xmlgen generates XML from a list structure. What I did find disappointing with the ``xmlgen` package that the format it supports is not quite the inverse of Emacs' xml

Can I get an XML AST dump of C/C++ code with clang without using the compiler?

岁酱吖の 提交于 2019-11-28 20:24:18
I managed to compile successfully clang for windows with cmake and visual studio 10. I would like to get an XML file as AST representation of the source code. There is one option that provides the result with clang with gcc under linux (ubuntu) but doesn't work on the windows box: clang -cc1 -ast-print-xml source.c However, this is invoking the compilation stage (which I would like to avoid). Digging in the source code didn't help me so far as I am quite new to clang. I could manage to generate the binary version of the AST by using: clang -emit-ast source.c Unfortunately, this format is

Change unhandled exception auto-generated catch code in Eclipse?

喜你入骨 提交于 2019-11-28 20:14:58
If I have unhandled exception in Java, Eclipse proposes two options to me: (1) add throws declaration and (2) surround with try/catch. If I choose (2) it adds a code try { myfunction(); } catch (MyUnhandledException e) { // TODO Auto-generated catch block e.printStackTrace(); } I want to change this to try { myfunction(); } catch (MyUnhandledException e) { throw new RuntimeException(e); } Is this possible? UPDATE Why are so love to change the topic people??? If exception is catched and printed it is also no need to catch it anymore. I like my application to crash if I forget to handle an

How can I see the assembly code that is generated by a gcc (any flavor) compiler for a C/C++ program?

二次信任 提交于 2019-11-28 20:07:01
I am trying to optimize a lot of multiplications and pointer arithmetics and would like to see what the compiler does underneath when I put in optimization flags. --Edit-- How to restrict it to a specific function or a code block? --Edit_2-- How to let gcc generate a less verbose assembly-code? P Shved Add -S switch to your command line. Edit: Do not forget that it will place the assembly to the files you specified under -o switch. How to restrict it to a specific function or a code block? Put that function in a separate source file (and use a different command-line parameter for that one

Maven example of annotation preprocessing and generation of classes in same compile process?

倖福魔咒の 提交于 2019-11-28 18:26:06
Does anyone have a clean example of a maven project preprocessing class annotations at compile time with subsequent generation of classes to be compiled in the same compilation process? Does anyone have a step-by-step procedure to implement such a project? Jérôme Verstrynge After navigating a lot in existing documentation on the net, I came up with the following: What needs to be clarified: In order to process annotations on a given project P, you first need an annotation processor compiled in a separate library S. P should have a dependency on S. Implementing annotation processing in Java 5

How to view “generated HTML code” in Firefox?

此生再无相见时 提交于 2019-11-28 18:14:35
If using Firebug, we can click on the HTML tab, and click to expand each element to see the generated HTML code. Is there a way to expand it all or get a plain text file? I just accidentally found out that there doesn't even need to be Firebug. We can just press CTRL-A (to select all) on the webpage, and then right click and choose "View Selection Source", then we will get a plain text file of the "current HTML code", even will see a <div> that is the Firebug panel that is before the <body> tag if Firebug is open. But it seems like a weird way to invoke this. Is there any other way? ( Update :