Table of Contents

Class CSharpGenerator

Namespace
SunamoDevCode
Assembly
SunamoDevCode.dll

Generates C# source code including classes, fields, constructors, regions, and attributes.

public class CSharpGenerator : GeneratorCodeAbstract
Inheritance
CSharpGenerator
Inherited Members
Extension Methods

Methods

AddIntoClass(List<string>, List<string>, out int, string)

EN: Inserts lines into a class before the closing brace CZ: Vloží řádky do třídy před uzavírací složenou závorku

public static List<string> AddIntoClass(List<string> lines, List<string> insertedLines, out int classIndex, string namespaceName)

Parameters

lines List<string>

File content as list of lines

insertedLines List<string>

Lines to insert into the class

classIndex int

Output: index of the class declaration line

namespaceName string

Namespace name to process

Returns

List<string>

Modified file content

AddValuesViaAddRange(int, string, string, string, List<string>, CSharpGeneratorArgs)

EN: Generates code to add multiple values to a collection via AddRange. Args.AddHyphens determines whether to wrap values in quotes. CZ: Generuje kód pro přidání více hodnot do kolekce pomocí AddRange. Args.AddHyphens určuje, zda obalit hodnoty do uvozovek.

public void AddValuesViaAddRange(int tabCount, string objectName, string collectionName, string type, List<string> values, CSharpGeneratorArgs args)

Parameters

tabCount int

Number of tabs for indentation

objectName string

Name of the object (can be null for static classes)

collectionName string

Name of the collection to add to

type string

Type of the array elements

values List<string>

Values to add to the collection

args CSharpGeneratorArgs

Generator arguments (AddHyphens, etc.)

AddValuesViaAddRange(int, string, string, Type, List<string>, CSharpGeneratorArgs)

EN: Generates code to add multiple values to a collection via AddRange (Type overload). If you don't want to use object identifier (e.g., for static classes), pass null for objectName. CZ: Generuje kód pro přidání více hodnot do kolekce pomocí AddRange (Type přetížení). Pokud nechcete použít identifikátor objektu (např. u statické třídy), předejte null pro objectName.

public void AddValuesViaAddRange(int tabCount, string objectName, string collectionName, Type type, List<string> values, CSharpGeneratorArgs args)

Parameters

tabCount int

Number of tabs for indentation

objectName string

Name of the object (can be null for static classes)

collectionName string

Name of the collection to add to

type Type

Type of the array elements

values List<string>

Values to add to the collection

args CSharpGeneratorArgs

Generator arguments (AddHyphens, etc.)

AssignValue(int, string, string, string, CSharpGeneratorArgs)

EN: Generates an assignment statement (objectName.variable = value). Args.AddHyphens determines whether to wrap value in quotes. CZ: Generuje přiřazovací příkaz (objectName.variable = value). Args.AddHyphens určuje, zda obalit hodnotu do uvozovek.

public void AssignValue(int tabCount, string objectName, string variableName, string value, CSharpGeneratorArgs args)

Parameters

tabCount int

Number of tabs for indentation

objectName string

Name of the object

variableName string

Name of the variable/property to assign to

value string

Value to assign

args CSharpGeneratorArgs

Generator arguments (AddHyphens, etc.)

Attribute(int, string, string)

EN: Generates an attribute with parameters CZ: Generuje atribut s parametry

public void Attribute(int tabCount, string attributeName, string attributeParameters)

Parameters

tabCount int

Number of tabs for indentation

attributeName string

Name of the attribute

attributeParameters string

Parameters for the attribute

CreateEnumItemsFromList(List<string>)

EN: Creates a list of EnumItem objects from a list of strings CZ: Vytvoří seznam EnumItem objektů ze seznamu stringů

public static List<EnumItem> CreateEnumItemsFromList(List<string> list)

Parameters

list List<string>

List of enum value names

Returns

List<EnumItem>

List of EnumItem objects

Ctor(int, ModifiersConstructor, string, bool, bool, params string[])

