protected override void LLWrite(ICodeWriter writer, object o) { string bang = IsTryBang ? "!" : ""; writer.Write($"try{bang} ", true); Expr.WriteAll(writer); }
public VisualStudioSolutionWriter(ILogger <VisualStudioSolutionWriter> logger, IFileWriter fileWriter, ICodeWriter codeWriter, ICVisualStudioVisitor visualStudioVisitor) { _logger = logger; _codeWriter = codeWriter; _visualStudioVisitor = visualStudioVisitor; _fileWriter = fileWriter; }
#pragma warning disable 1591 public override void Write(ICodeWriter writer) { var childIndex = 0; var numberOfChildren = Children.Count; writer.Write("{{"); if (numberOfChildren > 0) { writer.Newline(); writer.Indent(); foreach (var child in Children) { child.Write(writer); childIndex++; if (childIndex > 0 && childIndex < numberOfChildren) { writer.Write(","); } writer.Newline(); } writer.Unindent(); writer.WriteWithIndentation("}}"); } else { writer.Write("}}"); } }
protected override void LLWrite(ICodeWriter writer, object o) { writer.Write("(", true); Type.WriteAll(writer); writer.Write(')', true); ToCast.WriteAll(writer); }
protected override void LLWrite(ICodeWriter writer, object o) { writer.BeginNewLine(true); Contents.WriteAll(writer); writer.Write(';', false); writer.EndLine(); }
/// <summary> /// </summary> /// <param name="codeWriter"> /// </param> /// <param name="type"> /// </param> /// <param name="genericContext"> /// </param> public static void WriteTypeDefinition(ICodeWriter codeWriter, IType type, IGenericContext genericContext) { var fields = IlReader.Fields(type); var count = fields.Count(); var number = 1; Debug.Assert(!type.IsGenericType || !type.IsArray); codeWriter.WriteTypeStart(type, genericContext); codeWriter.WriteBeforeFields(count); if (!type.ToNormal().IsEnum) { foreach (var field in fields) { codeWriter.WriteFieldStart(field, number, count); codeWriter.WriteFieldEnd(field, number, count); number++; } } else { codeWriter.WriteFieldType(type.GetEnumUnderlyingType()); } codeWriter.WriteAfterFields(count); }
public void Gen(ICodeWriter writer) { foreach (var code in Codes) { code.Gen(writer); } }
private static void Writing(IlReader ilReader, string[] filter, ICodeWriter codeWriter, List <IType> newListOfITypes, SortedDictionary <string, IType> genDefinitionsByMetadataName, SortedDictionary <IType, IEnumerable <IMethod> > genericMethodSpecializationsSorted) { // writing codeWriter.WriteStart(ilReader.ModuleName, ilReader.AssemblyQualifiedName, ilReader.IsCoreLib, ilReader.AllReferences()); WriteForwardDeclarations(codeWriter, newListOfITypes); ConvertAllTypes( ilReader, filter, codeWriter, newListOfITypes, genDefinitionsByMetadataName, genericMethodSpecializationsSorted, ConvertingMode.Declaration); ConvertAllTypes( ilReader, filter, codeWriter, newListOfITypes, genDefinitionsByMetadataName, genericMethodSpecializationsSorted, ConvertingMode.Definition); // Append definition of Generic Methods of not used non-generic types ConvertAllTypes( ilReader, filter, codeWriter, genericMethodSpecializationsSorted.Keys.Where(k => !newListOfITypes.Contains(k)).ToList(), genDefinitionsByMetadataName, genericMethodSpecializationsSorted, ConvertingMode.Definition, true); codeWriter.WriteEnd(); codeWriter.Close(); }
protected override void LLWrite(ICodeWriter writer, object o) { writer.Write("where ", true); Name.Write(writer, o); writer.Write(" : ", true); IsA.WriteAll(writer); }
protected override void LLWrite(ICodeWriter writer, object o) { Closure.WriteAll(writer); writer.Write("(", false); Parameters.WriteAll(writer); writer.Write(")", false); }
public override void Render(ICodeWriter renderer) { renderer.Write("{0}<", name); string placeholders = CodeUtils.Placeholders(GenericArgumentTypes.Count()); renderer.Write(string.Format("{0}>", placeholders), GenericArgumentTypes.ToArray()); }
#pragma warning disable 1591 public override void Write(ICodeWriter writer) { writer.WriteWithIndentation("{0} = ", Name); if( Value != null ) Value.Write(writer); writer.Write(";"); writer.Newline(); }
/// <summary> /// Initializes a new <see cref="PascalScriptVisitorContext"/>, inheriting values from the supplied /// context <paramref name="inherited"/> when not explicitly supplied to the constructor /// </summary> /// <param name="inherited">A context that this context should mirror</param> /// <param name="installation">Instance of the class containing the code being visited</param> /// <param name="codeWriter">Reference to a <see cref="ICodeWriter"/> used to generate code</param> /// <param name="localVariables">A collection of local variables, keyed by the variable name</param> /// <param name="namespaces">A list of namespaces visible to the current node</param> /// <param name="methodSyntaxTreeFactory">Factory for returning a <see cref="SyntaxTree"/> from a <see cref="MethodInfo"/></param> /// <param name="aliasFactory">Factory for generating aliases for a method name</param> /// <param name="typeWriter">An <see cref="ICodeWriter"/> used for declaring types</param> /// <param name="declaredMembers">A list of members that have been scripted</param> /// <param name="methodDeclWriterFactory">Factory for creating <see cref="ICodeWriter"/> when scripting a method</param> /// <param name="baseInstallationType">The class type from which <paramref name="installation"/> is derived</param> /// <param name="definedMethods">A list of method names that have been scripted</param> public PascalScriptVisitorContext( PascalScriptVisitorContext inherited, ICodeWriter codeWriter = null, Installation installation = null, IDictionary <string, LoadedType> localVariables = null, HashSet <string> namespaces = null, Func <MethodInfo, SyntaxTree> methodSyntaxTreeFactory = null, Func <string, string> aliasFactory = null, ICodeWriter typeWriter = null, HashSet <MemberInfo> declaredMembers = null, Func <ICodeWriter> methodDeclWriterFactory = null, Type baseInstallationType = null, HashSet <string> definedMethods = null) : this( installation ?? inherited._installation, codeWriter ?? inherited._codeWriter, localVariables ?? inherited.LocalVariables, namespaces ?? inherited.Namespaces, methodSyntaxTreeFactory ?? inherited._methodSyntaxTreeFactory, inherited._referencedGlobalVariables, aliasFactory ?? inherited._aliasFactory, typeWriter ?? inherited.TypeWriter, declaredMembers ?? inherited._declaredMembers, methodDeclWriterFactory ?? inherited._methodDeclWriterFactory, baseInstallationType ?? inherited._baseInstallationType, definedMethods ?? inherited._definedMethods) { }
/// <summary> /// Initializes a new <see cref="PascalScriptVisitorContext"/> /// </summary> /// <param name="installation">Instance of the class containing the code being visited</param> /// <param name="codeWriter">Reference to a <see cref="ICodeWriter"/> used to generate code</param> /// <param name="localVariables">A collection of local variables, keyed by the variable name</param> /// <param name="namespaces">A list of namespaces visible to the current node</param> /// <param name="methodSyntaxTreeFactory">Factory for returning a <see cref="SyntaxTree"/> from a <see cref="MethodInfo"/></param> /// <param name="referencedGlobalVariables">Collection of global variables that are referenced at least once</param> /// <param name="aliasFactory">Factory for generating aliases for a method name</param> /// <param name="typeWriter">An <see cref="ICodeWriter"/> used for declaring types</param> /// <param name="declaredMembers">A list of members that have been scripted</param> /// <param name="methodDeclWriterFactory">Factory for creating <see cref="ICodeWriter"/> when scripting a method</param> /// <param name="baseInstallationType">The class type from which <paramref name="installation"/> is derived</param> /// <param name="definedMethods">A list of method names that have been scripted</param> public PascalScriptVisitorContext( Installation installation, ICodeWriter codeWriter, IDictionary <string, LoadedType> localVariables, HashSet <string> namespaces, Func <MethodInfo, SyntaxTree> methodSyntaxTreeFactory, Dictionary <FieldInfo, string> referencedGlobalVariables, Func <string, string> aliasFactory, ICodeWriter typeWriter, HashSet <MemberInfo> declaredMembers, Func <ICodeWriter> methodDeclWriterFactory, Type baseInstallationType, HashSet <string> definedMethods) { _installation = installation; _codeWriter = codeWriter; LocalVariables = localVariables ?? new Dictionary <string, LoadedType>(); Namespaces = namespaces ?? new HashSet <string>(); _methodSyntaxTreeFactory = methodSyntaxTreeFactory; _referencedGlobalVariables = referencedGlobalVariables ?? new Dictionary <FieldInfo, string>(); _aliasFactory = aliasFactory; TypeWriter = typeWriter; _declaredMembers = declaredMembers; _methodDeclWriterFactory = methodDeclWriterFactory; _baseInstallationType = baseInstallationType; _definedMethods = definedMethods; }
public void Render(ICodeWriter renderer) { if (!SingleLine) { renderer.WriteLine(""); renderer.WriteLine("{"); renderer.PushIndent(); foreach (ICode codeLine in codes) { renderer.WriteLine("{0}", codeLine); } renderer.PopIndent(); renderer.WriteLine("}"); } else { renderer.Write("{ "); foreach (ICode codeLine in codes) { renderer.Write("{0}", codeLine); } renderer.Write(" }"); } }
internal static ICodeWriter DoAppendSignature( this ICodeWriter @this, AccessProtectionOption protection, string frontModifier, MethodInfo method) { if (method == null) { throw new ArgumentNullException(nameof(method)); } string name = method.Name; if (method.ContainsGenericParameters) { name += '<'; name += String.Join(",", method.GetGenericArguments().Select(a => a.Name)); name += '>'; } if (protection != AccessProtectionOption.None) { @this.AppendAccessProtection(method, protection); } @this.Append(frontModifier) .AppendCSharpName(method.ReturnType, true, true, useValueTupleParentheses: true) .Space() .Append(name) .AppendParameters(method.GetParameters()); return(@this); }
#pragma warning disable 1591 public override void Write(ICodeWriter writer) { writer.WriteWithIndentation("Bifrost.namespace(\"{0}\", ", Name); Content.Write(writer); writer.WriteWithIndentation(");"); writer.Newline(); }
private void ReflectSerializedStructs(ICodeWriter writer) { foreach (var typePair in _typeFields) { var type = typePair.Key; using (var typeBlock = new IndentLevel(writer, $"BEGIN_SERIALIZE_TYPE({type})", $"END_SERIALIZE_TYPE({type})")) { foreach (var field in typePair.Value) { if (field.asFunc) { typeBlock.WriteLine($"SERIALIZE_FUNCTION({type}, {field.name})"); } else if (field.asRef) { typeBlock.WriteLine($"SERIALIZE_FIELD_ALIAS({type}, {field.name})"); } else { typeBlock.WriteLine($"SERIALIZE_FIELD({type}, {field.name})"); } } } writer.WriteLine(); } }
protected override void LLWrite(ICodeWriter writer, object o) { Name.WriteAll(writer); writer.Write("[", false); Parameters.WriteAll(writer); writer.Write("]", false); }
protected override void LLWrite(ICodeWriter writer, object o) { writer.BeginNewLine(true); if (Name != null) { Name.WriteAll(writer); } else { Subscript.WriteAll(writer); } if (TypeAnnotation != null) { writer.Write(": ", true); TypeAnnotation.WriteAll(writer); } if (Value != null) { writer.Write(" = ", true); Value.WriteAll(writer); } writer.EndLine(); }
/// <summary> /// Initializes members from the specified CodeGen configuration. /// </summary> /// <param name="xmlConfig">The CodeGen configuration.</param> /// <param name="logger">The logger.</param> /// <param name="errorLogger">The error logger.</param> private void Initialize(XmlConfig xmlConfig, TextWriter logger, TextWriter errorLogger) { stopwatch = System.Diagnostics.Stopwatch.StartNew(); this.logger = logger; this.errorLogger = errorLogger; this.xmlConfig = xmlConfig; xmlModules = xmlConfig.Modules; typeNames = xmlConfig.Types; includedFiles = xmlConfig.IncludedFiles; referencedAssemblies = xmlConfig.ReferencedAssemblies; generationOptions = xmlConfig.GetGenerationFlags(); int nameLimit = xmlConfig.GenerateAssemblyWithRoslyn ? 1000 : 250; if (xmlConfig.GenerateAssemblyWithILWriter && !string.IsNullOrEmpty(xmlConfig.GeneratedAssemblyName)) { nameLimit = 10000; codeWriter = new ManagedILCodeWriter(Path.GetFileNameWithoutExtension(xmlConfig.GeneratedAssemblyName), generationOptions, nameLimit); } else { codeWriter = new CSharpCodeWriter(generationOptions, nameLimit); } userTypeFactory = new UserTypeFactory(xmlConfig.Transformations, codeWriter.Naming); userTypes = new List <UserType>(); }
public TypeScriptWriter(Stream stream, ITypeScriptWriterOptions options) { _options = options ?? new TypeScriptWriterOptions(); _codeWriter = new CodeWriter(stream, _options.IndentCharacters); _parts = new List <CodeSnippetWriter>(); }
/// <summary> /// /// </summary> /// <param name="o"></param> /// <param name="typeName"></param> /// <param name="variableNameInLowerCamelCase"></param> /// <param name="defaultValue">Can be null</param> /// <param name="doesWriteGetter"></param> /// <param name="getterAccessibility">Can be null</param> /// <param name="doesWriteSetter"></param> /// <param name="setterAccessibility">Can be null</param> private static void WritePropertyImpl(ICodeWriter o, string typeName, string variableNameInLowerCamelCase, string defaultValue, bool doesWriteGetter, string getterAccessibility, bool doesWriteSetter, string setterAccessibility) { string getterAccessibilityWithSpace = ""; string setterAccessibilityWithSpace = ""; string defaultValueWithAssignMark = ""; if (getterAccessibility != null) { getterAccessibilityWithSpace = getterAccessibility + " "; } if (setterAccessibility != null) { setterAccessibilityWithSpace = setterAccessibility + " "; } if (defaultValue != null) { defaultValueWithAssignMark = " = " + defaultValue; } string variableNameInUpperCamelCase = GetVariableNameInUpperCamelCase(variableNameInLowerCamelCase); o.BeginBlock("public {0} {1} {{", typeName, variableNameInUpperCamelCase); if (doesWriteGetter) { o.WriteLine("{0}get {{ return {1}; }}", getterAccessibilityWithSpace, variableNameInLowerCamelCase); } if (doesWriteSetter) { o.WriteLine("{0}set {{ {1} = value; }}", setterAccessibilityWithSpace, variableNameInLowerCamelCase); } o.EndBlock("}"); o.WriteLine("{0} {1}{2};", typeName, variableNameInLowerCamelCase, defaultValueWithAssignMark); }
private static void WriteSerializeFieldStatementRecursive(ICodeWriter o, bool writeToBitstream, Type variableType, string variableName) { if (variableType.IsArray) { Type elemType = variableType.GetElementType(); if (writeToBitstream) { WriteStreamWriteStatement(o, variableName + ".Length"); o.BeginBlock("for (int i = 0; i < {0}.Length; i++) {{", variableName); WriteSerializeFieldStatementRecursive(o, writeToBitstream, elemType, variableName + "[i]"); o.EndBlock("}"); } else { string lengthVariableName = "_" + variableName + "Length"; o.WriteLine("int {0};", lengthVariableName); WriteStreamReadStatement(o, "out", lengthVariableName); o.WriteLine("{0} = new {1}[{2}];", variableName, elemType.ToString(), lengthVariableName); o.BeginBlock("for (int i = 0; i < {0}; i++) {{", lengthVariableName); WriteSerializeFieldStatementRecursive(o, writeToBitstream, elemType, variableName + "[i]"); o.EndBlock("}"); } } else { WriteSerializeNonCollectionStatement(o, writeToBitstream, variableType, variableName); } }
public override void GenerateReadFunctionBody(ICodeWriter read) { read.GeneratedByComment() .Append(@" if( r.TokenType != System.Text.Json.JsonTokenType.String ) throw new System.Text.Json.JsonException( $""BigInt input type must be string. Token is '{r.TokenType}'."" ); var s = r.GetString(); r.Read(); if( Int64.TryParse( s, System.Globalization.NumberStyles.Integer, System.Globalization.NumberFormatInfo.InvariantInfo, out var l ) ) { return l; } if( UInt64.TryParse( s, System.Globalization.NumberStyles.Integer, System.Globalization.NumberFormatInfo.InvariantInfo, out var ul ) ) { return ul; } if( Decimal.TryParse( s, out var d ) ) { return d; } if( System.Numerics.BigInteger.TryParse( s, System.Globalization.NumberStyles.Integer, System.Globalization.NumberFormatInfo.InvariantInfo, out var b ) ) { return b; } throw new System.IO.InvalidDataException( ""BigInt input type is invalid. Cannot parse a long, ulong, decimal or BigInteger from: "" + s );"); }
protected override void LLWrite(ICodeWriter writer, object o) { // hack - Parameters really want types. If you set them to void, we'll consider them to be // typeless. bool allVoid = Parameters.All(p => p.CSType == CSSimpleType.Void); writer.Write('(', true); if (allVoid) { bool didFirst = false; foreach (CSParameter p in Parameters) { if (didFirst) { writer.Write(", ", true); } p.Name.WriteAll(writer); didFirst = true; } } else { Parameters.WriteAll(writer); } writer.Write(") => ", true); if (Value != null) { Value.WriteAll(writer); } else { Body.WriteAll(writer); } }
#pragma warning disable 1591 public override void Write(ICodeWriter writer) { base.Write(writer); if (_extensions.Count > 0) { writer.Newline(); IndentMultiple(writer, 3); writer.WriteWithIndentation(".extend({{"); writer.Newline(); writer.Indent(); foreach (var extension in _extensions) { if (extension != _extensions[0]) { writer.Write(","); writer.Newline(); } writer.WriteWithIndentation("{0} : {1}", extension.Name, extension.Options); } writer.Unindent(); writer.Newline(); writer.WriteWithIndentation("}})"); UnindentMultiple(writer, 3); } }
public CProjectVisitor(ILogger <CProjectVisitor> logger, ICodeWriter codeWriter, IFileWriter fileWriter, INugetQueryService nugetQueryService) { _logger = logger; _codeWriter = codeWriter; FileWriter = fileWriter; _nugetQueryService = nugetQueryService; }
void UnindentMultiple(ICodeWriter writer, int numberOfIdentions) { for (var i = 0; i < numberOfIdentions; i++) { writer.Unindent(); } }
protected override void LLWrite(ICodeWriter writer, object o) { writer.BeginNewLine(true); if (CaseExpr != null) { writer.Write("case ", true); CaseExpr.WriteAll(writer); } else { writer.Write("default", true); } writer.Write(" : ", true); if (Actions != null) { if (Actions is ICodeElementSet) { writer.EndLine(); writer.Indent(); writer.BeginNewLine(true); } Actions.WriteAll(writer); writer.EndLine(); if (Actions is ICodeElementSet) { writer.Exdent(); } } }
private void ReflectBaseTypes(ICodeWriter writer) { var baseTypes = new[] { "int8_t", "uint8_t", "int16_t", "uint16_t", "int32_t", "uint32_t", "int64_t", "uint64_t", "bool", "float", "double" }; foreach (var type in baseTypes) { using (var baseType = new IndentLevel(writer, $"BEGIN_SERIALIZE_TYPE({type})", $"END_SERIALIZE_TYPE({type})")) { baseType.WriteLine($"SERIALIZE_SELF_ACCESS({type}, &ReflectionSet<{type}>, &ReflectionGet<{type}>)"); if (type == "uint32_t") { baseType.WriteLine("SERIALIZE_CONVERSION(uint32_t, int32_t)"); baseType.WriteLine("SERIALIZE_CONVERSION(uint32_t, int16_t)"); baseType.WriteLine("SERIALIZE_CONVERSION(uint32_t, int8_t)"); } else if (type == "int32_t") { baseType.WriteLine("SERIALIZE_CONVERSION(int32_t, uint32_t)"); baseType.WriteLine("SERIALIZE_CONVERSION(int32_t, uint16_t)"); baseType.WriteLine("SERIALIZE_CONVERSION(int32_t, uint8_t)"); } } writer.WriteLine(); } }
#pragma warning disable 1591 public override void Write(ICodeWriter writer) { var childIndex = 0; var numberOfChildren = Children.Count; writer.Write("{{"); if (numberOfChildren > 0) { writer.Newline(); writer.Indent(); foreach (var child in Children) { child.Write(writer); childIndex++; if (childIndex > 0 && childIndex < numberOfChildren) writer.Write(","); writer.Newline(); } writer.Unindent(); writer.WriteWithIndentation("}}"); } else { writer.Write("}}"); } }
#pragma warning restore 1591 /// <summary> /// Write all children to the given <see cref="ICodeWriter"/> /// </summary> /// <param name="writer"><see cref="ICodeWriter"/> to use for writing the children</param> protected void WriteChildren(ICodeWriter writer) { foreach (var child in Children) { child.Write(writer); } }
public void Write(ICodeWriter o) { o.WriteLine("[Transient]"); o.BeginBlock("internal sealed class {0} : IEventFactory {{", factoryName); WriteRecreateEvent(o); o.EndBlock("}"); }
private void WriteEvents(ICodeWriter o) { foreach (EventInfo ei in eventInfos) { o.WriteLine("public event GenericEventHandler<{0}> {1};", ei.Type.Name, GetHandlerName(ei.Type.Name)); } }
public static void WriteAccessor(ICodeWriter o, string typeName, string variableNameInLowerCamelCase) { o.BeginBlock("public {0} {1} {{", typeName, GetVariableNameInUpperCamelCase(variableNameInLowerCamelCase)); o.WriteLine("get {{ return {0}; }}", variableNameInLowerCamelCase); o.WriteLine("set {{ {0} = value; }}", variableNameInLowerCamelCase); o.EndBlock("}"); }
#pragma warning disable 1591 public override void Write(ICodeWriter writer) { base.Write(writer); if( _extensions.Count > 0 ) { writer.Newline(); IndentMultiple(writer, 3); writer.WriteWithIndentation(".extend({{"); writer.Newline(); writer.Indent(); foreach (var extension in _extensions) { if (extension != _extensions[0]) { writer.Write(","); writer.Newline(); } writer.WriteWithIndentation("{0} : {1}", extension.Name, extension.Options); } writer.Unindent(); writer.Newline(); writer.WriteWithIndentation("}})"); UnindentMultiple(writer, 3); } }
public static void WriteSingleton(ICodeWriter o, string className) { o.WriteLine("private static {0} instance = new {0}();", className); o.BeginBlock("public static {0} Instance {{", className); o.WriteLine("get { return instance; }"); o.EndBlock("}"); o.WriteLine("private {0}() {{ }}", className); }
public override void Write(ICodeWriter o) { WriteUsing(o); foreach (IGenerator generator in generators) { generator.Write(o); } }
public override void Render(ICodeWriter renderer) { foreach (AttributeStatement attribute in attributes) { renderer.Write("{0} ", attribute); } renderer.Write(snippet, AccessModifier, Modifier, ReturnType, name, parameterList, body); }
#pragma warning disable 1591 public override void Write(ICodeWriter writer) { writer.WriteWithIndentation("{0} : ", Name); if (Value != null) { Value.Write(writer); } }
public override void Render(ICodeWriter renderer) { foreach (AttributeStatement attribute in attributes) { renderer.Write("{0}", attribute); } base.Render(renderer); }
public override void Render(ICodeWriter renderer) { if(AccessModifier != null) { renderer.Write("{0} ", AccessModifier); } renderer.Write(snippet, name, statement); }
public void Write(ICodeWriter o) { o.WriteLine("[Transient]"); o.BeginBlock("internal sealed class {0} : IEventHandlers {{", handlersName); WriteCallHandler(o); WriteEvents(o); o.EndBlock("}"); }
protected override void LLWrite(ICodeWriter writer, object o) { writer.BeginNewLine(true); writer.Write("if (", false); Condition.WriteAll(writer); writer.Write(")", false); writer.EndLine(); }
protected override void LLWrite(ICodeWriter writer, object o) { writer.Write("return ", true); if (Value != null) { Value.WriteAll(writer); } }
public override void Render(ICodeWriter renderer) { var bracedCode = new BracedCode(statements) { SingleLine = SingleLine }; bracedCode.Render(renderer); }
public override void Render(ICodeWriter renderer) { renderer.Write("new {0}", type); renderer.Write(string.Format("({0})", CodeUtils.Placeholders(parameters.Count)), parameters.ToArray()); if (initializer.HasInitiCode()) { renderer.Write("{0}", initializer); } }
public override void Render(ICodeWriter renderer) { renderer.Write("{0} {1}({2})", AccessModifier, type.GetName(), parameterList); if (CallBaseCtor) { renderer.Write(string.Format(" : base({0})", CodeUtils.Placeholders(baseParameters.Count)), baseParameters.ToArray()); } renderer.Write("{0}", body); }
public void Render(ICodeWriter renderer) { renderer.Write("[{0}", type); if (parameters.Count > 0) { renderer.Write(string.Format("({0})", CodeUtils.Placeholders(parameters.Count)), parameters.ToArray()); } renderer.Write("]"); }
private static void RegisterAll(ICodeWriter codeWriter) { #if !FOR_MSCORLIBTEST GetHashCodeGen.Register(codeWriter); EqualsGen.Register(codeWriter); MemberwiseCloneGen.Register(codeWriter); ArrayCopyGen.Register(codeWriter); ArrayClearGen.Register(codeWriter); #endif }
#pragma warning disable 1591 public override void Write(ICodeWriter writer) { foreach (var child in Children) { writer.WriteWithIndentation("{0}.", Name); child.Write(writer); writer.Write(";"); writer.Newline(); } }
public override void Render(ICodeWriter renderer) { if (left.IsBool && right.IsBool) { renderer.Write(snippet, left, ConditionalOperator.And, right); } else { renderer.Write(snippet, left, BinaryOperator.And, right); } }
public override void Render(ICodeWriter renderer) { if (expression.IsBool) { renderer.Write(snippet, ConditionalOperator.Not, expression); } else { renderer.Write(snippet, BinaryOperator.Not, expression); } }
#pragma warning disable 1591 public override void Write(ICodeWriter writer) { writer.WriteWithIndentation("{0}", Name); if (Child != null) { writer.Write("."); Child.Write(writer); } writer.Newline(); }
public void Write(ICodeWriter o) { string className = t.Name; string protocolName = attr.ProtocolName; o.BeginBlock("internal partial class {0} : IProtocolInfo {{", className); ClassGeneratorHelper.WriteSingleton(o, className); WriteName(o, protocolName); WriteVersionProperty(o, "MajorVersion", attr.MajorVersion); WriteVersionProperty(o, "MinorVersion", minorVersion); o.EndBlock("}"); }
public override void Render(ICodeWriter renderer) { if (values.Count > 1) { string placeholders = CodeUtils.Placeholders(values.Count); renderer.Write(string.Format("{{ {0} }},", placeholders), values.ToArray()); } else if (values.Count > 0) { renderer.Write("{0},", values.ToArray()); } }
protected override void Establish_context() { _clipboard = CreateStub<IClipboard>(); _specParser = CreateStub<ISpecParser>(); _cSharpCodeWriter = CreateStub<ICodeWriter>(); _application = new Application(_clipboard, _specParser, _cSharpCodeWriter); var parsedSpec = new ParsedSpec(); _clipboard.Stub(c => c.GetData()).Return("spec"); _specParser.Stub(p => p.Parse("spec")).Return(parsedSpec); _cSharpCodeWriter.Stub(w => w.WriteCode(parsedSpec)).Return("code"); }
public void Write(ICodeWriter o) { o.BeginBlock("internal partial class {0} : IEvent {{", type.Name); WriteCtorWithId(o); WriteCtorWithStream(o); WriteAccessors(o); WriteGetStream(o); WriteId(o); WriteSourceOid(o); WriteTargetOid(o); WriteSender(o); WriteProtocolInfo(o); o.EndBlock("}"); }