CodeGenerationUtility¶
Namespace:
SideXP.Core.EditorOnly
Miscellaneous utility functions for generating code, following our standards.
Fields¶
CompileUnitOptions¶
The options used by default by the script generator.
Methods¶
MakeScriptCompileUnit(CodeNamespace, CodeNamespace)¶
public static CodeCompileUnit MakeScriptCompileUnit(out CodeNamespace importsNamespace, out CodeNamespace domNamespace)
Creates a C# CodeDom compile unit used to generate a script.
Parameters
importsNamespace: Outputs the global namespace used to list the using statements.domNamespace: Outputs the namespace where the class is generated. Can be the same as the imports namespace if the related type is not provided or doesn't have a namespace.
Returns
Returns the created CodeDom compile unit.
MakeScriptCompileUnit(Type, CodeNamespace, CodeNamespace)¶
public static CodeCompileUnit MakeScriptCompileUnit(Type relatedType, out CodeNamespace importsNamespace, out CodeNamespace domNamespace)
Creates a C# CodeDom compile unit used to generate a script.
Parameters
relatedType: The type to which the class is related. Used to set the same namespace for the script to generate.importsNamespace: Outputs the global namespace used to list the using statements.domNamespace: Outputs the namespace where the class is generated. Can be the same as the imports namespace if the related type is not provided or doesn't have a namespace.
Returns
Returns the created CodeDom compile unit.
GenerateScript(CodeCompileUnit)¶
Generates a script from a given CodeCompileUnit.
Parameters
compileUnit: The compile unit used to generate the script.
Returns
Returns the generated script content.
GenerateScriptFile(string, CodeCompileUnit)¶
Generates a script file from a given CodeCompileUnit.
Parameters
path: The path to the script file to generate.compileUnit: The compile unit used to generate the script.
Returns
Returns true if the script has been generated successfully.
RemoveAutocomment(string)¶
Removes the comment added by C# code DOM provider when generating a script.
Parameters
scriptContent: The content of the script as a string. Modified in place to strip the auto-comment.
RemoveAutocommentFromFile(string)¶
Removes the comment added by C# code DOM provider when generating a script.
Parameters
path: The path to the generated file.
FixBlankLines(string)¶
Removes excess blank lines and adds one between closing brackets.
Parameters
scriptContent: The content of the script as a string.