diff options
author | nosami <jasonimison@gmail.com> | 2016-08-23 19:40:10 +0300 |
---|---|---|
committer | nosami <jasonimison@gmail.com> | 2016-09-05 15:58:08 +0300 |
commit | cf0a345c3929a3202fc5f785ca1f975fb1147c30 (patch) | |
tree | 60cf97bd78bd67c9e52978afdf9f2b946372a302 | |
parent | edfbd8b4feebb5cb891564aaafd20f5e58354c15 (diff) |
Fix explicit FSharp.Core reference
When FSharp.Core is explicitly referenced (usually via NuGet), XS
should respect that. Re #43237
-rw-r--r-- | main/external/fsharpbinding/MonoDevelop.FSharp.Tests/CompilerArguments.fs (renamed from main/external/fsharpbinding/MonoDevelop.FSharp.Tests/Checker.fs) | 56 | ||||
-rw-r--r-- | main/external/fsharpbinding/MonoDevelop.FSharp.Tests/MonoDevelop.FSharp.Tests.fsproj | 2 | ||||
-rw-r--r-- | main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/CompilerArguments.fs | 9 |
3 files changed, 33 insertions, 34 deletions
diff --git a/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/Checker.fs b/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/CompilerArguments.fs index 5a0d3ac774..a37f55b95d 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/Checker.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/CompilerArguments.fs @@ -7,32 +7,31 @@ open System.Reflection open MonoDevelop.FSharp open MonoDevelop.Projects -type TestPlatform = +type TestPlatform = | Windows = 0 | Mono = 1 -//[<TestFixture>] +[<TestFixture>] type CompilerArgumentsTests() = + let makeTestableReference (path: string) = + let path = path.Substring(4) + let path = path.Substring(0,path.Length - 1) + path member private x.``Run Only mscorlib referenced`` (assemblyName) = use testProject = Services.ProjectService.CreateDotNetProject ("F#") let assemblyName = match assemblyName with Fqn a -> fromFqn a | File a -> a let _ = testProject.AddReference assemblyName - let references = + let references = CompilerArguments.generateReferences(testProject, Some (FSharpCompilerVersion.FSharp_3_1), FSharpTargetFramework.NET_4_5, ConfigurationSelector.Default, true) - //there should be two references references.Length |> should equal 3 //The two paths for mscorlib and FSharp.Core should match - let makeTestableReference (path: string) = - let path = path.Substring(4) - let path = path.Substring(0,path.Length - 1) - path let testPaths = references |> List.map makeTestableReference match testPaths |> List.map Path.GetDirectoryName with | [one; two; three] -> ()//one |> should equal three @@ -43,13 +42,12 @@ type CompilerArgumentsTests() = let assemblyName = match assemblyName with Fqn a -> fromFqn a | File a -> a let reference = testProject.AddReference assemblyName let references = - CompilerArguments.generateReferences(testProject, + CompilerArguments.generateReferences(testProject, Some (FSharpCompilerVersion.FSharp_3_1), FSharpTargetFramework.NET_4_5, ConfigurationSelector.Default, - false) + false) - //there should be two references references.Length |> should equal 3 //find the mscorlib inside the FSharp.Core ref @@ -64,16 +62,14 @@ type CompilerArgumentsTests() = //find the mscorlib from the returned references (removing unwanted chars "" / \ etc) let mscorlibReferenced = references - |> List.tryFind (fun ref -> ref.Contains("mscorlib")) + |> List.tryFind (fun ref -> ref.Contains("mscorlib")) |> Option.map (fun r -> Path.neutralise (r.Replace("-r:", ""))) mscorlibContained |> should equal mscorlibReferenced - //[<TestCaseAttribute(TestPlatform.Mono,"/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5/mscorlib.dll")>] - //[<TestCaseAttribute(TestPlatform.Mono,"mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" )>] - //[<TestCaseAttribute(TestPlatform.Windows,"mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" )>] - //[<Test>] - [<Ignore>] + [<TestCase(TestPlatform.Mono,"/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5/mscorlib.dll")>] + [<TestCase(TestPlatform.Mono,"mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" )>] + [<TestCase(TestPlatform.Windows,"mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" )>] member x.``Only mscorlib referenced`` (platform, assemblyName:string) = match platform with | TestPlatform.Mono when MonoDevelop.Core.Platform.IsWindows -> () @@ -81,14 +77,11 @@ type CompilerArgumentsTests() = | TestPlatform.Windows when not MonoDevelop.Core.Platform.IsWindows -> () | TestPlatform.Windows -> x.``Run Only mscorlib referenced`` (assemblyName) | _ -> () - - //[<TestCaseAttribute(TestPlatform.Windows,"FSharp.Core, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>] - //[<TestCaseAttribute(TestPlatform.Mono,"FSharp.Core, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>] - //[<TestCaseAttribute(TestPlatform.Mono, "/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/gac/FSharp.Core/4.3.0.0__b03f5f7f11d50a3a/FSharp.Core.dll")>] - //[<TestCaseAttribute(TestPlatform.Mono, "/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5/FSharp.Core.dll")>] - //[<Test>] - [<Ignore>] + [<TestCase(TestPlatform.Windows,"FSharp.Core, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>] + [<TestCase(TestPlatform.Mono,"FSharp.Core, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")>] + [<TestCase(TestPlatform.Mono, "/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/gac/FSharp.Core/4.3.0.0__b03f5f7f11d50a3a/FSharp.Core.dll")>] + [<TestCase(TestPlatform.Mono, "/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5/FSharp.Core.dll")>] member x.``Only FSharp.Core referenced`` (platform: TestPlatform, assemblyName:string) = match platform with | TestPlatform.Mono when MonoDevelop.Core.Platform.IsWindows -> () @@ -96,4 +89,17 @@ type CompilerArgumentsTests() = | TestPlatform.Windows when not MonoDevelop.Core.Platform.IsWindows -> () | TestPlatform.Windows -> x.``Run Only FSharp.Core referenced``(assemblyName) | _ -> () -
\ No newline at end of file + + [<Test>] + member x.``Explicit FSharp.Core and mscorlib referenced``() = + use testProject = Services.ProjectService.CreateDotNetProject ("F#") + let _ = testProject.AddReference "mscorlib" + let reference = testProject.AddReference "FSharp.Core.dll" + let references = + CompilerArguments.generateReferences(testProject, + Some (FSharpCompilerVersion.FSharp_3_1), + FSharpTargetFramework.NET_4_5, + ConfigurationSelector.Default, + true) + let testPaths = references |> List.map makeTestableReference + testPaths |> should contain (reference.HintPath.FullPath |> string) diff --git a/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/MonoDevelop.FSharp.Tests.fsproj b/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/MonoDevelop.FSharp.Tests.fsproj index a83b7c5fb7..c1c19e159d 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/MonoDevelop.FSharp.Tests.fsproj +++ b/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/MonoDevelop.FSharp.Tests.fsproj @@ -121,7 +121,7 @@ <Compile Include="TestViewContent.fs" /> <Compile Include="TestHelpers.fs" /> <Compile Include="DebuggerExpressionResolver.fs" /> - <Compile Include="Checker.fs" /> + <Compile Include="CompilerArguments.fs" /> <Compile Include="IndentationTrackerTests.fs" /> <Compile Include="FSharpUnitTestTextEditorExtensionTests.fs" /> <Compile Include="SyntaxHighlighting.fs" /> diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/CompilerArguments.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/CompilerArguments.fs index 79cd39905e..e8a775a912 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/CompilerArguments.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/CompilerArguments.fs @@ -230,19 +230,12 @@ module CompilerArguments = else Seq.empty - let refs = + let projectReferences = project.References |> Seq.collect Project.getAssemblyLocations |> Seq.append portableRefs |> Seq.append (getReferencedAssemblies project |> Seq.map (fun a -> a.FilePath |> string)) - let projectReferences = - refs - // The unversioned reference text "FSharp.Core" is used in Visual Studio .fsproj files. This can sometimes be - // incorrectly resolved so we just skip this simple reference form and rely on the default directory search below. - |> Seq.filter (fun (ref: string) -> not (ref.Contains("FSharp.Core"))) - |> set - let find assemblyName= projectReferences |> Seq.tryFind (fun fn -> fn.EndsWith(assemblyName + ".dll", true, CultureInfo.InvariantCulture) |