EN: Generates a constructor with automatic field assignment. Parameters are stored in pairs: type, name, type, name. Static constructors cannot be created here. CZ: Generuje konstruktor s automatickým přiřazením polí. Parametry jsou uloženy v párech: typ, název, typ, název. Statický konstruktor zde nelze vytvořit.

public void Ctor(int tabCount, ModifiersConstructor modifierType, string constructorName, bool autoAssign, bool isBase, params string[] parameters)

Parameters

tabCount int

Number of tabs for indentation

modifierType ModifiersConstructor

Constructor modifier (public, private, etc.)

constructorName string

Name of the constructor (should match class name)

autoAssign bool

Whether to automatically assign parameters to fields

isBase bool

Whether this is a base class constructor

parameters string[]

Alternating type and name pairs for parameters

Ctor(int, ModifiersConstructor, string, string, params string[])

EN: Generates a constructor declaration with parameters CZ: Generuje deklaraci konstruktoru s parametry

public void Ctor(int tabCount, ModifiersConstructor modifierType, string constructorName, string bodyContent, params string[] parameters)

Parameters

tabCount int

Number of tabs for indentation

modifierType ModifiersConstructor

Constructor modifier (public, private, etc.)

constructorName string

Name of the constructor (should match class name)

bodyContent string

Content of the constructor body

parameters string[]

Alternating type and name pairs for parameters (type1, name1, type2, name2, ...)

DictionaryFromDictionaryInnerList<Key, Value>(int, string, Dictionary<Key, Value>, CSharpGeneratorArgs)

EN: Generates a Dictionary with List values from another dictionary. Default: addingValue = true. CZ: Generuje Dictionary s hodnotami List z jiného dictionary. Výchozí: addingValue = true.

public void DictionaryFromDictionaryInnerList<Key, Value>(int tabCount, string dictionaryName, Dictionary<Key, Value> dictionary, CSharpGeneratorArgs args) where Key : notnull

Parameters

tabCount int

Number of tabs for indentation

dictionaryName string

Name of the dictionary variable

dictionary Dictionary<Key, Value>

Source dictionary

args CSharpGeneratorArgs

Generator arguments

Type Parameters

Key

Type of dictionary keys

Value

Type of list values

DictionaryFromDictionary<Key, Value>(int, string, Dictionary<Key, Value>, CSharpGeneratorArgs?)

EN: Generates a Dictionary from another dictionary. Args.AddingValue = true. CZ: Generuje Dictionary z jiného dictionary. Args.AddingValue = true.

public void DictionaryFromDictionary<Key, Value>(int tabCount, string dictionaryName, Dictionary<Key, Value> dictionary, CSharpGeneratorArgs? args = null) where Key : notnull

Parameters

tabCount int

Number of tabs for indentation

dictionaryName string

Name of the dictionary variable

dictionary Dictionary<Key, Value>

Source dictionary

args CSharpGeneratorArgs

Generator arguments (AddingValue = true)

Type Parameters

Key

Type of dictionary keys

Value

Type of dictionary values

DictionaryFromRandomValue<Key, Value>(int, string, List<Key>, Func<Value>, CSharpGeneratorArgs?)

EN: Generates a Dictionary with keys and random values. Args.AddingValue = true as default. CZ: Generuje Dictionary s klíči a náhodnými hodnotami. Args.AddingValue = true jako výchozí.

public void DictionaryFromRandomValue<Key, Value>(int tabCount, string dictionaryName, List<Key> keys, Func<Value> randomValueGenerator, CSharpGeneratorArgs? args = null) where Key : notnull

Parameters

tabCount int

Number of tabs for indentation

dictionaryName string

Name of the dictionary variable

keys List<Key>

List of keys

randomValueGenerator Func<Value>

Function to generate random values

args CSharpGeneratorArgs

Generator arguments (AddingValue = true as default)

Type Parameters

Key

Type of dictionary keys

Value

Type of dictionary values

DictionaryFromTwoList<Key, Value>(int, string, List<Key>, List<Value>, CSharpGeneratorArgs?)

