CodeObject Class

Base class for all code objects in the CodeDOM tree.

public abstract class CodeObject

Example

var unit = new CompilationUnit();
var ns = unit.AddNamespace("MyNamespace");
var cls = ns.AddType(new ClassDeclaration("MyClass"));

// Code objects form a tree
Assert.Same(ns, cls.Parent);
Assert.Same(unit, ns.Parent);

Constructors

NameDescription
CodeObject()

CodeObject()

CodeObject.cs
protected CodeObject()

No documentation is available.

Properties

NameDescription
DataGets a dictionary for storing custom data associated with this code object.
ParentGets or sets the parent code object in the CodeDOM tree.

Gets a dictionary for storing custom data associated with this code object.

public IDictionary<string, object?> Data { get; }

Gets or sets the parent code object in the CodeDOM tree.

public CodeObject? Parent { get; }

Property value

CodeObject?

Methods

NameDescription
SetData(string, object?)Sets custom data on this code object.
SetParent<T>(CodeObject, T?)
SetParent<T>(CodeObject, T?, T?)
SetParent<T>(T?)
SetParent<T>(T?, T?)
ToCsharpString()Converts this code object to C# code.
ToString()

SetData(string, object?)

CodeObject.cs

Sets custom data on this code object.

public void SetData(string key, object? value)

Parameters

key string
The data key.
value object?
The data value.

SetParent overloads

SetParent<T>(CodeObject, T?)

CodeObject.cs
protected static T SetParent<T>(CodeObject parent, T? value) where T : CodeObject
Type parameters
T
Parameters
parent CodeObject
value T?
Returns

T

No documentation is available.

SetParent<T>(CodeObject, T?, T?)

CodeObject.cs
protected static void SetParent<T>(CodeObject parent, ref T? field, T? value) where T : CodeObject
Type parameters
T
Parameters
parent CodeObject
field T?
value T?

No documentation is available.

SetParent<T>(T?)

CodeObject.cs
protected T SetParent<T>(T? value) where T : CodeObject
Type parameters
T
Parameters
value T?
Returns

T

No documentation is available.

SetParent<T>(T?, T?)

CodeObject.cs
protected void SetParent<T>(ref T? field, T? value) where T : CodeObject
Type parameters
T
Parameters
field T?
value T?

No documentation is available.

ToCsharpString()

CodeObject.cs

Converts this code object to C# code.

public string ToCsharpString()

Returns

string The generated C# code.

ToString()

CodeObject.cs
public override string ToString()

Returns

string

No documentation is available.