code-generation

How to debug/break in codedom compiled code

主宰稳场 提交于 2019-11-28 08:14:11
I have an application which loads up c# source files dynamically and runs them as plugins. When I am running the main application in debug mode, is it possible to debug into the dynamic assembly? Obviously setting breakpoints is problematic, since the source is not part of the original project, but should I be able to step into, or break on exceptions for the code? Is there a way to get codedom to generate PDBs for this or something? Here is the code I am using for dynamic compliation. CSharpCodeProvider codeProvider = new CSharpCodeProvider(new Dictionary<string, string>() { {

How to check for the presence of an OrderBy in a ObjectQuery<T> expression tree

五迷三道 提交于 2019-11-28 07:50:06
I'm using T4 for generating repositories for LINQ to Entities entities. The repository contains (amongst other things) a List method suitable for paging. The documentation for Supported and Unsupported Methods does not mention it, but you can't "call" Skip on a unordered IQueryable . It will raise the following exception: System.NotSupportedException: The method 'Skip' is only supported for sorted input in LINQ to Entities. The method 'OrderBy' must be called before the method 'Skip'.. I solved it by allowing to define a default sorting via a partial method. But I'm having problems checking if

How can I serialize an object to C# object initializer code?

戏子无情 提交于 2019-11-28 06:44:21
I'm looking to take an in-memory object (or JSON serialization of an object) and emit C# code to produce an equivalent object. This would be useful for pulling known-good examples from a repository to use as starting points in unit tests. We have considered deserializing JSON, but C# code would have an edge when it comes to refactoring. If your model is simple, you could use reflection and a string builder to output C# directly. I've done this to populate unit test data exactly like you discussed. The code sample below was written in a few minutes, and generated an object initializer that

Java source code parsers/generators [closed]

早过忘川 提交于 2019-11-28 06:25:11
I need tools to: Conveniently parse Java source code and easily access given elements. Easily generate source code files, to easily transform data structures into code Any good tips, libraries, frameworks, tools? Thank you for help. Since Java 6, the compiler has an API included in the JDK. Through it you can access the results of the Java parser through the javax.lang.model APIs. The same functionality was present with JDK5 in the form of the Mirror API . There's a good introductory article here . The best code generation tool I've seen is CodeModel . It has a very simple API and can generate

Creating T4 templates at runtime (build-time)?

半世苍凉 提交于 2019-11-28 06:24:21
We are building an inhouse application which needs to generate HTML files for upload into eBay listings. We are looking to use a template engine to generate the HTML files based on database and static fields that we have pre-defined. The template also needs to have logic capabilities (if-then, foreach, etc). We have looked at T4 and it looks perfect, but we don't see anything about whether it has the capabilities to be used at runtime, so that a user can create the T4 template, and then the application can "compile" it and generate the final HTML file. Is this possible, and how? If not, are

How do I execute ruby template files (ERB) without a web server from command line?

[亡魂溺海] 提交于 2019-11-28 04:53:35
I need ERB (Ruby's templating system) for templating of non-HTML files. (Instead, I want to use it for source files such as .java, .cs, ...) How do I "execute" Ruby templates from command line? You should have everything you need in your ruby/bin directory. On my (WinXP, Ruby 1.8.6) system, I have ruby/bin/erb.bat erb.bat [switches] [inputfile] -x print ruby script -n print ruby script with line number -v enable verbose mode -d set $DEBUG to true -r [library] load a library -K [kcode] specify KANJI code-set -S [safe_level] set $SAFE (0..4) -T [trim_mode] specify trim_mode (0..2, -) -P ignore

Generating assembly code from C# code?

亡梦爱人 提交于 2019-11-28 04:09:25
问题 Is there any way to generate assembly code from C# code? I know that it is possible with C code with GAS, but does anybody know if it's possible with C#? 回答1: C# is normally compiled to the .NET bytecode (called CIL or MSIL) and then JIT ("Just In Time") compiled to native code when the program is actually run. There exist ahead of time compilers for C# like Mono's AOT, so you could possibly compile a C# program through one of those and then disassemble it. The result is likely to be very

How do I get Eclipse to resolve classes generated with Maven 2?

你离开我真会死。 提交于 2019-11-28 03:54:37
I'm using Google Protocol Buffers to generate some Java classes for my project. Using Maven 2 and its "antrun" plugin, these classes are freshly generated before compile, output to target/generated-sources and put on the classpath during the build. So building the project from the POM is no problem. However, Eclipse doesn't know how to resolve the generated class, because the folder it's in doesn't seem to be on the IDE's classpath during development. I'm using m2eclipse and have it manage dependencies for me, so I had expected Maven to take care of this. How can I get IDE support (code

How to generate object @Entities from database?

扶醉桌前 提交于 2019-11-28 03:38:33
问题 I want to generate JPA's @Entity s from database (but I want it to be object oriented). for Example @Entity @Table(name = "badges") public class Badges implements java.io.Serializable { private Integer id; private User user; private String name; private String date; It would be cool if it also support ManyToOne, OneToMany, Parent and ManyToMany. P.S. I tried JBoss Tools(Hibernate Tools) and I did not work for me. 回答1: Use JBoss Tools (formerly hibernate tools). Quote from their site: Reverse

Type-safe generic data structures in plain-old C?

大兔子大兔子 提交于 2019-11-28 03:15:18
I have done far more C++ programming than "plain old C" programming. One thing I sorely miss when programming in plain C is type-safe generic data structures, which are provided in C++ via templates. For sake of concreteness, consider a generic singly linked list. In C++, it is a simple matter to define your own template class, and then instantiate it for the types you need. In C, I can think of a few ways of implementing a generic singly linked list: Write the linked list type(s) and supporting procedures once, using void pointers to go around the type system. Write preprocessor macros taking