From 51ab0277b070d41df9099cdf6f09df79b1fb433a Mon Sep 17 00:00:00 2001 From: Ville Penttinen Date: Sun, 1 Dec 2024 12:28:52 +0200 Subject: [PATCH] chore: Disable fsharplint temporarily --- .nuke/build.schema.json | 2 -- build/Build.cs | 31 +++++++++++++-------- build/_build.csproj | 4 +-- src/Visp.Cli/Properties/launchSettings.json | 12 ++++++++ src/Visp.Compiler/ParseUtils.fs | 17 ++++++----- 5 files changed, 43 insertions(+), 23 deletions(-) create mode 100644 src/Visp.Cli/Properties/launchSettings.json diff --git a/.nuke/build.schema.json b/.nuke/build.schema.json index 9ea4728..764de51 100644 --- a/.nuke/build.schema.json +++ b/.nuke/build.schema.json @@ -26,13 +26,11 @@ "enum": [ "CheckCsharpier", "CheckFantomas", - "CheckFSharpLint", "Compile", "FormatCsharpier", "FormatFantomas", "InstallCsharpier", "InstallFantomas", - "InstallFSharpLint", "InstallLinters", "Lint", "Pack", diff --git a/build/Build.cs b/build/Build.cs index f3016ac..943d788 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Linq; -using System.Security.Cryptography; using Nuke.Common; using Nuke.Common.CI.GitHubActions; using Nuke.Common.Execution; @@ -38,7 +37,7 @@ class Build : NukeBuild, IUseCsharpier, IUseFantomas, - IUseFSharpLint, + //IUseFSharpLint, IUseCustomLinters, IHazSolution, ITest, @@ -70,20 +69,20 @@ public T From() bool IUseCsharpier.UseGlobalTool => false; bool IUseFantomas.UseGlobalTool => false; - bool IUseFSharpLint.UseGlobalTool => false; + //bool IUseFSharpLint.UseGlobalTool => false; - IEnumerable IUseFantomas.DirectoriesToFormat => new[] - { + IEnumerable IUseFantomas.DirectoriesToFormat => + [ RootDirectory / "src", RootDirectory / "tests", - }; + ]; - IEnumerable IUseCustomLinters.Linters => new IProvideLinter[] - { + IEnumerable IUseCustomLinters.Linters => + [ From().Linter, From().Linter, - From().Linter, - }; + //From().Linter, + ]; // csharpier-ignore public Target RestoreTools => _ => _ @@ -297,7 +296,10 @@ public interface IUseFSharpLint : INukeBuild, IHazSolution { bool UseGlobalTool { get; } - IEnumerable FilesToFormat => new[] { Solution.Path }; + IEnumerable FilesToFormat => Solution + .AllProjects + .Where(it => it.Path.Extension.Contains("fsproj")) + .Select(it => it.Path); // csharpier-ignore Target CheckFSharpLint => _ => _ @@ -330,7 +332,12 @@ void RunFormat(AbsolutePath path) { DotNet( arguments: toolname + $" lint {path}", - logInvocation: true + logInvocation: true, + environmentVariables: new Dictionary + { + // https://github.com/fsprojects/FSharpLint/issues/687 + ["DOTNET_ROLL_FORWARD"] = "latestMajor", + } ); } } diff --git a/build/_build.csproj b/build/_build.csproj index d30f4d5..97a71ea 100644 --- a/build/_build.csproj +++ b/build/_build.csproj @@ -15,8 +15,8 @@ - - + + diff --git a/src/Visp.Cli/Properties/launchSettings.json b/src/Visp.Cli/Properties/launchSettings.json new file mode 100644 index 0000000..774faac --- /dev/null +++ b/src/Visp.Cli/Properties/launchSettings.json @@ -0,0 +1,12 @@ +{ + "profiles": { + "Visp.Cli": { + "commandName": "Project" + }, + "Debug.Cli": { + "commandName": "Project", + "commandLineArgs": ".\\visp\\tests\\include\\include-macros-0.visp --debug-tokens", + "workingDirectory": "$(SolutionDir)" + } + } +} \ No newline at end of file diff --git a/src/Visp.Compiler/ParseUtils.fs b/src/Visp.Compiler/ParseUtils.fs index b3f0ca5..a0a7df6 100644 --- a/src/Visp.Compiler/ParseUtils.fs +++ b/src/Visp.Compiler/ParseUtils.fs @@ -13,8 +13,7 @@ open System.Collections.Generic type NestedTokenizer = { mutable index: int - tokens: IReadOnlyList - } + tokens: IReadOnlyList } member t.ReadNext() = if t.index < t.tokens.Count then @@ -32,6 +31,7 @@ let rec mkTokenizerWithArgs args = let handle_next (args: LexArgs) next = let mutable actual = next + match next with | QUOTE_SYM -> args.mode <- LexMode.TokenStream TokenStreamMode.QuoteSym | QUOTE_KW -> // args.mode <- LexMode.TokenStream TokenStreamMode.Quote @@ -124,7 +124,7 @@ let rec mkTokenizerWithArgs args = let mutable token_list = [] let mutable include_tokenizers: NestedTokenizer list = [] - let read_next_nested_token () = + let read_next_nested_token () = match include_tokenizers with | [] -> None | it :: rest -> @@ -132,8 +132,7 @@ let rec mkTokenizerWithArgs args = | None -> include_tokenizers <- rest None - | Some (tok) -> - Some(tok) + | Some(tok) -> Some(tok) let read_next_token_list_token buf = match token_list with @@ -166,11 +165,13 @@ let rec mkTokenizerWithArgs args = while loop do let next = next_token buf + match next with - | STRING (it, _ ,_) -> + | STRING(it, _, _) -> includes <- it :: includes () | _ -> () + loop <- next <> RPAREN () // includes <- List.rev includes @@ -184,6 +185,7 @@ let rec mkTokenizerWithArgs args = let tokz = getNestedTokens buf.EndPos.FileName it false include_tokenizers <- tokz :: include_tokenizers includes <- rest + () // Includes will not be part of the final parse result @@ -211,10 +213,11 @@ and private getNestedTokens rootFile filePath dbg = while not lexbuf.IsPastEndOfStream do let next = tokenizer lexbuf + if next <> EOF then arr.Add(next) - { tokens = arr; index = 0} + { tokens = arr; index = 0 } and mkTokenizer dbg = mkTokenizerWithArgs