Table of Contents

Class CSharpHelperSunamo

Namespace
SunamoDevCode.SunamoCSharp.Helpers
Assembly
SunamoDevCode.dll

Helper class for C# code processing and generation

public class CSharpHelperSunamo
Inheritance
CSharpHelperSunamo
Inherited Members
Extension Methods

Methods

DefaultValueForType(string, Func<string, string>)

Gets default value for type as string representation

public static string DefaultValueForType(string typeName, Func<string, string> convertTypeShortcutFullNameToShortcut)

Parameters

typeName string

Type name

convertTypeShortcutFullNameToShortcut Func<string, string>

Function to convert full type name to shortcut

Returns

string

String representation of default value

DefaultValueForTypeT<T>(T, Func<string, string>)

Gets default value for type T. Not compatible with default operator - must cast manually https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/default-values

public static object DefaultValueForTypeT<T>(T value, Func<string, string> convertTypeShortcutFullNameToShortcut)

Parameters

value T

Example value to get type information from

convertTypeShortcutFullNameToShortcut Func<string, string>

Function to convert full type name to shortcut

Returns

object

Default value for the type

Type Parameters

T

Type to get default value for

DetectFromToString(string)

Detects string literal ranges in text by finding quote pairs

public static FromToList DetectFromToString(string text)

Parameters

text string

Text to analyze

Returns

FromToList

List of from-to ranges for string literals

IndentAsPreviousLine(List<string>)

Indents lines to match the indentation of the previous line

public static void IndentAsPreviousLine(List<string> lines)

Parameters

lines List<string>

Lines to process

IsAllCsprojAndSlnRightInHiearchy(string, TextOutputGeneratorDC)

Checks if all csproj and sln files are in correct hierarchy

public static string IsAllCsprojAndSlnRightInHiearchy(string path, TextOutputGeneratorDC textOutputGenerator)

Parameters

path string

Root path to search

textOutputGenerator TextOutputGeneratorDC

Text output generator for results

Returns

string

String containing report of incorrectly placed files

IsInterface(string)

Checks if type name follows interface naming convention (starts with 'I' followed by uppercase letter)

public static bool IsInterface(string text)

Parameters

text string

Type name to check

Returns

bool

True if name follows interface convention

ReplaceNulled(string)

Removes "(null)" text from string

public static string ReplaceNulled(string text)

Parameters

text string

Text to process

Returns

string

Text with "(null)" removed and trimmed

ReplaceReadonlyToConst(string)

Replaces 'readonly' and 'static readonly' keywords with 'const' keyword

public static string ReplaceReadonlyToConst(string text)

Parameters

text string

Text to process

Returns

string

Text with readonly keywords replaced by const

ShortcutForControl(string)

Creates shortcut from control name by extracting uppercase letters

public static string ShortcutForControl(string text)

Parameters

text string

Control name

Returns

string

Shortcut created from uppercase letters