-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(): adjust apigenerator to use dotnet format #747
base: main
Are you sure you want to change the base?
feat(): adjust apigenerator to use dotnet format #747
Conversation
bb21002
to
7abde69
Compare
src/ApiGenerator/Program.cs
Outdated
var rootPath = GetRootPath(typeof(Program).Assembly.Location); | ||
|
||
var relativeFolderList = new List<string>(); | ||
|
||
foreach (var item in Generator.ApiGenerator.GeneratedFilePaths) | ||
{ | ||
var relativePath = item.Replace(rootPath.FullName, string.Empty); | ||
relativeFolderList.Add($".{relativePath.Replace("\\", "/")}"); | ||
} | ||
|
||
var si = new System.Diagnostics.ProcessStartInfo | ||
{ | ||
WorkingDirectory = rootPath.FullName, | ||
FileName = "dotnet", | ||
Arguments = "format -v diag --include " + string.Join(' ', relativeFolderList.Select(item => $"{item}")), | ||
RedirectStandardInput = true, | ||
RedirectStandardOutput = true, | ||
RedirectStandardError = true, | ||
UseShellExecute = false, | ||
CreateNoWindow = true, | ||
}; | ||
|
||
var process = System.Diagnostics.Process.Start(si); | ||
|
||
Console.WriteLine(); | ||
Console.WriteLine($"Running dotnet format --include {string.Join(' ', relativeFolderList.Select(item => $"{item}"))} -v diag"); | ||
|
||
// hookup the eventhandlers to capture the data that is received | ||
process.OutputDataReceived += (sender, args) => Console.WriteLine(args.Data); | ||
process.ErrorDataReceived += (sender, args) => Console.WriteLine(args.Data); | ||
|
||
process.Start(); | ||
|
||
// start our event pumps | ||
process.BeginOutputReadLine(); | ||
process.BeginErrorReadLine(); | ||
|
||
process.WaitForExit(); | ||
Console.WriteLine(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you add a package reference on Proc = 0.8.1
which is already used by other projects in the solution, this could be simplified down to something like:
Proc.Exec(new ExecArguments("dotnet", "format", "--verbosity", "normal", "--include", "./src/*/_Generated/")
{
WorkingDirectory = GeneratorLocations.SolutionFolder
})
And just define GeneratorLocations.SolutionFolder
as something like:
public static string SolutionFolder { get; } = $"{Root}../../";
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem, thank you for the feedback. I will make the changes this evening
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Comments resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Xtansia I updated the pr off the current main branch. If you ignore _generated files, there are less than 20 files to review.
2338330
to
384648d
Compare
Signed-off-by: Joe Feser <[email protected]>
Signed-off-by: Joe Feser <[email protected]>
Signed-off-by: Joe Feser <[email protected]>
Signed-off-by: Joe Feser <[email protected]>
Signed-off-by: Joe Feser <[email protected]>
Signed-off-by: Joe Feser <[email protected]>
44310c0
to
439ec72
Compare
Signed-off-by: Joe Feser <[email protected]>
Signed-off-by: Joe Feser <[email protected]>
Description
Adjust the generator to use dotnet format
Issues Resolved
Request from #739, Phase 1
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.