Skip to content

Commit 28455cd

Browse files
committed
wip
1 parent 2e948b7 commit 28455cd

File tree

8 files changed

+218
-4
lines changed

8 files changed

+218
-4
lines changed

FSharp.Compiler.Service.sln

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharp_Analysis", "tests\se
5959
EndProject
6060
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Compiler.Service.ProjectCracker", "src\fsharp\FSharp.Compiler.Service.ProjectCracker\FSharp.Compiler.Service.ProjectCracker.fsproj", "{B1BDD96D-47E1-4E65-8107-FBAE23A06DB4}"
6161
EndProject
62+
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Compiler.Service.ProjectCrackerReader", "src\fsharp\FSharp.Compiler.Service.ProjectCrackerReader\FSharp.Compiler.Service.ProjectCrackerReader.fsproj", "{893C3CD9-5AF8-4027-A667-21E62FC2C703}"
63+
EndProject
6264
Global
6365
GlobalSection(SolutionConfigurationPlatforms) = preSolution
6466
Debug|Any CPU = Debug|Any CPU
@@ -207,6 +209,21 @@ Global
207209
{B1BDD96D-47E1-4E65-8107-FBAE23A06DB4}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
208210
{B1BDD96D-47E1-4E65-8107-FBAE23A06DB4}.Release|Mixed Platforms.Build.0 = Release|Any CPU
209211
{B1BDD96D-47E1-4E65-8107-FBAE23A06DB4}.Release|x86.ActiveCfg = Release|Any CPU
212+
{893C3CD9-5AF8-4027-A667-21E62FC2C703}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
213+
{893C3CD9-5AF8-4027-A667-21E62FC2C703}.Debug|Any CPU.Build.0 = Debug|Any CPU
214+
{893C3CD9-5AF8-4027-A667-21E62FC2C703}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
215+
{893C3CD9-5AF8-4027-A667-21E62FC2C703}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
216+
{893C3CD9-5AF8-4027-A667-21E62FC2C703}.Debug|x86.ActiveCfg = Debug|Any CPU
217+
{893C3CD9-5AF8-4027-A667-21E62FC2C703}.Proto|Any CPU.ActiveCfg = Release|Any CPU
218+
{893C3CD9-5AF8-4027-A667-21E62FC2C703}.Proto|Any CPU.Build.0 = Release|Any CPU
219+
{893C3CD9-5AF8-4027-A667-21E62FC2C703}.Proto|Mixed Platforms.ActiveCfg = Release|Any CPU
220+
{893C3CD9-5AF8-4027-A667-21E62FC2C703}.Proto|Mixed Platforms.Build.0 = Release|Any CPU
221+
{893C3CD9-5AF8-4027-A667-21E62FC2C703}.Proto|x86.ActiveCfg = Release|Any CPU
222+
{893C3CD9-5AF8-4027-A667-21E62FC2C703}.Release|Any CPU.ActiveCfg = Release|Any CPU
223+
{893C3CD9-5AF8-4027-A667-21E62FC2C703}.Release|Any CPU.Build.0 = Release|Any CPU
224+
{893C3CD9-5AF8-4027-A667-21E62FC2C703}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
225+
{893C3CD9-5AF8-4027-A667-21E62FC2C703}.Release|Mixed Platforms.Build.0 = Release|Any CPU
226+
{893C3CD9-5AF8-4027-A667-21E62FC2C703}.Release|x86.ActiveCfg = Release|Any CPU
210227
EndGlobalSection
211228
GlobalSection(SolutionProperties) = preSolution
212229
HideSolutionNode = FALSE

build.fsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ Target "NuGet" (fun _ ->
141141
Version = release.NugetVersion
142142
OutputPath = buildDir
143143
ReleaseNotes = toLines release.Notes })
144+
Paket.Pack (fun p ->
145+
{ p with
146+
TemplateFile = "nuget/projectcracker.template"
147+
Version = release.NugetVersion
148+
OutputPath = buildDir
149+
ReleaseNotes = toLines release.Notes }
144150
)
145151

