System.CodeDom
10.0.0-rc.2.25502.107
Prefix Reserved
See the version list below for details.
dotnet add package System.CodeDom --version 10.0.0-rc.2.25502.107
NuGet\Install-Package System.CodeDom -Version 10.0.0-rc.2.25502.107
<PackageReference Include="System.CodeDom" Version="10.0.0-rc.2.25502.107" />
<PackageVersion Include="System.CodeDom" Version="10.0.0-rc.2.25502.107" />
<PackageReference Include="System.CodeDom" />
paket add System.CodeDom --version 10.0.0-rc.2.25502.107
#r "nuget: System.CodeDom, 10.0.0-rc.2.25502.107"
#:package System.CodeDom@10.0.0-rc.2.25502.107
#addin nuget:?package=System.CodeDom&version=10.0.0-rc.2.25502.107&prerelease
#tool nuget:?package=System.CodeDom&version=10.0.0-rc.2.25502.107&prerelease
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.CodeObjectSystem.CodeDom.CodeCompileUnitSystem.CodeDom.CodeNamespaceSystem.CodeDom.CodeTypeDeclarationSystem.CodeDom.CodeMemberMethodSystem.CodeDom.CodeTypeReferenceSystem.CodeDom.CodeMethodInvokeExpressionSystem.CodeDom.CodeTypeReferenceExpressionSystem.CodeDom.CodePrimitiveExpressionSystem.CodeDom.Compiler.CodeDomProviderSystem.CodeDom.Compiler.CodeGeneratorOptionsMicrosoft.CSharp.CSharpCodeProviderMicrosoft.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 is compatible. 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.
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (580)
Showing the top 5 NuGet packages that depend on System.CodeDom:
| Package | Downloads |
|---|---|
|
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 |
|
|
EntityFramework
Entity Framework 6 (EF6) is a tried and tested object-relational mapper for .NET with many years of feature development and stabilization. |
|
|
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.Windows.Compatibility
This Windows Compatibility Pack provides access to APIs that were previously available only for .NET Framework. It can be used from both .NET as well as .NET Standard. |
GitHub repositories (133)
Showing the top 20 popular GitHub repositories that depend on System.CodeDom:
| Repository | Stars |
|---|---|
|
microsoft/PowerToys
Microsoft PowerToys is a collection of utilities that help you customize Windows and streamline everyday tasks
|
|
|
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.
|
|
|
PrismLibrary/Prism
Prism is a framework for building loosely coupled, maintainable, and testable XAML applications in WPF, Xamarin Forms, and Uno / Win UI Applications..
|
|
|
xamarin/Xamarin.Forms
Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
|
|
|
microsoft/agent-framework
A framework for building, orchestrating and deploying AI agents and multi-agent workflows with support for Python and .NET.
|
|
|
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
TiXL 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#
|
|
|
Facepunch/sbox-public
s&box is a modern game engine, built on Valve's Source 2 and the latest .NET technology, it provides a modern intuitive editor for creating games
|
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 10.0.0 | 195,712 | 11/11/2025 | |
| 10.0.0-rc.2.25502.107 | 23,577 | 10/14/2025 | |
| 10.0.0-rc.1.25451.107 | 26,571 | 9/9/2025 | |
| 10.0.0-preview.7.25380.108 | 10,695 | 8/12/2025 | |
| 10.0.0-preview.6.25358.103 | 7,428 | 7/15/2025 | |
| 10.0.0-preview.5.25277.114 | 6,451 | 6/6/2025 | |
| 10.0.0-preview.4.25258.110 | 6,346 | 5/12/2025 | |
| 10.0.0-preview.3.25171.5 | 13,864 | 4/10/2025 | |
| 10.0.0-preview.2.25163.2 | 8,757 | 3/18/2025 | |
| 10.0.0-preview.1.25080.5 | 5,212 | 2/25/2025 | |
| 9.0.11 | 54,292 | 11/11/2025 | |
| 9.0.10 | 889,936 | 10/14/2025 | |
| 9.0.9 | 780,096 | 9/9/2025 | |
| 9.0.8 | 1,152,585 | 8/4/2025 | |
| 9.0.7 | 549,918 | 7/8/2025 | |
| 9.0.6 | 1,008,277 | 6/10/2025 | |
| 9.0.5 | 2,630,620 | 5/13/2025 | |
| 9.0.4 | 1,460,747 | 4/8/2025 | |
| 9.0.3 | 815,770 | 3/11/2025 | |
| 9.0.2 | 2,224,967 | 2/11/2025 | |
| 9.0.1 | 1,926,699 | 1/14/2025 | |
| 9.0.0 | 4,743,837 | 11/12/2024 | |
| 9.0.0-rc.2.24473.5 | 83,232 | 10/8/2024 | |
| 9.0.0-rc.1.24431.7 | 20,272 | 9/10/2024 | |
| 9.0.0-preview.7.24405.7 | 12,381 | 8/13/2024 | |
| 9.0.0-preview.6.24327.7 | 22,086 | 7/9/2024 | |
| 9.0.0-preview.5.24306.7 | 7,518 | 6/11/2024 | |
| 9.0.0-preview.4.24266.19 | 7,667 | 5/21/2024 | |
| 9.0.0-preview.3.24172.9 | 17,390 | 4/11/2024 | |
| 9.0.0-preview.2.24128.5 | 6,781 | 3/12/2024 | |
| 9.0.0-preview.1.24080.9 | 47,036 | 2/13/2024 | |
| 8.0.0 | 56,648,914 | 11/14/2023 | |
| 8.0.0-rc.2.23479.6 | 27,819 | 10/10/2023 | |
| 8.0.0-rc.1.23419.4 | 77,978 | 9/12/2023 | |
| 8.0.0-preview.7.23375.6 | 68,521 | 8/8/2023 | |
| 8.0.0-preview.6.23329.7 | 24,101 | 7/11/2023 | |
| 8.0.0-preview.5.23280.8 | 9,601 | 6/13/2023 | |
| 8.0.0-preview.4.23259.5 | 18,137 | 5/16/2023 | |
| 8.0.0-preview.3.23174.8 | 37,033 | 4/11/2023 | |
| 8.0.0-preview.2.23128.3 | 38,889 | 3/14/2023 | |
| 8.0.0-preview.1.23110.8 | 37,469 | 2/21/2023 | |
| 7.0.0 | 98,571,144 | 11/7/2022 | |
| 7.0.0-rc.2.22472.3 | 104,759 | 10/11/2022 | |
| 7.0.0-rc.1.22426.10 | 72,232 | 9/14/2022 | |
| 7.0.0-preview.7.22375.6 | 16,980 | 8/9/2022 | |
| 7.0.0-preview.6.22324.4 | 4,179 | 7/12/2022 | |
| 7.0.0-preview.5.22301.12 | 4,119 | 6/14/2022 | |
| 7.0.0-preview.4.22229.4 | 23,145 | 5/10/2022 | |
| 7.0.0-preview.3.22175.4 | 6,946 | 4/13/2022 | |
| 7.0.0-preview.2.22152.2 | 20,382 | 3/14/2022 | |
| 7.0.0-preview.1.22076.8 | 15,892 | 2/17/2022 | |
| 6.0.0 | 167,898,161 | 11/8/2021 | |
| 6.0.0-rc.2.21480.5 | 22,417 | 10/12/2021 | |
| 6.0.0-rc.1.21451.13 | 56,581 | 9/14/2021 | |
| 6.0.0-preview.7.21377.19 | 14,862 | 8/10/2021 | |
| 6.0.0-preview.6.21352.12 | 15,724 | 7/14/2021 | |
| 6.0.0-preview.5.21301.5 | 8,687 | 6/15/2021 | |
| 6.0.0-preview.4.21253.7 | 31,145 | 5/24/2021 | |
| 6.0.0-preview.3.21201.4 | 51,171 | 4/8/2021 | |
| 6.0.0-preview.2.21154.6 | 10,866 | 3/11/2021 | |
| 6.0.0-preview.1.21102.12 | 36,740 | 2/12/2021 | |
| 5.0.0 | 101,415,883 | 11/9/2020 | |
| 5.0.0-rc.2.20475.5 | 15,937 | 10/13/2020 | |
| 5.0.0-rc.1.20451.14 | 10,465 | 9/14/2020 | |
| 5.0.0-preview.8.20407.11 | 18,089 | 8/25/2020 | |
| 5.0.0-preview.7.20364.11 | 41,659 | 7/21/2020 | |
| 5.0.0-preview.6.20305.6 | 143,430 | 6/25/2020 | |
| 5.0.0-preview.5.20278.1 | 13,752 | 6/10/2020 | |
| 5.0.0-preview.4.20251.6 | 11,026 | 5/18/2020 | |
| 5.0.0-preview.3.20214.6 | 53,906 | 4/23/2020 | |
| 5.0.0-preview.2.20160.6 | 34,733 | 4/2/2020 | |
| 5.0.0-preview.1.20120.5 | 9,602 | 3/16/2020 | |
| 4.7.0 | 99,611,706 | 12/3/2019 | |
| 4.7.0-preview3.19551.4 | 68,553 | 11/13/2019 | |
| 4.7.0-preview2.19523.17 | 19,096 | 11/1/2019 | |
| 4.7.0-preview1.19504.10 | 12,642 | 10/15/2019 | |
| 4.6.0 | 36,410,915 | 9/23/2019 | |
| 4.6.0-rc1.19456.4 | 62,127 | 9/16/2019 | |
| 4.6.0-preview9.19421.4 | 10,399 | 9/4/2019 | |
| 4.6.0-preview9.19416.11 | 962 | 9/4/2019 | |
| 4.6.0-preview8.19405.3 | 70,522 | 8/13/2019 | |
| 4.6.0-preview7.19362.9 | 219,550 | 7/23/2019 | |
| 4.6.0-preview6.19303.8 | 124,164 | 6/12/2019 | |
| 4.6.0-preview6.19264.9 | 951 | 9/4/2019 | |
| 4.6.0-preview5.19224.8 | 77,320 | 5/6/2019 | |
| 4.6.0-preview4.19212.13 | 2,834 | 4/18/2019 | |
| 4.6.0-preview3.19128.7 | 46,124 | 3/6/2019 | |
| 4.6.0-preview.19073.11 | 22,170 | 1/29/2019 | |
| 4.6.0-preview.18571.3 | 18,179 | 12/3/2018 | |
| 4.5.0 | 47,969,828 | 5/29/2018 | |
| 4.5.0-rc1 | 51,072 | 5/6/2018 | |
| 4.5.0-preview2-26406-04 | 26,043 | 4/10/2018 | |
| 4.5.0-preview1-26216-02 | 62,943 | 2/26/2018 | |
| 4.5.0-preview1-25914-04 | 366,156 | 11/15/2017 | |
| 4.4.0 | 312,487,062 | 8/11/2017 | |
| 4.4.0-preview2-25405-01 | 7,407 | 6/27/2017 | |
| 4.4.0-preview1-25305-02 | 6,323 | 5/9/2017 |