/// <summary> /// Generates code for the specified method information. /// </summary> /// <param name="methodInfo">The method information.</param> /// <param name="options">The generator options.</param> /// <returns>System.String.</returns> public string Generate(MethodInfo methodInfo, MethodGeneratorOptions options) { var sb = new StringBuilder(); if (options.Access) { sb.Append(Generator.Access(methodInfo.Attributes)); } if (options.Modifiers) { sb.Append(Generator.Modifier(methodInfo.Attributes)); } if (options.ReturnType) { sb.Append(Generator.Generate(methodInfo.ReturnType) + " "); } if (options.Name) { sb.Append(methodInfo.Name); } if (methodInfo.IsGenericMethod) { sb.Append("<" + Generator.Generate(methodInfo.GetGenericArguments()) + ">"); } //TODO use options sb.Append("("); sb.Append(Generator.Generate(methodInfo.GetParameters())); sb.Append(")"); if (sb.ToString() == "protected override void Finalize()") { return($"~{methodInfo.DeclaringType.Name}()"); // Destructor } return(GeneratorMode == GeneratorMode.InheriteDoc ? sb.ToString().Replace("<", "{").Replace(">", "}") : sb.ToString()); }
/// <summary> /// Generates code for the specified method information. /// </summary> /// <param name="methodInfo">The method information.</param> /// <returns>System.String.</returns> public string Generate(MethodInfo methodInfo) => Generate(methodInfo, MethodGeneratorOptions.Create(GeneratorMode));