code-generation

Is there a programatic way to identify c# reserved words?

我怕爱的太早我们不能终老 提交于 2019-12-02 20:47:24
I'm looking for a function like public bool IsAReservedWord(string TestWord) I know I could roll my own by grabbing a reserve word list from MSDN. However I was hoping there was something built into either the language or .NET reflection that could be relied upon so I wouldn't have to revisit the function when I move to newer versions of C#/.NET. The reason I'm looking for this is I'm looking for a safeguard in .tt file code generation. CSharpCodeProvider cs = new CSharpCodeProvider(); var test = cs.IsValidIdentifier("new"); // returns false var test2 = cs.IsValidIdentifier("new1"); // returns

Rails: creating a custom data type / creating a shorthand

霸气de小男生 提交于 2019-12-02 20:34:13
I am wondering how I could create a custom data type to use within the rake migration file. Example: if you would be creating a model, inside the migration file you can add columns. It could look like this: def self.up create_table :products do |t| t.column :name, :string t.timestamps end end I would like to know how to create something like this: t.column :name, :my_custom_data_type The reason for this to create for example a "currency" type, which is nothing more than a decimal with a precision of 8 and a scale of 2. Since I use only MySQL, the solution for this database is sufficient enough

What are the best resources for learning CIL (MSIL)

跟風遠走 提交于 2019-12-02 19:21:23
I'm an expert C# 3 / .NET 3.5 programmer looking to start doing some runtime codegen using System.Reflection.Emit.DynamicMethod. I'd love to move up to the next level by becoming intimately familiar with IL. Any pointers (pun intended)? The best way to learn it, is to write something you understand, then look at the IL it created. Also, depending on what you are doing, you can use expression trees instead of emitting IL, and then when you compile the expression trees, those smart guys at microsoft create the IL for ya. In addition to Darren's answer, I'd suggest picking or inventing a toy

MSVC++ 6.0: Fatal error C1509 “Too many exception handler states in function”

安稳与你 提交于 2019-12-02 18:40:02
问题 I'm working on a project that uses a lot of generated files for a GUI. After some recent updates, I get this error. If I remove some controls (the new ones or some old ones, doesn't seem to matter which), the error goes away. I've temporarily worked around the problem, but I'd like a more permanent solution. I've seen mentioned on the web that there's a fix for this in VS.Net 2003, but I can't find anything for 6.0. Does anyone know of a hotfix or service pack that fixes this? 回答1: This is an

Graphical Finite State Machine Editor [closed]

谁都会走 提交于 2019-12-02 18:07:44
I am looking for a sophisticated graphical FSM editor that can export a model in a well-documented output format, like SCXML or similar. Can anybody recommend me a tool? I am only just now starting to look at YAKINDU - it looks like it might be a great graphical FSM tool built on top of the Eclipse framework, and has (IIUC) automatic code generation for the state graph. I found this pretty interesting software DRAKON is a visual language for specifications from the Russian space program. DRAKON is used for capturing requirements and building software that controls spacecraft. http://drakon

What are the limits to code generation from XML Schema in C#?

笑着哭i 提交于 2019-12-02 17:37:32
I've seen several questions regarding problems with generating classes from XML Schema using xsd.exe , along with suggestions for how to pre-process the schema (often using XSLT) to resolve some of the trickier aspects prior to generation. My question is whether it's possible to construct a C# code generator that is 100% compliant with XML Schema. Are the problems with xsd.exe merely a question of its implementation, or do they point to a fundamental inconsistency between XML Schema and C#? In particular , I'm interested in how to map concepts in XML Schema to C# - what are the accepted

Code Generators or T4 Templates, are they really evil?

独自空忆成欢 提交于 2019-12-02 17:20:35
I have heard people state that Code Generators and T4 templates should not be used. The logic behind that is that if you are generating code with a generator then there is a better more efficient way to build the code through generics and templating. While I slightly agree with this statement above, I have not really found effective ways to build templates that can say for instance instantiate themselves. In otherwords I can never do : return new T(); Additionally, if I want to generate code based on database values I have found that using Microsoft.SqlServer.Management.SMO in conjunction with

Get Project or Relative Directory with T4

泪湿孤枕 提交于 2019-12-02 16:08:10
How can I get a reference to the directory of the visual studio project or solution or the directory of the t4 template from within a t4 template? I have a template that concatenates a number of files together which are located relative to the template. I need to get a reference to there absolute location through a relative means. Hard coding an absolute path is not acceptable because the visual studio project will not always be in the same location and this would break the code generation. Reading the current working directory from the environment doesn't work either because that returns the

What is scaffolding? Is it a term for a particular platform?

若如初见. 提交于 2019-12-02 15:43:11
Scaffolding, what is it? Is it a Rails-only thing? Scaffolding generally refers to a quickly set up skeleton for an app. It's not rails-only since other platforms have it as well. It's also not generally meant to be a "final" system; merely the first, smallest way to do it. wprl From Wikipedia : Scaffolding is a meta-programming method of building database-backed software applications. It is a technique supported by some model-view-controller frameworks, in which the programmer may write a specification that describes how the application database may be used. The compiler uses this

Seriously, should I write bad PHP code? [closed]

醉酒当歌 提交于 2019-12-02 14:57:02
I'm doing some PHP work recently, and in all the code I've seen, people tend to use few methods. (They also tend to use few variables, but that's another issue.) I was wondering why this is, and I found this note "A function call with one parameter and an empty function body takes about the same time as doing 7-8 $localvar++ operations. A similar method call is of course about 15 $localvar++ operations" here . Is this true, even when the PHP page has been compiled and cached? Should I avoid using methods as much as possible for efficiency? I like to write well-organized, human-readable code