From e5adb8cbc020d384ffb0de2e19a646c5da4e8862 Mon Sep 17 00:00:00 2001 From: nojaf Date: Wed, 13 Dec 2023 08:53:15 +0100 Subject: [PATCH] Warn on FS1178 --- Directory.Build.props | 7 ++++++- src/Fantomas.Client/Contracts.fs | 3 +++ src/Fantomas.Client/Contracts.fsi | 3 +++ src/Fantomas.Client/LSPFantomasService.fs | 2 ++ src/Fantomas.Client/LSPFantomasServiceTypes.fs | 5 +++-- src/Fantomas.Client/LSPFantomasServiceTypes.fsi | 5 +++-- src/Fantomas.Core/ASTTransformer.fs | 3 ++- src/Fantomas.Core/CodeFormatterTypes.fs | 1 + src/Fantomas.Core/Context.fs | 4 +++- src/Fantomas.Core/Context.fsi | 3 ++- src/Fantomas.Core/MultipleDefineCombinations.fs | 4 +++- src/Fantomas.Core/Selection.fs | 2 +- src/Fantomas.Core/SyntaxOak.fs | 7 ++++--- src/Fantomas/Format.fs | 3 ++- src/Fantomas/Format.fsi | 3 ++- src/Fantomas/IgnoreFile.fs | 1 + src/Fantomas/IgnoreFile.fsi | 1 + 17 files changed, 42 insertions(+), 15 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index abef3a92a0..1b4ea596aa 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -26,7 +26,12 @@ Some common use cases include: true true FS0025;FS1182 - 1182;3390;$(WarnOn) + + 1182;3390;1178;$(WarnOn) true true NU1603 diff --git a/src/Fantomas.Client/Contracts.fs b/src/Fantomas.Client/Contracts.fs index 9f16eb4ffd..5a0941ce89 100644 --- a/src/Fantomas.Client/Contracts.fs +++ b/src/Fantomas.Client/Contracts.fs @@ -19,6 +19,7 @@ module Methods = [] let Configuration = "fantomas/configuration" +[] type FormatDocumentRequest = { SourceCode: string FilePath: string @@ -35,6 +36,7 @@ and FormatCursorPosition = new(line: int, column: int) = { Line = line; Column = column } end +[] type FormatSelectionRequest = { SourceCode: string @@ -63,6 +65,7 @@ and FormatSelectionRange = EndColumn = endColumn } end +[] type FantomasResponse = { Code: int FilePath: string diff --git a/src/Fantomas.Client/Contracts.fsi b/src/Fantomas.Client/Contracts.fsi index c94e5a73dc..fde378c622 100644 --- a/src/Fantomas.Client/Contracts.fsi +++ b/src/Fantomas.Client/Contracts.fsi @@ -18,6 +18,7 @@ module Methods = [] val Configuration: string = "fantomas/configuration" +[] type FormatDocumentRequest = { SourceCode: string @@ -43,6 +44,7 @@ and FormatCursorPosition = val Column: int end +[] type FormatSelectionRequest = { SourceCode: string @@ -69,6 +71,7 @@ and FormatSelectionRange = val EndColumn: int end +[] type FantomasResponse = { Code: int diff --git a/src/Fantomas.Client/LSPFantomasService.fs b/src/Fantomas.Client/LSPFantomasService.fs index 16c2dc7b6b..710384df4c 100644 --- a/src/Fantomas.Client/LSPFantomasService.fs +++ b/src/Fantomas.Client/LSPFantomasService.fs @@ -10,6 +10,7 @@ open Fantomas.Client.Contracts open Fantomas.Client.LSPFantomasServiceTypes open Fantomas.Client.FantomasToolLocator +[] type ServiceState = { Daemons: Map FolderToVersion: Map } @@ -25,6 +26,7 @@ type GetDaemonError = | InCompatibleVersionFound | CompatibleVersionIsKnownButNoDaemonIsRunning of version: FantomasVersion +[] type Msg = | GetDaemon of folder: Folder * replyChannel: AsyncReplyChannel> | Reset of AsyncReplyChannel diff --git a/src/Fantomas.Client/LSPFantomasServiceTypes.fs b/src/Fantomas.Client/LSPFantomasServiceTypes.fs index 7505e3b22d..29f1844360 100644 --- a/src/Fantomas.Client/LSPFantomasServiceTypes.fs +++ b/src/Fantomas.Client/LSPFantomasServiceTypes.fs @@ -18,7 +18,7 @@ type FantomasResponseCode = | CancellationWasRequested = 10 | DaemonCreationFailed = 11 -[] +[] type FormatSelectionResponse = | Formatted of filename: string * formattedContent: string * formattedRange: FormatSelectionRange | Error of filename: string * formattingError: string @@ -38,7 +38,7 @@ type FormatSelectionResponse = SelectedRange = None Cursor = None } -[] +[] type FormatDocumentResponse = | Formatted of filename: string * formattedContent: string * cursor: FormatCursorPosition option | Unchanged of filename: string @@ -55,6 +55,7 @@ type FantomasToolStartInfo = | GlobalTool | ToolOnPath of executableFile: FantomasExecutableFile +[] type RunningFantomasTool = { Process: Process RpcClient: JsonRpc diff --git a/src/Fantomas.Client/LSPFantomasServiceTypes.fsi b/src/Fantomas.Client/LSPFantomasServiceTypes.fsi index 8dedde8b4e..3defeb1618 100644 --- a/src/Fantomas.Client/LSPFantomasServiceTypes.fsi +++ b/src/Fantomas.Client/LSPFantomasServiceTypes.fsi @@ -15,14 +15,14 @@ type FantomasResponseCode = | CancellationWasRequested = 10 | DaemonCreationFailed = 11 -[] +[] type FormatSelectionResponse = | Formatted of filename: string * formattedContent: string * formattedRange: FormatSelectionRange | Error of filename: string * formattingError: string member AsFormatResponse: unit -> FantomasResponse -[] +[] type FormatDocumentResponse = | Formatted of filename: string * formattedContent: string * cursor: FormatCursorPosition option | Unchanged of filename: string @@ -41,6 +41,7 @@ type FantomasToolStartInfo = | GlobalTool | ToolOnPath of executableFile: FantomasExecutableFile +[] type RunningFantomasTool = { Process: System.Diagnostics.Process RpcClient: StreamJsonRpc.JsonRpc diff --git a/src/Fantomas.Core/ASTTransformer.fs b/src/Fantomas.Core/ASTTransformer.fs index e3cf722350..fbe5589738 100644 --- a/src/Fantomas.Core/ASTTransformer.fs +++ b/src/Fantomas.Core/ASTTransformer.fs @@ -12,6 +12,7 @@ open Fantomas.Core.RangePatterns open Fantomas.Core.SyntaxOak open Microsoft.FSharp.Core +[] type CreationAide = { SourceText: ISourceText option } @@ -595,7 +596,7 @@ let (|ParenMatchLambda|_|) e = let mkMatchLambda creationAide mFunction cs m = ExprMatchLambdaNode(stn "function" mFunction, List.map (mkSynMatchClause creationAide) cs, m) -[] +[] type LinkExpr = | Identifier of // Could be SynExpr.LongIdent or SynExpr.TypeApp(LongIdent) diff --git a/src/Fantomas.Core/CodeFormatterTypes.fs b/src/Fantomas.Core/CodeFormatterTypes.fs index 9aac6a9d1a..f052975ecd 100644 --- a/src/Fantomas.Core/CodeFormatterTypes.fs +++ b/src/Fantomas.Core/CodeFormatterTypes.fs @@ -2,6 +2,7 @@ open Fantomas.FCS.Text +[] type FormatResult = { /// Formatted code diff --git a/src/Fantomas.Core/Context.fs b/src/Fantomas.Core/Context.fs index a60b7ca867..b6b2a60a5d 100644 --- a/src/Fantomas.Core/Context.fs +++ b/src/Fantomas.Core/Context.fs @@ -183,7 +183,7 @@ module WriterEvents = | WriteLineBecauseOfTrivia -> true | _ -> false) -[] +[] type Context = { Config: FormatConfig WriterModel: WriterModel @@ -961,6 +961,7 @@ let autoIndentAndNlnIfExpressionExceedsPageWidthUnlessStroustrup f (e: Expr) (ct else autoIndentAndNlnIfExpressionExceedsPageWidth (f e) ctx +[] type ColMultilineItem = | ColMultilineItem of // current expression @@ -968,6 +969,7 @@ type ColMultilineItem = // sepNln of current item sepNln: (Context -> Context) +[] type ColMultilineItemsState = { LastBlockMultiline: bool Context: Context } diff --git a/src/Fantomas.Core/Context.fsi b/src/Fantomas.Core/Context.fsi index 16731e5bcb..9118d47469 100644 --- a/src/Fantomas.Core/Context.fsi +++ b/src/Fantomas.Core/Context.fsi @@ -51,7 +51,7 @@ type WriterModel = member IsDummy: bool -[] +[] type Context = { Config: FormatConfig WriterModel: WriterModel @@ -264,6 +264,7 @@ val autoIndentAndNlnTypeUnlessStroustrup: f: (Type -> Context -> Context) -> t: val autoIndentAndNlnIfExpressionExceedsPageWidthUnlessStroustrup: f: (Expr -> Context -> Context) -> e: Expr -> ctx: Context -> Context +[] type ColMultilineItem = ColMultilineItem of expr: (Context -> Context) * sepNln: (Context -> Context) /// This helper function takes a list of expressions and ranges. diff --git a/src/Fantomas.Core/MultipleDefineCombinations.fs b/src/Fantomas.Core/MultipleDefineCombinations.fs index 34e4634fe0..593e407765 100644 --- a/src/Fantomas.Core/MultipleDefineCombinations.fs +++ b/src/Fantomas.Core/MultipleDefineCombinations.fs @@ -1,7 +1,6 @@ module internal Fantomas.Core.MultipleDefineCombinations open System -open System.Linq open System.Text open System.Text.RegularExpressions open Microsoft.FSharp.Core.CompilerServices @@ -107,12 +106,14 @@ type CodeFragment = // You should never enter the case where you need to compare a hash line with something other than a hash line. | x, other -> failwith $"Cannot compare %A{x} with %A{other}" +[] type FormatResultForDefines = { Result: FormatResult Defines: DefineCombination Fragments: CodeFragment list } /// Accumulator type used when building up the fragments. +[] type SplitHashState = { CurrentBuilder: StringBuilder LinesCollected: int @@ -129,6 +130,7 @@ and [] LastLineInfo = | Content /// Accumulator type used when folding over the selected CodeFragments. +[] type FragmentWeaverState = { LastLine: int Cursors: Map diff --git a/src/Fantomas.Core/Selection.fs b/src/Fantomas.Core/Selection.fs index 35389f9b5a..9909d7ad00 100644 --- a/src/Fantomas.Core/Selection.fs +++ b/src/Fantomas.Core/Selection.fs @@ -71,7 +71,7 @@ let findNode (selection: range) (node: Node) : Node option = if isExactSelection then Some node else None -[] +[] type TreeForSelection = /// Format this tree and return the entire result. | Standalone of Oak diff --git a/src/Fantomas.Core/SyntaxOak.fs b/src/Fantomas.Core/SyntaxOak.fs index 50d56e77fb..d2cfb394b9 100644 --- a/src/Fantomas.Core/SyntaxOak.fs +++ b/src/Fantomas.Core/SyntaxOak.fs @@ -95,7 +95,7 @@ let combineRanges (ranges: range seq) = else Seq.reduce Range.unionRanges ranges -[] +[] type IdentifierOrDot = | Ident of SingleTextNode | KnownDot of SingleTextNode @@ -1199,7 +1199,7 @@ type LinkSingleAppUnit(functionName: Expr, unit: UnitNode, range) = member val FunctionName = functionName member val Unit = unit -[] +[] type ChainLink = | Identifier of Expr | Dot of SingleTextNode @@ -1417,7 +1417,7 @@ type ElseIfNode(mElse: range, mIf: range, condition: Node, range) as elseIfNode member _.AddCursor _ = () member _.TryGetCursor = None -[] +[] type IfKeywordNode = | SingleWord of SingleTextNode | ElseIf of ElseIfNode @@ -1553,6 +1553,7 @@ type StaticOptimizationConstraintWhenTyparTyconEqualsTyconNode(typar: SingleText member val TypeParameter = typar member val Type = t +[] type StaticOptimizationConstraint = | WhenTyparTyconEqualsTycon of StaticOptimizationConstraintWhenTyparTyconEqualsTyconNode | WhenTyparIsStruct of SingleTextNode diff --git a/src/Fantomas/Format.fs b/src/Fantomas/Format.fs index 68abce0a98..c0282b53af 100644 --- a/src/Fantomas/Format.fs +++ b/src/Fantomas/Format.fs @@ -6,7 +6,7 @@ open Fantomas.Core type ProfileInfo = { LineCount: int; TimeTaken: TimeSpan } -[] +[] type FormatResult = | Formatted of filename: string * formattedContent: string * profileInfo: ProfileInfo option | Unchanged of filename: string * profileInfo: ProfileInfo option @@ -32,6 +32,7 @@ type FormatParams = Profile = profile File = file } +[] type CheckResult = { Errors: (string * exn) list Formatted: string list } diff --git a/src/Fantomas/Format.fsi b/src/Fantomas/Format.fsi index 9db8223506..89729dd8b9 100644 --- a/src/Fantomas/Format.fsi +++ b/src/Fantomas/Format.fsi @@ -5,7 +5,7 @@ open Fantomas.Core type ProfileInfo = { LineCount: int; TimeTaken: TimeSpan } -[] +[] type FormatResult = | Formatted of filename: string * formattedContent: string * profileInfo: ProfileInfo option | Unchanged of filename: string * profileInfo: ProfileInfo option @@ -22,6 +22,7 @@ type FormatParams = static member Create: bool * bool * string -> FormatParams static member Create: FormatConfig * bool * bool * string -> FormatParams +[] type CheckResult = { Errors: (string * exn) list Formatted: string list } diff --git a/src/Fantomas/IgnoreFile.fs b/src/Fantomas/IgnoreFile.fs index d5d653c7a5..4a7bf2b002 100644 --- a/src/Fantomas/IgnoreFile.fs +++ b/src/Fantomas/IgnoreFile.fs @@ -19,6 +19,7 @@ type AbsoluteFilePath = /// of the ignore-file. type IsPathIgnored = AbsoluteFilePath -> bool +[] type IgnoreFile = { Location: IFileInfo IsIgnored: IsPathIgnored } diff --git a/src/Fantomas/IgnoreFile.fsi b/src/Fantomas/IgnoreFile.fsi index 4f1440a342..1e7e75622a 100644 --- a/src/Fantomas/IgnoreFile.fsi +++ b/src/Fantomas/IgnoreFile.fsi @@ -13,6 +13,7 @@ type AbsoluteFilePath = /// of the ignore-file. type IsPathIgnored = AbsoluteFilePath -> bool +[] type IgnoreFile = { Location: IFileInfo IsIgnored: IsPathIgnored }