Skip to content

Commit e9202b8

Browse files
first go at deprecating FSharp.Data namespace usage
1 parent b4ee827 commit e9202b8

File tree

13 files changed

+120
-40
lines changed

13 files changed

+120
-40
lines changed

src/SqlClient.DesignTime/DesignTime.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ open System.Collections.Generic
99
open System.Diagnostics
1010
open Microsoft.FSharp.Quotations
1111
open ProviderImplementation.ProvidedTypes
12-
open FSharp.Data
12+
open FSharp.Data.SqlClient.Internals
1313
open System.Text.RegularExpressions
1414

1515
type internal RowType = {

src/SqlClient.DesignTime/QuotationsFactory.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ open System.Diagnostics
99

1010
open Microsoft.FSharp.Quotations
1111

12-
open FSharp.Data
12+
open FSharp.Data.SqlClient.Internals
1313

1414
type QuotationsFactory private() =
1515

src/SqlClient.DesignTime/SqlClientExtensions.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ open System.Collections.Generic
77
open System.IO
88
open System.Threading.Tasks
99
open System.Data.SqlClient
10-
open FSharp.Data
10+
open FSharp.Data.SqlClient.Internals
1111
open System.Diagnostics
1212

1313
type internal TypeInfoPerConnectionStringCache() =

src/SqlClient.DesignTime/SqlClientProvider.fs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ open Microsoft.FSharp.Quotations
1313
open ProviderImplementation.ProvidedTypes
1414

1515
open FSharp.Data.SqlClient
16+
open FSharp.Data.SqlClient.Internals
1617

1718
[<TypeProvider>]
1819
[<CompilerMessageAttribute("This API supports the FSharp.Data.SqlClient infrastructure and is not intended to be used directly from your code.", 101, IsHidden = true)>]
@@ -140,7 +141,7 @@ type SqlProgrammabilityProvider(config : TypeProviderConfig) as this =
140141
//tagProvidedType rowType
141142
]
142143

