safesparrow / fsharp

The F# compiler, F# core library, F# language service, and F# tooling integration for Visual Studio
https://dotnet.microsoft.com/languages/fsharp
MIT License
1 stars 0 forks source link

Sharing a namespace should not make the files depend on each other #5

Closed nojaf closed 1 year ago

nojaf commented 1 year ago
[<Test>]
let ``horsing around`` () =
    let A =
        """
namespace Fantomas.Core
[<RequireQualifiedAccess>]
module RangeHelpers =
    let mkStartEndRange (size: int) (r: range) : range * range = ()
    let mergeRanges (ranges: range list) : range option = ()

module RangePatterns =
    let (|StartEndRange|) (size: int) (range: range) = ()
    let (|StartRange|) (size: int) (range: range) = ()
""" 
    let B =
        """
module internal Fantomas.Core.Version

open System.Reflection

let fantomasVersion = "0.0.1"
"""

    let files = [
        "A.fs", A
        "B.fs", B
    ]
    let nodes =
        files
        |> List.map (fun (name, code) -> name, parseSourceCode(name, code))
        |> List.toArray

    let graph = detectFileDependencies nodes

    printfn "Detected file dependencies:"
    graph
    |> Array.iter (fun (file, deps) -> printfn $"{file} -> %+A{deps}")
Detected file dependencies:
A.fs -> [||]
B.fs -> [|"A.fs"|]
nojaf commented 1 year ago

This is no longer actionable.