EN: Generates a Dictionary from two lists (keys and values). Args.AddingValue = true was default. CZ: Generuje Dictionary ze dvou seznamů (klíče a hodnoty). Args.AddingValue = true byl výchozí.

public void DictionaryFromTwoList<Key, Value>(int tabCount, string dictionaryName, List<Key> keys, List<Value> values, CSharpGeneratorArgs? args = null) where Key : notnull

Parameters

tabCount int

Number of tabs for indentation

dictionaryName string

Name of the dictionary variable

keys List<Key>

List of keys

values List<Value>

List of values

args CSharpGeneratorArgs

Generator arguments

Type Parameters

Key

Type of dictionary keys

Value

Type of dictionary values

DictionaryNumberNumber<T, U>(int, string, Dictionary<T, U>, CSharpGeneratorArgs?)

EN: Generates a Dictionary with numeric key-value pairs. Args.AddingValue = true as default. CZ: Generuje Dictionary s číselnými páry klíč-hodnota. Args.AddingValue = true jako výchozí.

public void DictionaryNumberNumber<T, U>(int tabCount, string dictionaryName, Dictionary<T, U> dictionary, CSharpGeneratorArgs? args = null) where T : notnull where U : notnull

Parameters

tabCount int

Number of tabs for indentation

dictionaryName string

Name of the dictionary variable

dictionary Dictionary<T, U>

Dictionary with key-value pairs

args CSharpGeneratorArgs

Generator arguments (AddingValue = true as default)

Type Parameters

T

Type of dictionary keys

U

Type of dictionary values

DictionaryStringListString(int, string, Dictionary<string, List<string>>, CSharpGeneratorArgs?)

EN: Generates a Dictionary<string, List<string>>. Args.CreateInstance = true as default. CZ: Generuje Dictionary<string, List<string>>. Args.CreateInstance = true jako výchozí.

public void DictionaryStringListString(int tabCount, string dictionaryName, Dictionary<string, List<string>> dictionary, CSharpGeneratorArgs? args = null)

Parameters

tabCount int

Number of tabs for indentation

dictionaryName string

Name of the dictionary variable

dictionary Dictionary<string, List<string>>

Dictionary with string keys and string list values

args CSharpGeneratorArgs

Generator arguments (CreateInstance = true as default)

DictionaryStringObject<Value>(int, string, Dictionary<string, Value>, CSharpGeneratorArgs)

EN: Generates a Dictionary<string, object> with values. Args.AddingValue = true as default. CZ: Generuje Dictionary<string, object> s hodnotami. Args.AddingValue = true jako výchozí.

public void DictionaryStringObject<Value>(int tabCount, string dictionaryName, Dictionary<string, Value> dictionary, CSharpGeneratorArgs args)

Parameters

tabCount int

Number of tabs for indentation

dictionaryName string

Name of the dictionary variable

dictionary Dictionary<string, Value>

Source dictionary

args CSharpGeneratorArgs

Generator arguments (AddingValue = true as default)

Type Parameters

Value

Type of dictionary values

DictionaryStringString(int, string, Dictionary<string, string>, CSharpGeneratorArgs?)

EN: Generates a Dictionary<string, string>. Args.AddingValue = true as default. CZ: Generuje Dictionary<string, string>. Args.AddingValue = true jako výchozí.

public void DictionaryStringString(int tabCount, string dictionaryName, Dictionary<string, string> dictionary, CSharpGeneratorArgs? args = null)

Parameters

tabCount int

Number of tabs for indentation

dictionaryName string

Name of the dictionary variable

dictionary Dictionary<string, string>

Dictionary with string key-value pairs

args CSharpGeneratorArgs

Generator arguments (AddingValue = true as default)

Else(int)

EN: Generates an else statement with opening brace. Automatically adds the opening brace. CZ: Generuje else příkaz s otevírací závorkou. Automaticky přidává počáteční závorku.

public void Else(int tabCount)

Parameters

tabCount int

Number of tabs for indentation

EndRegion(int)