143-
static member internal UnitsOfMeasure( connStr, schema, sqlDataTypesForConnection: FSharp.Data.TypeInfo array) = [
144+
static member internal UnitsOfMeasure( connStr, schema, sqlDataTypesForConnection: TypeInfo array) = [
144145
for t in sqlDataTypesForConnection do
145146
if t.Schema = schema && t.IsUnitOfMeasure
146147
then
@@ -465,6 +466,9 @@ type SqlProgrammabilityProvider(config : TypeProviderConfig) as this =
465466

466467
let getMethodImpl =
467468
lazy
469+
// was hitting assert of datatypesmap not being loaded for connection
470+
let _ = conn.LoadDataTypesMap()
471+
468472
let sqlStatement, resultType, singleRow, allParametersOptional, typename =
469473
unbox args.[0], unbox args.[1], unbox args.[2], unbox args.[3], unbox args.[4]
470474

src/SqlClient.DesignTime/SqlCommandProvider.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ open Microsoft.FSharp.Core.CompilerServices
1010
open Microsoft.FSharp.Quotations
1111

1212
open FSharp.Data.SqlClient
13+
open FSharp.Data.SqlClient.Internals
1314

1415
open ProviderImplementation.ProvidedTypes
1516

src/SqlClient.Samples/WebApi/Global.asax.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace WebApi
1111
{
1212
public class Global : System.Web.HttpApplication
1313
{
14-
14+
1515
protected void Application_Start(object sender, EventArgs e)
1616
{
1717
GlobalConfiguration.Configuration.Routes.MapHttpRoute("DefaultAPI", "{controller}/{id}", new { controller = "Home", id = RouteParameter.Optional });

src/SqlClient/Configuration.fs

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,37 @@
1-
namespace FSharp.Data.SqlClient
1+
namespace FSharp.Data.SqlClient.Internals
22

33
//this is mess. Clean up later.
4-
type Configuration = {
4+
type FsharpDataSqlClientConfiguration = {
55
ResultsetRuntimeVerification: bool
6-
}
7-
8-
namespace FSharp.Data
6+
}
97

108
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
119
[<AutoOpen>]
1210
module Configuration =
13-
let private guard = obj()
14-
let mutable private current = { SqlClient.Configuration.ResultsetRuntimeVerification = false }
11+
let internal guard = obj()
12+
let mutable internal current = { FsharpDataSqlClientConfiguration.ResultsetRuntimeVerification = false }
1513

16-
type SqlClient.Configuration with
14+
type FsharpDataSqlClientConfiguration with
1715
static member Current
1816
with get() = lock guard <| fun() -> current
1917
and set value = lock guard <| fun() -> current <- value
18+
19+
#if WITH_LEGACY_NAMESPACE
20+
namespace FSharp.Data.SqlClient
21+
open System
22+
[<Obsolete("use 'FSharp.Data.SqlClient.Internals.FsharpDataSqlClientConfiguration' instead");AutoOpen>]
23+
type Configuration = FSharp.Data.SqlClient.Internals.FsharpDataSqlClientConfiguration
24+
namespace FSharp.Data
25+
open System
26+
open FSharp.Data.SqlClient.Internals
27+
open FSharp.Data.SqlClient.Internals.Configuration
28+
[<Obsolete("use open 'FSharp.Data.SqlClient.Internals' namespace instead")>]
29+
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
30+
[<AutoOpen>]
31+
module Configuration =
32+
type FsharpDataSqlClientConfiguration with
33+
static member Current
34+
with get() = lock Configuration.guard <| fun() -> Configuration.current
35+
and set value = lock Configuration.guard <| fun() -> Configuration.current <- value
36+
37+
#endif

src/SqlClient/DataTable.fs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
namespace FSharp.Data
1+
namespace FSharp.Data.SqlClient
22

33
open System
44
open System.Data
55
open System.Data.SqlClient
66
open System.Collections.Generic
7+
open FSharp.Data.SqlClient.Internals
78

89
[<Sealed>]
910
[<CompilerMessageAttribute("This API supports the FSharp.Data.SqlClient infrastructure and is not intended to be used directly from your code.", 101, IsHidden = true)>]
@@ -111,3 +112,10 @@ type DataTable<'T when 'T :> DataRow>(selectCommand: SqlCommand, ?connectionStri
111112
timeout |> Option.iter (fun x -> bulkCopy.BulkCopyTimeout <- int x.TotalSeconds)
112113
bulkCopy.WriteToServer this
113114

115+
#if WITH_LEGACY_NAMESPACE
116+
namespace FSharp.Data
117+
open System
118+
open System.Data
119+
[<Obsolete("use 'FSharp.Data.SqlClient.DataTable' instead");AutoOpen>]
120+
type DataTable<'T when 'T :> DataRow> = FSharp.Data.SqlClient.DataTable<'T>
121+
#endif

src/SqlClient/Extensions.fs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace FSharp.Data
1+
namespace FSharp.Data.SqlClient.Internals
22

33
open System
44
open System.Data
@@ -65,3 +65,12 @@ module Extensions =
6565
assert (this.State = ConnectionState.Open)
6666
use cmd = new SqlCommand("SELECT SERVERPROPERTY('edition')", this)
6767
cmd.ExecuteScalar().Equals("SQL Azure")
68+
69+
70+
#if WITH_LEGACY_NAMESPACE
71+
namespace FSharp.Data
72+
open System
73+
[<Obsolete("use open 'FSharp.Data.SqlClient.Internals' namespace instead");AutoOpen>]
74+
module ObsoleteExtensions =
75+
module Extensions = FSharp.Data.SqlClient.Internals.Extensions
76+
#endif

src/SqlClient/ISqlCommand.fs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
namespace FSharp.Data
1+
namespace FSharp.Data.SqlClient.Internals
22

33
open System
44
open System.Data
55
open System.Data.SqlClient
66
open System.Reflection
7-
87
open FSharp.Data.SqlClient
8+
open FSharp.Data.SqlClient.Internals
99
open System.Linq
1010

1111

@@ -245,7 +245,7 @@ type ``ISqlCommand Implementation``(cfg: DesignTimeConfig, connection: Connectio
245245
//Execute/AsyncExecute versions
246246

247247
static member internal VerifyResultsetColumns(cursor: SqlDataReader, expected) =
248-
if Configuration.Current.ResultsetRuntimeVerification
248+
if FsharpDataSqlClientConfiguration.Current.ResultsetRuntimeVerification
249249
then
250250
if cursor.FieldCount < Array.length expected
251251
then
@@ -278,14 +278,14 @@ type ``ISqlCommand Implementation``(cfg: DesignTimeConfig, connection: Connectio
278278

279279
static member internal ExecuteDataTable(cmd, getReaderBehavior, parameters, expectedDataReaderColumns) =
280280
use cursor = ``ISqlCommand Implementation``.ExecuteReader(cmd, getReaderBehavior, parameters, expectedDataReaderColumns)
281-
let result = new FSharp.Data.DataTable<DataRow>(cmd)
281+
let result = new DataTable<DataRow>(cmd)
282282
result.Load(cursor)
283283
result
284284

285285
static member internal AsyncExecuteDataTable(cmd, getReaderBehavior, parameters, expectedDataReaderColumns) =
286286
async {
287287
use! reader = ``ISqlCommand Implementation``.AsyncExecuteReader(cmd, getReaderBehavior, parameters, expectedDataReaderColumns)
288-
let result = new FSharp.Data.DataTable<DataRow>(cmd)
288+
let result = new DataTable<DataRow>(cmd)
289289
result.Load(reader)
290290
return result
291291
}
@@ -370,3 +370,15 @@ type ``ISqlCommand Implementation``(cfg: DesignTimeConfig, connection: Connectio
370370
use _ = cmd.Connection.UseLocally(manageConnection )
371371
return! cmd.AsyncExecuteNonQuery()
372372
}
373+
374+
#if WITH_LEGACY_NAMESPACE
375+
namespace FSharp.Data
376+
open System
377+
open System.Data
378+
[<Obsolete("use 'FSharp.Data.SqlClient.Internals.``ISqlCommand Implementation``' instead");AutoOpen>]
379+
type ``ISqlCommand Implementation`` = FSharp.Data.SqlClient.Internals.``ISqlCommand Implementation``
380+
[<Obsolete("use 'FSharp.Data.SqlClient.Internals.ISqlCommand' instead");AutoOpen>]
381+
type ISqlCommand = FSharp.Data.SqlClient.Internals.ISqlCommand
382+
[<Obsolete("use 'FSharp.Data.SqlClient.Internals.DesignTimeConfig' instead");AutoOpen>]
383+
type DesignTimeConfig = FSharp.Data.SqlClient.Internals.DesignTimeConfig
384+
#endif

0 commit comments

Comments
 (0)