Skip to content

Commit

Permalink
Fix formatting in AsyncPaginationExtensionGenerator.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
kfcampbell committed Apr 15, 2024
1 parent a0dee8b commit 28558c9
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions Octokit.Generators/AsyncPaginationExtensionsGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ namespace Octokit.Generators
class AsyncPaginationExtensionsGenerator
{

private const string HEADER = (
@"using System;
private const string HEADER = (
@"using System;
using System.Collections.Generic;
namespace Octokit.AsyncPaginationExtension
Expand All @@ -44,8 +44,8 @@ public static class Extensions
private const int DEFAULT_PAGE_SIZE = 30;
");

private const string FOOTER = (
@"
private const string FOOTER = (
@"
}
}");

Expand All @@ -63,17 +63,17 @@ public static async Task GenerateAsync(string root = "./")
var enumOptions = new EnumerationOptions { RecurseSubdirectories = true };
var paginatedCallRegex = new Regex(@".*Task<IReadOnlyList<(?<returnType>\w+)>>\s*(?<name>\w+)(?<template><.*>)?\((?<arg>.*?)(, )?ApiOptions \w*\);");

foreach (var file in Directory.EnumerateFiles(root, "I*.cs", enumOptions))
{
var type = Path.GetFileNameWithoutExtension(file);
foreach (var file in Directory.EnumerateFiles(root, "I*.cs", enumOptions))
{
var type = Path.GetFileNameWithoutExtension(file);

foreach (var line in File.ReadAllLines(file))
{
var match = paginatedCallRegex.Match(line);
foreach (var line in File.ReadAllLines(file))
{
var match = paginatedCallRegex.Match(line);

if (!match.Success) { continue; }
sb.Append(BuildBodyFromTemplate(match, type));
}
if (!match.Success) { continue; }
sb.Append(BuildBodyFromTemplate(match, type));
}
}

sb.Append(FOOTER);
Expand Down Expand Up @@ -103,14 +103,14 @@ private static string BuildBodyFromTemplate(Match match, string type)
: $"options => t.{name}{templateStr}({string.Join(' ', splitArgs.Where((_, i) => i % 2 == 1))}, options)";

var docArgs = string.Join(", ", splitArgs.Where((_, i) => i % 2 == 0)).Replace('<', '{').Replace('>', '}');
if (docArgs.Length != 0)
{
docArgs += ", ";
if (docArgs.Length != 0)
{
docArgs += ", ";
}

if (arg.Length != 0)
{
arg += ", ";
if (arg.Length != 0)
{
arg += ", ";
}

return ($@"
Expand Down

0 comments on commit 28558c9

Please sign in to comment.