146152

nuget/projectcracker.template

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
type file
2+
id FSharp.Compiler.Service.ProjectCracker
3+
description
4+
Adds cracking capabilities.
5+
authors
6+
Microsoft Corporation, Robin Neatherway
7+
summary
8+
Cracking projects
9+
licenseurl https://github.com/fsharp/FSharp.Compiler.Service/blob/master/LICENSE
10+
projecturl https://github.com/fsharp/FSharp.Compiler.Service
11+
iconurl https://raw.github.com/fsharp/FSharp.Compiler.Service/master/misc/logo.png
12+
tags
13+
F#, fsharp, msbuild, editor
14+
files
15+
../bin/v4.5/FSharp.Compiler.Service.ProjectCrackerSub.exe ==> lib/net45
16+
../bin/v4.5/FSharp.Compiler.Service.ProjectCrackerSub.?db ==> lib/net45
17+
../bin/v4.5/FSharp.Compiler.Service.ProjectCrackerSub.dll.?db ==> lib/net45
18+
../bin/v4.5/FSharp.Compiler.Service.ProjectCracker.dll ==> lib/net45
19+
../bin/v4.5/FSharp.Compiler.Service.ProjectCracker.XML ==> lib/net45
20+
../bin/v4.5/FSharp.Compiler.Service.ProjectCracker.?db ==> lib/net45
21+
../bin/v4.5/FSharp.Compiler.Service.ProjectCracker.dll.?db ==> lib/net45

src/fsharp/FSharp.Compiler.Service.ProjectCracker/FSharp.Compiler.Service.ProjectCracker.fsproj

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
<Name>FSharp.Compiler.Service.ProjectCracker</Name>
1616
<OtherFlags>$(OtherFlags) --staticlink:FSharp.Core</OtherFlags>
1717
<NoWarn>$(NoWarn);40</NoWarn>
18+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
19+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
20+
<TargetFSharpCoreVersion>4.3.1.0</TargetFSharpCoreVersion>
21+
<Name>FSharp.Compiler.Service.ProjectCracker</Name>
1822
</PropertyGroup>
1923
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2024
<DebugSymbols>true</DebugSymbols>
@@ -58,6 +62,14 @@
5862
<Reference Include="FSharp.Core, Version=$(TargetFSharpCoreVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
5963
<Private>False</Private>
6064
</Reference>
65+
<Reference Include="Microsoft.Build" />
66+
<Reference Include="Microsoft.Build.Engine" />
67+
<Reference Include="Microsoft.Build.Framework" />
68+
<Reference Include="Microsoft.Build.Utilities.v4.0" />
69+
<Reference Include="mscorlib" />
70+
<Reference Include="FSharp.Core, Version=$(TargetFSharpCoreVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
71+
<Private>True</Private>
72+
</Reference>
6173
<Reference Include="System" />
6274
<Reference Include="System.Core" />
6375
<Reference Include="System.Numerics" />
@@ -66,6 +78,9 @@
6678
</ItemGroup>
6779
<ItemGroup>
6880
<Compile Include="ProjectCrackerOptions.fs" />
81+
<Reference Include="System.Xml" />
82+
</ItemGroup>
83+
<ItemGroup>
6984
<Compile Include="Program.fs" />
7085
<None Include="App.config" />
7186
</ItemGroup>

src/fsharp/FSharp.Compiler.Service.ProjectCracker/Program.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ open System.IO
77
open System
88
open System.Reflection
99
open System.Runtime.Serialization.Formatters.Binary
10-
open System.Runtime.Serialization.Json
1110

1211
module Program =
1312
let runningOnMono =
@@ -356,7 +355,6 @@ module Program =
356355
member x.LogOutput = logOutput
357356
static member Parse(fsprojFileName:string, ?properties, ?enableLogging) = new FSharpProjectFileInfo(fsprojFileName, ?properties=properties, ?enableLogging=enableLogging)
358357

