Skip to content

Commit bac5ede

Browse files
Merge pull request #315 from samhanes/update-sdk-version
Update to latest version of SDK
2 parents fb8706f + 404b788 commit bac5ede

13 files changed

+270
-284
lines changed

paket.dependencies

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ generate_load_scripts: on
55

66
nuget FSharp.Core = 4.1.2
77
nuget Microsoft.SqlServer.TransactSql.ScriptDom
8+
nuget Microsoft.SqlServer.Types ~> 12
89

9-
github fsprojects/FSharp.TypeProviders.SDK:0a5fd0caa73df304062c8965e61850789d9f39e7 src/ProvidedTypes.fs
10-
github fsprojects/FSharp.TypeProviders.SDK:0a5fd0caa73df304062c8965e61850789d9f39e7 src/ProvidedTypes.fsi
11-
github fsprojects/FSharp.TypeProviders.SDK:0a5fd0caa73df304062c8965e61850789d9f39e7 src/ProvidedTypesTesting.fs
10+
github fsprojects/FSharp.TypeProviders.SDK:7d57cd409d7299592822713195924e42b2b7acde src/ProvidedTypes.fs
11+
github fsprojects/FSharp.TypeProviders.SDK:7d57cd409d7299592822713195924e42b2b7acde src/ProvidedTypes.fsi
12+
github fsprojects/FSharp.TypeProviders.SDK:7d57cd409d7299592822713195924e42b2b7acde src/ProvidedTypesTesting.fs
1213

1314
group Build
1415
source https://www.nuget.org/api/v2/

paket.lock

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ NUGET
3030
System.ValueTuple (>= 4.3) - restriction: && (>= net40) (< netstandard1.6)
3131
Microsoft.NETCore.Platforms (2.0.2) - restriction: || (&& (>= net40) (< net45) (>= netstandard1.1) (< netstandard1.2)) (&& (>= net40) (< net45) (>= netstandard1.2) (< netstandard1.3)) (&& (>= net40) (< net45) (>= netstandard1.3) (< netstandard1.4)) (&& (>= net40) (< net45) (>= netstandard1.4) (< netstandard1.5)) (&& (>= net40) (< net45) (>= netstandard1.5) (< netstandard1.6)) (&& (>= net40) (< net45) (< netstandard1.6) (>= netstandard2.0)) (&& (>= net40) (>= netcoreapp2.0) (< netstandard1.6)) (&& (>= net40) (>= netstandard1.0) (< portable-net45+win8+wpa81)) (&& (>= net40) (< netstandard1.3) (>= wpa81)) (&& (>= net40) (< netstandard1.5) (>= uap10.0)) (&& (>= net40) (>= uap10.1)) (&& (>= net40) (>= wp8)) (&& (>= net45) (< netstandard1.3)) (&& (>= net46) (< netstandard1.4))
3232
Microsoft.SqlServer.TransactSql.ScriptDom (14.0.3811.1)
33+
Microsoft.SqlServer.Types (12.0.5000)
3334
Microsoft.Win32.Primitives (4.3) - restriction: || (&& (>= net40) (< net45) (>= netstandard1.3) (< netstandard1.4)) (&& (>= net40) (< net45) (>= netstandard1.4) (< netstandard1.5)) (&& (>= net40) (< net45) (>= netstandard1.5) (< netstandard1.6)) (&& (>= net40) (< netstandard1.5) (>= uap10.0)) (&& (>= net46) (< netstandard1.4))
3435
NETStandard.Library (2.0.3) - restriction: && (>= net40) (< net461) (>= netstandard1.0) (< netstandard1.6)
3536
Microsoft.NETCore.Platforms (>= 1.1) - restriction: || (&& (>= net40) (< net45) (>= netstandard1.1) (< netstandard1.2)) (&& (>= net40) (< net45) (>= netstandard1.2) (< netstandard1.3)) (&& (>= net40) (< net45) (>= netstandard1.3) (< netstandard1.4)) (&& (>= net40) (< net45) (>= netstandard1.4) (< netstandard1.5)) (&& (>= net40) (< net45) (>= netstandard1.5) (< netstandard1.6)) (&& (>= net40) (< net45) (>= netstandard1.6) (< netstandard2.0)) (&& (>= net40) (< net45) (>= netstandard2.0)) (&& (>= net40) (>= netcoreapp2.0)) (&& (>= net40) (>= netstandard1.0) (< portable-net45+win8+wpa81)) (&& (>= net40) (< netstandard1.0) (>= portable-net45+win8)) (&& (>= net40) (< netstandard1.0) (< portable-net45+win8) (>= portable-net45+win8+wpa81)) (&& (>= net40) (< netstandard1.0) (>= portable-net45+win8+wp8+wpa81) (< portable-net45+win8+wpa81)) (&& (>= net40) (< netstandard1.0) (>= win8)) (&& (>= net40) (< netstandard1.3) (>= wpa81)) (&& (>= net40) (< netstandard1.5) (>= uap10.0)) (&& (>= net40) (>= uap10.1)) (&& (>= net40) (>= wp8)) (&& (>= net45) (< netstandard1.3)) (&& (>= net46) (< netstandard1.4)) (>= net461)
@@ -95,9 +96,9 @@ NUGET
9596
System.Xml.ReaderWriter (4.3.1) - restriction: || (&& (>= net40) (< net45) (>= netstandard1.1) (< netstandard1.2)) (&& (>= net40) (< net45) (>= netstandard1.2) (< netstandard1.3)) (&& (>= net40) (< net45) (>= netstandard1.3) (< netstandard1.4)) (&& (>= net40) (< net45) (>= netstandard1.4) (< netstandard1.5)) (&& (>= net40) (< net45) (>= netstandard1.5) (< netstandard1.6)) (&& (>= net40) (>= netstandard1.0) (< portable-net45+win8+wpa81)) (&& (>= net40) (< netstandard1.5) (>= uap10.0)) (&& (>= net46) (< netstandard1.4))
9697
GITHUB
9798
remote: fsprojects/FSharp.TypeProviders.SDK
98-
src/ProvidedTypes.fs (0a5fd0caa73df304062c8965e61850789d9f39e7)
99-
src/ProvidedTypes.fsi (0a5fd0caa73df304062c8965e61850789d9f39e7)
100-
src/ProvidedTypesTesting.fs (0a5fd0caa73df304062c8965e61850789d9f39e7)
99+
src/ProvidedTypes.fs (7d57cd409d7299592822713195924e42b2b7acde)
100+
src/ProvidedTypes.fsi (7d57cd409d7299592822713195924e42b2b7acde)
101+
src/ProvidedTypesTesting.fs (7d57cd409d7299592822713195924e42b2b7acde)
101102
GROUP Build
102103
GENERATE-LOAD-SCRIPTS: ON
103104
REDIRECTS: FORCE

