From 658124957352cc6ef908c34036597003dbb1746b Mon Sep 17 00:00:00 2001 From: Jimmy Byrd Date: Mon, 5 Aug 2024 09:55:30 -0400 Subject: [PATCH] Analyze only projects passed in via CLI --- CHANGELOG.md | 1 + src/FSharp.Analyzers.Cli/Program.fs | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ebb1d6..48d7e56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ### Fixed * [Reset the console foreground colour after printing results](https://github.com/ionide/FSharp.Analyzers.SDK/pull/216) (thanks @Numpsy!) +* [Only Analyze projects passed in via CLI](https://github.com/ionide/FSharp.Analyzers.SDK/pull/217) (thanks @TheAngryByrd) ## [0.26.0] - 2024-05-15 diff --git a/src/FSharp.Analyzers.Cli/Program.fs b/src/FSharp.Analyzers.Cli/Program.fs index 6531027..8b79100 100644 --- a/src/FSharp.Analyzers.Cli/Program.fs +++ b/src/FSharp.Analyzers.Cli/Program.fs @@ -119,6 +119,8 @@ let rec mkKn (ty: Type) = let mutable logger: ILogger = Abstractions.NullLogger.Instance +/// Runs MSBuild to create FSharpProjectOptions based on the projPaths. +/// Returns only the FSharpProjectOptions based on the projPaths and not any referenced projects. let loadProjects toolsPath properties (projPaths: string list) = async { let projPaths = @@ -140,7 +142,12 @@ let loadProjects toolsPath properties (projPaths: string list) = logger.LogError("Failed to load project '{0}'", failedLoads) exit 1 - return FCS.mapManyOptions projectOptions |> Seq.toList + let loaded = + FCS.mapManyOptions projectOptions + |> Seq.filter (fun p -> projPaths |> List.exists (fun x -> x = p.ProjectFileName)) // We only want to analyze what was passed in + |> Seq.toList + + return loaded } let runProject