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
typeNamestringType name
convertTypeShortcutFullNameToShortcutFunc<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
valueTExample value to get type information from
convertTypeShortcutFullNameToShortcutFunc<string, string>Function to convert full type name to shortcut
Returns
- object
Default value for the type
Type Parameters
TType to get default value for
DetectFromToString(string)
Detects string literal ranges in text by finding quote pairs
public static FromToList DetectFromToString(string text)
Parameters
textstringText 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
IsAllCsprojAndSlnRightInHiearchy(string, TextOutputGeneratorDC)
Checks if all csproj and sln files are in correct hierarchy
public static string IsAllCsprojAndSlnRightInHiearchy(string path, TextOutputGeneratorDC textOutputGenerator)
Parameters
pathstringRoot path to search
textOutputGeneratorTextOutputGeneratorDCText 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
textstringType 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
textstringText 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
textstringText 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
textstringControl name
Returns
- string
Shortcut created from uppercase letters