-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
WIP - Add fantomas formatting support #44801
base: main
Are you sure you want to change the base?
Conversation
reference issue - dotnet/format#1526 https://learn.microsoft.com/en-us/dotnet/fsharp/style-guide/formatting https://fsprojects.github.io/fantomas/ --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/jkone27/sdk?shareId=XXXX-XXXX-XXXX-XXXX).
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.
Potential deadlocks with RedirectStandardError, and missing handling for the <PROJECT | SOLUTION>
argument.
FileName = "dotnet", | ||
Arguments = "tool list", | ||
RedirectStandardOutput = true, | ||
RedirectStandardError = true, |
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.
RedirectStandardError = true
might cause a deadlock if the child process outputs a lot of text to standard error and the parent process doesn't read from process.StandardError
.
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.
shall we switch it off? or what's the best solution for this item?
var isFantomas = await CodeFormatter.IsFantomasInstalled(); | ||
if (!isFantomas) | ||
{ | ||
CodeFormatter.LogFantomasInstallationInstructions(logger); |
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 something attempts to run dotnet format
on F# code, but Fantomas is not installed, then I think it should report an error and return a nonzero exit code, so that it is clear it did not work.
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.
actually many times F# and C# project can be mixed within a single solution, so i wouldnt report an hard error? C# code can still be formatted. in my case i often have e.g. F# unit tests or integ tests on aspnet and maybe few F# modules, but most projects are C#
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.
Hmm… ok, but if the user specifies the path of a F#-only project without Fantomas installed, then that deserves at least a warning, no?
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.
yes then i should log warning instead of info, right?
One proposal I'd like to make is instead of calling |
@baronfel i think some stuff is internal atm, so cannot be accessed at this level (for example contracts for dotnet tool list), is there ways i can access tool list from here? is this store registered or available cross dotnet commands?
|
await process.WaitForExitAsync(); | ||
|
||
return result is not null | ||
&& result.Data.Any(r => r.PackageId.Contains("fantomas", StringComparison.OrdinalIgnoreCase)); |
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.
deserializing json output
var output = process.StandardOutput.ReadToEnd(); | ||
|
||
// log fantomas output | ||
logger.LogInformation(output); |
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.
log fantomas output
> dotnet tool install fantomas | ||
|
||
"""; | ||
logger.LogInformation(message); |
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.
updated helper message for fantomas installation instructions
reference issue - dotnet/format#1526
https://learn.microsoft.com/en-us/dotnet/fsharp/style-guide/formatting
https://fsprojects.github.io/fantomas/
not clear how to test this, tried dogfood but is not working ?
Can i test this from some build nuget feed? (similar to this below) does the package build trigger for branches too?