EN: Writes the end of a region directive CZ: Zapíše konec region direktivy

public void EndRegion(int tabCount)

Parameters

tabCount int

Number of tabs for indentation

Enum(int, AccessModifiers, string, List<EnumItem>)

EN: Generates an enum with XML comments and optional attributes for each member CZ: Generuje enum s XML komentáři a volitelnými atributy pro každý člen

public void Enum(int tabCount, AccessModifiers accessModifier, string enumName, List<EnumItem> enumItems)

Parameters

tabCount int

Number of tabs for indentation

accessModifier AccessModifiers

Access modifier for the enum

enumName string

Name of the enum

enumItems List<EnumItem>

List of enum items with their properties

EnumWithComments(int, AccessModifiers, string, Dictionary<string, string>)

EN: Generates an enum with XML summary comments for each member CZ: Generuje enum s XML summary komentáři pro každý člen

public void EnumWithComments(int tabCount, AccessModifiers accessModifier, string enumName, Dictionary<string, string> memberComments)

Parameters

tabCount int

Number of tabs for indentation

accessModifier AccessModifiers

Access modifier for the enum

enumName string

Name of the enum

memberComments Dictionary<string, string>

Dictionary mapping enum member names to their comments

Field(int, AccessModifiers, bool, VariableModifiers, string, string, ObjectInitializationOptions, string)

EN: Generates a field declaration with initialization CZ: Generuje deklaraci pole s inicializací

public void Field(int tabCount, AccessModifiers accessModifier, bool isStatic, VariableModifiers variableModifiers, string type, string name, ObjectInitializationOptions initializationOption, string value)

Parameters

tabCount int

Number of tabs for indentation

accessModifier AccessModifiers

Access modifier for the field. Private modifier is omitted (default).

isStatic bool

Whether the field should be static. Ignored if initializationOption is NewAssign.

variableModifiers VariableModifiers

Variable modifiers (const, readonly, etc.)

type string

Type of the field

name string

Name of the field

initializationOption ObjectInitializationOptions

How to initialize the field: Original (use value as-is), Hyphens (add quotes), or NewAssign (use new constructor)

value string

Initial value. If initializationOption is NewAssign, use string.Empty for empty constructor. If Original, put the part after =. Cannot be null.

Field(int, AccessModifiers, bool, VariableModifiers, string, string, bool)

EN: Generates a field declaration with optional default value CZ: Generuje deklaraci pole s volitelnou výchozí hodnotou

public void Field(int tabCount, AccessModifiers accessModifier, bool isStatic, VariableModifiers variableModifiers, string type, string name, bool isUsingDefaultValue)

Parameters

tabCount int

Number of tabs for indentation

accessModifier AccessModifiers

Access modifier for the field

isStatic bool

Whether the field should be static

variableModifiers VariableModifiers

Variable modifiers (const, readonly, etc.)

type string

Type of the field

name string

Name of the field

isUsingDefaultValue bool

Whether to add a default value for the type

Field(int, AccessModifiers, bool, VariableModifiers, string, string, bool, string)

EN: Generates a field declaration with optional quotation of the value CZ: Generuje deklaraci pole s volitelným přidáním uvozovek k hodnotě

public void Field(int tabCount, AccessModifiers accessModifier, bool isStatic, VariableModifiers variableModifiers, string type, string name, bool isAddingHyphensToValue, string value)

Parameters

tabCount int

Number of tabs for indentation

accessModifier AccessModifiers

Access modifier for the field

isStatic bool

Whether the field should be static

variableModifiers VariableModifiers

Variable modifiers (const, readonly, etc.)

type string

Type of the field

name string

Name of the field

isAddingHyphensToValue bool

Whether to add quotes around the value

value string

Initial value of the field

GetDictionaryValuesFromDictionaryInnerList<Key, Value>(int, string, Dictionary<Key, List<Value>>, CSharpGeneratorArgs)

EN: Generates dictionary value assignments from a dictionary with List values CZ: Generuje přiřazení hodnot do dictionary ze slovníku s hodnotami List

