codedom

creating enumeration using .NET's CodeDom

我怕爱的太早我们不能终老 提交于 2019-11-30 23:50:30
问题 I want to create an Enumeration using CodeDom API . I have searched enough on the internet and I get results which are hardly of any use. What I want to generate is public enum bug_tracker_type { [Description("Bugzilla")] Bugzilla, [Description("Debbugs")] Debbugs, [Description("PHP Project Bugtracker")] PHP_Project_Bugtracker, [Description("Google Code")] Google_Code } I used CodeTypeDeclaration and set it's IsEnum property as true, created a name, and set it's Attributes. Now the biggest

C# - Code compiler for .NET & CF.NET

邮差的信 提交于 2019-11-30 21:57:27
I've a same project that need to be compiled with .NET and Compact .NET Framework. It is possible to create a C# compiler that will compile my project with both framework ? Some feature aren't present in CF.NET Framework so I created it by myself (creating classes having exactly the same name & options that in .NET Framework. If I decore this classes with an attribute like [CF35] it's possible to parse the project and : Use this class when compile the project using CF.NET Ignore this class when compile the project using .NET ? Thanks for all constructive answers. [EDIT] I know the solution

Generate Extension Methods using System.CodeDom

回眸只為那壹抹淺笑 提交于 2019-11-30 20:45:20
Has anyone ever tried to generate extension methods using System.CodeDom under .NET 4.0? There doesn't seem to be any way to specify a CodeMemberMethod or CodeParameterDeclarationExpression as being an extension method/parameter. If this isn't possible, are there any good workarounds? Thanks Apparently CodeDom isn't able to generate the correct code for the first parameter of an extension method, but you can cheat it like this: var param = new CodeParameterDeclarationExpression("this string", "s"); It will blissfully ignore the fact that "this string" is not a valid type... See Extension

C# - Code compiler for .NET & CF.NET

时光怂恿深爱的人放手 提交于 2019-11-30 17:56:43
问题 I've a same project that need to be compiled with .NET and Compact .NET Framework. It is possible to create a C# compiler that will compile my project with both framework ? Some feature aren't present in CF.NET Framework so I created it by myself (creating classes having exactly the same name & options that in .NET Framework. If I decore this classes with an attribute like [CF35] it's possible to parse the project and : Use this class when compile the project using CF.NET Ignore this class

How can I target a specific language version using CodeDOM?

久未见 提交于 2019-11-30 08:44:27
Using the C# code provider and the ICodeCompiler.CompileAssemblyFromSource method, I am attempting to compile a code file in order to produce an executable assembly. The code that I would like to compile makes use of features such as optional parameters and extension methods that are only available when using the language C# 4. Having said that, the code that I would like to compile only requires (and needs ) to target version 2.0 of the .NET Framework. Using the proceeding code it is possible to avoid any compile-time errors pertaining to syntax however, the resulting assembly will target

C# 4.0: Expression trees vs. CodeDom

孤人 提交于 2019-11-30 06:53:26
问题 What are the differences between Expression trees and CodeDom? Which should I use for which scenario? 回答1: Expression trees have a lot in common with (for example) an AST. It doesn't map directly to code, but is very amenable to construction from algorithms. For example, if you are parsing a formula: ((a + 2) / b) that is: ParameterExpression a = ..., b = ... var body = Expression.Divide( Expression.Add(a, Expression.Constant(2)), b); var lambda = Expression.Lambda(body,a,b); // optionally

What exactly does <system.codedom>/<compilers> do in web.config in MVC 5?

走远了吗. 提交于 2019-11-30 05:52:42
I am about to migrate a bunch of projects from .NET 4.0 + MVC 3 to .NET 4.5.2 + MVC5. To make this easier, I've created a new blank MVC project to compare DLL references and some other stuff such as web.config. In the latter, the following entries are generated by Visual Studio: <system.codedom> <compilers> <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="

How to programmatically parse and modify C# code

爱⌒轻易说出口 提交于 2019-11-29 14:01:41
问题 What I want to do is to read C# code, parse it, insert some method calls and compile it finally. Is it possible to convert C# source code (a list of strings) to CodeDOM objects? 回答1: It is not directly possible to do this with the core .NET Framework. You need to use third party or add-on tools, for example: Open source C# Parser: http://www.codeplex.com/csparser GPLEX paired with a C# grammar: http://plas.fit.qut.edu.au/gplex/ 回答2: This is a really old question, but is worth noting that the

Error “Does not contain a static ”Main\" Method suitable for an entry point [duplicate]

谁说胖子不能爱 提交于 2019-11-29 13:06:25
This question already has an answer here: “does not contain a static 'main' method suitable for an entry point” 5 answers I got this Error when I try to compile a sourcecode with CodeDom Does not contain a static "Main" Method suitable for an entry point! I already googled it and read other answers here, but I dont know how to fix it. Can someone please help me? Here is my source code : http://picz.to/image/ao5n ^ private void button2_Click(object sender, EventArgs e) { SaveFileDialog d = new SaveFileDialog(); d.Filter = "Executable (*.exe)|*.exe"; if (d.ShowDialog() == DialogResult.OK) {

How can I target a specific language version using CodeDOM?

自闭症网瘾萝莉.ら 提交于 2019-11-29 11:52:28
问题 Using the C# code provider and the ICodeCompiler.CompileAssemblyFromSource method, I am attempting to compile a code file in order to produce an executable assembly. The code that I would like to compile makes use of features such as optional parameters and extension methods that are only available when using the language C# 4. Having said that, the code that I would like to compile only requires (and needs ) to target version 2.0 of the .NET Framework. Using the proceeding code it is