src/SqlClient.Tests/SqlEnumTests.fs

Lines changed: 91 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -12,138 +12,138 @@ type TinyIntMapping = SqlEnumProvider<"SELECT * FROM (VALUES(('One'), CAST(1 AS
1212

1313
[<Fact>]
1414
let tinyIntMapping() =
15-
Assert.Equal<(string * byte) seq>([| "One", 1uy; "Two", 2uy |], TinyIntMapping.Items)
15+
Assert.Equal<(string * byte) seq>([| "One", 1uy; "Two", 2uy |], TinyIntMapping.Items)
1616

1717
[<Fact>]
1818
let parse() =
19-
Assert.Equal(TinyIntMapping.One, TinyIntMapping.Parse("one", ignoreCase = true))
20-
Assert.Equal(TinyIntMapping.One, TinyIntMapping.Parse("One", ignoreCase = false))
21-
Assert.Equal(TinyIntMapping.One, TinyIntMapping.Parse("One"))
22-
Assert.Throws<ArgumentException>(fun() -> box (TinyIntMapping.Parse("blah-blah"))) |> ignore
23-
Assert.Throws<ArgumentException>(fun() -> box (TinyIntMapping.Parse("one"))) |> ignore
19+
Assert.Equal(TinyIntMapping.One, TinyIntMapping.Parse("one", ignoreCase = true))
20+
Assert.Equal(TinyIntMapping.One, TinyIntMapping.Parse("One", ignoreCase = false))
21+
Assert.Equal(TinyIntMapping.One, TinyIntMapping.Parse("One"))
22+
Assert.Throws<ArgumentException>(fun() -> box (TinyIntMapping.Parse("blah-blah"))) |> ignore
23+
Assert.Throws<ArgumentException>(fun() -> box (TinyIntMapping.Parse("one"))) |> ignore
2424

2525
[<Fact>]
2626
let Enums() =
27-
let succ, result = EnumMapping.TryParse("One")
28-
Assert.True succ
29-
Assert.Equal(EnumMapping.One, result)
27+
let succ, result = EnumMapping.TryParse("One")
28+
Assert.True succ
29+
Assert.Equal(EnumMapping.One, result)
3030

