.NET Core / Nancy 2 migration in progress

Only 55 build errors to go! :/  What remains is things that do not exist
in .NET Core yet, or API changes (specifically with Nancy and NodaTime).
This commit is contained in:
Daniel J. Summers
2016-08-22 22:39:49 -05:00
parent 710004dfc4
commit 1c3e84f5ec
41 changed files with 679 additions and 1896 deletions

View File

@@ -1,9 +1,7 @@
module MyWebLog.Data.RethinkDB.Category
open FSharp.Interop.Dynamic
open MyWebLog.Entities
open RethinkDb.Driver.Ast
open System.Dynamic
let private r = RethinkDb.Driver.RethinkDB.R
@@ -35,27 +33,36 @@ let addCategory conn (cat : Category) =
.Insert(cat)
.RunResultAsync(conn) |> await |> ignore
type CategoryUpdateRecord =
{ Name : string
Slug : string
Description : string option
ParentId : string option
}
/// Update a category
let updateCategory conn (cat : Category) =
let upd8 = ExpandoObject()
upd8?Name <- cat.Name
upd8?Slug <- cat.Slug
upd8?Description <- cat.Description
upd8?ParentId <- cat.ParentId
(category cat.WebLogId cat.Id)
.Update(upd8)
.Update({ CategoryUpdateRecord.Name = cat.Name
Slug = cat.Slug
Description = cat.Description
ParentId = cat.ParentId })
.RunResultAsync(conn) |> await |> ignore
type CategoryChildrenUpdateRecord =
{ Children : string list }
/// Update a category's children
let updateChildren conn webLogId parentId (children : string list) =
let upd8 = ExpandoObject()
upd8?Children <- children
(category webLogId parentId)
.Update(upd8)
.Update({ CategoryChildrenUpdateRecord.Children = children })
.RunResultAsync(conn) |> await |> ignore
type CategoryParentUpdateRecord =
{ ParentId : string option }
type PostCategoriesUpdateRecord =
{ CategoryIds : string list }
/// Delete a category
let deleteCategory conn cat =
let deleteCategory conn (cat : Category) =
// Remove the category from its parent
match cat.ParentId with
| Some parentId -> match tryFindCategory conn cat.WebLogId parentId with
@@ -65,8 +72,7 @@ let deleteCategory conn cat =
| _ -> ()
| _ -> ()
// Move this category's children to its parent
let newParent = ExpandoObject()
newParent?ParentId <- cat.ParentId
let newParent = { CategoryParentUpdateRecord.ParentId = cat.ParentId }
cat.Children
|> List.iter (fun childId -> (category cat.WebLogId childId)
.Update(newParent)
@@ -78,9 +84,9 @@ let deleteCategory conn cat =
.RunCursorAsync<Post>(conn)
|> await
|> Seq.toList
|> List.iter (fun post -> let newCats = ExpandoObject()
newCats?CategoryIds <- post.CategoryIds
|> List.filter (fun c -> c <> cat.Id)
|> List.iter (fun post -> let newCats =
{ PostCategoriesUpdateRecord.CategoryIds = post.CategoryIds
|> List.filter (fun c -> c <> cat.Id) }
r.Table(Table.Post)
.Get(post.Id)
.Update(newCats)

View File

@@ -1,161 +0,0 @@
<?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>d6c2be5e-883a-4f34-9905-b730543ca380</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>MyWebLog.Data.RethinkDB</RootNamespace>
<AssemblyName>MyWebLog.Data.RethinkDB</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<TargetFSharpCoreVersion>4.4.0.0</TargetFSharpCoreVersion>
<Name>MyWebLog.Data.RethinkDB</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>
<DocumentationFile>bin\Debug\MyWebLog.Data.RethinkDB.xml</DocumentationFile>
</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>
<DocumentationFile>bin\Release\MyWebLog.Data.RethinkDB.xml</DocumentationFile>
</PropertyGroup>
<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" />
</ItemGroup>
<ItemGroup>
<Compile Include="Extensions.fs" />
<Compile Include="Table.fs" />
<Compile Include="DataConfig.fs" />
<Compile Include="Category.fs" />
<Compile Include="Page.fs" />
<Compile Include="Post.fs" />
<Compile Include="User.fs" />
<Compile Include="WebLog.fs" />
<Compile Include="SetUp.fs" />
<Compile Include="RethinkMyWebLogData.fs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MyWebLog.Entities\MyWebLog.Entities.fsproj">
<Name>MyWebLog.Entities</Name>
<Project>{a87f3cf5-2189-442b-8acf-929f5153ac22}</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)" Condition="Exists('$(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>
-->
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.0' Or $(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.2')">
<ItemGroup>
<Reference Include="Common.Logging">
<HintPath>..\packages\Common.Logging\lib\net40\Common.Logging.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.0' Or $(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.2')">
<ItemGroup>
<Reference Include="Common.Logging.Core">
<HintPath>..\packages\Common.Logging.Core\lib\net40\Common.Logging.Core.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.0' Or $(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.2')">
<ItemGroup>
<Reference Include="Dynamitey">
<HintPath>..\packages\Dynamitey\lib\net40\Dynamitey.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.2')">
<ItemGroup>
<Reference Include="FSharp.Interop.Dynamic">
<HintPath>..\packages\FSharp.Interop.Dynamic\lib\portable-net45+sl50+win\FSharp.Interop.Dynamic.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.0'">
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json\lib\net40\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.2')">
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And ($(TargetFrameworkVersion) == 'v4.5' Or $(TargetFrameworkVersion) == 'v4.5.2')">
<ItemGroup>
<Reference Include="RethinkDb.Driver">
<HintPath>..\packages\RethinkDb.Driver\lib\net45\RethinkDb.Driver.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
</Project>

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>d6c2be5e-883a-4f34-9905-b730543ca380</ProjectGuid>
<RootNamespace>MyWebLog.Data.RethinkDB</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

