code-generation

Is there an automated way of transforming Java code with over-long (>64kb compiled) methods?

As I understand it, the JVM has a limit of 64KB of compiled code per method. I have a tool which generates Java code to be run, and sometimes the generated code contains methods which are longer than this. Does there exist an automated way of transforming a Java class file with overly long methods into one which produces the same result...

How to force VS2008 to "Generate Create Script to Project" to multiple files when multiple stored procedures are selected?

I'm using Visual Studio 2008 Developer Edition and I've created a Database Project and want to generate CREATE scripts from my database and save them in my database project. It works just fine when I select a single stored procedure in the Database and click "Generate Create Script to Project". The problem is that when I select MULTIPLE...

Code Generation based on method Attributes

I was reading through some articles on Caching and Memoization and how to implement it easily using delegates and generics. The syntax was pretty straightforward, and it is surprisingly easy to implement, but I just feel due to the repetitive nature it should be possible to generate code based on an Attribute, instead of having to write ...

How do you add a C# CodeClass2 AutoProperty?

I would like to generate an auto-property. At the moment I can add a property to the CodeClass by using the following: codeproperty = entityClass.AddProperty(columnName, columnName, c.ColumnType); but this produces code like this: int AddressID { get { return default(int); } s...

C# CodeFunction2 - How do you prevent creation of 'return'?

I am creating a C# class as per: http://msdn.microsoft.com/en-us/library/x6h10s6x.aspx however I want my own 'return' rather than the return default(int); it automatically generates. I know I can insert my own text using an EditPoint i.e editPoint.Insert("return records.AsEnumerable<" + tableNameAsSingular + ">();"); but it still ...

How to create CodeFunction2 with IEnumerable<> Type?

Hi All, I really need to create something like the following, I am building 2 classes, the first is a class with the name of tableNameAsSingular (i.e AddressEntity) , in my second worker class I need to having something like the following public IEnumerable<AddressEntity> GetAddressEntity() { // the good stuff... } When creating the ...

How could you enable a WPF application to create user controls on the fly?

How could you create an application that could search through a directory, find user controls in the form of paired .xaml / .xaml.cs files, and compile/execute these on the fly? Is this possible? Is there an .exec() or .compile() class somewhere that could do this? Basically what I want to do with this is have a WPF application that is ...

generate viewmodel from model?

Hello friends, I'm currently writing viewmodels for my (WPF/C#) app. I have to do a lot of copy and paste though. Isn't there a way to generate the viewmodel from the model like generating the model from the database? I haven't found anything about it on the net ... ...

How to write a Makefile rule to download a file only if it is missing?

I'm trying to write a Makefile which should download some sources if and only if they are missing. Something like: hello: hello.c gcc -o hello hello.c hello.c: wget -O hello.c http://example.org/hello.c But of course this causes hello.c to be downloaded every time make command is run. I would like hello.c to be downloaded by...

Code smell: Passing Javascript variable names and values from server script (ASP.NET)

What are some good ways to deal with this messy and unnecessary and not-really-dynamic generation of JavaScript: var <%# JavascriptId %> = new BusinessChart( '<%# JavascriptId %>',<%# CurrentUserId %>,'<%# ChartId %>' ,'<%# Helper.GetBaseUrl() %>','<%# ChartPath %>' ,'<%# Helper.ResolveUrl("~", true) %>' ); <%# JavascriptId...

How to configure StyleCop to suppress warnings on generated code?

Another project, Visual Studio's Code Analysis has this option. But I couldn't find it for StyleCop (AKA Source Analysis). The file I want to ignore is a dbml's .designer.cs code, that includes the // <autogenerated> tag. A blog post tells me that it would be sufficient, but in my case it is not. ...

Debugging a generated .NET assembly from within the application that generated it

The question in short: How can I debug the code generated during a debugging session on the generating program? (see code below) I am facing the following issue: I would like to debug into dynamically generated/compiled code from the application that generates it. I provided an oversimplified example to clarify it. This example doesn't ...

Java: create new implementation of type at runtime?

So, I realize the answer to this is probably "it's hard", but: I've got a weird idea, and was wondering if it's possible in Java to create a method like: <T> T wrapInterface (Class<T> interfaceClass, T wrappedObject) { if (mClass.isInterface()) { //create a new implementation of interfaceClass that, in each method, //does so...

Alter initial Visual Studio code behind stub code?

When I add a new form to an ASP.NET project (WebForms), and then "View Code" some basic stub code is added -- basic "using" statements, form_load event, etc. So the first thing I have to do is add some project usings, etc. Is there anyway to alter this canned code to what I want, vs. what it puts up by default? Would templates be the ...

Code generator in C#

I've got to develop a multi-language code generator in C#. Well actually the idea is, we have several in house application frameworks for database access in various languages (Java, Python, C++). But their basic working principle is same. And we feel that a code generator will help us to reduce our development time. So I have decided to ...

How can I strip comments and doc strings from python source code?

Is there a program which I can run like this: py2py.py < orig.py > smaller.py Where orig.py contains python source code with comments and doc strings, and smaller.py contains identical, runnable source code but without the comments and doc strings? Code which originally looked like this: #/usr/bin/python """Do something blah blah......

Generating ADO.NET Entity Data Model files, where to start?

Our product is partially built using Delphi and partially .NET and in our current state of migration to .NET, we have the data dictionary in a Delphi component, so this is the master. From this we generate .NET source code through templating, to support simple querying but also to do Linq2Sql, since our product requires SQL Server. How...

Generate xml from csv data in conformance with given xsd schema

I have an xml schema and csv data to generate corresponding xml files. I found this, how to generate xml files from given CSV file. But with my schema, it's always the same mapping because of the element. So the last 5 columns are mapped according to the DataType column. I could expand the code with case switch, and map every element ...

How to force Visual Studio 2008 to regenerate code from T4 templates when an XML file changes?

I'm generating quite a bit of code from a single XML file, but the templates are organized in two different T4 templates. Whenever I change the XML file, I have to remember to open the two *.tt files, change them trivially (add / delete a space) and save them again to make sure the code is generated. This can't be the right way to do it...

Linking to MATLAB generated code

I'm using embedded MATLAB to generate C code from an .m script. However, after the generation I'm left with about 15 files (most of them are source). If I want to write a standalone main in C how do I link to the MATLAB generated code? Is there a way to do this without writing my own Makefile? So I figured out how to generate stati...