-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
214 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="NUnit.Runners" version="2.6.3" /> | ||
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
module FSharp.ProjectTemplate.ConfigDSL | ||
|
||
open System | ||
open System.IO | ||
open System.Collections.Generic | ||
open Microsoft.FSharp.Compiler.Interactive.Shell | ||
|
||
let initialCode = """ | ||
let config = new System.Collections.Generic.Dictionary<string,string>() | ||
let source x = () // Todo | ||
let nuget x y = config.Add(x,y) | ||
""" | ||
|
||
let runConfig fileName = | ||
let fsiConfig = FsiEvaluationSession.GetDefaultConfiguration() | ||
|
||
let commonOptions = [| "fsi.exe"; "--noninteractive" |] | ||
|
||
let sbOut = new Text.StringBuilder() | ||
let sbErr = new Text.StringBuilder() // TODO: evtl. irgendwo ausgeben | ||
let outStream = new StringWriter(sbOut) | ||
let errStream = new StringWriter(sbErr) | ||
|
||
let stdin = new StreamReader(Stream.Null) | ||
|
||
try | ||
let session = FsiEvaluationSession.Create(fsiConfig, commonOptions, stdin, outStream, errStream) | ||
|
||
try | ||
|
||
session.EvalInteraction initialCode |> ignore | ||
session.EvalScript fileName | ||
match session.EvalExpression "config" with | ||
| Some x -> x.ReflectionValue :?> System.Collections.Generic.Dictionary<string,string> | ||
| _ -> failwithf "Error: %s" <| sbErr.ToString() | ||
with | ||
| _ -> failwithf "Error: %s" <| sbErr.ToString() | ||
|
||
with | ||
| exn -> | ||
printfn "FsiEvaluationSession could not be created." | ||
|
||
raise exn | ||
|
||
// TODO make this correct | ||
let merge (config1:Dictionary<string,string>) (config2:Dictionary<string,string>) = | ||
|
||
let config = Dictionary<string,string>() | ||
for x in config1 do | ||
config.Add(x.Key,x.Value) | ||
|
||
for x in config2 do | ||
config.[x.Key] <- x.Value | ||
|
||
config | ||
|
||
let (==>) c1 c2 = merge c1 c2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="FSharp.Compiler.Service" version="0.0.58" targetFramework="net40" /> | ||
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="12.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>0252f0b5-b106-42f5-aba8-743a1aae8a6e</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<RootNamespace>ManualTest</RootNamespace> | ||
<AssemblyName>ManualTest</AssemblyName> | ||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> | ||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
<TargetFSharpCoreVersion>4.3.1.0</TargetFSharpCoreVersion> | ||
<Name>ManualTest</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\ManualTest.XML</DocumentationFile> | ||
<Prefer32Bit>true</Prefer32Bit> | ||
</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\ManualTest.XML</DocumentationFile> | ||
<Prefer32Bit>true</Prefer32Bit> | ||
</PropertyGroup> | ||
<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)" /> | ||
<ItemGroup> | ||
<Content Include="myConfig.fsx"> | ||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | ||
</Content> | ||
<Compile Include="Program.fs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Reference Include="mscorlib" /> | ||
<Reference Include="FSharp.Core, Version=$(TargetFSharpCoreVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Numerics" /> | ||
<ProjectReference Include="..\..\src\FSharp.ProjectTemplate\FSharp.ProjectTemplate.fsproj"> | ||
<Name>FSharp.ProjectTemplate</Name> | ||
<Project>{7e90d6ce-a10b-4858-a5bc-41df7250cbca}</Project> | ||
<Private>True</Private> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="myConfig2.fsx" /> | ||
</ItemGroup> | ||
<!-- 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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
open FSharp.ProjectTemplate.ConfigDSL | ||
|
||
let completeConfig = | ||
runConfig "myConfig.fsx" | ||
==> runConfig "myConfig2.fsx" | ||
|
||
for x in completeConfig do | ||
printfn "%s => %s" x.Key x.Value | ||
|
||
System.Console.ReadKey() |> ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
source "http://nuget.org/api/v2" | ||
|
||
printfn "hello world from config" | ||
|
||
nuget "Castle.Windsor-log4net" "~> 3.2" | ||
nuget "Rx-Main" "~> 2.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
source "http://nuget.org/api/v2" | ||
|
||
printfn "hello world from config2" | ||
|
||
nuget "FAKE" "~> 3" | ||
nuget "Rx-Main" "~> 3.0" |