Skip to content

Commit 5858481

Browse files
committed
Using simple dictionary for msbuild props
1 parent 11fcf6e commit 5858481

File tree

4 files changed

+19
-17
lines changed

4 files changed

+19
-17
lines changed

src/FsAutoComplete/LspHelpers.fs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ type NotificationsDto =
610610
TraceNamespaces: string array option }
611611

612612
type BuildOptionsDto =
613-
{ MsBuildProperties: string array option }
613+
{ MsBuildProperties: Dictionary<string, string> option }
614614

615615
type DebugDto =
616616
{ DontCheckRelatedFiles: bool option
@@ -729,17 +729,22 @@ type FSACConfig =
729729

730730
member this.AddDto(dto: FSACDto) =
731731
{ CachedTypeCheckCount = defaultArg dto.CachedTypeCheckCount this.CachedTypeCheckCount }
732+
732733
type BuildOptions =
733-
{ MsBuildProperties: string array }
734+
{ MsBuildProperties: Map<string, string> }
734735

735-
static member Default = { MsBuildProperties = [||] }
736+
static member Default = { MsBuildProperties = Map.empty }
736737

737738
static member FromDto(dto: BuildOptionsDto) : BuildOptions =
738-
{ MsBuildProperties = defaultArg dto.MsBuildProperties BuildOptions.Default.MsBuildProperties }
739+
let props = dto.MsBuildProperties |> Option.map (Seq.map (|KeyValue|) >> Map.ofSeq)
740+
741+
{ MsBuildProperties = defaultArg props BuildOptions.Default.MsBuildProperties }
739742

740743

741744
member this.AddDto(dto: BuildOptionsDto) : BuildOptions =
742-
{ MsBuildProperties = defaultArg dto.MsBuildProperties this.MsBuildProperties }
745+
let props = dto.MsBuildProperties |> Option.map (Seq.map (|KeyValue|) >> Map.ofSeq)
746+
747+
{ MsBuildProperties = defaultArg props this.MsBuildProperties }
743748

744749
type DebugConfig =
745750
{ DontCheckRelatedFiles: bool

src/FsAutoComplete/LspServers/AdaptiveFSharpLspServer.fs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -509,22 +509,15 @@ type AdaptiveFSharpLspServer(workspaceLoader: Map<string, string> -> IWorkspaceL
509509

510510
file |> addAValLogging logMsg
511511

512-
let loaderFactory = cval<Map<string, string> -> Ionide.ProjInfo.IWorkspaceLoader> workspaceLoader
512+
let loaderFactory =
513+
cval<Map<string, string> -> Ionide.ProjInfo.IWorkspaceLoader> workspaceLoader
514+
513515
let loader =
514516
aval {
515517
let! loaderFactory = loaderFactory
516518
and! config = config
517519

518-
let props =
519-
config.BuildOptions.MsBuildProperties
520-
|> Array.choose(fun s ->
521-
match s.Split("=") |> Array.toList with
522-
| head::shoulders::_ -> Some(head,shoulders)
523-
| _ -> None
524-
)
525-
|> Map.ofArray
526-
527-
return loaderFactory props
520+
return loaderFactory config.BuildOptions.MsBuildProperties
528521
}
529522

530523

src/FsAutoComplete/LspServers/FsAutoComplete.Lsp.fs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2953,7 +2953,9 @@ module FSharpLspServer =
29532953
|> Map.add "fsproj/removeFile" (serverRequestHandling (fun s p -> s.FsProjRemoveFile(p)))
29542954

29552955
let regularServer lspClient =
2956-
let state = State.Initial toolsPath stateStorageDir (fun toolsPath -> workspaceLoaderFactory toolsPath Map.empty)
2956+
let state =
2957+
State.Initial toolsPath stateStorageDir (fun toolsPath -> workspaceLoaderFactory toolsPath Map.empty)
2958+
29572959
let originalFs = FSharp.Compiler.IO.FileSystemAutoOpens.FileSystem
29582960
FSharp.Compiler.IO.FileSystemAutoOpens.FileSystem <- FsAutoComplete.FileSystem(originalFs, state.Files.TryFind)
29592961
new FSharpLspServer(state, lspClient) :> IFSharpLspServer

src/FsAutoComplete/Parser.fs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ module Parser =
132132
let workspaceLoaderFactory =
133133
fun toolsPath props ->
134134
let props = Map.merge ProjectLoader.globalProperties props |> Map.toList
135+
135136
if projectGraphEnabled then
136137
Ionide.ProjInfo.WorkspaceLoaderViaProjectGraph.Create(toolsPath, props)
137138
else
@@ -192,6 +193,7 @@ module Parser =
192193
if ctx.ParseResult.GetValueForOption otelTracingOption then
193194
let serviceName = FsAutoComplete.Utils.Tracing.serviceName
194195
let version = FsAutoComplete.Utils.Version.info().Version
196+
195197
tracerProvider <-
196198
Sdk
197199
.CreateTracerProviderBuilder()

0 commit comments

Comments
 (0)