Skip to content

Commit 089df23

Browse files
WIP
1 parent 9d851b9 commit 089df23

40 files changed

+1910
-1922
lines changed

SqlClient.sln

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.28010.2041
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.30011.22
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".paket", ".paket", "{FD7933BD-2A90-49EB-A4B2-95F9D3076BBD}"
77
ProjectSection(SolutionItems) = preProject
88
paket.dependencies = paket.dependencies
9+
paket.lock = paket.lock
910
EndProjectSection
1011
EndProject
1112
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{7ECDF2A7-A71C-43B5-AFF2-64468098B7B6}"
@@ -17,7 +18,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1718
ProjectSection(SolutionItems) = preProject
1819
build.cmd = build.cmd
1920
build.fsx = build.fsx
21+
fsc.props = fsc.props
2022
LICENSE.md = LICENSE.md
23+
netfx.props = netfx.props
2124
README.md = README.md
2225
RELEASE_NOTES.md = RELEASE_NOTES.md
2326
EndProjectSection

docker-compose.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
version: '3'
2+
services:
3+
4+
fsharpdata-sql:
5+
image: nuitsjp/adventureworks:latest
6+
#image: microsoft/mssql-server-linux:2017-latest
7+
environment:
8+
- SA_PASSWORD=M=qX7kYsg#Z@Ag3mX-tm
9+
- ACCEPT_EULA=Y
10+
- MSSQL_AGENT_ENABLED=true
11+
ports:
12+
- "1434:1433"
13+
# volumes:
14+
# - C:\\data:/sqldb
15+
16+
#Server=tcp:localhost,1434;Initial Catalog=AdventureWorks;User ID=sa;Password=P@ssw0rd!

netfx.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
</PropertyGroup>
4646

4747
<ItemGroup>
48-
<PackageReference Include="System.Data.SqlClient" Version="4.5.1" Condition="'$(TargetFramework)' != 'net40'" />
48+
<!--<PackageReference Include="System.Data.SqlClient" Version="4.5.1" Condition="'$(TargetFramework)' != 'net40'" />-->
4949
<PackageReference Include="Microsoft.Data.SqlClient" Version="1.1.1" Condition="'$(TargetFramework)' != 'net40'" />
5050
</ItemGroup>
5151

paket.dependencies

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ github fsprojects/FSharp.TypeProviders.SDK:28a24a69ada68ebd1ad25226634f4608e4875
77

88
group Build
99
source https://www.nuget.org/api/v2/
10-
framework: >= net451
10+
framework: netstandard20
1111
generate_load_scripts: on
1212

1313
nuget FAKE = 5.8.4
@@ -21,47 +21,32 @@ group Build
2121

2222
group DesignTime
2323
source https://www.nuget.org/api/v2/
24-
framework: >= net461,netstandard20
24+
framework: netcoreapp2.0
2525

26-
nuget System.Configuration.ConfigurationManager
27-
nuget System.Data.Common
28-
nuget Microsoft.Data.SqlClient
29-
nuget System.Runtime.Caching
3026
nuget FSharp.Core
31-
nuget Microsoft.SqlServer.TransactSql.ScriptDom
32-
nuget Microsoft.SqlServer.Types
33-
27+
3428
group Test
3529
source https://www.nuget.org/api/v2/
36-
framework: net461, netcoreapp2.0
30+
framework: netcoreapp2.0
3731

3832
nuget FSharp.Core = 4.5.2
3933
nuget Microsoft.Data.SqlClient
40-
nuget System.Configuration.ConfigurationManager
41-
42-
nuget Microsoft.SqlServer.Types ~> 12
34+
4335
nuget Newtonsoft.Json
4436
nuget xunit = 2.4.1
4537
nuget xunit.runner.visualstudio = 2.4.1
4638

47-
group Net40
48-
source https://www.nuget.org/api/v2/
49-
framework: net40
50-
51-
nuget FSharp.Core = 4.1.18
52-
5339
group TestProjects
5440
source https://www.nuget.org/api/v2/
55-
framework: >= net40, netcoreapp2.0, netstandard2.0
41+
framework: netcoreapp2.0, netstandard2.0
5642