31-
Assert.Equal(1, int EnumMapping.One)
32-
Assert.True(EnumMapping.One = (Enum.Parse(typeof<EnumMapping>, "One") |> unbox))
33-
Assert.Equal(enum 1, EnumMapping.One)
31+
Assert.Equal(1, int EnumMapping.One)
32+
Assert.True(EnumMapping.One = (Enum.Parse(typeof<EnumMapping>, "One") |> unbox))
33+
Assert.Equal(enum 1, EnumMapping.One)
3434

3535
[<Fact>]
3636
let Name() =
37-
let value = TinyIntMapping.One
38-
Assert.Equal(Some "One", TinyIntMapping.TryFindName value)
39-
Assert.Equal(None, TinyIntMapping.TryFindName Byte.MinValue)
37+
let value = TinyIntMapping.One
38+
Assert.Equal(Some "One", TinyIntMapping.TryFindName value)
39+
Assert.Equal(None, TinyIntMapping.TryFindName Byte.MinValue)
4040

4141
type SingleColumnSelect = SqlEnumProvider<"SELECT Name FROM Purchasing.ShipMethod", ConnectionStrings.AdventureWorksNamed>
4242

4343
[<Fact>]
4444
let SingleColumn() =
45-
Assert.Equal<string>("CARGO TRANSPORT 5", SingleColumnSelect.``CARGO TRANSPORT 5``)
46-
let all =
47-
use cmd = new SqlCommandProvider<"SELECT Name, Name FROM Purchasing.ShipMethod", ConnectionStrings.AdventureWorksNamed, ResultType.Tuples>()
48-
cmd.Execute() |> Seq.toArray
49-
let items = SingleColumnSelect.Items
50-
Assert.Equal<_ seq>(all, items)
45+
Assert.Equal<string>("CARGO TRANSPORT 5", SingleColumnSelect.``CARGO TRANSPORT 5``)
46+
let all =
47+
use cmd = new SqlCommandProvider<"SELECT Name, Name FROM Purchasing.ShipMethod", ConnectionStrings.AdventureWorksNamed, ResultType.Tuples>()
48+
cmd.Execute() |> Seq.toArray
49+
let items = SingleColumnSelect.Items
50+
Assert.Equal<_ seq>(all, items)
5151

5252
[<Fact>]
5353
let PatternMatchingOn() =
54-
let actual =
55-
SingleColumnSelect.Items
56-
|> Seq.choose (fun (tag, value) ->
57-
match value with
58-
| SingleColumnSelect.``CARGO TRANSPORT 5``
59-
| SingleColumnSelect.``OVERNIGHT J-FAST``
60-
| SingleColumnSelect.``OVERSEAS - DELUXE``
61-
| SingleColumnSelect.``XRQ - TRUCK GROUND``
62-
| SingleColumnSelect.``ZY - EXPRESS`` -> Some tag
63-
| _ -> None
64-
)
65-
66-
Assert.Equal<_ seq>(
67-
SingleColumnSelect.Items |> Seq.map fst,
68-
actual
69-
)
54+
let actual =
55+
SingleColumnSelect.Items
56+
|> Seq.choose (fun (tag, value) ->
57+
match value with
58+
| SingleColumnSelect.``CARGO TRANSPORT 5``
59+
| SingleColumnSelect.``OVERNIGHT J-FAST``
60+
| SingleColumnSelect.``OVERSEAS - DELUXE``
61+
| SingleColumnSelect.``XRQ - TRUCK GROUND``
62+
| SingleColumnSelect.``ZY - EXPRESS`` -> Some tag
63+
| _ -> None
64+
)
65+
66+
Assert.Equal<_ seq>(
67+
SingleColumnSelect.Items |> Seq.map fst,
68+
actual
69+
)
7070

