Skip to content

Commit f6f7b70

Browse files
* fix assembly replacement map given to TypeProviderForNamespaces constructors
* fix remaining naked references to System.Data.SqlClient namespaces in tests
1 parent c90ef2a commit f6f7b70

6 files changed

Lines changed: 54 additions & 7 deletions

File tree

src/SqlClient.DesignTime/SingleRootTypeProvider.fs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,16 @@ open System
88
[<AbstractClass>]
99
[<CompilerMessageAttribute("This API supports the FSharp.Data.SqlClient infrastructure and is not intended to be used directly from your code.", 101, IsHidden = true)>]
1010
type SingleRootTypeProvider(config: TypeProviderConfig, providerName, parameters, ?isErased) as this =
11-
inherit TypeProviderForNamespaces (config, assemblyReplacementMap=[("FSharp.Data.SqlClient.DesignTime", "FSharp.Data.SqlClient")], addDefaultProbingLocation=true)
11+
inherit TypeProviderForNamespaces (
12+
config
13+
#if MICROSOFT_DATA_SQLCLIENT
14+
, assemblyReplacementMap=[("FSharp.Data.MicrosoftSqlClient.DesignTime", "FSharp.Data.MicrosoftSqlClient")]
15+
#endif
16+
#if SYSTEM_DATA_SQLCLIENT
17+
, assemblyReplacementMap=[("FSharp.Data.SqlClient.DesignTime", "FSharp.Data.SqlClient")]
18+
#endif
19+
, addDefaultProbingLocation=true
20+
)
1221

1322
let cache = new Cache<ProvidedTypeDefinition>()
1423
do

src/SqlClient.DesignTime/SqlClientProvider.fs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,16 @@ open FSharp.Data.SqlClient.Internals
2424
[<TypeProvider>]
2525
[<CompilerMessageAttribute("This API supports the FSharp.Data.SqlClient infrastructure and is not intended to be used directly from your code.", 101, IsHidden = true)>]
2626
type SqlProgrammabilityProvider(config : TypeProviderConfig) as this =
27-
inherit TypeProviderForNamespaces (config, assemblyReplacementMap=[("FSharp.Data.SqlClient.DesignTime", "FSharp.Data.SqlClient")], addDefaultProbingLocation=true)
27+
inherit TypeProviderForNamespaces (
28+
config
29+
#if MICROSOFT_DATA_SQLCLIENT
30+
, assemblyReplacementMap=[("FSharp.Data.MicrosoftSqlClient.DesignTime", "FSharp.Data.MicrosoftSqlClient")]
31+
#endif
32+
#if SYSTEM_DATA_SQLCLIENT
33+
, assemblyReplacementMap=[("FSharp.Data.SqlClient.DesignTime", "FSharp.Data.SqlClient")]
34+
#endif
35+
, addDefaultProbingLocation=true
36+
)
2837

2938
let assembly = Assembly.GetExecutingAssembly()
3039
let nameSpace = this.GetType().Namespace

src/SqlClient.DesignTime/SqlCommandProvider.fs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,16 @@ module X =
3737
[<TypeProvider>]
3838
[<CompilerMessageAttribute("This API supports the FSharp.Data.SqlClient infrastructure and is not intended to be used directly from your code.", 101, IsHidden = true)>]
3939
type SqlCommandProvider(config : TypeProviderConfig) as this =
40-
inherit TypeProviderForNamespaces (config, assemblyReplacementMap=[("FSharp.Data.SqlClient.DesignTime", "FSharp.Data.SqlClient")], addDefaultProbingLocation=true)
40+
inherit TypeProviderForNamespaces (
41+
config
42+
#if MICROSOFT_DATA_SQLCLIENT
43+
, assemblyReplacementMap=[("FSharp.Data.MicrosoftSqlClient.DesignTime", "FSharp.Data.MicrosoftSqlClient")]
44+
#endif
45+
#if SYSTEM_DATA_SQLCLIENT
46+
, assemblyReplacementMap=[("FSharp.Data.SqlClient.DesignTime", "FSharp.Data.SqlClient")]
47+
#endif
48+
, addDefaultProbingLocation=true
49+
)
4150