public void GetDictionaryValuesFromDictionaryInnerList<Key, Value>(int tabCount, string dictionaryName, Dictionary<Key, List<Value>> dictionary, CSharpGeneratorArgs args) where Key : notnull

Parameters

tabCount int

Number of tabs for indentation

dictionaryName string

Name of the dictionary variable

dictionary Dictionary<Key, List<Value>>

Source dictionary

args CSharpGeneratorArgs

Generator arguments (AlsoField, UseCA, etc.)

Type Parameters

Key

Type of dictionary keys

Value

Type of list values

GetDictionaryValuesFromDictionary<Key, Value>(int, string, Dictionary<Key, Value>)

EN: Generates dictionary value assignments from a dictionary CZ: Generuje přiřazení hodnot do dictionary ze slovníku

public void GetDictionaryValuesFromDictionary<Key, Value>(int tabCount, string dictionaryName, Dictionary<Key, Value> dictionary) where Key : notnull

Parameters

tabCount int

Number of tabs for indentation

dictionaryName string

Name of the dictionary variable

dictionary Dictionary<Key, Value>

Source dictionary

Type Parameters

Key

Type of dictionary keys

Value

Type of dictionary values

GetDictionaryValuesFromRandomValue<Key, Value>(int, string, List<Key>, Func<Value>)

EN: Generates dictionary value assignments from random values CZ: Generuje přiřazení hodnot do dictionary z náhodných hodnot

public void GetDictionaryValuesFromRandomValue<Key, Value>(int tabCount, string dictionaryName, List<Key> keys, Func<Value> randomValueGenerator) where Key : notnull

Parameters

tabCount int

Number of tabs for indentation

dictionaryName string

Name of the dictionary variable

keys List<Key>

List of keys

randomValueGenerator Func<Value>

Function to generate random values

Type Parameters

Key

Type of dictionary keys

Value

Type of dictionary values

GetDictionaryValuesFromTwoList<Key, Value>(int, string, List<Key>, List<Value>, CSharpGeneratorArgs)

EN: Generates dictionary value assignments from two lists. Args.SplitKeyWith allows splitting keys. CZ: Generuje přiřazení hodnot do dictionary ze dvou seznamů. Args.SplitKeyWith umožňuje rozdělení klíčů.

public void GetDictionaryValuesFromTwoList<Key, Value>(int tabCount, string dictionaryName, List<Key> keys, List<Value> values, CSharpGeneratorArgs args) where Key : notnull

Parameters

tabCount int

Number of tabs for indentation

dictionaryName string

Name of the dictionary variable

keys List<Key>

List of keys

values List<Value>

List of values

args CSharpGeneratorArgs

Generator arguments (SplitKeyWith, etc.)

Type Parameters

Key

Type of dictionary keys

Value

Type of dictionary values

GetTKeyAndTValue<Key, Value>(Dictionary<Key, List<Value>>, out Type, out Type, out Key)

EN: Extracts key and value types from a dictionary with list values CZ: Získá typy klíče a hodnoty ze slovníku s hodnotami typu list

public static void GetTKeyAndTValue<Key, Value>(Dictionary<Key, List<Value>> dictionary, out Type keyType, out Type valueType, out Key firstKey) where Key : notnull

Parameters

dictionary Dictionary<Key, List<Value>>

Source dictionary

keyType Type

Output: key type

valueType Type

Output: value type

firstKey Key

Output: first key from dictionary

Type Parameters

Key

Type of dictionary keys

Value

Type of list values

If(int, string)

EN: Generates an if statement with opening brace. Automatically adds the opening brace. CZ: Generuje if příkaz s otevírací závorkou. Automaticky přidává počáteční závorku.

public void If(int tabCount, string condition)

Parameters

tabCount int

Number of tabs for indentation

condition string

Condition for the if statement

List(int, string, string, List<string>, CSharpGeneratorArgs?)

EN: Generates a list initialization with specified generic type. Default: adds quotes to string values. CZ: Generuje inicializaci seznamu se zadaným generickým typem. Výchozí: přidává uvozovky k řetězcovým hodnotám.

