Skip to content
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

Fantomas is trying to format the input multiple times due to the detection of multiple defines #2822

Closed
3 tasks
manxjason opened this issue Apr 3, 2023 · 2 comments · Fixed by #2828
Closed
3 tasks

Comments

@manxjason
Copy link

Issue created from fantomas-online

Code

fun config ->
#if LOGGING_DEBUG || LOGGING_LOCAL
            let template =
                "[{Timestamp:HH:mm:ss.fff} {Level:u3} {SourceContext:l}] {Message:lj} | {Properties}{NewLine}{Exception}"
#endif

            config
#if LOGGING_DEBUG
                .WriteTo
                .Debug(outputTemplate = template)
#endif
#if LOGGING_LOCAL
                .WriteTo
                .AnsiConsoleLog(
                    outputTemplate = template
                )
#endif
            

Error

System.FormatException: Fantomas is trying to format the input multiple times due to the detection of multiple defines.
There is a problem with merging all the code back together.
[] has 13 fragments
[LOGGING_DEBUG, LOGGING_LOCAL] has 13 fragments
[LOGGING_DEBUG] has 15 fragments
[LOGGING_LOCAL] has 15 fragments
Please raise an issue at https://fsprojects.github.io/fantomas-tools/#/fantomas/preview.
   at Fantomas.Core.MultipleDefineCombinations.mergeMultipleFormatResults(FormatConfig config, FSharpList`1 results) in /_//src/Fantomas.Core/MultipleDefineCombinations.fs:line 211
   at Fantomas.Core.CodeFormatterImpl.formatDocument@95-5.Invoke(FSharpList`1 results) in /_//src/Fantomas.Core/CodeFormatterImpl.fs:line 99
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b](AsyncActivation`1 ctxt, b result1, FSharpFunc`2 userCode) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 525
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in D:\a\_work\1\s\src\FSharp.Core\async.fs:line 112

Problem description

Please describe here the Fantomas problem you encountered.
Check out our Contribution Guidelines.

Extra information

  • The formatted result breaks my code.
  • The formatted result gives compiler warnings.
  • I or my company would be willing to help fix this.

Options

Fantomas main branch at 2023-03-31T07:24:53Z - 8e10a1b

Default Fantomas configuration

Did you know that you can ignore files when formatting from fantomas-tool or the FAKE targets by using a .fantomasignore file?

@nojaf
Copy link
Contributor

nojaf commented Apr 3, 2023

Thank you, are you interested in submitting a PR for this?

@manxjason
Copy link
Author

Not in the short term, but not entirely off the table

@manxjason manxjason changed the title Fantomas is trying to format the input multiple times due to the detection of multiple defines<Insert meaningful title> Fantomas is trying to format the input multiple times due to the detection of multiple defines Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants