Skip to content

Commit

Permalink
add repro for bug under linux
Browse files Browse the repository at this point in the history
  • Loading branch information
matthid committed Nov 18, 2015
1 parent 3291102 commit 548894a
Show file tree
Hide file tree
Showing 15 changed files with 518 additions and 9 deletions.
44 changes: 42 additions & 2 deletions FSharp.Compiler.Service.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "project", "project", "{B6B68AE6-E7A4-4D43-9B34-FFA74BFE192B}"
ProjectSection(SolutionItems) = preProject
Expand Down Expand Up @@ -56,6 +56,10 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Fsc", "samples\FscExe\Fsc.f
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharp_Analysis", "tests\service\data\CSharp_Analysis\CSharp_Analysis.csproj", "{887630A3-4B1D-40EA-B8B3-2D842E9C40DB}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "RunAssemblyResolveProblem", "RunAssemblyResolveProblem\RunAssemblyResolveProblem.fsproj", "{8990E2BF-92DB-43B1-AFFE-9EAD609FCCE4}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "AssemblyResolveProblem", "tests\service\data\AssemblyResolveProblem\AssemblyResolveProblem.fsproj", "{7114EB5B-C1E0-476A-B384-25BB209DF8AE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -189,6 +193,42 @@ Global
{887630A3-4B1D-40EA-B8B3-2D842E9C40DB}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{887630A3-4B1D-40EA-B8B3-2D842E9C40DB}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{887630A3-4B1D-40EA-B8B3-2D842E9C40DB}.Release|x86.ActiveCfg = Release|Any CPU
{8990E2BF-92DB-43B1-AFFE-9EAD609FCCE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8990E2BF-92DB-43B1-AFFE-9EAD609FCCE4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8990E2BF-92DB-43B1-AFFE-9EAD609FCCE4}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{8990E2BF-92DB-43B1-AFFE-9EAD609FCCE4}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{8990E2BF-92DB-43B1-AFFE-9EAD609FCCE4}.Debug|x86.ActiveCfg = Debug|Any CPU
{8990E2BF-92DB-43B1-AFFE-9EAD609FCCE4}.Debug|x86.Build.0 = Debug|Any CPU
{8990E2BF-92DB-43B1-AFFE-9EAD609FCCE4}.Proto|Any CPU.ActiveCfg = Release|Any CPU
{8990E2BF-92DB-43B1-AFFE-9EAD609FCCE4}.Proto|Any CPU.Build.0 = Release|Any CPU
{8990E2BF-92DB-43B1-AFFE-9EAD609FCCE4}.Proto|Mixed Platforms.ActiveCfg = Release|Any CPU
{8990E2BF-92DB-43B1-AFFE-9EAD609FCCE4}.Proto|Mixed Platforms.Build.0 = Release|Any CPU
{8990E2BF-92DB-43B1-AFFE-9EAD609FCCE4}.Proto|x86.ActiveCfg = Release|Any CPU
{8990E2BF-92DB-43B1-AFFE-9EAD609FCCE4}.Proto|x86.Build.0 = Release|Any CPU
{8990E2BF-92DB-43B1-AFFE-9EAD609FCCE4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8990E2BF-92DB-43B1-AFFE-9EAD609FCCE4}.Release|Any CPU.Build.0 = Release|Any CPU
{8990E2BF-92DB-43B1-AFFE-9EAD609FCCE4}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{8990E2BF-92DB-43B1-AFFE-9EAD609FCCE4}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{8990E2BF-92DB-43B1-AFFE-9EAD609FCCE4}.Release|x86.ActiveCfg = Release|Any CPU
{8990E2BF-92DB-43B1-AFFE-9EAD609FCCE4}.Release|x86.Build.0 = Release|Any CPU
{7114EB5B-C1E0-476A-B384-25BB209DF8AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7114EB5B-C1E0-476A-B384-25BB209DF8AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7114EB5B-C1E0-476A-B384-25BB209DF8AE}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{7114EB5B-C1E0-476A-B384-25BB209DF8AE}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{7114EB5B-C1E0-476A-B384-25BB209DF8AE}.Debug|x86.ActiveCfg = Debug|Any CPU
{7114EB5B-C1E0-476A-B384-25BB209DF8AE}.Debug|x86.Build.0 = Debug|Any CPU
{7114EB5B-C1E0-476A-B384-25BB209DF8AE}.Proto|Any CPU.ActiveCfg = Release|Any CPU
{7114EB5B-C1E0-476A-B384-25BB209DF8AE}.Proto|Any CPU.Build.0 = Release|Any CPU
{7114EB5B-C1E0-476A-B384-25BB209DF8AE}.Proto|Mixed Platforms.ActiveCfg = Release|Any CPU
{7114EB5B-C1E0-476A-B384-25BB209DF8AE}.Proto|Mixed Platforms.Build.0 = Release|Any CPU
{7114EB5B-C1E0-476A-B384-25BB209DF8AE}.Proto|x86.ActiveCfg = Release|Any CPU
{7114EB5B-C1E0-476A-B384-25BB209DF8AE}.Proto|x86.Build.0 = Release|Any CPU
{7114EB5B-C1E0-476A-B384-25BB209DF8AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7114EB5B-C1E0-476A-B384-25BB209DF8AE}.Release|Any CPU.Build.0 = Release|Any CPU
{7114EB5B-C1E0-476A-B384-25BB209DF8AE}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{7114EB5B-C1E0-476A-B384-25BB209DF8AE}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{7114EB5B-C1E0-476A-B384-25BB209DF8AE}.Release|x86.ActiveCfg = Release|Any CPU
{7114EB5B-C1E0-476A-B384-25BB209DF8AE}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
6 changes: 6 additions & 0 deletions RunAssemblyResolveProblem/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
41 changes: 41 additions & 0 deletions RunAssemblyResolveProblem/AssemblyInfo.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
namespace RunAssemblyResolveProblem.AssemblyInfo

open System.Reflection
open System.Runtime.CompilerServices
open System.Runtime.InteropServices

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[<assembly: AssemblyTitle("RunAssemblyResolveProblem")>]
[<assembly: AssemblyDescription("")>]
[<assembly: AssemblyConfiguration("")>]
[<assembly: AssemblyCompany("")>]
[<assembly: AssemblyProduct("RunAssemblyResolveProblem")>]
[<assembly: AssemblyCopyright("Copyright © 2015")>]
[<assembly: AssemblyTrademark("")>]
[<assembly: AssemblyCulture("")>]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[<assembly: ComVisible(false)>]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[<assembly: Guid("8990e2bf-92db-43b1-affe-9ead609fcce4")>]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [<assembly: AssemblyVersion("1.0.*")>]
[<assembly: AssemblyVersion("1.0.0.0")>]
[<assembly: AssemblyFileVersion("1.0.0.0")>]

do
()
125 changes: 125 additions & 0 deletions RunAssemblyResolveProblem/Program.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
module RunAssemblyResolveProblem.Test

open System
open System.IO
open Microsoft.FSharp.Compiler
open Microsoft.FSharp.Compiler.Interactive.Shell
open Microsoft.FSharp.Compiler.SourceCodeServices

// Intialize output and input streams
let inStream = new StringReader("")
let outStream = new CompilerOutputStream()
let errStream = new CompilerOutputStream()

// Build command line arguments & start FSI session

open System
open System.Reflection
let sysLib nm =
if System.Environment.OSVersion.Platform = System.PlatformID.Win32NT then // file references only valid on Windows
@"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\" + nm + ".dll"
else
let sysDir = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()
let (++) a b = System.IO.Path.Combine(a,b)
sysDir ++ nm + ".dll"

let run () =
printfn "Creating Checker..."
let checker = FSharpChecker.Create()
let base1 = Path.GetTempFileName()
let dllName = Path.ChangeExtension(base1, ".dll")
let xmlName = Path.ChangeExtension(base1, ".xml")
let fileName1 = Path.ChangeExtension(base1, ".fs")
let projFileName = Path.ChangeExtension(base1, ".fsproj")
File.WriteAllText(fileName1, "module M")
let checkerArgs =
[| "--simpleresolution"
"--noframework"
"--debug:full"
"--define:DEBUG"
"--optimize-"
fileName1
"-r:" + sysLib "mscorlib"
"-r:" + sysLib "System"
"-r:" + sysLib "System.Core"
"-r:" + Path.GetFullPath "TEST_BUG/FSharp.Core.dll"
"-r:" + Path.GetFullPath "TEST_BUG/AssemblyResolveProblem.dll"
"-r:" + Path.GetFullPath "TEST_BUG/FSharp.Configuration.dll"
"-r:" + Path.GetFullPath "TEST_BUG/unresolved/SharpYaml.dll"
"--out:" + dllName
"--doc:" + xmlName
"--warn:3"
"--fullpaths"
"--flaterrors"
"--target:library" |]

printfn "Get results... %A" checkerArgs
let options = checker.GetProjectOptionsFromCommandLineArgs(projFileName, checkerArgs)
printfn "Get ParseAndCheckProject..."
let results = checker.ParseAndCheckProject(options) |> Async.RunSynchronously

let mapError (err:FSharpErrorInfo) =
sprintf "**** %s: %s" (if err.Severity = Microsoft.FSharp.Compiler.FSharpErrorSeverity.Error then "error" else "warning") err.Message
if results.HasCriticalErrors then
let errors = results.Errors |> Seq.map mapError
let errorMsg = sprintf "Parsing and checking project failed: \n\t%s" (System.String.Join("\n\t", errors))
failwith errorMsg
else
if results.Errors.Length > 0 then
let warnings = results.Errors |> Seq.map mapError
printfn "Parsing and checking warnings: \n\t%s" (System.String.Join("\n\t", warnings))

printfn "Get referenceMap..."
let referenceMap =
results.ProjectContext.GetReferencedAssemblies()
|> Seq.choose (fun (r:FSharpAssembly) -> r.FileName |> Option.map (fun f -> f, r))
|> dict

printfn "Get map..."
let map =
["AssemblyResolveProblem.dll"] |> Seq.map (fun file -> file, if referenceMap.ContainsKey file then Some referenceMap.[file] else None)
map


[<EntryPoint>]
let main argv =
let fscore =
if System.Environment.OSVersion.Platform = System.PlatformID.Win32NT then // file references only valid on Windows
@"C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp\.NETFramework\v4.0\4.4.0.0\FSharp.Core.dll"
else
typeof<_ option>.Assembly.Location

let yamlPath = "unresolved/SharpYaml.dll"
let files =
[| fscore, "FSharp.Core.dll"
Path.ChangeExtension (fscore, "optdata"), "FSharp.Core.optdata"
Path.ChangeExtension (fscore, "sigdata"), "FSharp.Core.sigdata"
"bin/v4.5/AssemblyResolveProblem.dll", "AssemblyResolveProblem.dll"
"bin/v4.5/SharpYaml.dll", yamlPath
"bin/v4.5/FSharp.Configuration.dll", "FSharp.Configuration.dll"
|]
let destDir = "TEST_BUG"
for sourceFile, destFile in files do
let destPath = Path.Combine(destDir, destFile)
let destDir = Path.GetDirectoryName(destPath)
if not (Directory.Exists destDir) then
Directory.CreateDirectory destDir |> ignore
if not (File.Exists destPath) then
File.Copy(sourceFile, destPath)

//System.Environment.CurrentDirectory <- Path.GetFullPath(destDir)

let fsiConfig = FsiEvaluationSession.GetDefaultConfiguration()
let argv = [| "C:\\fsi.exe" |]
let allArgs =
Array.append argv
[| "--noninteractive"; "--noframework"; "-r:" + Path.GetFullPath "TEST_BUG/FSharp.Core.dll" |]
printfn "Start Session... "
let fsiSession = FsiEvaluationSession.Create(fsiConfig, allArgs, inStream, new StreamWriter(outStream), new StreamWriter(errStream))

printfn "Start EvalInteraction... "
try
fsiSession.EvalScript (Path.GetFullPath "RunAssemblyResolveProblem.fsx")
finally
printfn "Output: %s, Error: %s" (outStream.Read()) (errStream.Read())
0 // return an integer exit code
89 changes: 89 additions & 0 deletions RunAssemblyResolveProblem/RunAssemblyResolveProblem.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>8990e2bf-92db-43b1-affe-9ead609fcce4</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>RunAssemblyResolveProblem</RootNamespace>
<AssemblyName>RunAssemblyResolveProblem</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFSharpCoreVersion>4.4.0.0</TargetFSharpCoreVersion>
<Name>RunAssemblyResolveProblem</Name>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<Tailcalls>false</Tailcalls>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<PlatformTarget>AnyCPU</PlatformTarget>
<DocumentationFile>bin\Debug\RunAssemblyResolveProblem.XML</DocumentationFile>
<Prefer32Bit>true</Prefer32Bit>
<StartWorkingDirectory>C:\Users\dragon\Documents\Projects\FSharp.Compiler.Service\</StartWorkingDirectory>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<Tailcalls>true</Tailcalls>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<WarningLevel>3</WarningLevel>
<PlatformTarget>AnyCPU</PlatformTarget>
<DocumentationFile>bin\Release\RunAssemblyResolveProblem.XML</DocumentationFile>
<Prefer32Bit>true</Prefer32Bit>
<StartWorkingDirectory>C:\Users\dragon\Documents\Projects\FSharp.Compiler.Service\</StartWorkingDirectory>
</PropertyGroup>
<ItemGroup>
<Reference Include="mscorlib" />
<Reference Include="FSharp.Core, Version=$(TargetFSharpCoreVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.fs" />
<Compile Include="Program.fs" />
<None Include="App.config" />
<None Include="RunAssemblyResolveProblem.fsx">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\src\fsharp\FSharp.Compiler.Service\FSharp.Compiler.Service.fsproj">
<Name>FSharp.Compiler.Service</Name>
<Project>{2e4d67b4-522d-4cf7-97e4-ba940f0b18f3}</Project>
<Private>True</Private>
</ProjectReference>
</ItemGroup>
<PropertyGroup>
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>
</PropertyGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '11.0'">
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')">
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets')">
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath>
</PropertyGroup>
</Otherwise>
</Choose>
<Import Project="$(FSharpTargetsPath)" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
22 changes: 22 additions & 0 deletions RunAssemblyResolveProblem/RunAssemblyResolveProblem.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

open System
open System.IO
open System.Reflection

printfn "Adding Handler..."
AppDomain.CurrentDomain.add_AssemblyResolve(
new ResolveEventHandler(fun _ e ->
printfn "resolving %s" e.Name
if e.Name.StartsWith "SharpYaml" then
Assembly.LoadFrom(Path.GetFullPath "TEST_BUG/unresolved/SharpYaml.dll")
elif e.Name.StartsWith "FSharp.Core" then
Assembly.LoadFrom(Path.GetFullPath "TEST_BUG/FSharp.Core.dll")
else null))

#r @"FSharp.Compiler.Service.dll"
#r @"RunAssemblyResolveProblem.exe"

try
let map = RunAssemblyResolveProblem.Test.run()
ignore map
with e -> printfn "Error: %O" e
3 changes: 3 additions & 0 deletions paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ nuget FAKE
nuget FSharp.Formatting
nuget SourceLink.Fake

# tests
nuget FSharp.Configuration

github fsharp/FAKE modules/Octokit/Octokit.fsx
Loading

0 comments on commit 548894a

Please sign in to comment.