5743
nuget FSharp.Core = 4.3.4
5844

5945
nuget Microsoft.Data.SqlClient
60-
nuget System.Configuration.ConfigurationManager
6146

6247
group Samples
6348
source https://www.nuget.org/api/v2/
64-
framework: >= net40
49+
framework: netcoreapp2.0
6550

6651
nuget FSharp.Core = 4.5.2
6752

paket.lock

Lines changed: 1163 additions & 1770 deletions
Large diffs are not rendered by default.

src/SqlClient.DesignTime/DesignTime.fs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ open System
44
open System.Reflection
55
open System.Data
66
open Microsoft.Data.SqlClient
7-
open Microsoft.SqlServer.Server
7+
open Microsoft.Data.SqlClient.Server
88
open System.Collections.Generic
99
open System.Diagnostics
1010
open Microsoft.FSharp.Quotations
@@ -572,10 +572,8 @@ type DesignTime private() =
572572

573573
rowType.AddMember ctor
574574
rowType.AddXmlDoc "User-Defined Table Type"
575-
576575
rowType
577576

578-
579577
static member internal GetExecuteArgs(cmdProvidedType: ProvidedTypeDefinition, sqlParameters: Parameter list, udttsPerSchema: Dictionary<_, ProvidedTypeDefinition>, ?unitsOfMeasurePerSchema) =
580578
[
581579
for p in sqlParameters do
@@ -593,7 +591,7 @@ type DesignTime private() =
593591
if p.Direction.HasFlag(ParameterDirection.Output)
594592
then
595593
ProvidedParameter(parameterName, parameterType = p.TypeInfo.ClrType.MakeByRefType(), isOut = true)
596-
else
594+
else
597595
ProvidedParameter(parameterName, parameterType = p.GetProvidedType(?unitsOfMeasurePerSchema = unitsOfMeasurePerSchema), ?optionalValue = p.DefaultValue)
598596
else
599597
assert(p.Direction = ParameterDirection.Input)

src/SqlClient.DesignTime/SingleFileChangeMonitor.fs

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,46 @@
22

33
open System
44
open System.IO
5-
open System.Runtime.Caching
5+
//open System.Runtime.Caching
6+
7+
type ChangeMonitor =
8+
inherit IDisposable
9+
abstract member NotifyOnChanged : (obj -> unit) -> unit
10+
abstract member UniqueId : string
611

712
[<CompilerMessageAttribute("This API supports the FSharp.Data.SqlClient infrastructure and is not intended to be used directly from your code.", 101, IsHidden = true)>]
813
type internal SingleFileChangeMonitor(path) as this =
9-
inherit ChangeMonitor()
14+
//inherit ChangeMonitor()
1015

1116
let file = new FileInfo(path)
1217
let watcher = new FileSystemWatcher( Path.GetDirectoryName(path) )
1318

1419
do
15-
let dispose = ref true
16-
try
17-
watcher.NotifyFilter <- NotifyFilters.LastWrite ||| NotifyFilters.FileName
18-
watcher.Changed.Add <| fun args -> this.TriggerOnFileChange(args.Name)
19-
watcher.Deleted.Add <| fun args -> this.TriggerOnFileChange(args.Name)
20-
watcher.Renamed.Add <| fun args -> this.TriggerOnFileChange(args.OldName)
21-
watcher.Error.Add <| fun _ -> this.TriggerOnChange()
22-
watcher.EnableRaisingEvents <- true
23-
dispose := false
24-
finally
25-
base.InitializationComplete()
26-
if !dispose
27-
then
28-
base.Dispose()
29-
30-
member private __.TriggerOnChange() = base.OnChanged(state = null)
20+
watcher.NotifyFilter <- NotifyFilters.LastWrite ||| NotifyFilters.FileName
21+
watcher.Changed.Add <| fun args -> this.TriggerOnFileChange(args.Name)
22+
watcher.Deleted.Add <| fun args -> this.TriggerOnFileChange(args.Name)
23+
watcher.Renamed.Add <| fun args -> this.TriggerOnFileChange(args.OldName)
24+
watcher.Error.Add <| fun _ -> this.TriggerOnChange()
25+
watcher.EnableRaisingEvents <- true
26+
27+
let onChangedEvent = new Event<_>()
28+
29+
[<CLIEvent>]
30+
member this.OnChanged = onChangedEvent.Publish
31+
32+
member private this.TriggerOnChange() =
33+
onChangedEvent.Trigger null
34+
3135
member private __.TriggerOnFileChange(fileName) =
3236
if String.Compare(file.Name, fileName, StringComparison.OrdinalIgnoreCase) = 0
3337
then
3438
this.TriggerOnChange()
3539

36-
override __.UniqueId = path + string file.LastWriteTimeUtc.Ticks + string file.Length;
37-
override __.Dispose( disposing) = if disposing then watcher.Dispose()
40+
interface ChangeMonitor with
41+
member __.NotifyOnChanged(callback) =
42+
this.OnChanged.Add callback
43+
44+
member __.UniqueId = path + string file.LastWriteTimeUtc.Ticks + string file.Length;
3845

46+
interface IDisposable with
47+
member this.Dispose() = watcher.Dispose()

src/SqlClient.DesignTime/SingleRootTypeProvider.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type SingleRootTypeProvider(config: TypeProviderConfig, providerName, parameters
1919
let providerType = ProvidedTypeDefinition(assembly, nameSpace, providerName, Some typeof<obj>, hideObjectMethods = true, isErased = isErased)
2020

2121
providerType.DefineStaticParameters(
22-
parameters = parameters,
22+
parameters = parameters,
2323
instantiationFunction = fun typeName args ->
2424
match cache.TryGetValue(typeName) with
2525
| true, cachedType -> cachedType.Value
@@ -28,7 +28,7 @@ type SingleRootTypeProvider(config: TypeProviderConfig, providerName, parameters
2828
monitors
2929
|> Seq.iter(fun m ->
3030
match m with
31-
| :? System.Runtime.Caching.ChangeMonitor as monitor ->
31+
| :? ChangeMonitor as monitor ->
3232
monitor.NotifyOnChanged(fun _ ->
3333
cache.Remove(typeName)
3434
this.Invalidate()

src/SqlClient.DesignTime/SqlClient.DesignTime.fsproj

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
<Project Sdk="Microsoft.NET.Sdk">
33
<Import Project="..\..\netfx.props" />
44
<PropertyGroup>
5-
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
5+
<TargetFrameworks>netcoreapp2.0</TargetFrameworks>
6+
<!--<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>-->
67
<AssemblyName>FSharp.Data.SqlClient.DesignTime</AssemblyName>
78
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
89
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
@@ -12,8 +13,14 @@
1213
</PropertyGroup>
1314

1415
<ItemGroup>
15-
<PackageReference Include="FSharp.Core" Version="4.1.18" Condition="'$(TargetFramework)' == 'net40'" />
16-
<PackageReference Include="FSharp.Core" Version="4.3.4" Condition="'$(TargetFramework)' == 'net461'" />
16+
<PackageReference Include="FSharp.Core" Version="4.6.0" />
17+
18+
<PackageReference Include="Microsoft.SqlServer.TransactSql.ScriptDom" Version="150.4573.2" />
19+
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.6.0" />
20+
<PackageReference Include="Microsoft.Data.SqlClient" Version="1.1.3" />
21+
22+
<!--<PackageReference Include="FSharp.Core" Version="4.1.18" Condition="'$(TargetFramework)' == 'net40'" />-->
23+
<!--<PackageReference Include="FSharp.Core" Version="4.3.4" Condition="'$(TargetFramework)' == 'net461'" />-->
1724
<!--<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.5.0" Condition="'$(TargetFramework)' == 'net461'" />
1825
1926
<PackageReference Include="Microsoft.SqlServer.TransactSql.ScriptDom" Version="14.0.3811.1" />
@@ -33,11 +40,13 @@
3340
<Reference Include="System.ServiceModel" />
3441
<Reference Include="System.Transactions" />
3542
<Reference Include="System.Xml" />
36-
</ItemGroup>-->
43+
</ItemGroup>
3744
<ItemGroup Condition="$(TargetFramework) == 'net461'">
3845
<Reference Include="System.Data" />
3946
</ItemGroup>
47+
-->
4048
<ItemGroup>
49+
<None Include="paket.references" />
4150
<Compile Include="AssemblyInfo.fs" />
4251
<Compile Include="..\..\paket-files\fsprojects\FSharp.TypeProviders.SDK\src\ProvidedTypes.fsi">
4352
<Link>ProvidedTypes.fsi</Link>
@@ -67,20 +76,25 @@
6776
<None Include="Scripts\ReverseLineOrderForNotex.fsx" />
6877
<None Include="Scripts\XE.fsx" />
6978
</ItemGroup>
79+
7080
<Target Name="CopyAssembliesToTPFolder" AfterTargets="Build">
7181
<ItemGroup>
72-
<DesignTimeAssemblies Include="$(OutputPath)\FSharp.Data.SqlClient.DesignTime.*" />
73-
<DesignTimeAssemblies Include="$(OutputPath)\Microsoft.SqlServer.*.dll" />
82+
<DesignTimeAssemblies Include="$(OutputPath)FSharp.Data.SqlClient.DesignTime.*" />
83+
<DesignTimeAssemblies Include="$(OutputPath)Microsoft.Data.SqlClient.*" />
84+
<DesignTimeAssemblies Include="$(OutputPath)Microsoft.SqlServer.*" />
85+
<DesignTimeAssemblies Include="$(OutputPath)System.Configuration.ConfigurationManager.*" />
7486
</ItemGroup>
7587
<Copy SourceFiles="@(DesignTimeAssemblies)" DestinationFolder="..\..\bin\typeproviders\fsharp41\$(TargetFramework)" />
7688
</Target>
89+
90+
<!--
7791
<Target Name="CopyAssembliesToLegacyFolder" AfterTargets="Build" Condition="$(TargetFramework) == 'net40'">
7892
<ItemGroup>
7993
<DesignTimeAssemblies Include="$(OutputPath)\FSharp.Data.SqlClient.DesignTime.*" />
8094
<DesignTimeAssemblies Include="$(OutputPath)\Microsoft.SqlServer.*.dll" />
8195
</ItemGroup>
8296
<Copy SourceFiles="@(DesignTimeAssemblies)" DestinationFolder="..\..\bin\$(TargetFramework)" />
8397
</Target>
84-
98+
-->
8599
<Import Project="..\..\.paket\Paket.Restore.targets" />
86100
</Project>

src/SqlClient.DesignTime/SqlClientProvider.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ type SqlProgrammabilityProvider(config : TypeProviderConfig) as this =
7777
AppDomain.CurrentDomain.SetData("DataDirectory", dataDirectoryFullPath)
7878

7979
let conn = new SqlConnection(designTimeConnectionString.Value)
80+
failwith "Whaa"
8081
use closeConn = conn.UseLocally()
8182
conn.CheckVersion()
8283
conn.LoadDataTypesMap()

src/SqlClient.DesignTime/SqlCommandProvider.fs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,12 @@ type SqlCommandProvider(config : TypeProviderConfig) as this =
9999
AppDomain.CurrentDomain.SetData("DataDirectory", dataDirectoryFullPath)
100100

101101
let conn = new SqlConnection(designTimeConnectionString.Value)
102-
use closeConn = conn.UseLocally()
102+
use closeConn =
103+
try
104+
conn.OpenWithCloseOnDispose()
105+
with
106+
_ -> failwith "Could not open a connection to the database"
107+
103108
conn.CheckVersion()
104109
conn.LoadDataTypesMap()
105110

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,2 @@
11
group DesignTime
22

3-
System.Configuration.ConfigurationManager
4-
System.Data.Common
5-
System.Data.SqlClient
6-
System.Runtime.Caching
7-
Microsoft.SqlServer.TransactSql.ScriptDom
8-
Microsoft.SqlServer.Types
9-
Microsoft.Data.SqlClient

0 commit comments

Comments
 (0)