<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using NUnit.Framework;
using Nustache;
using Nustache.Core;

namespace Refit.Tests
{
    // * Find all calls to RestService.For<T>, extract all T's
    // * Search for all Interfaces, find the method definitions
    // * Generate the data we need for the template based on interface method 
    //   defn's
    //
    // What if the Interface is in another module? (fuck 'em)
    // What if the Interface itself is Generic? (fuck 'em)
    public class InterfaceStubGenerator
    {
        public string GenerateInterfaceStubs(string[] paths)
        {
            var trees = paths.Select(x => CSharpSyntaxTree.ParseFile(x)).ToList();
            var interfaceNamesToFind = trees.SelectMany(FindInterfacesToGenerate).Distinct().ToList();

            var interfacesToGenerate = trees.SelectMany(x => x.GetRoot().DescendantNodes().OfType<InterfaceDeclarationSyntax>())
                .Where(x => interfaceNamesToFind.Contains(x.Identifier.ValueText))
                .ToList();

            var templateInfo = GenerateTemplateInfoForInterfaceList(interfacesToGenerate);<commit_msg>Update The Plan<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using NUnit.Framework;
using Nustache;
using Nustache.Core;

namespace Refit.Tests
{
    // * Find all calls to RestService.For<T>, extract all T's
    // * Search for all Interfaces, find the method definitions
    // * Generate the data we need for the template based on interface method 
    //   defn's
    // * Get this into an EXE in tools, write a targets file to beforeBuild execute it
    // * Get a props file that adds a dummy file to the project
    // * Write an implementation of RestService that just takes the interface name to
    //   guess the class name based on our template
    //
    // What if the Interface is in another module? (since we copy usings, should be fine)
    // What if the Interface itself is Generic? (fuck 'em)
    public class InterfaceStubGenerator
    {
        public string GenerateInterfaceStubs(string[] paths)
        {
            var trees = paths.Select(x => CSharpSyntaxTree.ParseFile(x)).ToList();
            var interfaceNamesToFind = trees.SelectMany(FindInterfacesToGenerate).Distinct().ToList();

            var interfacesToGenerate = trees.SelectMany(x => x.GetRoot().DescendantNodes().OfType<InterfaceDeclarationSyntax>())
                .Where(x => interfaceNamesToFind.Contains(x.Identifier.ValueText))
                .ToList();

            var templateInfo = GenerateTemplateInfoForInterfaceList(interfacesToGenerate);
{'fraction_non_alphanumeric': 0.09093926319283106, 'fraction_numerical': 0.0, 'mean_word_length': 3.3554913294797686, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3382507', 'n_tokens_mistral': 807, 'n_tokens_neox': 785, 'n_words': 249}