code-generation

'CompanyName.Foo' is a 'namespace' but is used like a 'type'

左心房为你撑大大i 提交于 2019-12-17 08:29:55
问题 Restatement of the question I'm resurrecting this question because I just ran into this error again today, and I'm still utterly confused why the C# compiler bothers to check for collisions between namespaces and types in contexts where it makes no sense for a namespace to exist. If I have... public Foo MyFoo { get; set; } ...why would the compiler care that Foo is both a namespace and a type? Can you declare a property as a namespace instead of a type? What is the logic behind the "namespace

Reflection.Emit vs CodeDOM

邮差的信 提交于 2019-12-17 08:26:00
问题 What are some pros/cons for using the Reflection.Emit library versus CodeDOM for dynamically generating code at runtime? I am trying to generate some (relatively complicated) dynamic classes in a system based on metadata available at runtime in XML form. I will be generating classes that extend existing classes in the application assembly, implementing additional interfaces, adding methods, and overriding virtual and abstract members. I want to make sure I select the appropriate technique

Reflection.Emit vs CodeDOM

落花浮王杯 提交于 2019-12-17 08:24:47
问题 What are some pros/cons for using the Reflection.Emit library versus CodeDOM for dynamically generating code at runtime? I am trying to generate some (relatively complicated) dynamic classes in a system based on metadata available at runtime in XML form. I will be generating classes that extend existing classes in the application assembly, implementing additional interfaces, adding methods, and overriding virtual and abstract members. I want to make sure I select the appropriate technique

Generate a Version.java file in Maven

独自空忆成欢 提交于 2019-12-17 08:14:10
问题 I have a Java project that I build using an Ant script. I am trying to convert the project to Maven. One of the tasks generates a Java source file called Version.java that contains a static String representation of the compilation timestamp, as follows: package com.foo.bar; public final class Version { public static String VERSION="100301.1046"; } The Ant task is very simple: <target name="version" depends="init" description="Create Version.java"> <echo file="src/${package.dir}/Version.java"

R.raw.anything cannot be resolved [duplicate]

吃可爱长大的小学妹 提交于 2019-12-17 07:30:43
问题 This question already has answers here : R cannot be resolved - Android error (106 answers) Closed 6 years ago . I'm developing an android apps with Eclipse. In my app, I try to read a file : data.xml. I put it in res/raw/, and to access it i'm supposed to use getRessources().openRawResource(R.raw.data); But Eclipse show me an error : "data" cannot be resolved or is not a field. But the field is in the gen/R.java !!! public final class R { public static final class raw { public static final

Can a Rust macro create new identifiers?

萝らか妹 提交于 2019-12-17 05:13:25
问题 I'd like to create a setter/getter pair of functions where the names are automatically generated based on a shared component, but I couldn't find any example of macro rules generating a new name. Is there a way to generate code like fn get_$iden() and SomeEnum::XX_GET_$enum_iden ? 回答1: My mashup crate provides a stable way to create new identifiers that works with any Rust version >= 1.15.0. #[macro_use] extern crate mashup; macro_rules! make_a_struct_and_getters { ($name:ident { $($field

Can a Rust macro create new identifiers?

天涯浪子 提交于 2019-12-17 05:13:05
问题 I'd like to create a setter/getter pair of functions where the names are automatically generated based on a shared component, but I couldn't find any example of macro rules generating a new name. Is there a way to generate code like fn get_$iden() and SomeEnum::XX_GET_$enum_iden ? 回答1: My mashup crate provides a stable way to create new identifiers that works with any Rust version >= 1.15.0. #[macro_use] extern crate mashup; macro_rules! make_a_struct_and_getters { ($name:ident { $($field

Generate POCO classes in different project to the project with Entity Framework model

给你一囗甜甜゛ 提交于 2019-12-17 04:26:51
问题 I'm trying to use the Repository Pattern with EF4 using VS2010. To this end I am using POCO code generation by right clicking on the entity model designer and clicking Add code generation item. I then select the POCO template and get my classes. What I would like to be able to do is have my solution structured into separate projects for Entity (POCO) classes and another project for the entity model and repository code. This means that my MVC project could use the POCO classes for strongly

Generate POCO classes in different project to the project with Entity Framework model

冷暖自知 提交于 2019-12-17 04:26:10
问题 I'm trying to use the Repository Pattern with EF4 using VS2010. To this end I am using POCO code generation by right clicking on the entity model designer and clicking Add code generation item. I then select the POCO template and get my classes. What I would like to be able to do is have my solution structured into separate projects for Entity (POCO) classes and another project for the entity model and repository code. This means that my MVC project could use the POCO classes for strongly

A Java API to generate Java source files [closed]

浪尽此生 提交于 2019-12-17 02:39:09
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 years ago . I'm looking for a framework to generate Java source files. Something like the following API: X clazz = Something.createClass("package name", "class name"); clazz.addSuperInterface("interface name"); clazz.addMethod("method name", returnType, argumentTypes, ...); File targetDir = ...; clazz.generate(targetDir);