From a0c2077a0b86068776050f92aa469431f0d1ca2e Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Thu, 5 Sep 2024 14:27:30 +0800 Subject: [PATCH] fsxc: refactoring (DRY) Tiny DRY-respect improvement. --- fsxc/Fsxc.fs | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/fsxc/Fsxc.fs b/fsxc/Fsxc.fs index 7eb8bc0..5dc69dd 100644 --- a/fsxc/Fsxc.fs +++ b/fsxc/Fsxc.fs @@ -710,6 +710,18 @@ let fsi = { CommandLineArgs = System.Environment.GetCommandLineArgs() } : FileInfo = let projectFile = GetAutoGenerationTargets origScript "fsproj" + let addFile fileName = + let fsProjFragment = + sprintf + "" + Path.DirectorySeparatorChar + fileName + + File.AppendAllText( + projectFile.FullName, + fsProjFragment + Environment.NewLine + ) + let rec iterate(lines: List) : unit = match lines with | head :: tail -> @@ -740,17 +752,8 @@ let fsi = { CommandLineArgs = System.Environment.GetCommandLineArgs() } + fsprojFragmentEnd + Environment.NewLine ) - | PreProcessorAction.Load fileName -> - let fsProjFragment = - sprintf - "" - Path.DirectorySeparatorChar - fileName + | PreProcessorAction.Load fileName -> addFile fileName - File.AppendAllText( - projectFile.FullName, - fsProjFragment + Environment.NewLine - ) | PreProcessorAction.Ref refName -> let fsProjFragment = if refName.ToLower().EndsWith(".dll") then @@ -797,13 +800,9 @@ let fsi = { CommandLineArgs = System.Environment.GetCommandLineArgs() } iterate contents - File.AppendAllText( - projectFile.FullName, - " - - " - .Replace("{userScriptFileName}", origScript.Name) - ) + addFile origScript.Name + + File.AppendAllText(projectFile.FullName, "") projectFile #endif