From bc8bf26c511bdd0b528bf242be3d7c1efbd522e4 Mon Sep 17 00:00:00 2001 From: Martin521 <29605222+Martin521@users.noreply.github.com> Date: Fri, 12 Sep 2025 18:15:11 +0200 Subject: [PATCH 1/4] added source, dll and project references --- .gitignore | 4 ++++ src/Runfs/ProjectFile.fs | 19 +++++++++++++++++++ src/Runfs/Runfs.fs | 3 ++- tests/Runfs.Tests/DirectivesTests.fs | 4 ++-- tests/Runfs.Tests/TestFiles/test1.fs | 4 ++-- 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index bc78471..80e90a3 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,10 @@ ## ## Get latest from `dotnet new gitignore` +TODO.md +meeting.md +dotnet-tools.json + # dotenv files .env diff --git a/src/Runfs/ProjectFile.fs b/src/Runfs/ProjectFile.fs index eea9551..538a15a 100644 --- a/src/Runfs/ProjectFile.fs +++ b/src/Runfs/ProjectFile.fs @@ -27,6 +27,15 @@ let private packageLine (name, version) = | None -> $""" """ | Some v -> $""" """ +let private sourceLine name = + $""" """ + +let private dllLine name = + $""" """ + +let private projectLine name = + $""" """ + let createProjectFileLines directives entryPointSourceFullPath artifactsPath assemblyName = let sdks = match directives |> List.choose (function Sdk(n, v) -> Some(n, v) | _ -> None) with @@ -37,6 +46,9 @@ let createProjectFileLines directives entryPointSourceFullPath artifactsPath ass let remainingDefaultProperties = DefaultProperties |> List.filter (fun (k, _) -> not (Map.containsKey (k.ToLowerInvariant()) properties)) let packages = directives |> List.choose (function Package(n, v) -> Some(n, v) | _ -> None) + let dlls = directives |> List.choose (function Dll n -> Some n | _ -> None) + let sources = directives |> List.choose (function Source n -> Some n | _ -> None) + let projects = directives |> List.choose (function Project n -> Some n | _ -> None) [ "" @@ -56,6 +68,13 @@ let createProjectFileLines directives entryPointSourceFullPath artifactsPath ass yield! packages |> List.map packageLine " " " " + yield! dlls |> List.map dllLine + " " + " " + yield! projects |> List.map projectLine + " " + " " + yield! sources |> List.map sourceLine $""" """ " " yield! sdks |> List.map (sdkLine "Sdk.targets") diff --git a/src/Runfs/Runfs.fs b/src/Runfs/Runfs.fs index 7ae69b8..3bf5f3b 100644 --- a/src/Runfs/Runfs.fs +++ b/src/Runfs/Runfs.fs @@ -118,7 +118,8 @@ let run (options, sourcePath, args) = let readPreviousSourceHash() = File.ReadAllText sourceHashPath not (File.Exists sourceHashPath && readPreviousSourceHash() = sourceHash) let noDll = not (File.Exists dllPath) - Ok (dependenciesChanged || noDll, sourceChanged) + let hasProjectDirective = directives |> List.exists (function Project _ -> true | _ -> false) + Ok (dependenciesChanged || noDll || hasProjectDirective, sourceChanged) if needsRestore then do! guardAndTime "creating and writing project file" <| fun () -> diff --git a/tests/Runfs.Tests/DirectivesTests.fs b/tests/Runfs.Tests/DirectivesTests.fs index 3ce4d42..600bae6 100644 --- a/tests/Runfs.Tests/DirectivesTests.fs +++ b/tests/Runfs.Tests/DirectivesTests.fs @@ -7,8 +7,8 @@ let thisFileDirectory = __SOURCE_DIRECTORY__ let testFileDirectory = Path.Join(thisFileDirectory, "TestFiles") let expectedDirectives = [ - Project "abc/xyz.fsproj" - Dll "System.dll" + // Project "abc/xyz.fsproj" + // Dll "System.dll" Property ("myprop", "42") Property ("TargetFramework", "net8.0") Sdk ("Microsoft.Net.Sdk", Some "10.0.100") diff --git a/tests/Runfs.Tests/TestFiles/test1.fs b/tests/Runfs.Tests/TestFiles/test1.fs index fc3b416..43b3266 100644 --- a/tests/Runfs.Tests/TestFiles/test1.fs +++ b/tests/Runfs.Tests/TestFiles/test1.fs @@ -1,8 +1,8 @@ module A = open System -#r_project "abc/xyz.fsproj" -#r_dll "System.dll" +// #r_project "abc/xyz.fsproj" +// #r_dll "System.dll" #r_property "myprop=43" #r_property "TargetFramework=net9.0" From 3389de4ba973068e8865bff34812403c2db6c9d9 Mon Sep 17 00:00:00 2001 From: Martin521 <29605222+Martin521@users.noreply.github.com> Date: Fri, 12 Sep 2025 18:20:57 +0200 Subject: [PATCH 2/4] fix test --- tests/Runfs.Tests/DirectivesTests.fs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Runfs.Tests/DirectivesTests.fs b/tests/Runfs.Tests/DirectivesTests.fs index 600bae6..3ce4d42 100644 --- a/tests/Runfs.Tests/DirectivesTests.fs +++ b/tests/Runfs.Tests/DirectivesTests.fs @@ -7,8 +7,8 @@ let thisFileDirectory = __SOURCE_DIRECTORY__ let testFileDirectory = Path.Join(thisFileDirectory, "TestFiles") let expectedDirectives = [ - // Project "abc/xyz.fsproj" - // Dll "System.dll" + Project "abc/xyz.fsproj" + Dll "System.dll" Property ("myprop", "42") Property ("TargetFramework", "net8.0") Sdk ("Microsoft.Net.Sdk", Some "10.0.100") From edaf4d162019a6be9874cd7f2f1d81b877c0f013 Mon Sep 17 00:00:00 2001 From: Martin521 <29605222+Martin521@users.noreply.github.com> Date: Fri, 12 Sep 2025 18:22:16 +0200 Subject: [PATCH 3/4] update readme --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0a1028b..7233f30 100644 --- a/README.md +++ b/README.md @@ -22,9 +22,9 @@ The following directives (source lines) are recognized by runfs: - `#r_package "pp@1.0.0"` - references package pp, version 1.0.0 - `#r_sdk "mysdk@0.0.1"` - references an sdk - `#r_property "myprop=42"` - sets a build property -- `#r_project "xyz.fsproj"` - references a project [not yet implemented] -- `#r_dll "mylib.dll"` - references a library [not yet implemented] -- `#r_source "utilities.fs"` - references a source file [not yet implemented] +- `#r_project "xyz.fsproj"` - references a project +- `#r_dll "mylib.dll"` - references a library +- `#r_source "utilities.fs"` - references a source file > The above directive syntax is preliminary and made to work with the current F# compiler (the parser accepts and ignores them). Ideally, the syntax defined for "dotnet run app.cs" should be reused, like `#:package pp@1.0.0`, but this needs a compiler fix first. @@ -63,7 +63,7 @@ Main learnings Runfs - investigate if the "compile only" shortcut can be replicated for F# - add more tests, possibly Rid-package, fix case sensitivity issue in Directives.fs -- implement the #project, #source and #dll directives and `--convert` +- implement `--convert` Elsewhere - propose and possibly implement a compiler change so that the 'dotnet run app.cs' syntax for directives can be used From a7e671d1572dccf4c1c64f2aa2b7570a940bf821 Mon Sep 17 00:00:00 2001 From: Martin521 <29605222+Martin521@users.noreply.github.com> Date: Fri, 12 Sep 2025 21:37:22 +0200 Subject: [PATCH 4/4] version and changelog --- CHANGELOG.md | 6 ++++++ src/Runfs/Runfs.fsproj | 12 ++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e15c922..16e071e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # CHANGELOG +## 1.0.6 + +### added + +* support for "source", "project" and "dll" reference directives + ## 1.0.5 ### changed diff --git a/src/Runfs/Runfs.fsproj b/src/Runfs/Runfs.fsproj index f020813..ac2c7e5 100644 --- a/src/Runfs/Runfs.fsproj +++ b/src/Runfs/Runfs.fsproj @@ -2,7 +2,7 @@ Runfs - 1.0.5 + 1.0.6 "dotnet run app.cs" functionality for F#. Copyright 2025 by Martin521 Martin521 and contributors @@ -14,7 +14,13 @@ F# True runfs - https://github.com/Martin521/Runfs/blob/main/CHANGELOG.md + +## 1.0.6 + +### added + +* support for "source", "project" and "dll" reference directives + true @@ -39,7 +45,5 @@ - - \ No newline at end of file