public void List(int tabCount, string genericType, string listName, List<string> list, CSharpGeneratorArgs? args = null)

Parameters

tabCount int

Number of tabs for indentation

genericType string

Generic type parameter for the list (e.g., "string", "int")

listName string

Name of the list variable

list List<string>

List of values to initialize with

args CSharpGeneratorArgs

Optional arguments for list generation (default: AddHyphens = true)

Method(int, AccessModifiers, bool, string, string, string, string)

EN: Generates a method declaration with body. The inner content must already be indented for this method. CZ: Generuje deklaraci metody s tělem. Vnitřní obsah již musí být odsazený pro tuto metodu.

public void Method(int tabCount, AccessModifiers accessModifier, bool isStatic, string returnType, string name, string bodyContent, string parametersDeclaration)

Parameters

tabCount int

Number of tabs for indentation

accessModifier AccessModifiers

Access modifier for the method

isStatic bool

Whether the method is static

returnType string

Return type of the method

name string

Name of the method

bodyContent string

Body content of the method (already indented)

parametersDeclaration string

Method parameters declaration

Method(int, string, string)

EN: Generates a method with pre-formatted header and body content CZ: Generuje metodu s předformátovanou hlavičkou a obsahem těla

public void Method(int tabCount, string header, string bodyContent)

Parameters

tabCount int

Number of tabs for indentation

header string

Pre-formatted method header

bodyContent string

Body content of the method

Namespace(string)

EN: Generates a namespace declaration CZ: Generuje deklaraci namespace

public void Namespace(string namespaceName)

Parameters

namespaceName string

Name of the namespace

Property(int, AccessModifiers, bool, string, string, object, object, string, bool, bool)

EN: Generates a property with getter and setter. The get and set parameters can be string (custom implementation) or bool (auto-implementation). CZ: Generuje vlastnost s getterem a setterem. Parametry get a set mohou být string (vlastní implementace) nebo bool (auto-implementace).

public void Property(int tabCount, AccessModifiers accessModifier, bool isStatic, string returnType, string name, object getImplementation, object setImplementation, string field, bool shortGet, bool shortSet)

Parameters

tabCount int

Number of tabs for indentation

accessModifier AccessModifiers

Access modifier for the property

isStatic bool

Whether the property is static

returnType string

Type of the property

name string

Name of the property

getImplementation object

Getter implementation: true for auto-implementation, string for custom code, null/false for none

setImplementation object

Setter implementation: true for auto-implementation, string for custom code, null/false for none

field string

Backing field name

shortGet bool

Whether to use short getter syntax (get;)

shortSet bool

Whether to use short setter syntax (set;)

Region(int, string)

EN: Writes the start of a region directive with a name CZ: Zapíše začátek region direktivy se jménem

public void Region(int tabCount, string regionName)

Parameters

tabCount int

Number of tabs for indentation

regionName string

Name of the region

StartClass(int, AccessModifiers, bool, string, params string[])

EN: Generates the start of a class declaration with optional inheritance CZ: Generuje začátek deklarace třídy s volitelným děděním

public void StartClass(int tabCount, AccessModifiers accessModifier, bool isStatic, string className, params string[] derivedTypes)

Parameters

tabCount int

Number of tabs for indentation

accessModifier AccessModifiers

Access modifier for the class

isStatic bool

Whether the class should be static

className string

Name of the class

derivedTypes string[]

Base types or interfaces to derive from

This(int, string)

EN: Generates a this.memberName reference CZ: Generuje odkaz na this.memberName

public void This(int tabCount, string memberName)

Parameters

tabCount int

Number of tabs for indentation

memberName string

Name of the member to reference

Using(string)

EN: Generates a using directive, automatically adding 'using' keyword and semicolon if needed CZ: Generuje using direktivu, automaticky přidává klíčové slovo 'using' a středník pokud chybí

public void Using(string usingStatement)

Parameters

usingStatement string

Using statement (with or without 'using' keyword and semicolon)