Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

Commit 4f00837

Browse files
teo-tsirpanisKevinRansom
authored andcommitted
Refactor the Fsc task's toolpath logic. (dotnet#10126)
* Refactor the Fsc task's toolpath logic. * Remove invalid test case Co-authored-by: KevinRansom <[email protected]>
1 parent 0fd66ae commit 4f00837

File tree

2 files changed

+6
-20
lines changed

2 files changed

+6
-20
lines changed

src/fsharp/FSharp.Build/Fsc.fs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ type public Fsc () as this =
6464
let mutable targetProfile : string = null
6565
let mutable targetType : string = null
6666
let mutable toolExe : string = "fsc.exe"
67-
let mutable toolPath : string =
67+
let defaultToolPath =
6868
let locationOfThisDll =
6969
try Some(Path.GetDirectoryName(typeof<Fsc>.Assembly.Location))
7070
with _ -> None
@@ -471,11 +471,6 @@ type public Fsc () as this =
471471
member fsc.TreatWarningsAsErrors
472472
with get() = treatWarningsAsErrors
473473
and set(p) = treatWarningsAsErrors <- p
474-
475-
// For targeting other folders for "fsc.exe" (or ToolExe if different)
476-
member fsc.ToolPath
477-
with get() = toolPath
478-
and set(s) = toolPath <- s
479474

480475
// When set to true, generate resource names in the same way as C# with root namespace and folder names
481476
member fsc.UseStandardResourceNames
@@ -536,8 +531,9 @@ type public Fsc () as this =
536531
override fsc.StandardErrorEncoding = if utf8output then System.Text.Encoding.UTF8 else base.StandardErrorEncoding
537532
override fsc.StandardOutputEncoding = if utf8output then System.Text.Encoding.UTF8 else base.StandardOutputEncoding
538533
override fsc.GenerateFullPathToTool() =
539-
if toolPath = "" then raise (new System.InvalidOperationException(FSBuild.SR.toolpathUnknown()))
540-
System.IO.Path.Combine(toolPath, fsc.ToolExe)
534+
if defaultToolPath = "" then
535+
raise (new System.InvalidOperationException(FSBuild.SR.toolpathUnknown()))
536+
System.IO.Path.Combine(defaultToolPath, fsc.ToolExe)
541537
override fsc.LogToolCommand (message:string) =
542538
fsc.Log.LogMessageFromText(message, MessageImportance.Normal) |>ignore
543539

@@ -579,8 +575,8 @@ type public Fsc () as this =
579575
invokeCompiler baseCallDelegate
580576
with
581577
| e ->
582-
Debug.Assert(false, "HostObject received by Fsc task did not have a Compile method or the compile method threw an exception. "+(e.ToString()))
583-
reraise()
578+
Debug.Fail("HostObject received by Fsc task did not have a Compile method or the compile method threw an exception. " + (e.ToString()))
579+
reraise()
584580

585581
override fsc.GenerateCommandLineCommands() =
586582
let builder = new FSharpCommandLineBuilder()

vsintegration/tests/UnitTests/Tests.Build.fs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,6 @@ type Build() =
6969
member this.TearDown() =
7070
()
7171

72-
[<Test>]
73-
member public this.MissingToolPathError() =
74-
let tool = new FSharp.Build.Fsc()
75-
tool.ToolPath <- ""
76-
try
77-
let p = tool.InternalGenerateFullPathToTool()
78-
Assert.Fail("should not succeed")
79-
with e ->
80-
e.Message.AssertMatchesPattern("ToolPath is unknown; specify the path to the tool.")
81-
8272
[<Test>]
8373
member public this.TestCodePage() =
8474
let tool = new FSharp.Build.Fsc()

0 commit comments

Comments
 (0)