CSharpProcedural Class

Summary

[Editor-Only] A variety of methods relating to procedurally generating C# code.
Assembly
Weaver.dll
Namespace
Weaver.Editor.Procedural.Scripting
Base Types
  • Object
graph BT Type-->Base0["Object"] Type["CSharpProcedural"] class Type type-node

Syntax

public static class CSharpProcedural

Methods

Name Value Summary
AppendDeclaration(AccessModifiers, StringBuilder) void
Appends the C# declaration of the specified access `modifiers` to the `text`.
static
AppendDefault(StringBuilder, Type) void
Appends "null" for classes or "default(type)" for structs.
static
AppendDefault<T>(StringBuilder) void
Appends "null" for classes or "default(T)" for structs.
static
AppendEndRegion(StringBuilder, int) void
Indents the text by the specified amount and appends #endregion.
static
AppendForLoop(StringBuilder, int, string, string) void
Appends the opening of a for loop: for (int i = 0; i < length; i++).
static
AppendInterfaceMethodCall(StringBuilder, Type, Type, string, string) void
Appends a call to the specified `methodName`. If the method is non-public, the object is casted to the `interfaceType` to call an explicitly implemented method.
static
AppendObsoleteAttribute(StringBuilder, int, string, bool) void
Appends an [System.ObsoleteAttribute] with the specified message in its constructor.

If `message` is null, this method does nothing.
static
AppendObsoleteDeclaration(StringBuilder, int, ConstructorInfo, string, bool) void
Appends the C# declaration of a constructor with a signature matching the specified `constructor` and an [Obsolete] attribute.

The body of the constructor will simply throw a System.NotImplementedException.
static
AppendObsoleteDeclaration(StringBuilder, int, FieldInfo, string, bool) void
Appends the C# declaration of a field with a signature matching the specified `field` and an [Obsolete] attribute.

If the field is static and Weaver.Editor.Procedural.Scripting.CSharpProcedural.GetInitializer(System.Object) is able to determine the initializer for its current value, that initializer will also be included.
static
AppendObsoleteDeclaration(StringBuilder, int, MemberInfo, string, bool) void
Appends the C# declaration of a member with a signature matching the specified `member` and an [Obsolete] attribute.
static
AppendObsoleteDeclaration(StringBuilder, int, MethodInfo, string, bool) void
Appends the C# declaration of a method with a signature matching the specified `method` and an [Obsolete] attribute.

The body of the method will simply throw a System.NotImplementedException.
static
AppendObsoleteDeclaration(StringBuilder, int, PropertyInfo, string, bool) void
Appends the C# declaration of a property with a signature matching the specified `property` and an [Obsolete] attribute.

The body of the property will simply throw a System.NotImplementedException.
static
AppendObsoleteDeclaration(StringBuilder, int, Type, string, bool) void
Appends the C# declaration of a type with a signature matching the specified `type` and an [Obsolete] attribute.

Also calls Weaver.Editor.Procedural.Scripting.CSharpProcedural.AppendObsoleteDeclaration(System.Text.StringBuilder,System.Int32,System.Reflection.MemberInfo,System.String,System.Boolean) for each of the type's members.
static
AppendObsoleteMethodBody(StringBuilder, MemberInfo, string) void
Appends a method body which throws a System.NotImplementedException.
static
AppendRegion(StringBuilder, int, string) void
Indents the text by the specified amount and appends #region regionName.
static
AppendSingleLineXmlComment(StringBuilder, int, string) void
Appends `comment` inside summary tags as appropriate for a C# XML comment.
static
AppendStringLiteral(StringBuilder, string) void
Appends the `literal` with escape characters inserted as necessary.
static
AppendUnderscoredFullName(StringBuilder, Type) void
Appends the full name of the given type with underscores instead of any characters that wouldn't be valid in a symbol name.
static
AppendUnhandledMember(StringBuilder, int, MemberInfo) void
Appends and logs a message indicating that the specified `member` was not handled.
static
CloseScope(StringBuilder, int) void
text.Indent(--indent).AppendLineConst("}");
static
CloseScopeFully(StringBuilder, int) void
Appends closing brackets and new lines until the nestCount reaches 0.
static
Contains(AccessModifiers, AccessModifiers) bool
Returns true if `modifiers` contains all of the flags specified in `contains`.
static
GetDeclaration(AccessModifiers) string
Returns the C# declaration of the specified access `modifiers`.
static
GetInitializer(Object) string
Tries to return a string which could be used as a C# field initializer to give the field the specified `value`. Returns null if the 'value is null or if unable to determine the appropriate field initializer.

If the value is a custom type with a static string GetInitializer(T value) method, that method will be called to determine the result.
static
GetKeyword(ParameterModifier) string
Gets the C# keyword associated with the `modifier`.
static
GetRestrictivenessModifier(MethodInfo) AccessModifiers
Returns the restrictiveness modifier (public/private/protected/internal) of the specified `method`.
static
HasModifiers(FieldInfo, AccessModifiers) bool
Returns true if the specified `field` has the specified access `modifiers`.
static
HasModifiers(MethodBase, AccessModifiers) bool
Returns true if the specified `method` has the specified access `modifiers`.
static
HasModifiers(PropertyInfo, AccessModifiers) bool
Returns true if the specified `property` has the specified access `modifiers`.
static
HasModifiers(PropertyInfo, AccessModifiers, AccessModifiers) bool
Returns true if the specified `property` has the specified access `modifiers`.
static
HasModifiers(Type, AccessModifiers) bool
Returns true if the specified `type` has the specified access `modifiers`.
static
IsValidInMemberName(char) bool
Checks if the specified char can be used in a C# symbol name.
static
OpenScope(StringBuilder, int) void
text.Indent(indent++).AppendLineConst("{");
static
ToStringCS(bool) string
Returns a string representation of the `value` as a C# literal: either "true" or "false" instead of the uppercase forms returned by System.Boolean.ToString.
static
ValidateMemberName(string, bool) string
Converts the specified string into a valid member name by skipping any invalid characters or replacing them with underscores.
static
ValidateMemberName(string, int, int, bool) string
Converts the specified sub-string into a valid member name by skipping any invalid characters or replacing them with underscores.
static