7171
type MoreThan2Columns = SqlEnumProvider< @"
72-
select * from (
72+
select * from (
7373
values
74-
('a', 1, 'this is a')
75-
, ('b', 2, 'this is b')
76-
, ('c', 3, 'this is c')
74+
('a', 1, 'this is a')
75+
, ('b', 2, 'this is b')
76+
, ('c', 3, 'this is c')
7777
) as v(code, id, description)
7878
", connectionString>
7979

8080
[<Fact>]
8181
let MoreThan2ColumnReturnsCorrectTuples() =
82-
Assert.Equal((1, "this is a"), MoreThan2Columns.a)
83-
Assert.Equal<_[]>(
84-
expected = [|
85-
("a", (1, "this is a"))
86-
("b", (2, "this is b"))
87-
("c", (3, "this is c"))
88-
|],
89-
actual = Array.ofSeq MoreThan2Columns.Items
90-
)
82+
Assert.Equal((1, "this is a"), MoreThan2Columns.a)
83+
Assert.Equal<_[]>(
84+
expected = [|
85+
("a", (1, "this is a"))
86+
("b", (2, "this is b"))
87+
("c", (3, "this is c"))
88+
|],
89+
actual = Array.ofSeq MoreThan2Columns.Items
90+
)
9191

9292
type CurrencyCode =
93-
SqlEnumProvider<"
94-
SELECT CurrencyCode
95-
FROM Sales.Currency
96-
WHERE CurrencyCode IN ('USD', 'EUR', 'GBP')
97-
", ConnectionStrings.AdventureWorksLiteral, Kind = SqlEnumKind.UnitsOfMeasure>
93+
SqlEnumProvider<"
94+
SELECT CurrencyCode
95+
FROM Sales.Currency
96+
WHERE CurrencyCode IN ('USD', 'EUR', 'GBP')
97+
", ConnectionStrings.AdventureWorksLiteral, Kind = SqlEnumKind.UnitsOfMeasure>
9898

9999
[<Fact>]
100100
let ConvertUsdToGbp() =
101-
let getLatestRate = new SqlCommandProvider<"
102-
SELECT TOP 1 *
103-
FROM Sales.CurrencyRate
104-
WHERE FromCurrencyCode = @fromCurrency
101+
let getLatestRate = new SqlCommandProvider<"
102+
SELECT TOP 1 *
103+
FROM Sales.CurrencyRate
104+
WHERE FromCurrencyCode = @fromCurrency
105105
AND ToCurrencyCode = @toCurrency
106-
ORDER BY CurrencyRateDate DESC
107-
", ConnectionStrings.AdventureWorksNamed, SingleRow = true>()
108-
let rate =
109-
getLatestRate.Execute(fromCurrency = "USD", toCurrency = "GBP")
110-
|> Option.map(fun x -> x.AverageRate * 1M<CurrencyCode.GBP/CurrencyCode.USD>)
111-
|> Option.get
106+
ORDER BY CurrencyRateDate DESC
107+
", ConnectionStrings.AdventureWorksNamed, SingleRow = true>()
108+
let rate =
109+
getLatestRate.Execute(fromCurrency = "USD", toCurrency = "GBP")
110+
|> Option.map(fun x -> x.AverageRate * 1M<CurrencyCode.GBP/CurrencyCode.USD>)
111+
|> Option.get
112112

113-
let actual = 42M<CurrencyCode.USD> * rate
114-
let expected = 26.5986M<CurrencyCode.GBP>
115-
Assert.Equal( expected, actual)
113+
let actual = 42M<CurrencyCode.USD> * rate
114+
let expected = 26.5986M<CurrencyCode.GBP>
115+
Assert.Equal( expected, actual)
116116

117117
type ProductsUnitsOfMeasure = SqlEnumProvider<"SELECT UnitMeasureCode FROM Production.UnitMeasure", ConnectionStrings.AdventureWorksLiteral, Kind = SqlEnumKind.UnitsOfMeasure>
118118
type ProductCategory = SqlEnumProvider<"SELECT Name FROM Production.ProductCategory", ConnectionStrings.AdventureWorksLiteral>
119119

120120
type Bikes = {
121-
Id: int
122-
Name: string
123-
Weight: decimal<ProductsUnitsOfMeasure.``LB ``> option
124-
Size: float<ProductsUnitsOfMeasure.``CM ``> option
121+
Id: int
122+
Name: string
123+
Weight: decimal<ProductsUnitsOfMeasure.``LB ``> option
124+
Size: float<ProductsUnitsOfMeasure.``CM ``> option
125125
}
126126

127127
[<Fact>]
128128
let ProductWeightAndSizeUnitsOfMeasure() =
129-
let allBikes = [
130-
use cmd =
131-
new SqlCommandProvider<"
132-
SELECT ProductID, Product.Name, Size, SizeUnitMeasureCode, Weight, WeightUnitMeasureCode
133-
FROM Production.Product
129+
let allBikes = [
130+
use cmd =
131+
new SqlCommandProvider<"
132+
SELECT ProductID, Product.Name, Size, SizeUnitMeasureCode, Weight, WeightUnitMeasureCode
133+
FROM Production.Product
134134
JOIN Production.ProductCategory ON ProductSubcategoryID = ProductCategoryID
135-
WHERE ProductCategory.Name = @category
136-
", ConnectionStrings.AdventureWorksNamed>()
135+
WHERE ProductCategory.Name = @category
136+
", ConnectionStrings.AdventureWorksNamed>()
137137

138-
for x in cmd.Execute(ProductCategory.Bikes) do
139-
yield {
140-
Id = x.ProductID
141-
Name = x.Name
142-
Weight = x.Weight |> Option.map(fun weight -> weight * 1M<_>)
143-
Size = x.Size |> Option.map(fun size -> size |> float |> LanguagePrimitives.FloatWithMeasure )
144-
}
145-
]
146-
147-
let bigBikes = allBikes |> List.choose ( fun x -> if x.Size = Some 52.<ProductsUnitsOfMeasure.``CM ``> then Some x.Name else None)
148-
149-
Assert.Equal<_ list>( ["Mountain-500 Silver, 52"; "Mountain-500 Black, 52"], bigBikes)
138+
for x in cmd.Execute(ProductCategory.Bikes) do
139+
yield {
140+
Id = x.ProductID
141+
Name = x.Name
142+
Weight = x.Weight |> Option.map(fun weight -> weight * 1M<_>)
143+
Size = x.Size |> Option.map(fun size -> size |> float |> LanguagePrimitives.FloatWithMeasure )
144+
}
145+
]
146+
147+
let bigBikes = allBikes |> List.choose ( fun x -> if x.Size = Some 52.<ProductsUnitsOfMeasure.``CM ``> then Some x.Name else None)
148+
149+
Assert.Equal<_ list>( ["Mountain-500 Silver, 52"; "Mountain-500 Black, 52"], bigBikes)

src/SqlClient/DebugProvidedTypes.fs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ module internal Debug =
2929
cfg?ReferencedAssemblies <- Array.zeroCreate<string> 0
3030

3131
let typeProviderForNamespaces = typeProviderForNamespacesConstructor cfg :> TypeProviderForNamespaces
32-
33-
let providedTypeDefinition = typeProviderForNamespaces.Namespaces |> Seq.last |> snd |> Seq.last
34-
32+
let ns = typeProviderForNamespaces.Namespaces |> Seq.last
33+
//let providedTypeDefinition = typeProviderForNamespaces.Namespaces |> Seq.last |> snd |> Seq.last
34+
let providedTypeDefinition = ns.GetTypes() |> Seq.last :?> ProvidedTypeDefinition
35+
3536
match args with
3637
| [||] -> providedTypeDefinition
3738
| args ->
@@ -41,7 +42,7 @@ module internal Debug =
4142
else
4243
// The type name ends up quite mangled in the dll output if we combine the name using static parameters, so for generated types we don't do that
4344
providedTypeDefinition.Name
44-
providedTypeDefinition.MakeParametricType(typeName, args)
45+
providedTypeDefinition.ApplyStaticArguments(typeName, args)
4546

4647
/// Returns a string representation of the signature (and optionally also the body) of all the
4748
/// types generated by the type provider up to a certain depth and width
@@ -412,15 +413,15 @@ module internal Debug =
412413
seq { if not m.IsStatic then yield (ProvidedTypeDefinition.EraseType m.DeclaringType)
413414
for param in m.GetParameters() do yield (ProvidedTypeDefinition.EraseType param.ParameterType) }
414415
|> Seq.map (fun typ -> Expr.Value(null, typ))
415-
|> Array.ofSeq
416-
|> m.GetInvokeCodeInternal false
416+
|> List.ofSeq
417+
|> (Option.get m.GetInvokeCode)
417418

418419
let getConstructorBody (c: ProvidedConstructor) =
419-
if c.IsImplicitCtor then Expr.Value(()) else
420+
if c.IsImplicitConstructor then Expr.Value(()) else
420421
seq { for param in c.GetParameters() do yield (ProvidedTypeDefinition.EraseType param.ParameterType) }
421422
|> Seq.map (fun typ -> Expr.Value(null, typ))
422-
|> Array.ofSeq
423-
|> c.GetInvokeCodeInternal false
423+
|> List.ofSeq
424+
|> c.GetInvokeCode
424425

425426
let printExpr x =
426427
if not ignoreOutput then
@@ -454,7 +455,7 @@ module internal Debug =
454455
if not signatureOnly then
455456
cons |> getConstructorBody |> printExpr
456457

457-
| :? ProvidedLiteralField as field ->
458+
| :? ProvidedField as field when field.IsLiteral = true ->
458459
let value =
459460
if signatureOnly then ""
460461
else field.GetRawConstantValue() |> printObj

0 commit comments

Comments
 (0)