code-generation

Share Constants Between PHP and JavaScript

I have several constants in a PHP application I'm developing. I've defined a Constants class and the defined the constants as const VAR_NAME = value; in this class. I would like to share these constants between my JavaScript and PHP code. Is there a DRY (Don't Repeat Yourself) mechanism to share them? class Constants { const RESOU...

"Cannot resolve symbol" error in Visual Studio 2008?

I have started working on some code left behind by previous developers, and I'm having a strange issue with it. The code is C# in ASP.NET 2.0, and I'm using ReSharper 4.1 in Visual Studio 2008. This code compiles just fine and works in my Web app, but ReSharper is barfing on it with the message, "Cannot resolve symbol '<name of class he...

How much time it saves code generators?

My question seems easy but is little more theoretical than it looks. There are Code Generation software or application building software that gets done without the use of a programming language. Application like VE Server and VE Designer from Intelliun should accomplish this task. My question is, in reality have someone out there trac...

Is there a way to generate java classes from MS-Dataset XSD files?

Given a Dataset XSD file, is it possible to generate java classes, that don't make use of System.Data? I've tried running a test using JAXB's XJC tool, but it doesn't produce anything terribly useful. Update: I've tried XmlBeans also, following Fernando's suggestion, and it generates something similar to the XJC output - that is, class ...

JPA java code generation

I am specifically looking for JPA code generation technique First, what are all the project could generate JPA complaint code? (Eg. HibernateTools) Second, I would also like to customize the code generation utility, as it has to compliant to our corporate standards. If not, what are all the framework available to generate java code us...

Resource for c# codegen best practices

I am looking for one or more resources on best practices for c# codegen (writing c# via code at runtime). ...

Associate attribute with code generated property in .net

I wish to set an attribute on a public property in .NET, however I do not have access to the explicit property itself, as this has been code generated in another file. I have this field: public virtual string Name { get; set; } I wish to set this: [ValidateNonEmpty("Name is required", ExecutionOrder = 1)] public virtual string Name ...

How do I get Visual Studio to generate code using System types (Int32) instead of built-in aliases (int)

Can I get Visual Studio to transform the built-in aliases into the System types? For example, if I define the following interface public interface IExample { Int32 DoWork(String input); } and use VS to automatically generate the interface, I get the built-in types. public class Demo : IExample { public int DoWork(string input...

How to programmatically find a many to many relation in an SQL Server 2005 database

I can find a direct table foreign key in c# like: foreach (ForeignKey key in CurrentTable.ForeignKeys) { Console.WriteLine("FK:" + key.ReferencedTable); } The classic representation for a many to many relationship is achieved via an intermediate table that has a one to many relation to the two principa...

String Utility Library for Code Generation

CodeSmith has a nice StringUtils class that can be used to change database object names to singular, plural, camel case, pascal case, etc... Very useful for creating data access layers in their code generation tool. I'm trying to port some CodeSmith templates to the T4 template files used by Visual Studio, and I'm trying to find a si...

garble javascript code before sending to client side

How can I garble javascript code before sending it to client side. I don't want to expose functionalities. The code is already compressed using jsmin. ...

Generated exception classes with Axis2

I have several web services in the same package that throw a custom exception. The problem is that the generated exception class contains a reference to the web service that generated it, so I can't use the same exception name across multiple web services. Is there a way to make Axis2 generate the exception classes inside the web servi...

How to write a code generator given a custom IDL?

If you have a simple enough schema with basic boolean string fields, how to go about writing a code generator in C++. If you ever wrote , how did you start. Articles/recommendation welcome. EDIT: Note that this is not the standard CORBA idl. ...

Generate Delete Statement From Foreign Key Relationships in SQL 2008 ?

Is it possible via script/tool to generate a delete statement based on the tables fk relations. i.e. I have the table: DelMe(ID) and there are 30 tables with fk references to its ID that I need to delete first, is there some tool/script that I can run that will generate the 30 delete statements based on the FK relations for me ? (btw I...

Is anyone using the built in code-generation in VS2008 (.tt files)?

Is anyone using the built-in code generation provided via text templates (using .tt files)? If so what are the main pro's/con's over other solutions like codesmith? ...

T4 vs CodeDom vs Oslo

In an application scaffolding project on which I'm working, I'm trying to decide whether to use Oslo, T4 or CodeDom for generating code. Our goals are to keep dependencies to a minimum and drive code generation for a domain driven design from user stories. The first step will be to create the tests from the user stories, but we want the ...

How should I design the interface to a SQL column generator in PHP?

I'm working on a framework in PHP, part of this frameworks job is to write SQL code to generate new MySQL columns. What is the most elegant way to pass in a bunch of parameters for a column and then turn that into SQL code? As an example here is some YAML I have, that specifies parameters for creating a varchar column: - type: characte...

What are your favorite skeleton files for the various languages?

It is useful to have skeleton or template files that you can just copy and use as a basis for a new script or app. For example, I use the following ones (emacs with the auto-insert module automatically opens a copy of the appropriate skeleton file when I create a new file). Perl: #!/usr/bin/perl -w use strict; use Getopt::Long; my...

How do I test a code generation tool?

I am currently developing a small project of mine that generates SQL calls in a dynamic way to be used by an other software. The SQL calls are not known beforehand and therefore I would like to be able to unit test the object that generates the SQL. Do you have a clue of how would be the best approach to do this? Bear in mind that ther...

What are the Differences between XSLT and the T4 Code Generation Methods?

I am just getting into the idea of code generation for repetitive coding tasks and have seen both of these approaches. I've seen the XSLT approach in an Apress book Code Generation in Microsoft .Net and have read about the T4 approach in relation to what's new in the MVC framework. What kind of projects is each method better suited for?...