System.CodeDom
9.0.6
Prefix Reserved
See the version list below for details.
dotnet add package System.CodeDom --version 9.0.6
NuGet\Install-Package System.CodeDom -Version 9.0.6
<PackageReference Include="System.CodeDom" Version="9.0.6" />
<PackageVersion Include="System.CodeDom" Version="9.0.6" />
<PackageReference Include="System.CodeDom" />
paket add System.CodeDom --version 9.0.6
#r "nuget: System.CodeDom, 9.0.6"
#addin nuget:?package=System.CodeDom&version=9.0.6
#tool nuget:?package=System.CodeDom&version=9.0.6
About
Provides functionality for dynamically generating and compiling source code using the Code Document Object Model (CodeDOM).
It allows developers to represent code in a language-agnostic format and then generate code in multiple languages, such as C# and VB.NET. The primary use cases include creating dynamic code generation tools, runtime code generation, and facilitating code analysis or transformation.
For a new modern development consider using the .NET Compiler Platform SDK, in particular Roslyn source generators.
Key Features
- Write code using a common object model that can be translated into multiple programming languages.
- Generate and compile code at runtime based on the CodeDOM.
How to Use
Generating and compiling C# code:
using System.CodeDom;
using System.CodeDom.Compiler;
using Microsoft.CSharp;
// Create a new CodeCompileUnit to hold the code
var compileUnit = new CodeCompileUnit();
// Create a namespace
var codeNamespace = new CodeNamespace("MyNamespace");
compileUnit.Namespaces.Add(codeNamespace);
// Create a class
var classDeclaration = new CodeTypeDeclaration("MyClass")
{
IsClass = true
};
codeNamespace.Types.Add(classDeclaration);
// Add a simple method to the class
var method = new CodeMemberMethod
{
Name = "HelloWorld",
ReturnType = new CodeTypeReference(typeof(void)),
};
classDeclaration.Members.Add(method);
var methodInvocation = new CodeMethodInvokeExpression(new CodeTypeReferenceExpression("Console"),
"WriteLine",
new CodePrimitiveExpression("Hello, World!"));
method.Statements.Add(methodInvocation);
// Generate C# code from the CodeDOM structure
CodeDomProvider provider = new CSharpCodeProvider();
using (var writer = new StringWriter())
{
var codeGenereationOptions = new CodeGeneratorOptions()
{
BlankLinesBetweenMembers = false,
IndentString = " ",
};
provider.GenerateCodeFromCompileUnit(compileUnit, writer, codeGenereationOptions);
Console.WriteLine(writer.GetStringBuilder().ToString());
}
This example generates:
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace MyNamespace {
public class MyClass {
private void HelloWorld() {
Console.WriteLine("Hello, World!");
}
}
}
Main Types
The main types provided by this library are:
System.CodeDom.CodeObject
System.CodeDom.CodeCompileUnit
System.CodeDom.CodeNamespace
System.CodeDom.CodeTypeDeclaration
System.CodeDom.CodeMemberMethod
System.CodeDom.CodeTypeReference
System.CodeDom.CodeMethodInvokeExpression
System.CodeDom.CodeTypeReferenceExpression
System.CodeDom.CodePrimitiveExpression
System.CodeDom.Compiler.CodeDomProvider
System.CodeDom.Compiler.CodeGeneratorOptions
Microsoft.CSharp.CSharpCodeProvider
Microsoft.VisualBasic.VBCodeProvider
Additional Documentation
Feedback & Contributing
System.CodeDom is released as open source under the MIT license. Bug reports and contributions are welcome at the GitHub repository.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- No dependencies.
-
.NETStandard 2.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (534)
Showing the top 5 NuGet packages that depend on System.CodeDom:
Package | Downloads |
---|---|
EntityFramework
Entity Framework 6 (EF6) is a tried and tested object-relational mapper for .NET with many years of feature development and stabilization. |
|
System.Management
Provides access to a rich set of management information and management events about the system, devices, and applications instrumented to the Windows Management Instrumentation (WMI) infrastructure. Commonly Used Types: System.Management.ManagementClass System.Management.ManagementObject System.Management.SelectQuery |
|
Mono.TextTemplating
Embeddable engine for the T4 templating language, a general-purpose way to generate text or code files using C# |
|
Microsoft.Build.Tasks.Core
This package contains the Microsoft.Build.Tasks assembly which implements the commonly used tasks of MSBuild. |
|
Microsoft.CodeAnalysis.Workspaces.MSBuild
.NET Compiler Platform ("Roslyn") support for analyzing MSBuild projects and solutions. This should be used with at least one of the following packages to add the appropriate language support: - Microsoft.CodeAnalysis.CSharp.Workspaces - Microsoft.CodeAnalysis.VisualBasic.Workspaces More details at https://aka.ms/roslyn-packages This package was built from the source at https://github.com/dotnet/roslyn/commit/8edf7bcd4f1594c3d68a6a567469f41dbd33dd1b. |
GitHub repositories (120)
Showing the top 20 popular GitHub repositories that depend on System.CodeDom:
Repository | Stars |
---|---|
microsoft/PowerToys
Windows system utilities to maximize productivity
|
|
dotnet/maui
.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
|
|
dotnet/roslyn
The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
|
|
chocolatey/choco
Chocolatey - the package manager for Windows
|
|
dotnet/orleans
Cloud Native application framework for .NET
|
|
dotnet/machinelearning
ML.NET is an open source and cross-platform machine learning framework for .NET.
|
|
dotnet/wpf
WPF is a .NET Core UI framework for building Windows desktop applications.
|
|
xamarin/Xamarin.Forms
Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
|
|
dotnet/msbuild
The Microsoft Build Engine (MSBuild) is the build platform for .NET and Visual Studio.
|
|
protobuf-net/protobuf-net
Protocol Buffers library for idiomatic .NET
|
|
dotnet/winforms
Windows Forms is a .NET UI framework for building Windows desktop applications.
|
|
Azure/azure-powershell
Microsoft Azure PowerShell
|
|
dotnetcore/FreeSql
.NET aot orm, VB.NET/C# orm, Mysql/PostgreSQL/SqlServer/Oracle orm, Sqlite/Firebird/Clickhouse/DuckDB orm, 达梦/金仓/虚谷/翰高/高斯 orm, 神通 orm, 南大通用 orm, 国产 orm, TDengine orm, QuestDB orm, MsAccess orm.
|
|
tixl3d/tixl
Tooll 3 is an open source software to create realtime motion graphics.
|
|
hardkoded/puppeteer-sharp
Headless Chrome .NET API
|
|
dotnet/sdk
Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
|
|
dotnet/macios
.NET for iOS, Mac Catalyst, macOS, and tvOS provide open-source bindings of the Apple SDKs for use with .NET managed languages such as C#
|
|
IronLanguages/ironpython3
Implementation of Python 3.x for .NET Framework that is built on top of the Dynamic Language Runtime.
|
|
ErikEJ/EFCorePowerTools
Entity Framework Core Power Tools - reverse engineering, migrations and model visualization in Visual Studio & CLI
|
|
EWSoftware/SHFB
Sandcastle Help File Builder (SHFB). A standalone GUI, Visual Studio integration package, and MSBuild tasks providing full configuration and extensibility for building help files with the Sandcastle tools.
|
Version | Downloads | Last Updated | |
---|---|---|---|
10.0.0-preview.5.25277.114 | 3,347 | a month ago | |
10.0.0-preview.4.25258.110 | 4,584 | 2 months ago | |
10.0.0-preview.3.25171.5 | 10,965 | 3 months ago | |
10.0.0-preview.2.25163.2 | 6,251 | 4 months ago | |
10.0.0-preview.1.25080.5 | 4,384 | 4 months ago | |
9.0.7 | 8,185 | 2 days ago | |
9.0.6 | 261,639 | a month ago | |
9.0.5 | 483,918 | 2 months ago | |
9.0.4 | 759,033 | 3 months ago | |
9.0.3 | 519,039 | 4 months ago | |
9.0.2 | 1,274,160 | 5 months ago | |
9.0.1 | 1,039,237 | 6 months ago | |
9.0.0 | 2,418,236 | 8 months ago | |
9.0.0-rc.2.24473.5 | 63,796 | 9 months ago | |
9.0.0-rc.1.24431.7 | 19,131 | 10 months ago | |
9.0.0-preview.7.24405.7 | 11,590 | 8/13/2024 | |
9.0.0-preview.6.24327.7 | 20,050 | 7/9/2024 | |
9.0.0-preview.5.24306.7 | 7,192 | 6/11/2024 | |
9.0.0-preview.4.24266.19 | 7,363 | 5/21/2024 | |
9.0.0-preview.3.24172.9 | 16,861 | 4/11/2024 | |
9.0.0-preview.2.24128.5 | 6,146 | 3/12/2024 | |
9.0.0-preview.1.24080.9 | 39,502 | 2/13/2024 | |
8.0.0 | 38,242,529 | 11/14/2023 | |
8.0.0-rc.2.23479.6 | 27,152 | 10/10/2023 | |
8.0.0-rc.1.23419.4 | 77,271 | 9/12/2023 | |
8.0.0-preview.7.23375.6 | 64,121 | 8/8/2023 | |
8.0.0-preview.6.23329.7 | 22,862 | 7/11/2023 | |
8.0.0-preview.5.23280.8 | 8,796 | 6/13/2023 | |
8.0.0-preview.4.23259.5 | 17,941 | 5/16/2023 | |
8.0.0-preview.3.23174.8 | 36,482 | 4/11/2023 | |
8.0.0-preview.2.23128.3 | 36,343 | 3/14/2023 | |
8.0.0-preview.1.23110.8 | 32,055 | 2/21/2023 | |
7.0.0 | 70,120,818 | 11/7/2022 | |
7.0.0-rc.2.22472.3 | 98,899 | 10/11/2022 | |
7.0.0-rc.1.22426.10 | 71,540 | 9/14/2022 | |
7.0.0-preview.7.22375.6 | 16,592 | 8/9/2022 | |
7.0.0-preview.6.22324.4 | 4,008 | 7/12/2022 | |
7.0.0-preview.5.22301.12 | 3,959 | 6/14/2022 | |
7.0.0-preview.4.22229.4 | 22,782 | 5/10/2022 | |
7.0.0-preview.3.22175.4 | 6,797 | 4/13/2022 | |
7.0.0-preview.2.22152.2 | 20,223 | 3/14/2022 | |
7.0.0-preview.1.22076.8 | 15,671 | 2/17/2022 | |
6.0.0 | 118,401,426 | 11/8/2021 | |
6.0.0-rc.2.21480.5 | 21,199 | 10/12/2021 | |
6.0.0-rc.1.21451.13 | 55,737 | 9/14/2021 | |
6.0.0-preview.7.21377.19 | 14,689 | 8/10/2021 | |
6.0.0-preview.6.21352.12 | 15,408 | 7/14/2021 | |
6.0.0-preview.5.21301.5 | 8,484 | 6/15/2021 | |
6.0.0-preview.4.21253.7 | 30,793 | 5/24/2021 | |
6.0.0-preview.3.21201.4 | 50,993 | 4/8/2021 | |
6.0.0-preview.2.21154.6 | 10,618 | 3/11/2021 | |
6.0.0-preview.1.21102.12 | 35,528 | 2/12/2021 | |
5.0.0 | 88,792,545 | 11/9/2020 | |
5.0.0-rc.2.20475.5 | 15,754 | 10/13/2020 | |
5.0.0-rc.1.20451.14 | 10,306 | 9/14/2020 | |
5.0.0-preview.8.20407.11 | 17,487 | 8/25/2020 | |
5.0.0-preview.7.20364.11 | 40,390 | 7/21/2020 | |
5.0.0-preview.6.20305.6 | 143,226 | 6/25/2020 | |
5.0.0-preview.5.20278.1 | 13,585 | 6/10/2020 | |
5.0.0-preview.4.20251.6 | 10,718 | 5/18/2020 | |
5.0.0-preview.3.20214.6 | 51,671 | 4/23/2020 | |
5.0.0-preview.2.20160.6 | 33,618 | 4/2/2020 | |
5.0.0-preview.1.20120.5 | 9,435 | 3/16/2020 | |
4.7.0 | 91,738,373 | 12/3/2019 | |
4.7.0-preview3.19551.4 | 65,907 | 11/13/2019 | |
4.7.0-preview2.19523.17 | 18,277 | 11/1/2019 | |
4.7.0-preview1.19504.10 | 12,493 | 10/15/2019 | |
4.6.0 | 34,095,568 | 9/23/2019 | |
4.6.0-rc1.19456.4 | 61,062 | 9/16/2019 | |
4.6.0-preview9.19421.4 | 10,152 | 9/4/2019 | |
4.6.0-preview9.19416.11 | 836 | 9/4/2019 | |
4.6.0-preview8.19405.3 | 66,210 | 8/13/2019 | |
4.6.0-preview7.19362.9 | 169,944 | 7/23/2019 | |
4.6.0-preview6.19303.8 | 116,936 | 6/12/2019 | |
4.6.0-preview6.19264.9 | 820 | 9/4/2019 | |
4.6.0-preview5.19224.8 | 73,525 | 5/6/2019 | |
4.6.0-preview4.19212.13 | 2,701 | 4/18/2019 | |
4.6.0-preview3.19128.7 | 43,487 | 3/6/2019 | |
4.6.0-preview.19073.11 | 21,723 | 1/29/2019 | |
4.6.0-preview.18571.3 | 17,020 | 12/3/2018 | |
4.5.0 | 45,198,574 | 5/29/2018 | |
4.5.0-rc1 | 49,726 | 5/6/2018 | |
4.5.0-preview2-26406-04 | 25,242 | 4/10/2018 | |
4.5.0-preview1-26216-02 | 59,163 | 2/26/2018 | |
4.5.0-preview1-25914-04 | 352,757 | 11/15/2017 | |
4.4.0 | 264,526,296 | 8/11/2017 | |
4.4.0-preview2-25405-01 | 7,195 | 6/27/2017 | |
4.4.0-preview1-25305-02 | 6,058 | 5/9/2017 |