Skip to content

Commit caed8aa

Browse files
committed
fix csharp tests
1 parent 70197ec commit caed8aa

File tree

1 file changed

+8
-28
lines changed

1 file changed

+8
-28
lines changed

tests/service/CSharpProjectAnalysis.fs

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,11 @@ open Microsoft.FSharp.Compiler.SourceCodeServices
2222

2323
open FSharp.Compiler.Service.Tests.Common
2424

25-
let internal getProjectReferences (content, dllFiles, libDirs, otherFlags) =
26-
let otherFlags = defaultArg otherFlags []
27-
let libDirs = defaultArg libDirs []
28-
let base1 = Path.GetTempFileName()
29-
let dllName = Path.ChangeExtension(base1, ".dll")
30-
let fileName1 = Path.ChangeExtension(base1, ".fs")
31-
let projFileName = Path.ChangeExtension(base1, ".fsproj")
32-
File.WriteAllText(fileName1, content)
33-
let options =
34-
checker.GetProjectOptionsFromCommandLineArgs(projFileName,
35-
[| yield "--debug:full"
36-
yield "--define:DEBUG"
37-
yield "--optimize-"
38-
yield "--out:" + dllName
39-
yield "--doc:test.xml"
40-
yield "--warn:3"
41-
yield "--fullpaths"
42-
yield "--flaterrors"
43-
yield "--target:library"
44-
for dllFile in dllFiles do
45-
yield "-r:"+dllFile
46-
for libDir in libDirs do
47-
yield "-I:"+libDir
48-
yield! otherFlags
49-
yield fileName1 |])
25+
let internal getProjectReferences (content, dllFiles) =
26+
let fileName, options =
27+
mkTestFileAndOptions content
28+
[| for dllFile in dllFiles do
29+
yield "-r:"+dllFile |]
5030
let results = checker.ParseAndCheckProject(options) |> Async.RunSynchronously
5131
if results.HasCriticalErrors then
5232
let builder = new System.Text.StringBuilder()
@@ -67,7 +47,7 @@ let internal getProjectReferences (content, dllFiles, libDirs, otherFlags) =
6747
#endif
6848
let ``Test that csharp references are recognized as such`` () =
6949
let csharpAssembly = PathRelativeToTestAssembly "CSharp_Analysis.dll"
70-
let _, table = getProjectReferences("""module M""", [csharpAssembly], None, None)
50+
let _, table = getProjectReferences("""module M""", [csharpAssembly])
7151
let ass = table.["CSharp_Analysis"]
7252
let search = ass.Contents.Entities |> Seq.tryFind (fun e -> e.DisplayName = "CSharpClass")
7353
Assert.True search.IsSome
@@ -113,7 +93,7 @@ let _ = CSharpOuterClass.InnerEnum.Case1
11393
let _ = CSharpOuterClass.InnerClass.StaticMember()
11494
"""
11595

116-
let results, _ = getProjectReferences(content, [csharpAssembly], None, None)
96+
let results, _ = getProjectReferences(content, [csharpAssembly])
11797
results.GetAllUsesOfAllSymbols()
11898
|> Async.RunSynchronously
11999
|> Array.map (fun su -> su.Symbol.ToString())
@@ -134,7 +114,7 @@ open FSharp.Compiler.Service.Tests
134114
135115
let _ = CSharpClass(0)
136116
"""
137-
let results, _ = getProjectReferences(content, [csharpAssembly], None, None)
117+
let results, _ = getProjectReferences(content, [csharpAssembly])
138118
let ctor =
139119
results.GetAllUsesOfAllSymbols()
140120
|> Async.RunSynchronously

0 commit comments

Comments
 (0)