C
C#6mo ago
Ares

how difficult would this be to do?

so basically just for pratcice, I want to make an app that takes a github url and then goes throught he repo and determines all of the constructor DI being used in the app and which controllers are using them. and then i can display the info with interactive ui. i will have to find some way to read the github repo, and then i will need Roslyn (which i dont know anything about) to analyze the code. but am i missing something majorly important that i didnt mention or advice?
9 Replies
Pobiega
Pobiega6mo ago
That should be fairly straight forward tbh - something like CliWrap to run a git clone on the github repo, then Roslyn to analyze the files. Won't be trivial, even if each individual step is "straight forward" it will require a fair bit of understanding of the Roslyn results for example
Ares
AresOP6mo ago
ok thats good to know i will continue then cause i was having second thoughts
Omnissiah
Omnissiah6mo ago
if you want to compare the result you can also extract constructors from code with codeql
Ares
AresOP6mo ago
thx. idk what codeql is but ill look into that too
public async Task<string> GetDependencyInformation(string url)
{
string path = @"c:\MyDir";


if (Directory.Exists(path))
{
Console.WriteLine("That path exists already.");
Directory.Delete(path, true);
}

DirectoryInfo di = Directory.CreateDirectory(path);
Console.WriteLine("The directory was created successfully at {0}.", Directory.GetCreationTime(path));

var result = Repository.Clone(url, path);

di.Delete();
Console.WriteLine("The directory was deleted successfully.");
return path;
}
public async Task<string> GetDependencyInformation(string url)
{
string path = @"c:\MyDir";


if (Directory.Exists(path))
{
Console.WriteLine("That path exists already.");
Directory.Delete(path, true);
}

DirectoryInfo di = Directory.CreateDirectory(path);
Console.WriteLine("The directory was created successfully at {0}.", Directory.GetCreationTime(path));

var result = Repository.Clone(url, path);

di.Delete();
Console.WriteLine("The directory was deleted successfully.");
return path;
}
so i made this code to clone the repo locally. but i just realized that, since this is a web app, that means that i should not be cloning anything locally. if i cant create anything locally, that means i cant use Roslyn. So is making something this into a web app even possible?
Kouhai
Kouhai6mo ago
You can clone the repository to your VPS and do the analysis server-side then present the results to the user So yes, it's possible to make it into a web app
Ares
AresOP6mo ago
ok so something like digital ocean? i dont know how hard or easy that would be because ive never done that before
Kouhai
Kouhai6mo ago
Yes, I think we have a tag here for VPS $vps
Ares
AresOP6mo ago
ok thx
Want results from more Discord servers?
Add your server