4251
let nameSpace = this.GetType().Namespace
4352
let assembly = Assembly.GetExecutingAssembly()

src/SqlClient.DesignTime/SqlEnumProvider.fs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,16 @@ open FSharp.Data.SqlClient
1717
[<TypeProvider>]
1818
[<CompilerMessageAttribute("This API supports the FSharp.Data.SqlClient infrastructure and is not intended to be used directly from your code.", 101, IsHidden = true)>]
1919
type SqlEnumProvider(config : TypeProviderConfig) as this =
20-
inherit TypeProviderForNamespaces (config, assemblyReplacementMap=[("FSharp.Data.SqlClient.DesignTime", "FSharp.Data.SqlClient")], addDefaultProbingLocation=true)
20+
inherit TypeProviderForNamespaces (
21+
config
22+
#if MICROSOFT_DATA_SQLCLIENT
23+
, assemblyReplacementMap=[("FSharp.Data.MicrosoftSqlClient.DesignTime", "FSharp.Data.MicrosoftSqlClient")]
24+
#endif
25+
#if SYSTEM_DATA_SQLCLIENT
26+
, assemblyReplacementMap=[("FSharp.Data.SqlClient.DesignTime", "FSharp.Data.SqlClient")]
27+
#endif
28+
, addDefaultProbingLocation=true
29+
)
2130

2231
let nameSpace = this.GetType().Namespace
2332
let assembly = Assembly.GetExecutingAssembly()

tests/SqlClient.Tests/CreateCommand.fs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,18 @@ module TraceTests =
141141
let expected = sprintf "exec sp_executesql N'SELECT CAST(@Value AS NVARCHAR(20))',N'@Value NVarChar(20)',@Value=NULL"
142142
Assert.Equal<string>(expected, actual = DB.CreateCommand<"SELECT CAST(@Value AS NVARCHAR(20))">().ToTraceString(Unchecked.defaultof<string>))
143143

144+
#if SYSTEM_DATA_SQLCLIENT
145+
open System.Data.SqlClient
146+
#endif
147+
#if MICROSOFT_DATA_SQLCLIENT
148+
open Microsoft.Data.SqlClient
149+
#endif
150+
144151
[<Fact>]
145152
let resultSetMapping() =
146153
let cmd = DB.CreateCommand<"SELECT * FROM (VALUES ('F#', 2005), ('Scala', 2003), ('foo bar',NULL)) AS T(lang, DOB)", ResultType.DataReader>()
147154

148-
let readToMap(reader : System.Data.SqlClient.SqlDataReader) =
155+
let readToMap(reader : SqlDataReader) =
149156
seq {
150157
try
151158
while(reader.Read()) do
@@ -182,7 +189,6 @@ let ``Runtime column names``() =
182189
use cmd = DB.CreateCommand<"exec dbo.[Get]", ResultType.DataReader>()
183190
Assert.False( cmd.Execute().NextResult())
184191

185-
open System.Data.SqlClient
186192
type SqlDataReader with
187193
member this.ToRecords<'T>() =
188194
seq {
@@ -199,7 +205,7 @@ let CreareDynamicRecords() =
199205
use cmd = DB.CreateCommand<getDatesQuery, TypeName = "GetDatesQuery">()
200206
use conn = new SqlConnection(ConnectionStrings.AdventureWorksLiteral)
201207
conn.Open()
202-
let cmd = new System.Data.SqlClient.SqlCommand(getDatesQuery, conn)
208+
let cmd = new SqlCommand(getDatesQuery, conn)
203209

204210
cmd.ExecuteReader().ToRecords<DB.Commands.GetDatesQuery.Record>()
205211
|> Seq.toArray

tests/SqlClient.Tests/ProgrammabilityTests.fs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ open FSharp.Data.SqlClient
44
open FSharp.Data.SqlClient.Tests
55

66
open System
7+
#if SYSTEM_DATA_SQLCLIENT
78
open System.Data.SqlClient
9+
#endif
10+
#if MICROSOFT_DATA_SQLCLIENT
11+
open Microsoft.Data.SqlClient
12+
#endif
813
open Xunit
914

1015
type AdventureWorks = SqlProgrammabilityProvider<ConnectionStrings.AdventureWorksNamed>

0 commit comments

Comments
 (0)