359-
360358
let getOptions file enableLogging properties =
361359
let rec getOptions file : Option<string> * ProjectOptions =
362360
let parsedProject = FSharpProjectFileInfo.Parse(file, properties=properties, enableLogging=enableLogging)
@@ -371,6 +369,7 @@ module Program =
371369
Options = Array.ofList parsedProject.Options
372370
ReferencedProjectOptions = referencedProjectOptions
373371
LogOutput = parsedProject.LogOutput }
372+
374373
parsedProject.OutputFile, options
375374

376375
snd (getOptions file)
@@ -409,6 +408,7 @@ module Program =
409408
with e ->
410409
2, { ProjectFile = ""; Options = [||]; ReferencedProjectOptions = [||]; LogOutput = e.ToString() }
411410

412-
let ser = new DataContractJsonSerializer(typeof<ProjectOptions>)
413-
ser.WriteObject(Console.OpenStandardOutput(), opts)
411+
let fmt = new BinaryFormatter()
412+
use out = new StreamWriter(System.Console.OpenStandardOutput())
413+
fmt.Serialize(out.BaseStream, opts)
414414
ret
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
5+
</startup>
6+
<runtime>
7+
8+
9+
10+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
11+
<dependentAssembly>
12+
<assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
13+
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
14+
</dependentAssembly>
15+
<dependentAssembly>
16+
<assemblyIdentity name="Microsoft.Build.Engine" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
17+
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
18+
</dependentAssembly>
19+
</assemblyBinding>
20+
</runtime>
21+
</configuration>
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>893c3cd9-5af8-4027-a667-21e62fc2c703</ProjectGuid>
9+
<OutputType>Library</OutputType>
10+
<RootNamespace>FSharp.Compiler.Service.ProjectCrackerReader</RootNamespace>
11+
<AssemblyName>FSharp.Compiler.Service.ProjectCrackerReader</AssemblyName>
12+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14+
<TargetFSharpCoreVersion>4.3.1.0</TargetFSharpCoreVersion>
15+
<Name>FSharp.Compiler.Service.ProjectCrackerReader</Name>
16+
</PropertyGroup>
17+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<Tailcalls>false</Tailcalls>
22+
<OutputPath>bin\Debug\</OutputPath>
23+
<DefineConstants>DEBUG;TRACE</DefineConstants>
24+
<WarningLevel>3</WarningLevel>
25+
<PlatformTarget>AnyCPU</PlatformTarget>
26+
<DocumentationFile>bin\Debug\FSharp.Compiler.Service.ProjectCrackerReader.XML</DocumentationFile>
27+
<Prefer32Bit>true</Prefer32Bit>
28+
</PropertyGroup>
29+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
30+
<DebugType>pdbonly</DebugType>
31+
<Optimize>true</Optimize>
32+
<Tailcalls>true</Tailcalls>
33+
<OutputPath>bin\Release\</OutputPath>
34+
<DefineConstants>TRACE</DefineConstants>
35+
<WarningLevel>3</WarningLevel>
36+
<PlatformTarget>AnyCPU</PlatformTarget>
37+
<DocumentationFile>bin\Release\FSharp.Compiler.Service.ProjectCrackerReader.XML</DocumentationFile>
38+
<Prefer32Bit>true</Prefer32Bit>
39+
</PropertyGroup>
40+
<ItemGroup>
41+
<Reference Include="mscorlib" />
42+
<Reference Include="FSharp.Core, Version=$(TargetFSharpCoreVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
43+
<Private>True</Private>
44+
</Reference>
45+
<Reference Include="System" />
46+
<Reference Include="System.Core" />
47+
<Reference Include="System.Numerics" />
48+
</ItemGroup>
49+
<ItemGroup>
50+
<Compile Include="Program.fs" />
51+
<None Include="App.config" />
52+
</ItemGroup>
53+
<ItemGroup>
54+
<ProjectReference Include="..\FSharp.Compiler.Service.ProjectCracker\FSharp.Compiler.Service.ProjectCracker.fsproj">
55+
<Name>FSharp.Compiler.Service.ProjectCracker</Name>
56+
<Project>{b1bdd96d-47e1-4e65-8107-fbae23a06db4}</Project>
57+
<Private>True</Private>
58+
</ProjectReference>
59+
</ItemGroup>
60+
<PropertyGroup>
61+
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>
62+
</PropertyGroup>
63+
<Choose>
64+
<When Condition="'$(VisualStudioVersion)' == '11.0'">
65+
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')">
66+
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath>
67+
</PropertyGroup>
68+
</When>
69+
<Otherwise>
70+
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets')">
71+
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath>
72+
</PropertyGroup>
73+
</Otherwise>
74+
</Choose>
75+
<Import Project="$(FSharpTargetsPath)" />
76+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
77+
Other similar extension points exist, see Microsoft.Common.targets.
78+
<Target Name="BeforeBuild">
79+
</Target>
80+
<Target Name="AfterBuild">
81+
</Target>
82+
-->
83+
</Project>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
namespace FSharp.Compiler.Service
2+
3+
open System.Diagnostics
4+
open System.Text
5+
open System.IO
6+
open System
7+
open System.Runtime.Serialization.Formatters.Binary
8+
9+
open FSharp.Compiler.Service.ProjectCracker
10+
11+
type ProjectCrackerReader =
12+
13+
static member GetProjectOptionsFromProjectFileLogged(projectFileName : string, ?properties : (string * string) list, ?loadedTimeStamp, ?enableLogging) =
14+
let loadedTimeStamp = defaultArg loadedTimeStamp DateTime.MaxValue // Not 'now', we don't want to force reloading
15+
let properties = defaultArg properties []
16+
let enableLogging = defaultArg enableLogging false
17+
18+
let rec convert (opts: FSharp.Compiler.Service.ProjectCracker.ProjectOptions) : FSharpProjectOptions =
19+
let referencedProjects = Array.map (fun (a, b) -> a, convert b) opts.ReferencedProjectOptions
20+
{ ProjectFileName = opts.ProjectFile
21+
ProjectFileNames = [| |]
22+
OtherOptions = opts.Options
23+
ReferencedProjects = referencedProjects
24+
IsIncompleteTypeCheckEnvironment = false
25+
UseScriptResolutionRules = false
26+
LoadTime = loadedTimeStamp
27+
UnresolvedReferences = None }
28+
29+
let arguments = new StringBuilder()
30+
arguments.Append(projectFileName) |> ignore
31+
arguments.Append(' ').Append(enableLogging.ToString()) |> ignore
32+
for k, v in properties do
33+
arguments.Append(' ').Append(k).Append(' ').Append(v) |> ignore
34+
35+
let p = new System.Diagnostics.Process()
36+
p.StartInfo.FileName <- Path.Combine(Path.GetDirectoryName(Reflection.Assembly.GetExecutingAssembly().Location),
37+
"FSharp.Compiler.Service.ProjectCracker.exe")
38+
p.StartInfo.Arguments <- arguments.ToString()
39+
p.StartInfo.UseShellExecute <- false
40+
p.StartInfo.CreateNoWindow <- true
41+
p.StartInfo.RedirectStandardOutput <- true
42+
ignore <| p.Start()
43+
44+
let ser = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof<FSharp.Compiler.Service.ProjectCracker.ProjectOptions>)
45+
let opts = ser.ReadObject(p.StandardOutput.BaseStream) :?> FSharp.Compiler.Service.ProjectCracker.ProjectOptions
46+
p.WaitForExit()
47+
48+
convert opts, opts.LogOutput
49+
50+
let GetProjectOptionsFromProjectFile(projectFileName : string, ?properties : (string * string) list, ?loadedTimeStamp) =
51+
fst (ic.GetProjectOptionsFromProjectFileLogged(projectFileName, ?properties=properties, ?loadedTimeStamp=loadedTimeStamp))

0 commit comments

Comments
 (0)