From be6b8973b8efa3de6ef707dccbf016bcdca7ac89 Mon Sep 17 00:00:00 2001 From: Florian Verdonck Date: Tue, 28 Sep 2021 08:20:05 +0200 Subject: [PATCH] Add warning about ASTContext and section on Rider. (#1891) --- CONTRIBUTING.md | 10 ++++++++++ src/Fantomas/CodePrinter.fs | 1 + 2 files changed, 11 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 41fab44535..b12e4596c8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -234,6 +234,16 @@ Often this kind of bug is because Fantomas has added a newline due to some forma Use a helper function like `sepNlnConsideringTriviaContentBeforeForMainNode` instead of `sepNln` in `CodePrinter.fs` to solve this. +### ASTContext + +In [CodePrinter.fs](https://github.com/fsprojects/fantomas/blob/master/src/Fantomas/CodePrinter.fs) the ASTContext record is used to indicate context aware information. This usually is an escape hatch and should be avoided at all times. +The key issue is that flags of the ASTContext are usually not cleaned up after they served their purpose. +Leading to very strange situations and unexpected behavior. + +## Rider + +The core contributors of this project are using JetBrains Rider. Running and debugging unit tests works out of the box and no additional plugins are needed. + ## Ionide When you want to contribute to this project in VSCode with Ionide, there is a trick you need to know to debug Unit tests. diff --git a/src/Fantomas/CodePrinter.fs b/src/Fantomas/CodePrinter.fs index 3fcc30cf70..f60b446980 100644 --- a/src/Fantomas/CodePrinter.fs +++ b/src/Fantomas/CodePrinter.fs @@ -15,6 +15,7 @@ open Fantomas.TriviaContext open Fantomas.AstExtensions /// This type consists of contextual information which is important for formatting +/// Please avoid using this record as it can be the cause of unexpected behavior when used incorrectly type ASTContext = { /// Current node is the first child of its parent IsFirstChild: bool