View File

@@ -1,9 +1,7 @@
module MyWebLog.Data.RethinkDB.Page
open FSharp.Interop.Dynamic
open MyWebLog.Entities
open RethinkDb.Driver.Ast
open System.Dynamic
let private r = RethinkDb.Driver.RethinkDB.R
@@ -11,13 +9,13 @@ let private r = RethinkDb.Driver.RethinkDB.R
let tryFindPageById conn webLogId (pageId : string) includeRevs =
let pg = r.Table(Table.Page)
.Get(pageId)
match (match includeRevs with
| true -> pg.RunAtomAsync<Page>(conn)
| _ -> pg.Without("Revisions").RunAtomAsync<Page>(conn)
|> await |> box) with
| null -> None
| page -> let pg : Page = unbox page
match pg.WebLogId = webLogId with true -> Some pg | _ -> None
match includeRevs with true -> pg.RunAtomAsync<Page>(conn) | _ -> pg.Without("Revisions").RunAtomAsync<Page>(conn)
|> await
|> box
|> function
| null -> None
| page -> let pg : Page = unbox page
match pg.WebLogId = webLogId with true -> Some pg | _ -> None
/// Find a page by its permalink
let tryFindPageByPermalink conn (webLogId : string) (permalink : string) =
@@ -44,19 +42,24 @@ let addPage conn (page : Page) =
.Insert(page)
.RunResultAsync(conn) |> await |> ignore
type PageUpdateRecord =
{ Title : string
Permalink : string
PublishedOn : int64
UpdatedOn : int64
Text : string
Revisions : Revision list }
/// Update a page
let updatePage conn (page : Page) =
match tryFindPageById conn page.WebLogId page.Id false with
| Some _ -> let upd8 = ExpandoObject()
upd8?Title <- page.Title
upd8?Permalink <- page.Permalink
upd8?PublishedOn <- page.PublishedOn
upd8?UpdatedOn <- page.UpdatedOn
upd8?Text <- page.Text
upd8?Revisions <- page.Revisions
r.Table(Table.Page)
| Some _ -> r.Table(Table.Page)
.Get(page.Id)
.Update(upd8)
.Update({ PageUpdateRecord.Title = page.Title
Permalink = page.Permalink
PublishedOn = page.PublishedOn
UpdatedOn = page.UpdatedOn
Text = page.Text
Revisions = page.Revisions })
.RunResultAsync(conn) |> await |> ignore
| _ -> ()

View File

@@ -1,9 +1,7 @@
module MyWebLog.Data.RethinkDB.Post
open FSharp.Interop.Dynamic
open MyWebLog.Entities
open RethinkDb.Driver.Ast
open System.Dynamic
let private r = RethinkDb.Driver.RethinkDB.R

View File

@@ -1,2 +0,0 @@
FSharp.Interop.Dynamic
RethinkDb.Driver

View File

@@ -0,0 +1,37 @@
{
"buildOptions": {
"compilerName": "fsc",
"compile": {
"includeFiles": [
"AssemblyInfo.fs",
"Extensions.fs",
"Table.fs",
"DataConfig.fs",
"Category.fs",
"Page.fs",
"Post.fs",
"User.fs",
"WebLog.fs",
"SetUp.fs",
"RethinkMyWebLogData.fs"
]
}
},
"dependencies": {
"MyWebLog.Entities": "0.9.2",
"RethinkDb.Driver": "2.3.12"
},
"frameworks": {
"netstandard1.6": {
"imports": "dnxcore50",
"dependencies": {
"Microsoft.FSharp.Core.netcore": "1.0.0-alpha-160629",
"NETStandard.Library": "1.6.0"
}
}
},
"tools": {
"dotnet-compile-fsc": "1.0.0-preview2-*"
},
"version": "0.9.2"
}