24 |
25 | > NOTE: Use ``FSharp.Data.TypeProviders`` instead of ``Microsoft.FSharp.Data.TypeProviders``
26 |
27 |
28 | This component contains the following F# type providers:
29 |
30 | * [EdmxFile](edmx.html) - Provides the types to access a database with the schema in an .edmx file, using a LINQ to Entities mapping.
31 |
32 | * [ODataService](odata.html) - Provides the types to access an OData service.
33 |
34 | * [SqlDataConnection](sqldata.html) - Provides the types to access a SQL database.
35 |
36 | * [SqlEntityConnection](sqlentity.html) - Provides the types to access a database, using a LINQ to Entities mapping.
37 |
38 | * [WsdlService](wsdl.html) - Provides the types for a Web Services Description Language (WSDL) web service.
39 |
40 | * [DbmlFile](dbml.html) - Provides the types for a database schema encoded in a .dbml file.
41 |
42 |
43 | History
44 | -------
45 |
46 | This component is shipped in the Visual F# Tools for Visual Studio 2012-2015 at version 4.3.0.0.
47 | This repository implemented versions 5.0.0.0 and above. The proposal is that
48 | subsequent versions and development will happen as an F# community component.
49 |
50 | Referencing the library
51 | -------
52 |
53 | Reference the library as shown below.
54 |
55 | *)
56 | #r "nuget: FSharp.Data.TypeProviders"
57 | open FSharp.Data.TypeProviders
58 |
59 |
60 |
61 |
62 | (**
63 |
64 |
65 | Contributing and copyright
66 | --------------------------
67 |
68 | The project is hosted on [GitHub][gh] where you can [report issues][issues], fork
69 | the project and submit pull requests. If you're adding a new public API, please also
70 | consider adding [samples][content] that can be turned into a documentation. You might
71 | also want to read the [library design notes][readme] to understand how it works.
72 |
73 | The library is available under the Apache 2.0 license, which allows modification and
74 | redistribution for both commercial and non-commercial purposes. For more information see the
75 | [License file][license] in the GitHub repository.
76 |
77 | [content]: https://github.com/fsprojects/FSharp.Data.TypeProviders/tree/main/docs/content
78 | [gh]: https://github.com/fsprojects/FSharp.Data.TypeProviders
79 | [issues]: https://github.com/fsprojects/FSharp.Data.TypeProviders/issues
80 | [readme]: https://github.com/fsprojects/FSharp.Data.TypeProviders/blob/main/README.md
81 | [license]: https://github.com/fsprojects/FSharp.Data.TypeProviders/blob/main/LICENSE.txt
82 | *)
83 |
--------------------------------------------------------------------------------
/docs/odata.fsx:
--------------------------------------------------------------------------------
1 | (*** hide ***)
2 | // This block of code is omitted in the generated HTML documentation. Use
3 | // it to define helpers that you do not want to show in the documentation.
4 | #I "../bin"
5 |
6 | (**
7 | The ODataService Type Provider (FSharp.Data.TypeProviders)
8 | ========================
9 |
10 |
11 | Please see [Archived Walkthrough: Accessing an OData Service by Using Type Providers](https://web.archive.org/web/20140704061901/https://msdn.microsoft.com/en-us/library/hh156504.aspx)
12 |
13 | > NOTE: Use ``FSharp.Data.TypeProviders`` instead of ``Microsoft.FSharp.Data.TypeProviders``
14 |
15 | Reference
16 | ---------
17 |
18 | Please see the [Archived MSDN Documentation](https://web.archive.org/web/20140301090938/https://msdn.microsoft.com/en-us/library/hh362325.aspx)
19 |
20 | Example
21 | ---------
22 |
23 | See below for a micro use of the type provider:
24 |
25 | *)
26 | #r "nuget: FSharp.Data.TypeProviders"
27 | open FSharp.Data.TypeProviders
28 |
29 | type OData1= ODataService< @"http://services.odata.org/V2/OData/OData.svc/">
30 |
31 | type ST = OData1.ServiceTypes
32 | type Address = OData1.ServiceTypes.Address
33 | module M =
34 | let ctx = OData1.GetDataContext()
35 |
--------------------------------------------------------------------------------
/docs/sqldata.fsx:
--------------------------------------------------------------------------------
1 | (*** hide ***)
2 | // This block of code is omitted in the generated HTML documentation. Use
3 | // it to define helpers that you do not want to show in the documentation.
4 | #I "../bin"
5 |
6 | (**
7 | The SqlDataConnection Type Provider (FSharp.Data.TypeProviders)
8 | ========================
9 |
10 | Please see [Archived Walkthrough: Accessing a SQL Database by Using Type Providers](https://web.archive.org/web/20140625103027/https://msdn.microsoft.com/en-us/library/hh361033.aspx)
11 |
12 | > NOTE: Use ``FSharp.Data.TypeProviders`` instead of ``Microsoft.FSharp.Data.TypeProviders``
13 |
14 | Reference
15 | ---------
16 |
17 | Please see the [Archived MSDN Documentation](https://web.archive.org/web/20140704072705/https://msdn.microsoft.com/en-us/library/hh362320.aspx)
18 |
19 |
20 | Example
21 | ---------
22 |
23 | See below for a micro example use of the type provider:
24 |
25 | *)
26 | #r "System.Data.Linq.dll"
27 | #r "nuget: FSharp.Data.TypeProviders"
28 | open FSharp.Data.TypeProviders
29 |
30 | // The database connection string
31 | let [] CONN =
32 | @"AttachDBFileName='C:\DB\NORTHWND.MDF';Server='(localdb)\MSSQLLocalDB'"
33 |
34 | // Connect to the database at compile-time
35 | type SqlData1 = SqlDataConnection
36 |
37 | // Connect to the database at runtime
38 | let ctxt = SqlData1.GetDataContext()
39 |
40 | // Execute a query
41 | let categories =
42 | query { for d in ctxt.Categories do
43 | where (d.CategoryID > 10)
44 | select (d.CategoryName, d.Description) }
45 |
--------------------------------------------------------------------------------
/docs/sqlentity.fsx:
--------------------------------------------------------------------------------
1 | (*** hide ***)
2 | // This block of code is omitted in the generated HTML documentation. Use
3 | // it to define helpers that you do not want to show in the documentation.
4 | #I "../bin"
5 |
6 | (**
7 | The SqlEntityConnection Type Provider (FSharp.Data.TypeProviders)
8 | ========================
9 |
10 | Please see [Archived Walkthrough: Accessing a SQL Database by Using Type Providers and Entities](https://web.archive.org/web/20130726000319/https://msdn.microsoft.com/en-us/library/hh361035.aspx)
11 |
12 | > NOTE: Use ``FSharp.Data.TypeProviders`` instead of ``Microsoft.FSharp.Data.TypeProviders``
13 |
14 | Reference
15 | ---------
16 |
17 | Please see the [Archived MSDN Documentation](https://web.archive.org/web/20130727141440/https://msdn.microsoft.com/en-us/library/hh362322.aspx)
18 |
19 | Example
20 | ---------
21 |
22 | See below for a micro example use of the type provider:
23 |
24 | *)
25 | #r "System.Data.Entity"
26 | #r "nuget: FSharp.Data.TypeProviders"
27 | open FSharp.Data.TypeProviders
28 |
29 | // The database connection string
30 | let [] CONN = @"AttachDBFileName = 'C:\GitHub\fsprojects\FSharp.Data.TypeProviders\tests\FSharp.Data.TypeProviders.Tests\SqlDataConnection\DB\NORTHWND.MDF';Server='(localdb)\MSSQLLocalDB'"
31 |
32 | // Connect to the database at compile-time
33 | type Northwnd = SqlEntityConnection
34 |
35 | // Connect to the database at runtime
36 | let ctxt = Northwnd.GetDataContext()
37 |
38 | // Execute a query
39 | let categories =
40 | query { for d in ctxt.Categories do
41 | where (d.CategoryID > 10)
42 | select (d.CategoryName, d.Description) }
--------------------------------------------------------------------------------
/docs/tutorial.fsx:
--------------------------------------------------------------------------------
1 | (*** hide ***)
2 | // This block of code is omitted in the generated HTML documentation. Use
3 | // it to define helpers that you do not want to show in the documentation.
4 | #I "../bin"
5 |
6 | (**
7 | Introducing your project
8 | ========================
9 |
10 | Say more
11 |
12 | *)
13 | #r "nuget: FSharp.Data.TypeProviders"
14 | open FSharp.Data.TypeProviders
15 |
16 | (**
17 | Some more info
18 | *)
19 |
--------------------------------------------------------------------------------
/docs/wsdl.fsx:
--------------------------------------------------------------------------------
1 | (*** hide ***)
2 | // This block of code is omitted in the generated HTML documentation. Use
3 | // it to define helpers that you do not want to show in the documentation.
4 | #I "../bin"
5 |
6 | (**
7 | The WsdlService Type Provider (FSharp.Data.TypeProviders)
8 | ========================
9 |
10 | Please see [Archived Walkthrough: Archived: Accessing a Web Service by Using Type Providers](https://web.archive.org/web/20131207011653/http://msdn.microsoft.com/en-us/library/hh156503.aspx)
11 |
12 | > NOTE: Use ``FSharp.Data.TypeProviders`` instead of ``Microsoft.FSharp.Data.TypeProviders``
13 |
14 | Reference
15 | ---------
16 |
17 | Please see the [Archived MSDN Documentation](https://web.archive.org/web/20131013140233/http://msdn.microsoft.com/en-us/library/hh362328.aspx)
18 |
19 | Example
20 | ------
21 |
22 | See below for a micro example use of the type provider:
23 |
24 | *)
25 | #r "System.ServiceModel"
26 | #r "nuget: FSharp.Data.TypeProviders"
27 | open FSharp.Data.TypeProviders
28 |
29 | type Wsdl1 = WsdlService<"http://api.microsofttranslator.com/V2/Soap.svc">
30 |
31 | let ctxt = Wsdl1.GetBasicHttpBinding_LanguageService()
32 |
--------------------------------------------------------------------------------
/src/FSharp.Data.TypeProviders/AssemblyInfo.fs:
--------------------------------------------------------------------------------
1 | // Auto-Generated by FAKE; do not edit
2 | namespace System
3 | open System.Reflection
4 |
5 | []
6 | []
7 | []
8 | []
9 | []
10 | do ()
11 |
12 | module internal AssemblyVersionInformation =
13 | let [] AssemblyTitle = "FSharp.Data.TypeProviders"
14 | let [] AssemblyProduct = "FSharp.Data.TypeProviders"
15 | let [] AssemblyDescription = "F# Type Providers using .NET Framework generators, was FSharp.Data.TypeProviders.dll"
16 | let [] AssemblyVersion = "5.0.0.6"
17 | let [] AssemblyFileVersion = "5.0.0.6"
18 |
--------------------------------------------------------------------------------
/src/FSharp.Data.TypeProviders/FSData.fs:
--------------------------------------------------------------------------------
1 | namespace FSData
2 |
3 | open Microsoft.FSharp.Core.LanguagePrimitives.IntrinsicOperators
4 | open Microsoft.FSharp.Reflection
5 | open System.Reflection
6 | // (namespaces below for specific case of using the tool to compile FSharp.Core itself)
7 | open Microsoft.FSharp.Core
8 | open Microsoft.FSharp.Core.Operators
9 | open Microsoft.FSharp.Text
10 | open Microsoft.FSharp.Collections
11 | open Printf
12 |
13 | type internal SR private() =
14 |
15 | static let resources = lazy (new System.Resources.ResourceManager("FSharp.Data.TypeProviders.FSData", System.Reflection.Assembly.GetExecutingAssembly()))
16 |
17 | static let GetString(name:string) =
18 | let s = resources.Value.GetString(name, System.Globalization.CultureInfo.CurrentUICulture)
19 | #if DEBUG
20 | if null = s then
21 | System.Diagnostics.Debug.Assert(false, sprintf "**RESOURCE ERROR**: Resource token %s does not exist!" name)
22 | #endif
23 | s
24 |
25 | static let mkFunctionValue (tys: System.Type[]) (impl:obj->obj) =
26 | FSharpValue.MakeFunction(FSharpType.MakeFunctionType(tys.[0],tys.[1]), impl)
27 |
28 | static let funTyC = typeof<(obj -> obj)>.GetGenericTypeDefinition()
29 |
30 | static let isNamedType(ty:System.Type) = not (ty.IsArray || ty.IsByRef || ty.IsPointer)
31 | static let isFunctionType (ty1:System.Type) =
32 | isNamedType(ty1) && ty1.IsGenericType && (ty1.GetGenericTypeDefinition()).Equals(funTyC)
33 |
34 | static let rec destFunTy (ty:System.Type) =
35 | if isFunctionType ty then
36 | ty, ty.GetGenericArguments()
37 | else
38 | match ty.BaseType with
39 | | null -> failwith "destFunTy: not a function type"
40 | | b -> destFunTy b
41 |
42 | static let buildFunctionForOneArgPat (ty: System.Type) impl =
43 | let _,tys = destFunTy ty
44 | let rty = tys.[1]
45 | // PERF: this technique is a bit slow (e.g. in simple cases, like 'sprintf "%x"')
46 | mkFunctionValue tys (fun inp -> impl rty inp)
47 |
48 | static let capture1 (fmt:string) i args ty (go : obj list -> System.Type -> int -> obj) : obj =
49 | match fmt.[i] with
50 | | '%' -> go args ty (i+1)
51 | | 'd'
52 | | 'f'
53 | | 's' -> buildFunctionForOneArgPat ty (fun rty n -> go (n::args) rty (i+1))
54 | | _ -> failwith "bad format specifier"
55 |
56 | // newlines and tabs get converted to strings when read from a resource file
57 | // this will preserve their original intention
58 | static let postProcessString (s : string) =
59 | s.Replace("\\n","\n").Replace("\\t","\t").Replace("\\r","\r").Replace("\\\"", "\"")
60 |
61 | static let createMessageString (messageString : string) (fmt : Printf.StringFormat<'T>) : 'T =
62 | let fmt = fmt.Value // here, we use the actual error string, as opposed to the one stored as fmt
63 | let len = fmt.Length
64 |
65 | /// Function to capture the arguments and then run.
66 | let rec capture args ty i =
67 | if i >= len || (fmt.[i] = '%' && i+1 >= len) then
68 | let b = new System.Text.StringBuilder()
69 | b.AppendFormat(messageString, [| for x in List.rev args -> x |]) |> ignore
70 | box(b.ToString())
71 | // REVIEW: For these purposes, this should be a nop, but I'm leaving it
72 | // in incase we ever decide to support labels for the error format string
73 | // E.g., "%s%d"
74 | elif System.Char.IsSurrogatePair(fmt,i) then
75 | capture args ty (i+2)
76 | else
77 | match fmt.[i] with
78 | | '%' ->
79 | let i = i+1
80 | capture1 fmt i args ty capture
81 | | _ ->
82 | capture args ty (i+1)
83 |
84 | (unbox (capture [] (typeof<'T>) 0) : 'T)
85 |
86 | static let mutable swallowResourceText = false
87 |
88 | static let GetStringFunc((messageID : string),(fmt : Printf.StringFormat<'T>)) : 'T =
89 | if swallowResourceText then
90 | sprintf fmt
91 | else
92 | let mutable messageString = GetString(messageID)
93 | messageString <- postProcessString messageString
94 | createMessageString messageString fmt
95 |
96 | /// If set to true, then all error messages will just return the filled 'holes' delimited by ',,,'s - this is for language-neutral testing (e.g. localization-invariant baselines).
97 | static member SwallowResourceText with get () = swallowResourceText
98 | and set (b) = swallowResourceText <- b
99 | // END BOILERPLATE
100 |
101 | /// The .NET SDK 4.0 or 4.5 tools could not be found
102 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:7)
103 | static member unsupportedFramework() = (GetStringFunc("unsupportedFramework",",,,") )
104 | /// The operation '%s' on item '%s' should not be called on provided type, member or parameter
105 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:13)
106 | static member invalidOperationOnProvidedType(a0 : System.String, a1 : System.String) = (GetStringFunc("invalidOperationOnProvidedType",",,,%s,,,%s,,,") a0 a1)
107 | /// constructor for %s
108 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:14)
109 | static member constructorFor(a0 : System.String) = (GetStringFunc("constructorFor",",,,%s,,,") a0)
110 | ///
111 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:15)
112 | static member notYetKnownType() = (GetStringFunc("notYetKnownType",",,,") )
113 | /// ProvidedConstructor: declaringType already set on '%s'
114 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:16)
115 | static member declaringTypeAlreadySet(a0 : System.String) = (GetStringFunc("declaringTypeAlreadySet",",,,%s,,,") a0)
116 | /// ProvidedConstructor: no invoker for '%s'
117 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:17)
118 | static member pcNoInvoker(a0 : System.String) = (GetStringFunc("pcNoInvoker",",,,%s,,,") a0)
119 | /// ProvidedConstructor: code already given for '%s'
120 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:18)
121 | static member pcCodeAlreadyGiven(a0 : System.String) = (GetStringFunc("pcCodeAlreadyGiven",",,,%s,,,") a0)
122 | /// ProvidedMethod: no invoker for %s on type %s
123 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:19)
124 | static member pmNoInvokerName(a0 : System.String, a1 : System.String) = (GetStringFunc("pmNoInvokerName",",,,%s,,,%s,,,") a0 a1)
125 | /// ProvidedConstructor: code already given for %s on type %s
126 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:20)
127 | static member pcNoInvokerName(a0 : System.String, a1 : System.String) = (GetStringFunc("pcNoInvokerName",",,,%s,,,%s,,,") a0 a1)
128 | /// ProvidedProperty: getter MethodInfo has already been created
129 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:21)
130 | static member ppGetterAlreadyCreated() = (GetStringFunc("ppGetterAlreadyCreated",",,,") )
131 | /// ProvidedProperty: setter MethodInfo has already been created
132 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:22)
133 | static member ppSetterAlreadyCreated() = (GetStringFunc("ppSetterAlreadyCreated",",,,") )
134 | /// unreachable
135 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:23)
136 | static member unreachable() = (GetStringFunc("unreachable",",,,") )
137 | /// non-array type
138 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:24)
139 | static member nonArrayType() = (GetStringFunc("nonArrayType",",,,") )
140 | /// non-generic type
141 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:25)
142 | static member nonGenericType() = (GetStringFunc("nonGenericType",",,,") )
143 | /// not an array, pointer or byref type
144 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:26)
145 | static member notAnArrayPointerOrByref() = (GetStringFunc("notAnArrayPointerOrByref",",,,") )
146 | /// Unit '%s' not found in FSharp.Core SI module
147 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:27)
148 | static member unitNotFound(a0 : System.String) = (GetStringFunc("unitNotFound",",,,%s,,,") a0)
149 | /// Use 'null' for global namespace
150 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:28)
151 | static member useNullForGlobalNamespace() = (GetStringFunc("useNullForGlobalNamespace",",,,") )
152 | /// type '%s' was not added as a member to a declaring type
153 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:29)
154 | static member typeNotAddedAsAMember(a0 : System.String) = (GetStringFunc("typeNotAddedAsAMember",",,,%s,,,") a0)
155 | /// ProvidedTypeDefinition: expecting %d static parameters but given %d for type %s
156 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:30)
157 | static member pdErrorExpectingStaticParameters(a0 : System.Int32, a1 : System.Int32, a2 : System.String) = (GetStringFunc("pdErrorExpectingStaticParameters",",,,%d,,,%d,,,%s,,,") a0 a1 a2)
158 | /// ProvidedTypeDefinition: DefineStaticParameters was not called
159 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:31)
160 | static member pdDefineStaticParametersNotCalled() = (GetStringFunc("pdDefineStaticParametersNotCalled",",,,") )
161 | /// ProvidedTypeDefinition: static parameters supplied but not expected for %s
162 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:32)
163 | static member ptdStaticParametersSuppliedButNotExpected(a0 : System.String) = (GetStringFunc("ptdStaticParametersSuppliedButNotExpected",",,,%s,,,") a0)
164 | /// container type for '%s' was already set to '%s'
165 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:33)
166 | static member containerTypeAlreadySet(a0 : System.String, a1 : System.String) = (GetStringFunc("containerTypeAlreadySet",",,,%s,,,%s,,,") a0 a1)
167 | /// GetMethodImpl does not support overloads
168 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:34)
169 | static member getMethodImplDoesNotSupportOverloads() = (GetStringFunc("getMethodImplDoesNotSupportOverloads",",,,") )
170 | /// Need to handle specified return type in GetPropertyImpl
171 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:35)
172 | static member gpiNeedToHandleSpecifiedReturnType() = (GetStringFunc("gpiNeedToHandleSpecifiedReturnType",",,,") )
173 | /// Need to handle specified parameter types in GetPropertyImpl
174 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:36)
175 | static member gpiNeedToHandleSpecifiedParameterTypes() = (GetStringFunc("gpiNeedToHandleSpecifiedParameterTypes",",,,") )
176 | /// Need to handle specified modifiers in GetPropertyImpl
177 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:37)
178 | static member gpiNeedToHandleSpecifiedModifiers() = (GetStringFunc("gpiNeedToHandleSpecifiedModifiers",",,,") )
179 | /// Need to handle binder in GetPropertyImpl
180 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:38)
181 | static member gpiNeedToHandleBinder() = (GetStringFunc("gpiNeedToHandleBinder",",,,") )
182 | /// There is more than one nested type called '%s' in type '%s'
183 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:39)
184 | static member moreThanOneNestedType(a0 : System.String, a1 : System.String) = (GetStringFunc("moreThanOneNestedType",",,,%s,,,%s,,,") a0 a1)
185 | /// Error writing to local schema file. %s
186 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:45)
187 | static member errorWritingLocalSchemaFile(a0 : System.String) = (GetStringFunc("errorWritingLocalSchemaFile",",,,%s,,,") a0)
188 | /// Error reading schema. %s
189 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:46)
190 | static member errorReadingSchema(a0 : System.String) = (GetStringFunc("errorReadingSchema",",,,%s,,,") a0)
191 | /// The extension of the given LocalSchema file '%s' is not valid. The required extension is '%s'.
192 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:47)
193 | static member errorInvalidExtensionSchema(a0 : System.String, a1 : System.String) = (GetStringFunc("errorInvalidExtensionSchema",",,,%s,,,%s,,,") a0 a1)
194 | /// The file '%s' doesn't contain XML element '%s'
195 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:48)
196 | static member fileDoesNotContainXMLElement(a0 : System.String, a1 : System.String) = (GetStringFunc("fileDoesNotContainXMLElement",",,,%s,,,%s,,,") a0 a1)
197 | /// Failed to load the file '%s' as XML
198 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:49)
199 | static member failedToLoadFileAsXML(a0 : System.String) = (GetStringFunc("failedToLoadFileAsXML",",,,%s,,,") a0)
200 | /// Contains the simplified context types for the %s
201 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:55)
202 | static member xmlDocContainsTheSimplifiedContextTypes(a0 : System.String) = (GetStringFunc("xmlDocContainsTheSimplifiedContextTypes",",,,%s,,,") a0)
203 | /// The full API to the %s.To use the service via the full API, create an instance of one of the types %s.You may need to set the Credentials property on the instance.
204 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:56)
205 | static member xmlDocFullServiceTypesAPI(a0 : System.String, a1 : System.String) = (GetStringFunc("xmlDocFullServiceTypesAPI",",,,%s,,,%s,,,") a0 a1)
206 | /// The full API to the %s.To use the service via the full API, create an instance of one of the types %s.
207 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:57)
208 | static member xmlDocFullServiceTypesAPINoCredentials(a0 : System.String, a1 : System.String) = (GetStringFunc("xmlDocFullServiceTypesAPINoCredentials",",,,%s,,,%s,,,") a0 a1)
209 | /// A simplified data context for the %s. The full data context object is available via the DataContext property.
210 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:58)
211 | static member xmlDocSimplifiedDataContext(a0 : System.String) = (GetStringFunc("xmlDocSimplifiedDataContext",",,,%s,,,") a0)
212 | /// Execute the '%s' procedure
213 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:59)
214 | static member xmlDocExecuteProcedure(a0 : System.String) = (GetStringFunc("xmlDocExecuteProcedure",",,,%s,,,") a0)
215 | /// Gets the '%s' entities from the %s. This property may be used as the source in a query expression.
216 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:60)
217 | static member xmlDocGetEntities(a0 : System.String, a1 : System.String) = (GetStringFunc("xmlDocGetEntities",",,,%s,,,%s,,,") a0 a1)
218 | /// Gets the full data context object for this %s
219 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:61)
220 | static member xmlDocGetFullContext(a0 : System.String) = (GetStringFunc("xmlDocGetFullContext",",,,%s,,,") a0)
221 | /// Get a simplified data context for this %s. By default, no credentials are set
222 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:62)
223 | static member xmlDocGetSimplifiedContext(a0 : System.String) = (GetStringFunc("xmlDocGetSimplifiedContext",",,,%s,,,") a0)
224 | /// Construct a simplified data context for this %s. By default, no credentials are set
225 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:63)
226 | static member xmlDocConstructSimplifiedContext(a0 : System.String) = (GetStringFunc("xmlDocConstructSimplifiedContext",",,,%s,,,") a0)
227 | /// Provides the types to access a database with the schema in a DBML file, using a LINQ-to-SQL mappingThe DBML file containing the schema descriptionThe folder used to resolve relative file paths at compile-time (default: folder containing the project or script)The name of data context class (default: derived from database name)Generate uni-directional serializable classes (default: false, which means no serialization)
228 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:64)
229 | static member dbmlFileTypeHelp() = (GetStringFunc("dbmlFileTypeHelp",",,,") )
230 | /// SQL connection
231 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:65)
232 | static member sqlDataConnection() = (GetStringFunc("sqlDataConnection",",,,") )
233 | /// Gets the connection used by the framework
234 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:66)
235 | static member sqlDataConnectionInfo() = (GetStringFunc("sqlDataConnectionInfo",",,,") )
236 | /// Provides the types to access a database, using a LINQ-to-SQL mappingThe connection string for the database connection. If using Visual Studio, a connection string can be found in database properties in the Server Explorer window.The name of the connection string for the database connection in the configuration file.The local .dbml file for the database schema (default: no local schema file)Require that a direct connection to the database be available at design-time and force the refresh of the local schema file (default: true)Automatically pluralize or singularize class and member names using English language rules (default: false)Extract database views (default: true)Extract database functions (default: true)The name of the configuration file used for connection strings (default: app.config or web.config is used)The name of the data directory, used to replace |DataDirectory| in connection strings (default: the project or script directory)The folder used to resolve relative file paths at compile-time (default: folder containing the project or script)Extract stored procedures (default: true)Timeout value in seconds to use when SqlMetal accesses the database (default: 0, which means infinite)The name of data context class (default: derived from database name)Generate uni-directional serializable classes (default: false, which means no serialization)
237 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:67)
238 | static member sqlDataConnectionTypeHelp() = (GetStringFunc("sqlDataConnectionTypeHelp",",,,") )
239 | /// Provides the types to access a database with the schema in an EDMX file, using a LINQ-to-Entities mappingThe EDMX file containing the conceptual, storage and mapping schema descriptionsThe folder used to resolve relative file paths at compile-time (default: folder containing the project or script)
240 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:68)
241 | static member edmxFileTypeHelp() = (GetStringFunc("edmxFileTypeHelp",",,,") )
242 | /// SQL Entity connection
243 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:69)
244 | static member sqlEntityConnection() = (GetStringFunc("sqlEntityConnection",",,,") )
245 | /// Provides the types to access a database, using a LINQ-to-Entities mappingThe connection string for the database connectionThe name of the connection string for the database connection in the configuration file.The local file for the database schemaThe name of the ADO.NET data provider to be used for ssdl generation (default: System.Data.SqlClient)The name to use for the EntityContainer in the conceptual modelThe name of the configuration file used for connection strings (default: app.config or web.config is used)The name of the data directory, used to replace |DataDirectory| in connection strings (default: the project or script directory)The folder used to resolve relative file paths at compile-time (default: folder containing the project or script)Require that a direct connection to the database be available at design-time and force the refresh of the local schema file (default: true)Automatically pluralize or singularize class and member names using English language rules (default: false)Exclude foreign key properties in entity type definitions (default: false)
246 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:70)
247 | static member sqlEntityConnectionTypeHelp() = (GetStringFunc("sqlEntityConnectionTypeHelp",",,,") )
248 | /// Gets the connection used by the object context
249 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:71)
250 | static member connectionInfo() = (GetStringFunc("connectionInfo",",,,") )
251 | /// Gets or sets the authentication information used by each query for this data context object
252 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:72)
253 | static member odataServiceCredentialsInfo() = (GetStringFunc("odataServiceCredentialsInfo",",,,") )
254 | /// Provides the types to access an OData serviceThe Uri for the OData serviceThe local .csdl file for the service schemaRequire that a direct connection to the service be available at design-time and force the refresh of the local schema file (default: true)The folder used to resolve relative file paths at compile-time (default: folder containing the project or script)Generate collections derived from DataServiceCollection (default: false)
255 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:73)
256 | static member odataServiceTypeHelp() = (GetStringFunc("odataServiceTypeHelp",",,,") )
257 | /// Provides the types to access a WSDL web serviceThe Uri for the WSDL serviceThe .wsdlschema file to store locally cached service schemaRequire that a direct connection to the service be available at design-time and force the refresh of the local schema file (default: true)The folder used to resolve relative file paths at compile-time (default: folder containing the project or script)Generate Message Contract types (default: false)Implement the System.ComponentModel.INotifyPropertyChanged interface on all DataContract types to enable data binding (default: false)Generate classes marked with the Serializable Attribute (default: false)Generate both synchronous and asynchronous method signatures (default: false, which means generate only synchronous method signatures)A fully-qualified or assembly-qualified name of the type to use as a collection data type when code is generated from schemasControls whether special-casing is used for document-literal styled documents with wrapped parameters (default: false)
258 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:74)
259 | static member wsdlServiceTypeHelp() = (GetStringFunc("wsdlServiceTypeHelp",",,,") )
260 | /// static parameter '%s' not found for type '%s'
261 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:75)
262 | static member staticParameterNotFoundForType(a0 : System.String, a1 : System.String) = (GetStringFunc("staticParameterNotFoundForType",",,,%s,,,%s,,,") a0 a1)
263 | /// unexpected MethodBase
264 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:76)
265 | static member unexpectedMethodBase() = (GetStringFunc("unexpectedMethodBase",",,,") )
266 | /// Disposes the given context
267 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:77)
268 | static member xmlDocDisposeSimplifiedContext() = (GetStringFunc("xmlDocDisposeSimplifiedContext",",,,") )
269 | /// %s is not valid name for data context class
270 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:78)
271 | static member invalidDataContextClassName(a0 : System.String) = (GetStringFunc("invalidDataContextClassName",",,,%s,,,") a0)
272 | /// The provided ServiceUri is for a data service that supports fixed queries. The OData type provider does not support such services.
273 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:79)
274 | static member fixedQueriesNotSupported() = (GetStringFunc("fixedQueriesNotSupported",",,,") )
275 | /// Services that implement the Data Quality Services API are not supported.
276 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:80)
277 | static member dqsServicesNotSupported() = (GetStringFunc("dqsServicesNotSupported",",,,") )
278 | /// The supplied connection string should be either a valid provider-specific connection string or a valid connection string accepted by the EntityClient.
279 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:81)
280 | static member invalidConnectionString() = (GetStringFunc("invalidConnectionString",",,,") )
281 | /// Connection string presented in EntityClient format can differ only in provider-specific part.
282 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:82)
283 | static member nonEquivalentConnectionString() = (GetStringFunc("nonEquivalentConnectionString",",,,") )
284 | /// A configuration string name was specified but no configuration file was found. Neither app.config nor web.config found in project or script directory.
285 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:83)
286 | static member noConfigFileFound1() = (GetStringFunc("noConfigFileFound1",",,,") )
287 | /// A configuration string name was specified but the configuration file '%s' was not found
288 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:84)
289 | static member noConfigFileFound2(a0 : System.String) = (GetStringFunc("noConfigFileFound2",",,,%s,,,") a0)
290 | /// When using this provider you must specify either a connection string or a connection string name. To specify a connection string, use %s<\"...connection string...\">.
291 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:85)
292 | static member noConnectionStringOrConnectionStringName(a0 : System.String) = (GetStringFunc("noConnectionStringOrConnectionStringName",",,,%s,,,") a0)
293 | /// When using this provider you must specify either a connection string or a connection string name, but not both. To specify a connection string, use SqlDataConnection<\"...connection string...\">.
294 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:86)
295 | static member notBothConnectionStringOrConnectionStringName() = (GetStringFunc("notBothConnectionStringOrConnectionStringName",",,,") )
296 | /// Invalid provider '%s' in connection string entry '%s' in config file '%s'. SqlDataConnection can only be used with provider 'System.Data.SqlClient'.
297 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:87)
298 | static member invalidProviderInConfigFile(a0 : System.String, a1 : System.String, a2 : System.String) = (GetStringFunc("invalidProviderInConfigFile",",,,%s,,,%s,,,%s,,,") a0 a1 a2)
299 | /// Invalid empty connection string '%s' for the connection string name '%s' in config file '%s'
300 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:88)
301 | static member invalidConnectionStringInConfigFile(a0 : System.String, a1 : System.String, a2 : System.String) = (GetStringFunc("invalidConnectionStringInConfigFile",",,,%s,,,%s,,,%s,,,") a0 a1 a2)
302 | /// An error occured while reading connection string '%s' from the config file '%s': '%s'
303 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:89)
304 | static member errorWhileReadingConnectionStringInConfigFile(a0 : System.String, a1 : System.String, a2 : System.String) = (GetStringFunc("errorWhileReadingConnectionStringInConfigFile",",,,%s,,,%s,,,%s,,,") a0 a1 a2)
305 | /// ServiceMetadataFile element cannot be empty
306 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:90)
307 | static member serviceMetadataFileElementIsEmpty() = (GetStringFunc("serviceMetadataFileElementIsEmpty",",,,") )
308 | /// The parameter 'ServiceUri' cannot be an empty string.
309 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:91)
310 | static member invalidWsdlUri() = (GetStringFunc("invalidWsdlUri",",,,") )
311 | /// The required tool '%s' could not be found.
312 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:92)
313 | static member requiredToolNotFound(a0 : System.String) = (GetStringFunc("requiredToolNotFound",",,,%s,,,") a0)
314 | /// The data directory '%s' did not exist.
315 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:93)
316 | static member dataDirectoryNotFound(a0 : System.String) = (GetStringFunc("dataDirectoryNotFound",",,,%s,,,") a0)
317 | /// File '%s' requires .NET 4.5. To use this file please change project target framework to .NET 4.5.
318 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:94)
319 | static member edmxFileRequiresDotNet45(a0 : System.String) = (GetStringFunc("edmxFileRequiresDotNet45",",,,%s,,,") a0)
320 | /// Connection string '%s' not found in configuration file.
321 | /// (Originally from C:\GitHub\dsyme\visualfsharp\src\fsharp\FSharp.Data.TypeProviders\FSData.txt:95)
322 | static member connectionStringNotFound(a0 : System.String) = (GetStringFunc("connectionStringNotFound",",,,%s,,,") a0)
323 |
324 | /// Call this method once to validate that all known resources are valid; throws if not
325 | static member RunStartupValidation() =
326 | ignore(GetString("unsupportedFramework"))
327 | ignore(GetString("invalidOperationOnProvidedType"))
328 | ignore(GetString("constructorFor"))
329 | ignore(GetString("notYetKnownType"))
330 | ignore(GetString("declaringTypeAlreadySet"))
331 | ignore(GetString("pcNoInvoker"))
332 | ignore(GetString("pcCodeAlreadyGiven"))
333 | ignore(GetString("pmNoInvokerName"))
334 | ignore(GetString("pcNoInvokerName"))
335 | ignore(GetString("ppGetterAlreadyCreated"))
336 | ignore(GetString("ppSetterAlreadyCreated"))
337 | ignore(GetString("unreachable"))
338 | ignore(GetString("nonArrayType"))
339 | ignore(GetString("nonGenericType"))
340 | ignore(GetString("notAnArrayPointerOrByref"))
341 | ignore(GetString("unitNotFound"))
342 | ignore(GetString("useNullForGlobalNamespace"))
343 | ignore(GetString("typeNotAddedAsAMember"))
344 | ignore(GetString("pdErrorExpectingStaticParameters"))
345 | ignore(GetString("pdDefineStaticParametersNotCalled"))
346 | ignore(GetString("ptdStaticParametersSuppliedButNotExpected"))
347 | ignore(GetString("containerTypeAlreadySet"))
348 | ignore(GetString("getMethodImplDoesNotSupportOverloads"))
349 | ignore(GetString("gpiNeedToHandleSpecifiedReturnType"))
350 | ignore(GetString("gpiNeedToHandleSpecifiedParameterTypes"))
351 | ignore(GetString("gpiNeedToHandleSpecifiedModifiers"))
352 | ignore(GetString("gpiNeedToHandleBinder"))
353 | ignore(GetString("moreThanOneNestedType"))
354 | ignore(GetString("errorWritingLocalSchemaFile"))
355 | ignore(GetString("errorReadingSchema"))
356 | ignore(GetString("errorInvalidExtensionSchema"))
357 | ignore(GetString("fileDoesNotContainXMLElement"))
358 | ignore(GetString("failedToLoadFileAsXML"))
359 | ignore(GetString("xmlDocContainsTheSimplifiedContextTypes"))
360 | ignore(GetString("xmlDocFullServiceTypesAPI"))
361 | ignore(GetString("xmlDocFullServiceTypesAPINoCredentials"))
362 | ignore(GetString("xmlDocSimplifiedDataContext"))
363 | ignore(GetString("xmlDocExecuteProcedure"))
364 | ignore(GetString("xmlDocGetEntities"))
365 | ignore(GetString("xmlDocGetFullContext"))
366 | ignore(GetString("xmlDocGetSimplifiedContext"))
367 | ignore(GetString("xmlDocConstructSimplifiedContext"))
368 | ignore(GetString("dbmlFileTypeHelp"))
369 | ignore(GetString("sqlDataConnection"))
370 | ignore(GetString("sqlDataConnectionInfo"))
371 | ignore(GetString("sqlDataConnectionTypeHelp"))
372 | ignore(GetString("edmxFileTypeHelp"))
373 | ignore(GetString("sqlEntityConnection"))
374 | ignore(GetString("sqlEntityConnectionTypeHelp"))
375 | ignore(GetString("connectionInfo"))
376 | ignore(GetString("odataServiceCredentialsInfo"))
377 | ignore(GetString("odataServiceTypeHelp"))
378 | ignore(GetString("wsdlServiceTypeHelp"))
379 | ignore(GetString("staticParameterNotFoundForType"))
380 | ignore(GetString("unexpectedMethodBase"))
381 | ignore(GetString("xmlDocDisposeSimplifiedContext"))
382 | ignore(GetString("invalidDataContextClassName"))
383 | ignore(GetString("fixedQueriesNotSupported"))
384 | ignore(GetString("dqsServicesNotSupported"))
385 | ignore(GetString("invalidConnectionString"))
386 | ignore(GetString("nonEquivalentConnectionString"))
387 | ignore(GetString("noConfigFileFound1"))
388 | ignore(GetString("noConfigFileFound2"))
389 | ignore(GetString("noConnectionStringOrConnectionStringName"))
390 | ignore(GetString("notBothConnectionStringOrConnectionStringName"))
391 | ignore(GetString("invalidProviderInConfigFile"))
392 | ignore(GetString("invalidConnectionStringInConfigFile"))
393 | ignore(GetString("errorWhileReadingConnectionStringInConfigFile"))
394 | ignore(GetString("serviceMetadataFileElementIsEmpty"))
395 | ignore(GetString("invalidWsdlUri"))
396 | ignore(GetString("requiredToolNotFound"))
397 | ignore(GetString("dataDirectoryNotFound"))
398 | ignore(GetString("edmxFileRequiresDotNet45"))
399 | ignore(GetString("connectionStringNotFound"))
400 | ()
401 |
--------------------------------------------------------------------------------
/src/FSharp.Data.TypeProviders/FSData.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | The .NET SDK 4.0 or 4.5 tools could not be found
122 |
123 |
124 | The operation '{0}' on item '{1}' should not be called on provided type, member or parameter
125 |
126 |
127 | constructor for {0}
128 |
129 |
130 | <not yet known type>
131 |
132 |
133 | ProvidedConstructor: declaringType already set on '{0}'
134 |
135 |
136 | ProvidedConstructor: no invoker for '{0}'
137 |
138 |
139 | ProvidedConstructor: code already given for '{0}'
140 |
141 |
142 | ProvidedMethod: no invoker for {0} on type {1}
143 |
144 |
145 | ProvidedConstructor: code already given for {0} on type {1}
146 |
147 |
148 | ProvidedProperty: getter MethodInfo has already been created
149 |
150 |
151 | ProvidedProperty: setter MethodInfo has already been created
152 |
153 |
154 | unreachable
155 |
156 |
157 | non-array type
158 |
159 |
160 | non-generic type
161 |
162 |
163 | not an array, pointer or byref type
164 |
165 |
166 | Unit '{0}' not found in FSharp.Core SI module
167 |
168 |
169 | Use 'null' for global namespace
170 |
171 |
172 | type '{0}' was not added as a member to a declaring type
173 |
174 |
175 | ProvidedTypeDefinition: expecting {0} static parameters but given {1} for type {2}
176 |
177 |
178 | ProvidedTypeDefinition: DefineStaticParameters was not called
179 |
180 |
181 | ProvidedTypeDefinition: static parameters supplied but not expected for {0}
182 |
183 |
184 | container type for '{0}' was already set to '{1}'
185 |
186 |
187 | GetMethodImpl does not support overloads
188 |
189 |
190 | Need to handle specified return type in GetPropertyImpl
191 |
192 |
193 | Need to handle specified parameter types in GetPropertyImpl
194 |
195 |
196 | Need to handle specified modifiers in GetPropertyImpl
197 |
198 |
199 | Need to handle binder in GetPropertyImpl
200 |
201 |
202 | There is more than one nested type called '{0}' in type '{1}'
203 |
204 |
205 | Error writing to local schema file. {0}
206 |
207 |
208 | Error reading schema. {0}
209 |
210 |
211 | The extension of the given LocalSchema file '{0}' is not valid. The required extension is '{1}'.
212 |
213 |
214 | The file '{0}' doesn't contain XML element '{1}'
215 |
216 |
217 | Failed to load the file '{0}' as XML
218 |
219 |
220 | Contains the simplified context types for the {0}
221 |
222 |
223 | <summary><para>The full API to the {0}.</para><para>To use the service via the full API, create an instance of one of the types {1}.</para><para>You may need to set the Credentials property on the instance.</para></summary>
224 |
225 |
226 | <summary><para>The full API to the {0}.</para><para>To use the service via the full API, create an instance of one of the types {1}.</para></summary>
227 |
228 |
229 | A simplified data context for the {0}. The full data context object is available via the DataContext property.
230 |
231 |
232 | Execute the '{0}' procedure
233 |
234 |
235 | Gets the '{0}' entities from the {1}. This property may be used as the source in a query expression.
236 |
237 |
238 | Gets the full data context object for this {0}
239 |
240 |
241 | Get a simplified data context for this {0}. By default, no credentials are set
242 |
243 |
244 | Construct a simplified data context for this {0}. By default, no credentials are set
245 |
246 |
247 | <summary>Provides the types to access a database with the schema in a DBML file, using a LINQ-to-SQL mapping</summary><param name='File'>The DBML file containing the schema description</param><param name='ResolutionFolder'>The folder used to resolve relative file paths at compile-time (default: folder containing the project or script)</param><param name='ContextTypeName'>The name of data context class (default: derived from database name)</param><param name='Serializable'>Generate uni-directional serializable classes (default: false, which means no serialization)</param>
248 |
249 |
250 | SQL connection
251 |
252 |
253 | Gets the connection used by the framework
254 |
255 |
256 | <summary>Provides the types to access a database, using a LINQ-to-SQL mapping</summary><param name='ConnectionString'>The connection string for the database connection. If using Visual Studio, a connection string can be found in database properties in the Server Explorer window.</param><param name='ConnectionStringName'>The name of the connection string for the database connection in the configuration file.</param><param name='LocalSchemaFile'>The local .dbml file for the database schema (default: no local schema file)</param><param name='ForceUpdate'>Require that a direct connection to the database be available at design-time and force the refresh of the local schema file (default: true)</param><param name='Pluralize'>Automatically pluralize or singularize class and member names using English language rules (default: false)</param><param name='Views'>Extract database views (default: true)</param><param name='Functions'>Extract database functions (default: true)</param><param name='ConfigFile'>The name of the configuration file used for connection strings (default: app.config or web.config is used)</param><param name='DataDirectory'>The name of the data directory, used to replace |DataDirectory| in connection strings (default: the project or script directory)</param><param name='ResolutionFolder'>The folder used to resolve relative file paths at compile-time (default: folder containing the project or script)</param><param name='StoredProcedures'>Extract stored procedures (default: true)</param><param name='Timeout'>Timeout value in seconds to use when SqlMetal accesses the database (default: 0, which means infinite)</param><param name='ContextTypeName'>The name of data context class (default: derived from database name)</param><param name='Serializable'>Generate uni-directional serializable classes (default: false, which means no serialization)</param>
257 |
258 |
259 | <summary>Provides the types to access a database with the schema in an EDMX file, using a LINQ-to-Entities mapping</summary><param name='File'>The EDMX file containing the conceptual, storage and mapping schema descriptions</param><param name='ResolutionFolder'>The folder used to resolve relative file paths at compile-time (default: folder containing the project or script)</param>
260 |
261 |
262 | SQL Entity connection
263 |
264 |
265 | <summary>Provides the types to access a database, using a LINQ-to-Entities mapping</summary><param name='ConnectionString'>The connection string for the database connection</param><param name='ConnectionStringName'>The name of the connection string for the database connection in the configuration file.</param><param name='LocalSchemaFile'>The local file for the database schema</param><param name='Provider'>The name of the ADO.NET data provider to be used for ssdl generation (default: System.Data.SqlClient)</param><param name='EntityContainer'>The name to use for the EntityContainer in the conceptual model</param><param name='ConfigFile'>The name of the configuration file used for connection strings (default: app.config or web.config is used)</param><param name='DataDirectory'>The name of the data directory, used to replace |DataDirectory| in connection strings (default: the project or script directory)</param><param name='ResolutionFolder'>The folder used to resolve relative file paths at compile-time (default: folder containing the project or script)</param><param name='ForceUpdate'>Require that a direct connection to the database be available at design-time and force the refresh of the local schema file (default: true)</param><param name='Pluralize'>Automatically pluralize or singularize class and member names using English language rules (default: false)</param><param name='SuppressForeignKeyProperties'>Exclude foreign key properties in entity type definitions (default: false)</param>
266 |
267 |
268 | Gets the connection used by the object context
269 |
270 |
271 | Gets or sets the authentication information used by each query for this data context object
272 |
273 |
274 | <summary>Provides the types to access an OData service</summary><param name="ServiceUri">The Uri for the OData service</param><param name='LocalSchemaFile'>The local .csdl file for the service schema</param><param name='ForceUpdate'>Require that a direct connection to the service be available at design-time and force the refresh of the local schema file (default: true)</param><param name='ResolutionFolder'>The folder used to resolve relative file paths at compile-time (default: folder containing the project or script)</param><param name='DataServiceCollection'>Generate collections derived from DataServiceCollection (default: false)</param>
275 |
276 |
277 | <summary>Provides the types to access a WSDL web service</summary><param name='ServiceUri'>The Uri for the WSDL service</param><param name='LocalSchemaFile'>The .wsdlschema file to store locally cached service schema</param><param name='ForceUpdate'>Require that a direct connection to the service be available at design-time and force the refresh of the local schema file (default: true)</param><param name='ResolutionFolder'>The folder used to resolve relative file paths at compile-time (default: folder containing the project or script)</param><param name='MessageContract'>Generate Message Contract types (default: false)</param><param name='EnableDataBinding'>Implement the System.ComponentModel.INotifyPropertyChanged interface on all DataContract types to enable data binding (default: false)</param><param name='Serializable'>Generate classes marked with the Serializable Attribute (default: false)</param><param name='Async'>Generate both synchronous and asynchronous method signatures (default: false, which means generate only synchronous method signatures)</param><param name='CollectionType'>A fully-qualified or assembly-qualified name of the type to use as a collection data type when code is generated from schemas</param><param name='Wrapped'>Controls whether special-casing is used for document-literal styled documents with wrapped parameters (default: false)</param>><param name='SvcUtilPath'>Overrides the default resolution rules for SvcUtil.exe the type provider will resolve the location to the given path. (default: "")</param>
278 |
279 |
280 | static parameter '{0}' not found for type '{1}'
281 |
282 |
283 | unexpected MethodBase
284 |
285 |
286 | Disposes the given context
287 |
288 |
289 | {0} is not valid name for data context class
290 |
291 |
292 | The provided ServiceUri is for a data service that supports fixed queries. The OData type provider does not support such services.
293 |
294 |
295 | Services that implement the Data Quality Services API are not supported.
296 |
297 |
298 | The supplied connection string should be either a valid provider-specific connection string or a valid connection string accepted by the EntityClient.
299 |
300 |
301 | Connection string presented in EntityClient format can differ only in provider-specific part.
302 |
303 |
304 | A configuration string name was specified but no configuration file was found. Neither app.config nor web.config found in project or script directory.
305 |
306 |
307 | A configuration string name was specified but the configuration file '{0}' was not found
308 |
309 |
310 | When using this provider you must specify either a connection string or a connection string name. To specify a connection string, use {0}<\"...connection string...\">.
311 |
312 |
313 | When using this provider you must specify either a connection string or a connection string name, but not both. To specify a connection string, use SqlDataConnection<\"...connection string...\">.
314 |
315 |
316 | Invalid provider '{0}' in connection string entry '{1}' in config file '{2}'. SqlDataConnection can only be used with provider 'System.Data.SqlClient'.
317 |
318 |
319 | Invalid empty connection string '{0}' for the connection string name '{1}' in config file '{2}'
320 |
321 |
322 | An error occured while reading connection string '{0}' from the config file '{1}': '{2}'
323 |
324 |
325 | ServiceMetadataFile element cannot be empty
326 |
327 |
328 | The parameter 'ServiceUri' cannot be an empty string.
329 |
330 |
331 | The required tool '{0}' could not be found.
332 |
333 |
334 | The data directory '{0}' did not exist.
335 |
336 |
337 | File '{0}' requires .NET 4.5. To use this file please change project target framework to .NET 4.5.
338 |
339 |
340 | Connection string '{0}' not found in configuration file.
341 |
342 |
--------------------------------------------------------------------------------
/src/FSharp.Data.TypeProviders/FSharp.Data.TypeProviders.fsproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net45
5 | ..\..\bin
6 | 3218
7 | Old F# Type Providers using .NET Framework generators, for Linq-to-SQL, Linq-to-Entities, OData and WSDL
8 | 6.0.1
9 | Microsoft, F# Community Contributors (fsprojects)
10 | Old F# Type Providers using .NET Framework generators
11 | Microsoft, F# Community Contributors (fsprojects)
12 | MIT
13 | https://raw.githubusercontent.com/fsprojects/FSharp.Data.TypeProviders/main/docs/img/logo.png
14 | http://github.com/fsprojects/FSharp.Data.TypeProviders
15 | main
16 | git
17 | See https://github.com/fsprojects/FSharp.Data.TypeProviders/blob/main/RELEASE_NOTES.md
18 | true
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/src/FSharp.Data.TypeProviders/TypeProviderEmit.fsi:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
2 |
3 | namespace Internal.Utilities.TypeProvider.Emit
4 |
5 | open System
6 | open System.Reflection
7 | open System.Linq.Expressions
8 | open Microsoft.FSharp.Core.CompilerServices
9 |
10 |
11 | /// Represents an erased provided parameter
12 | type internal ProvidedParameter =
13 | inherit System.Reflection.ParameterInfo
14 | new : parameterName: string * parameterType: Type * ?isOut:bool * ?optionalValue:obj -> ProvidedParameter
15 |
16 |
17 | /// Represents an erased provided constructor.
18 | type internal ProvidedConstructor =
19 | inherit System.Reflection.ConstructorInfo
20 |
21 | /// Create a new provided constructor. It is not initially associated with any specific provided type definition.
22 | new : parameters: ProvidedParameter list -> ProvidedConstructor
23 |
24 | /// Add a 'System.Obsolete' attribute to this provided constructor
25 | member AddObsoleteAttribute : message: string * ?isError: bool -> unit
26 |
27 | /// Add XML documentation information to this provided constructor
28 | member AddXmlDoc : xmlDoc: string -> unit
29 |
30 | /// Add XML documentation information to this provided constructor, where the computation of the documentation is delayed until necessary
31 | member AddXmlDocDelayed : xmlDocFunction: (unit -> string) -> unit
32 |
33 | /// Add XML documentation information to this provided constructor, where the documentation is re-computed every time it is required.
34 | member AddXmlDocComputed : xmlDocFunction: (unit -> string) -> unit
35 |
36 | /// Set the quotation used to compute the implementation of invocations of this constructor.
37 | member InvokeCode : (Quotations.Expr list -> Quotations.Expr) with set
38 |
39 | /// Set the function used to compute the implementation of invocations of this constructor.
40 | member InvokeCodeInternal : (Quotations.Expr[] -> Quotations.Expr) with get,set
41 |
42 | /// Add definition location information to the provided constructor.
43 | member AddDefinitionLocation : line:int * column:int * filePath:string -> unit
44 |
45 |
46 | type internal ProvidedMethod =
47 | inherit System.Reflection.MethodInfo
48 |
49 | /// Create a new provided method. It is not initially associated with any specific provided type definition.
50 | new : methodName:string * parameters: ProvidedParameter list * returnType: Type -> ProvidedMethod
51 |
52 | /// Add a 'System.Obsolete' attribute to this provided constructor
53 | member AddObsoleteAttribute : message: string * ?isError: bool -> unit
54 |
55 | /// Add XML documentation information to this provided constructor
56 | member AddXmlDoc : xmlDoc: string -> unit
57 |
58 | /// Add XML documentation information to this provided constructor, where the computation of the documentation is delayed until necessary
59 | member AddXmlDocDelayed : xmlDocFunction: (unit -> string) -> unit
60 |
61 | /// Add XML documentation information to this provided constructor, where the computation of the documentation is delayed until necessary
62 | /// The documentation is re-computed every time it is required.
63 | member AddXmlDocComputed : xmlDocFunction: (unit -> string) -> unit
64 |
65 | /// Set the method attributes of the method. By default these are simple 'MethodAttributes.Public'
66 | member SetMethodAttrs : attributes:MethodAttributes -> unit
67 |
68 | /// Get or set a flag indicating if the property is static.
69 | member IsStaticMethod : bool with get, set
70 |
71 | /// Set the quotation used to compute the implementation of invocations of this method.
72 | member InvokeCode : (Quotations.Expr list -> Quotations.Expr) with set
73 |
74 | /// Set the function used to compute the implementation of invocations of this method.
75 | member InvokeCodeInternal : (Quotations.Expr[] -> Quotations.Expr) with get,set
76 |
77 |
78 | /// Add definition location information to the provided type definition.
79 | member AddDefinitionLocation : line:int * column:int * filePath:string -> unit
80 |
81 |
82 | /// Represents an erased provided property.
83 | type internal ProvidedProperty =
84 | inherit System.Reflection.PropertyInfo
85 |
86 | /// Create a new provided type. It is not initially associated with any specific provided type definition.
87 | new : propertyName: string * propertyType: Type * ?parameters:ProvidedParameter list -> ProvidedProperty
88 |
89 | /// Add a 'System.Obsolete' attribute to this provided constructor
90 | member AddObsoleteAttribute : message: string * ?isError: bool -> unit
91 |
92 | /// Add XML documentation information to this provided constructor
93 | member AddXmlDoc : xmlDoc: string -> unit
94 |
95 | /// Add XML documentation information to this provided constructor, where the computation of the documentation is delayed until necessary
96 | member AddXmlDocDelayed : xmlDocFunction: (unit -> string) -> unit
97 |
98 | /// Add XML documentation information to this provided constructor, where the computation of the documentation is delayed until necessary
99 | /// The documentation is re-computed every time it is required.
100 | member AddXmlDocComputed : xmlDocFunction: (unit -> string) -> unit
101 |
102 | /// Get or set a flag indicating if the property is static.
103 | member IsStatic : bool with set
104 |
105 | /// Set the quotation used to compute the implementation of invocations of this constructor.
106 | member GetterCode : (Quotations.Expr list -> Quotations.Expr) with set
107 |
108 | /// Set the function used to compute the implementation of invocations of this constructor.
109 | member GetterCodeInternal : (Quotations.Expr[] -> Quotations.Expr) with get,set
110 |
111 | /// Set the function used to compute the implementation of invocations of the property setter
112 | member SetterCode : (Quotations.Expr list -> Quotations.Expr) with set
113 |
114 | /// Set the function used to compute the implementation of invocations of this constructor.
115 | member SetterCodeInternal : (Quotations.Expr[] -> Quotations.Expr) with get,set
116 |
117 | /// Add definition location information to the provided type definition.
118 | member AddDefinitionLocation : line:int * column:int * filePath:string -> unit
119 |
120 | /// Represents an erased provided parameter
121 | type internal ProvidedStaticParameter =
122 | inherit System.Reflection.ParameterInfo
123 | new : parameterName: string * parameterType:Type * ?parameterDefaultValue:obj -> ProvidedStaticParameter
124 |
125 | /// Represents an erased provided type definition.
126 | type internal ProvidedTypeDefinition =
127 | inherit System.Type
128 |
129 | /// Create a new provided type definition in a namespace.
130 | new : assembly: Assembly * namespaceName: string * className: string * baseType: Type option -> ProvidedTypeDefinition
131 |
132 | /// Create a new provided type definition, to be located as a nested type in some type definition.
133 | new : className : string * baseType: Type option -> ProvidedTypeDefinition
134 |
135 | /// Add the given type as an implemented interface.
136 | member AddInterfaceImplementation : interfaceType: Type -> unit
137 |
138 | /// Specifies that the given method body implements the given method declaration.
139 | member DefineMethodOverride : methodInfoBody: ProvidedMethod * methodInfoDeclaration: MethodInfo -> unit
140 |
141 | /// Add a 'System.Obsolete' attribute to this provided constructor
142 | member AddObsoleteAttribute : message: string * ?isError: bool -> unit
143 |
144 | /// Add XML documentation information to this provided constructor
145 | member AddXmlDoc : xmlDoc: string -> unit
146 |
147 | /// Add XML documentation information to this provided constructor, where the computation of the documentation is delayed until necessary.
148 | /// The documentation is only computed once.
149 | member AddXmlDocDelayed : xmlDocFunction: (unit -> string) -> unit
150 |
151 | /// Add XML documentation information to this provided constructor, where the computation of the documentation is delayed until necessary
152 | /// The documentation is re-computed every time it is required.
153 | member AddXmlDocComputed : xmlDocFunction: (unit -> string) -> unit
154 |
155 | /// Set the attributes on the provided type. This fully replaces the default TypeAttributes.
156 | member SetAttributes : System.Reflection.TypeAttributes -> unit
157 |
158 | /// Add a method, property, nested type or other member to a ProvidedTypeDefinition
159 | member AddMember : memberInfo:MemberInfo -> unit
160 | /// Add a set of members to a ProvidedTypeDefinition
161 | member AddMembers : memberInfos:list<#MemberInfo> -> unit
162 |
163 | /// Add a member to a ProvidedTypeDefinition, delaying computation of the members until required by the compilation context.
164 | member AddMemberDelayed : memberFunction:(unit -> #MemberInfo) -> unit
165 |
166 | /// Add a set of members to a ProvidedTypeDefinition, delaying computation of the members until required by the compilation context.
167 | member AddMembersDelayed : (unit -> list<#MemberInfo>) -> unit
168 |
169 | /// Add the types of the generated assembly as generative types, where types in namespaces get hierarchically positioned as nested types.
170 | member AddAssemblyTypesAsNestedTypesDelayed : assemblyFunction:(unit -> System.Reflection.Assembly) -> unit
171 |
172 | // Parametric types
173 | member DefineStaticParameters : parameters: ProvidedStaticParameter list * instantiationFunction: (string -> obj[] -> ProvidedTypeDefinition) -> unit
174 |
175 | /// Add definition location information to the provided type definition.
176 | member AddDefinitionLocation : line:int * column:int * filePath:string -> unit
177 |
178 | /// Suppress System.Object entries in intellisense menus in instances of this provided type
179 | member HideObjectMethods : bool with set
180 | /// Emit the given provided type definition and its nested type definitions into an assembly
181 | /// and adjust the 'Assembly' property of all provided type definitions to return that
182 | /// assembly.
183 | ///
184 | /// The assembly is only emitted when the Assembly property on the root type is accessed for the first time.
185 | member ConvertToGenerated : assemblyFileName:string * ?reportAssembly: (Assembly * byte[] -> unit) -> unit
186 |
187 | /// Get or set a flag indicating if the ProvidedTypeDefinition is erased
188 | member IsErased : bool with get,set
189 |
190 | /// Get or set a flag indicating if the ProvidedTypeDefinition has type-relocation suppressed
191 | []
192 | member SuppressRelocation : bool with get,set
193 |
194 | #if PROVIDER_TRANSFORMATIONS
195 | []
196 | type ProviderTransformations =
197 | static member FilterTypes : types: Type list * ?methodFilter : (MethodInfo -> bool) * ?eventFilter : (EventInfo -> bool) * ?propertyFilter : (PropertyInfo -> bool) * ?constructorFilter : (ConstructorInfo -> bool) * ?fieldFilter : (FieldInfo -> bool) * ?baseTypeTransform : (Type -> Type option) -> Type list
198 | #endif
199 |
200 |
--------------------------------------------------------------------------------
/src/FSharp.Data.TypeProviders/Util.fs:
--------------------------------------------------------------------------------
1 | // Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
2 |
3 | namespace FSharp.Data.TypeProviders.Utility
4 |
5 | module internal Util =
6 | open System
7 | open System.IO
8 | open System.Collections.Generic
9 | open System.Reflection
10 |
11 | type ProcessResult = { exitCode : int; stdout : string[] ; stderr : string[] }
12 |
13 | let executeProcess (workingDirectory,exe,cmdline) =
14 | try
15 | // External tools (like edmgen.exe) run as part of default OS locale/codepage/LCID. We need to ensure we translate their output
16 | // accordingly, by setting up the correct encoding on the stdout/stderr streams.
17 | let encodingToTranslateToolOutput = System.Text.Encoding.Default
18 |
19 | let psi = new System.Diagnostics.ProcessStartInfo(exe,cmdline)
20 | psi.WorkingDirectory <- workingDirectory
21 | psi.UseShellExecute <- false
22 | psi.RedirectStandardOutput <- true
23 | psi.RedirectStandardError <- true
24 | psi.CreateNoWindow <- true
25 | psi.StandardOutputEncoding <- encodingToTranslateToolOutput
26 | psi.StandardErrorEncoding <- encodingToTranslateToolOutput
27 | let p = System.Diagnostics.Process.Start(psi)
28 | let output = ResizeArray()
29 | let error = ResizeArray()
30 |
31 | // nulls are skipped because they act as signal that redirected stream is closed and not as part of output data
32 | p.OutputDataReceived.Add(fun args -> if args.Data <> null then output.Add(args.Data))
33 | p.ErrorDataReceived.Add(fun args -> if args.Data <> null then error.Add(args.Data))
34 | p.BeginErrorReadLine()
35 | p.BeginOutputReadLine()
36 | p.WaitForExit()
37 | { exitCode = p.ExitCode; stdout = output.ToArray(); stderr = error.ToArray() }
38 | with
39 | | :? System.IO.FileNotFoundException
40 | | :? System.ComponentModel.Win32Exception -> failwith (FSData.SR.requiredToolNotFound(exe))
41 | | _ -> reraise()
42 |
43 | let shell (workingDirectory,exe,cmdline,formatError) =
44 | // printfn "execute: %s %s" exe cmdline
45 | let result = executeProcess(workingDirectory,exe,cmdline)
46 | if result.exitCode > 0 then
47 | //failwithf "The command\n%s %s\n failed.\n\nError:%s\n\nOutput: %s\n" exe cmdline result.stderr result.stdout
48 | match formatError with
49 | | None ->
50 | let merge lines = String.concat Environment.NewLine lines
51 | failwith ((merge result.stderr) + Environment.NewLine + (merge result.stdout))
52 | | Some f -> f result.stdout result.stderr
53 | else
54 | // printfn "<--command-->\n%s %s\n<-- success --><-- stdout -->\n%s<-- stderr -->\n%s\n" exe cmdline result.stdout result.stderr
55 | ()
56 |
57 | let cscExe () =
58 | let toolPath =
59 | //if System.Runtime.InteropServices.RuntimeEnvironment.GetSystemVersion().StartsWith("v4.0") then
60 | System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()
61 | //else
62 | // Path.Combine(System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory(), @"..\v3.5")
63 | Path.Combine(toolPath, "csc.exe")
64 |
65 |
66 | let dataSvcUtilExe () =
67 | let toolPath =
68 | //if System.Runtime.InteropServices.RuntimeEnvironment.GetSystemVersion().StartsWith("v4.0") then
69 | System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()
70 | //else
71 | // Path.Combine(System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory(), @"..\v4.0.30319")
72 | Path.Combine(toolPath, "DataSvcUtil.exe")
73 |
74 |
75 | let edmGenExe () =
76 | let toolPath = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()
77 | Path.Combine(toolPath, "edmgen.exe")
78 |
79 |
80 |
81 |
82 | let sdkPath () =
83 |
84 | let tryResult (key: Microsoft.Win32.RegistryKey) =
85 | match key with
86 | | null -> None
87 | | _ ->
88 | let installFolder = key.GetValue("InstallationFolder") :?> string
89 | if Directory.Exists installFolder then
90 | Some installFolder
91 | else
92 | None
93 | // Annoyingly, the F# 2.0 decoding of 'use key = ...' on a registry key doesn't use an null check on the
94 | // key before calling Dispose. THis is because the key type doesn't use the IDisposable pattern.
95 | let useKey keyName f =
96 | // Look for WinSDK reg keys under the 32bit view of the registry.
97 | let reg32view = Microsoft.Win32.RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, Microsoft.Win32.RegistryView.Registry32)
98 | let key = reg32view.OpenSubKey keyName
99 | try f key
100 | finally
101 | match key with
102 | | null -> ()
103 | | _ -> key.Dispose()
104 | reg32view.Dispose() // if reg32view were really null, we would not be here and the user would have more serious issues not being able to access HKLM
105 |
106 | let SDK_REGPATHS = [ @"Software\Microsoft\Microsoft SDKs\NETFXSDK\4.7.2\WinSDK-NetFx40Tools"
107 | @"Software\Microsoft\Microsoft SDKs\NETFXSDK\4.7.1\WinSDK-NetFx40Tools"
108 | @"Software\Microsoft\Microsoft SDKs\NETFXSDK\4.7\WinSDK-NetFx40Tools"
109 | @"Software\Microsoft\Microsoft SDKs\NETFXSDK\4.6.2\WinSDK-NetFx40Tools"
110 | @"Software\Microsoft\Microsoft SDKs\NETFXSDK\4.6.1\WinSDK-NetFx40Tools"
111 | @"Software\Microsoft\Microsoft SDKs\NETFXSDK\4.6\WinSDK-NetFx40Tools"
112 | @"Software\Microsoft\Microsoft SDKs\Windows\v8.1A\WinSDK-NetFx40Tools"
113 | @"Software\Microsoft\Microsoft SDKs\Windows\v8.0A\WinSDK-NetFx40Tools"
114 | @"Software\Microsoft\Microsoft SDKs\Windows\v7.1\WinSDK-NetFx40Tools"
115 | @"Software\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDK-NetFx40Tools"
116 | @"Software\Wow6432node\Microsoft\Microsoft SDKs\NETFXSDK\4.8\WinSDK-NetFx40Tools" ]
117 |
118 | SDK_REGPATHS
119 | |> Seq.tryPick (fun p -> useKey p tryResult)
120 | |> function
121 | | Some p -> p
122 | | _ -> raise <| System.NotSupportedException(FSData.SR.unsupportedFramework())
123 |
124 | let sdkUtil name = Path.Combine(sdkPath(), name)
125 |
126 | let svcUtilExe toolPath =
127 | match toolPath with
128 | | Some toolPath -> Path.Combine(toolPath, "svcutil.exe")
129 | | None -> sdkUtil "svcutil.exe"
130 |
131 | let xsdExe () = sdkUtil "xsd.exe"
132 |
133 | type FileResource =
134 | abstract member Path : string
135 | inherit IDisposable
136 |
137 | let ExistingFile(fileName : string) =
138 | { new FileResource with
139 | member this.Path = fileName
140 | interface IDisposable with
141 | member this.Dispose() = () }
142 |
143 | let TemporaryFile(extension : string) =
144 | let filename =
145 | let fs = Path.GetTempFileName()
146 | let fs' = Path.ChangeExtension(fs, extension)
147 | if fs <> fs' then
148 | File.Delete fs
149 | fs'
150 |
151 | { new FileResource with
152 | member this.Path = filename
153 | interface IDisposable with
154 | member this.Dispose() = File.Delete(filename) }
155 |
156 | type DirectoryResource =
157 | abstract member Path : string
158 | inherit IDisposable
159 |
160 | let TemporaryDirectory() =
161 | let dirName =
162 | let fs = Path.GetTempFileName()
163 | File.Delete fs
164 | Directory.CreateDirectory fs |> ignore
165 | fs
166 |
167 | { new DirectoryResource with
168 | member this.Path = dirName
169 | interface IDisposable with
170 | member this.Dispose() =
171 | for f in Directory.EnumerateFiles dirName do File.Delete f
172 | Directory.Delete dirName }
173 |
174 | let ExistingDirectory(dirName : string) =
175 | { new DirectoryResource with
176 | member this.Path = dirName
177 | interface IDisposable with
178 | member this.Dispose() = () }
179 |
180 | type MemoizationTable<'T,'U when 'T : equality>(f) =
181 | let createdDB = new Dictionary<'T,'U>()
182 | member x.Contents = (createdDB :> IDictionary<_,_>)
183 | member x.Apply typeName =
184 | let found,result = createdDB.TryGetValue typeName
185 | if found then
186 | result
187 | else
188 | let ty = f typeName
189 | createdDB.[typeName] <- ty
190 | ty
191 |
192 | open System.Threading
193 |
194 | let WithExclusiveAccessToFile (fileName : string) f =
195 | // file name is not specified - run function directly
196 | if String.IsNullOrWhiteSpace fileName then f()
197 | else
198 | // convert filename to the uniform representation: full path + no backslashes + upper case
199 |
200 | // MSDN: In Silverlight for Windows Phone, private object namespaces are not supported.
201 | // In the .NET Framework, object namespaces are supported and because of this the backslash (\) is considered a delimiter and is not supported in the name parameter.
202 | // In Silverlight for Windows Phone you can use a backslash (\) in the name parameter.
203 | let fileName = Path.GetFullPath(fileName)
204 | let fileName = fileName.Replace('\\', '_')
205 | let fileName = fileName.ToUpper()
206 |
207 | // MSDN: On a server that is running Terminal Services, a named system mutex can have two levels of visibility.
208 | // If its name begins with the prefix "Global\", the mutex is visible in all terminal server sessions.
209 | // Since we use mutex to protect access to file - use Global prefix to cover all terminal sessions
210 | let fileName = @"Global\" + fileName
211 | use mutex =
212 | let mutable createdNew = false
213 | let mutex = new Mutex(initiallyOwned = true, name = fileName, createdNew = &createdNew)
214 | // createdNew = true - we created and immediately acquired mutex - can continue
215 | // createdNew = false - mutex already exists and we do not own it - must wait until it is released
216 | if createdNew then mutex
217 | else
218 | try
219 | mutex.WaitOne() |> ignore
220 | mutex
221 | with
222 | | :? AbandonedMutexException ->
223 | // if thread that owns mutex was terminated abnormally - then WaitOne will raise AbandonedMutexException
224 | // MSDN: The next thread to request ownership of the mutex can handle this exception and proceed,
225 | // provided that the integrity of the data structures can be verified.
226 | // Current thread still owns mutex so we can return it
227 | mutex
228 | | _ ->
229 | mutex.Dispose()
230 | reraise()
231 | try f()
232 | finally mutex.ReleaseMutex()
233 |
234 |
--------------------------------------------------------------------------------
/tests/FSharp.Data.TypeProviders.Tests/.gitignore:
--------------------------------------------------------------------------------
1 |
2 | FSharp.Data.TypeProviders.dll
3 |
4 | EdmxFile/SampleModel01.edmx
5 |
6 | EdmxFile/*.exe.config
7 | EdmxFile/*.dll.config
8 |
9 | ODataService/*.exe.config
10 | ODataService/*.dll.config
11 | ODataService/svc.csdl
12 | ODataService/svc2.csdl
13 |
14 | SqlDataConnection/*.exe.config
15 | SqlDataConnection/*.dll.config
16 | SqlDataConnection/app.config
17 | SqlDataConnection/NORTHWND.mdf
18 | SqlDataConnection/NORTHWND_log.ldf
19 | SqlDataConnection/nwind2.dbml
20 | SqlDataConnection/nwind3.dbml
21 | SqlDataConnection/test.config
22 |
23 | SqlEntityConnection/*.exe.config
24 | SqlEntityConnection/*.dll.config
25 |
26 | WsdlService/*.exe.config
27 | WsdlService/*.dll.config
28 | WsdlService/sfile.wsdlschema
29 | WsdlService/sfile2.wsdlschema
30 |
--------------------------------------------------------------------------------
/tests/FSharp.Data.TypeProviders.Tests/EdmxFile/EdmxFileTests.fs:
--------------------------------------------------------------------------------
1 | // #Conformance #TypeProviders #EdmxFile
2 | #if COMPILED
3 | module FSharp.Data.TypeProviders.Tests.EdmxFile
4 | #else
5 | #r "../../bin/FSharp.Data.TypeProviders.dll"
6 | #endif
7 |
8 | open Microsoft.FSharp.Core.CompilerServices
9 | open System
10 | open System.IO
11 | open NUnit.Framework
12 |
13 | []
14 | module Infrastructure =
15 | let reportFailure () = stderr.WriteLine " NO"; Assert.Fail("test failed")
16 | let test s b = stderr.Write(s:string); if b then stderr.WriteLine " OK" else reportFailure()
17 | let check s v1 v2 = stderr.Write(s:string); if v1 = v2 then stderr.WriteLine " OK" else Assert.Fail(sprintf "... FAILURE: expected %A, got %A " v2 v1)
18 |
19 | let (++) a b = Path.Combine(a,b)
20 |
21 | module CheckEdmxfileTypeProvider =
22 |
23 | let checkHostedType (hostedType: System.Type) =
24 | test "ceklc09wlkm1a" (hostedType.Assembly <> typeof.Assembly)
25 | test "ceklc09wlkm1b" (hostedType.Assembly.FullName.StartsWith "tmp")
26 |
27 | check "ceklc09wlkm2" hostedType.DeclaringType null
28 | check "ceklc09wlkm3" hostedType.DeclaringMethod null
29 | check "ceklc09wlkm4" hostedType.FullName "SampleModel01.EdmxFileApplied"
30 | check "ceklc09wlkm5" (hostedType.GetConstructors()) [| |]
31 | check "ceklc09wlkm6" (hostedType.GetCustomAttributesData().Count) 1
32 | check "ceklc09wlkm6" (hostedType.GetCustomAttributesData().[0].Constructor.DeclaringType.FullName) typeof.FullName
33 | check "ceklc09wlkm7" (hostedType.GetEvents()) [| |]
34 | check "ceklc09wlkm8" (hostedType.GetFields()) [| |]
35 | check "ceklc09wlkm9" (hostedType.GetMethods()) [| |]
36 | check "ceklc09wlkm10" (hostedType.GetProperties()) [| |]
37 | check "ceklc09wlkm11" (hostedType.GetNestedTypes().Length) 1
38 | check "ceklc09wlkm12"
39 | (set [ for x in hostedType.GetNestedTypes() -> x.Name ])
40 | (set ["SampleModel01"])
41 |
42 | let hostedServiceTypes = hostedType.GetNestedTypes().[0]
43 | check "ceklc09wlkm12b" (hostedServiceTypes.GetMethods()) [| |]
44 | check "ceklc09wlkm12c"
45 | (set [ for x in hostedServiceTypes.GetNestedTypes() -> x.Name ])
46 | (set ["Customers"; "Orders"; "Persons"; "SampleModel01Container"])
47 |
48 | // Deep check on one type: Customers
49 | let customersType = (hostedServiceTypes.GetNestedTypes() |> Seq.find (fun t -> t.Name = "Customers"))
50 | check "ceklc09wlkm131" (set [ for x in customersType.GetProperties() -> x.Name ]) (set [| "Id"; "Orders"; "ID"; "FirstName"; "LastName"; "EntityState"; "EntityKey" |])
51 | check "ceklc09wlkm133a" (set [ for x in customersType.GetFields() -> x.Name ]) (set [| |])
52 | check "ceklc09wlkm133b" (set [ for x in customersType.GetFields(System.Reflection.BindingFlags.Static ||| System.Reflection.BindingFlags.Public ||| System.Reflection.BindingFlags.FlattenHierarchy) -> x.Name ])
53 | (set [ "EntityKeyPropertyName"] )
54 | check "ceklc09wlkm134" (set [ for x in customersType.GetMethods() -> x.Name ])
55 | (set ["CreateCustomers"; "get_Id"; "set_Id"; "get_Orders"; "set_Orders"; "get_ID"; "set_ID"; "get_FirstName"; "set_FirstName"; "get_LastName"; "set_LastName";
56 | "get_EntityState"; "get_EntityKey"; "set_EntityKey"; "add_PropertyChanged"; "remove_PropertyChanged"; "add_PropertyChanging"; "remove_PropertyChanging"; "ToString"; "Equals";
57 | "GetHashCode"; "GetType"] )
58 | check "ceklc09wlkm135" (set [ for x in customersType.GetMethods(System.Reflection.BindingFlags.Static ||| System.Reflection.BindingFlags.Public ||| System.Reflection.BindingFlags.FlattenHierarchy) -> x.Name ])
59 | (set [ "CreateCustomers"; "CreatePersons"; "Equals"; "ReferenceEquals" ] )
60 | check "ceklc09wlkm136" (customersType.GetNestedTypes()) [||]
61 |
62 | // Not so deep check on another type: SampleModel01Container
63 | let SampleModel01ContainerType = (hostedServiceTypes.GetNestedTypes() |> Seq.find (fun t -> t.Name = "SampleModel01Container"))
64 | check "ceklc09wlkm141" (set [ for x in SampleModel01ContainerType.GetProperties() -> x.Name ]) (set [|"Orders"; "Persons"; "Connection"; "DefaultContainerName"; "MetadataWorkspace"; "ObjectStateManager"; "CommandTimeout"; "ContextOptions"|])
65 | check "ceklc09wlkm142" (SampleModel01ContainerType.GetFields()) [||]
66 | check "ceklc09wlkm144" (set [ for x in SampleModel01ContainerType.GetMethods() -> x.Name ])
67 | (set [|"get_Orders"; "get_Persons"; "AddToOrders"; "AddToPersons"; "get_Connection"; "get_DefaultContainerName"; "set_DefaultContainerName"; "get_MetadataWorkspace"; "get_ObjectStateManager"; "get_CommandTimeout"; "set_CommandTimeout"; "get_ContextOptions"; "add_SavingChanges"; "remove_SavingChanges"; "add_ObjectMaterialized"; "remove_ObjectMaterialized"; "AcceptAllChanges"; "AddObject"; "LoadProperty"; "LoadProperty"; "LoadProperty"; "LoadProperty"; "ApplyPropertyChanges"; "ApplyCurrentValues"; "ApplyOriginalValues"; "AttachTo"; "Attach"; "CreateEntityKey"; "CreateObjectSet"; "CreateObjectSet"; "CreateQuery"; "DeleteObject"; "Detach"; "Dispose"; "GetObjectByKey"; "Refresh"; "Refresh"; "SaveChanges"; "SaveChanges"; "SaveChanges"; "DetectChanges"; "TryGetObjectByKey"; "ExecuteFunction"; "ExecuteFunction"; "ExecuteFunction"; "CreateProxyTypes"; "CreateObject"; "ExecuteStoreCommand"; "ExecuteStoreQuery"; "ExecuteStoreQuery"; "Translate"; "Translate"; "CreateDatabase"; "DeleteDatabase"; "DatabaseExists"; "CreateDatabaseScript"; "ToString"; "Equals"; "GetHashCode"; "GetType"|])
68 | check "ceklc09wlkm146" (SampleModel01ContainerType.GetNestedTypes()) [||]
69 |
70 |
71 | let instantiateTypeProviderAndCheckOneHostedType( useMsPrefix, edmxfile : string, typeFullPath ) =
72 |
73 | let assemblyFile = typeof.Assembly.CodeBase.Replace("file:///","").Replace("/","\\")
74 | test "CheckFSharpDataTypeProvidersDLLExist" (File.Exists assemblyFile)
75 |
76 | // If/when we care about the "target framework", this mock function will have to be fully implemented
77 | let systemRuntimeContainsType s =
78 | Console.WriteLine (sprintf "Call systemRuntimeContainsType(%s) returning dummy value 'true'" s)
79 | true
80 |
81 | let tpConfig = new TypeProviderConfig(systemRuntimeContainsType, ResolutionFolder=__SOURCE_DIRECTORY__, RuntimeAssembly=assemblyFile, ReferencedAssemblies=[| |], TemporaryFolder=Path.GetTempPath(), IsInvalidationSupported=false, IsHostedExecution=true)
82 | use typeProvider1 = (new FSharp.Data.TypeProviders.DesignTime.DataProviders( tpConfig ) :> ITypeProvider)
83 |
84 | // Setup machinery to keep track of the "invalidate event" (see below)
85 | let invalidateEventCount = ref 0
86 | typeProvider1.Invalidate.Add(fun _ -> incr invalidateEventCount)
87 |
88 | // Load a type provider instance for the type and restart
89 | let hostedNamespace1 = typeProvider1.GetNamespaces() |> Seq.find (fun t -> t.NamespaceName = if useMsPrefix then "Microsoft.FSharp.Data.TypeProviders" else "FSharp.Data.TypeProviders")
90 |
91 | check "CheckAllTPsAreThere" (set [ for i in hostedNamespace1.GetTypes() -> i.Name ]) (set ["DbmlFile"; "EdmxFile"; "ODataService"; "SqlDataConnection";"SqlEntityConnection";"WsdlService"])
92 |
93 | let hostedType1 = hostedNamespace1.ResolveTypeName("EdmxFile")
94 | let hostedType1StaticParameters = typeProvider1.GetStaticParameters(hostedType1)
95 | check "VerifyStaticParam"
96 | (set [ for i in hostedType1StaticParameters -> i.Name ])
97 | (set [ "File"; "ResolutionFolder" ])
98 |
99 | let staticParameterValues =
100 | [| for x in hostedType1StaticParameters ->
101 | (match x.Name with
102 | | "File" -> box edmxfile
103 | | _ -> box x.RawDefaultValue) |]
104 | Console.WriteLine (sprintf "instantiating type... may take a while for code generation tool to run and csc.exe to run...")
105 | let hostedAppliedType1 = typeProvider1.ApplyStaticArguments(hostedType1, typeFullPath, staticParameterValues)
106 |
107 | checkHostedType hostedAppliedType1
108 |
109 | let edmxfileAbs = if Path.IsPathRooted edmxfile then edmxfile else __SOURCE_DIRECTORY__ ++ edmxfile
110 | // Write replacement text into the file and check that the invalidation event is triggered....
111 | let file1NewContents = File.ReadAllText(edmxfileAbs).Replace("Customer", "Client") // Rename 'Customer' to 'Client'
112 | do File.WriteAllText(edmxfileAbs, file1NewContents)
113 |
114 | // Wait for invalidate event to fire....
115 | for i in 0 .. 30 do
116 | if !invalidateEventCount = 0 then
117 | System.Threading.Thread.Sleep 100
118 |
119 | check "VerifyInvalidateEventFired" !invalidateEventCount 1
120 |
121 | let edmxfile = Path.Combine(__SOURCE_DIRECTORY__, "SampleModel01.edmx")
122 |
123 | []
124 | let ``EDMX Tests 1`` () =
125 | let testIt useMsPrefix =
126 | // Test with absolute path
127 | // Copy the .edmx used for tests to avoid trashing our original (we may overwrite it when testing the event)
128 | File.Copy(Path.Combine(__SOURCE_DIRECTORY__, @"EdmxFiles\SampleModel01.edmx"), edmxfile, true)
129 | File.SetAttributes(edmxfile, FileAttributes.Normal)
130 | CheckEdmxfileTypeProvider.instantiateTypeProviderAndCheckOneHostedType(useMsPrefix, edmxfile, [| "EdmxFileApplied" |])
131 |
132 | testIt false // Typeprovider name = FSharp.Data.TypeProviders
133 | testIt true // Typeprovider name = Microsoft.FSharp.Data.TypeProviders
134 |
135 | []
136 | let ``EDMX Tests 2`` () =
137 | let testIt useMsPrefix =
138 | // Test with relative path
139 | // Copy the .edmx used for tests to avoid trashing our original (we may overwrite it when testing the event)
140 | File.Copy(Path.Combine(__SOURCE_DIRECTORY__, @"EdmxFiles\SampleModel01.edmx"), edmxfile, true)
141 | File.SetAttributes(edmxfile, FileAttributes.Normal)
142 | CheckEdmxfileTypeProvider.instantiateTypeProviderAndCheckOneHostedType(useMsPrefix, Path.GetFileName(edmxfile), [| "EdmxFileApplied" |])
143 |
144 | testIt false // Typeprovider name = FSharp.Data.TypeProviders
145 | testIt true // Typeprovider name = Microsoft.FSharp.Data.TypeProviders
146 |
--------------------------------------------------------------------------------
/tests/FSharp.Data.TypeProviders.Tests/EdmxFile/EdmxFiles/SampleModel01.edmx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/tests/FSharp.Data.TypeProviders.Tests/FSharp.Data.TypeProviders.Tests.fsproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net472
4 | false
5 | false
6 | true
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/tests/FSharp.Data.TypeProviders.Tests/ODataService/ODataServiceTests.fs:
--------------------------------------------------------------------------------
1 | // #Conformance #TypeProviders #ODataService
2 |
3 | #if COMPILED
4 | module FSharp.Data.TypeProviders.Tests.OdataServiceTests
5 | #else
6 | #r "../../bin/FSharp.Data.TypeProviders.dll"
7 | #endif
8 |
9 | open Microsoft.FSharp.Core.CompilerServices
10 | open System
11 | open System.IO
12 | open NUnit.Framework
13 |
14 | []
15 | module Infrastructure =
16 | let reportFailure () = stderr.WriteLine " NO"; Assert.Fail("test failed")
17 | let test s b = stderr.Write(s:string); if b then stderr.WriteLine " OK" else reportFailure()
18 | let check s v1 v2 = stderr.Write(s:string); if v1 = v2 then stderr.WriteLine " OK" else Assert.Fail(sprintf "... FAILURE: expected %A, got %A " v2 v1)
19 |
20 | let checkHostedType (hostedType: System.Type) =
21 | //let hostedType = hostedAppliedType1
22 | test "ceklc09wlkm1a" (hostedType.Assembly <> typeof.Assembly)
23 | test "ceklc09wlkm1b" (hostedType.Assembly.FullName.StartsWith "tmp")
24 |
25 | check "ceklc09wlkm2" hostedType.DeclaringType null
26 | check "ceklc09wlkm3" hostedType.DeclaringMethod null
27 | check "ceklc09wlkm4" hostedType.FullName "FSharp.Data.TypeProviders.ODataServiceApplied"
28 | check "ceklc09wlkm5" (hostedType.GetConstructors()) [| |]
29 | check "ceklc09wlkm6" (hostedType.GetCustomAttributesData().Count) 1
30 | check "ceklc09wlkm6" (hostedType.GetCustomAttributesData().[0].Constructor.DeclaringType.FullName) typeof.FullName
31 | check "ceklc09wlkm7" (hostedType.GetEvents()) [| |]
32 | check "ceklc09wlkm8" (hostedType.GetFields()) [| |]
33 | check "ceklc09wlkm9" [ for m in hostedType.GetMethods() -> m.Name ] [ "GetDataContext" ; "GetDataContext" ]
34 | let m1 = hostedType.GetMethods().[0]
35 | let m2 = hostedType.GetMethods().[1]
36 | check "ceklc09wlkm9b" (m1.GetParameters().Length) 0
37 | check "ceklc09wlkm9b" (m2.GetParameters().Length) 1
38 | check "ceklc09wlkm9b" (m1.ReturnType.Name) "DemoService"
39 | check "ceklc09wlkm9c" (m1.ReturnType.FullName) ("FSharp.Data.TypeProviders.ODataServiceApplied+ServiceTypes+SimpleDataContextTypes+DemoService")
40 |
41 | check "ceklc09wlkm9d" (m1.ReturnType.GetProperties().Length) 5
42 | check "ceklc09wlkm9e" (set [ for p in m1.ReturnType.GetProperties() -> p.Name ]) (set ["Categories"; "Credentials"; "DataContext"; "Products"; "Suppliers"])
43 | check "ceklc09wlkm9f" (set [ for p in m1.ReturnType.GetProperties() -> p.PropertyType.Name ]) (set ["DataServiceQuery`1"; "DataServiceQuery`1";"DataServiceQuery`1";"ICredentials"; "DataServiceContext"])
44 |
45 | // We expose some getters and 1 setter on the simpler data context
46 | check "ceklc09wlkm9g" (m1.ReturnType.GetMethods().Length) 6
47 | check "ceklc09wlkm9h" (set [ for p in m1.ReturnType.GetMethods() -> p.Name ]) (set ["get_Categories"; "get_Credentials"; "get_DataContext"; "get_Products"; "get_Suppliers"; "set_Credentials"])
48 |
49 | check "ceklc09wlkm10" (hostedType.GetProperties()) [| |]
50 | check "ceklc09wlkm11" (hostedType.GetNestedTypes().Length) 1
51 | check "ceklc09wlkm12"
52 | (set [ for x in hostedType.GetNestedTypes() -> x.Name ])
53 | (set ["ServiceTypes"])
54 |
55 | let hostedServiceTypes = hostedType.GetNestedTypes().[0]
56 |
57 | check "ceklc09wlkm11" (hostedServiceTypes.GetNestedTypes().Length) 6
58 | check "ceklc09wlkm12"
59 | (set [ for x in hostedServiceTypes.GetNestedTypes() -> x.Name ])
60 | (set ["Address"; "Category"; "DemoService"; "Product"; "SimpleDataContextTypes"; "Supplier"])
61 |
62 | let productType = (hostedServiceTypes.GetNestedTypes() |> Seq.find (fun t -> t.Name = "Product"))
63 | check "ceklc09wlkm13" (productType.GetProperties().Length) 9
64 |
65 | check "ceklc09wlkm14"
66 | (set [ for x in productType.GetProperties() -> x.Name ])
67 | (set ["ID"; "Name"; "Description"; "ReleaseDate"; "DiscontinuedDate"; "Rating"; "Price"; "Category"; "Supplier"])
68 |
69 | let instantiateTypeProviderAndCheckOneHostedType(useMsPrefix, useLocalSchemaFile: string option, useForceUpdate: bool option, typeFullPath:string[]) =
70 | //let useLocalSchemaFile : string option = None
71 | //let useForceUpdate : bool option = None
72 | let assemblyFile = typeof.Assembly.CodeBase.Replace("file:///","").Replace("/","\\")
73 | test "cnlkenkewe" (File.Exists assemblyFile)
74 |
75 | // If/when we care about the "target framework", this mock function will have to be fully implemented
76 | let systemRuntimeContainsType s =
77 | Console.WriteLine (sprintf "Call systemRuntimeContainsType(%s) returning dummy value 'true'" s)
78 | true
79 |
80 | let tpConfig = new TypeProviderConfig(systemRuntimeContainsType, ResolutionFolder=__SOURCE_DIRECTORY__, RuntimeAssembly=assemblyFile, ReferencedAssemblies=[| |], TemporaryFolder=Path.GetTempPath(), IsInvalidationSupported=false, IsHostedExecution=true)
81 | use typeProvider1 = (new FSharp.Data.TypeProviders.DesignTime.DataProviders( tpConfig ) :> ITypeProvider)
82 |
83 | let invalidateEventCount = ref 0
84 |
85 | typeProvider1.Invalidate.Add(fun _ -> incr invalidateEventCount)
86 |
87 | // Load a type provider instance for the type and restart
88 | let hostedNamespace1 = typeProvider1.GetNamespaces() |> Seq.find (fun t -> t.NamespaceName = if useMsPrefix then "Microsoft.FSharp.Data.TypeProviders" else "FSharp.Data.TypeProviders")
89 |
90 | check "eenewioinw" (set [ for i in hostedNamespace1.GetTypes() -> i.Name ]) (set ["DbmlFile"; "EdmxFile"; "ODataService"; "SqlDataConnection";"SqlEntityConnection";"WsdlService"])
91 |
92 | let hostedType1 = hostedNamespace1.ResolveTypeName("ODataService")
93 | let hostedType1StaticParameters = typeProvider1.GetStaticParameters(hostedType1)
94 | check "eenewioinw2"
95 | (set [ for i in hostedType1StaticParameters -> i.Name ])
96 | (set ["ServiceUri"; "LocalSchemaFile"; "ForceUpdate"; "ResolutionFolder"; "DataServiceCollection"])
97 |
98 | let serviceUri = "http://services.odata.org/V2/OData/OData.svc/"
99 | let staticParameterValues =
100 | [| for x in hostedType1StaticParameters ->
101 | (match x.Name with
102 | | "ServiceUri" -> box serviceUri
103 | | "LocalSchemaFile" when useLocalSchemaFile.IsSome -> box useLocalSchemaFile.Value
104 | | "ForceUpdate" when useForceUpdate.IsSome -> box useForceUpdate.Value
105 | | _ -> box x.RawDefaultValue) |]
106 | Console.WriteLine (sprintf "instantiating service type... may take a while for OData service metadata to be downloaded, code generation tool to run and csc.exe to run...")
107 | try
108 | let hostedAppliedType1 = typeProvider1.ApplyStaticArguments(hostedType1, typeFullPath, staticParameterValues)
109 |
110 | checkHostedType hostedAppliedType1
111 | with
112 | | e ->
113 | Console.WriteLine (sprintf "%s" (e.ToString()))
114 | reportFailure()
115 |
116 |
117 |
118 | []
119 | let ``OData Tests 1`` () =
120 | instantiateTypeProviderAndCheckOneHostedType(false, None, None, [| "ODataServiceApplied" |]) // Typeprovider name = FSharp.Data.TypeProviders
121 | instantiateTypeProviderAndCheckOneHostedType(true, None, None, [| "ODataServiceApplied" |]) // Typeprovider name = Microsoft.FSharp.Data.TypeProviders
122 |
123 | []
124 | let ``OData Tests 2`` () =
125 | let testIt useMsPrefix =
126 | let schemaFile2 = Path.Combine(__SOURCE_DIRECTORY__, "svc.csdl")
127 | (try File.Delete schemaFile2 with _ -> ())
128 | instantiateTypeProviderAndCheckOneHostedType(useMsPrefix, Some (Path.Combine(__SOURCE_DIRECTORY__, "svc.csdl")), Some true, [| "ODataServiceApplied" |])
129 | // schemaFile2 should now exist
130 | test "eoinew0c9e" (File.Exists schemaFile2)
131 |
132 | // Reuse the CSDL just created
133 | instantiateTypeProviderAndCheckOneHostedType(useMsPrefix, Some (Path.Combine(__SOURCE_DIRECTORY__, "svc.csdl")), Some false, [| "ODataServiceApplied" |])
134 | // schemaFile2 should now still exist
135 | test "eoinew0c9e" (File.Exists schemaFile2)
136 | testIt false // Typeprovider name = FSharp.Data.TypeProviders
137 | testIt true // Typeprovider name = Microsoft.FSharp.Data.TypeProviders
138 |
139 | []
140 | let ``OData Tests 4`` () =
141 | let testIt useMsPrefix =
142 | let schemaFile3 = Path.Combine(__SOURCE_DIRECTORY__, "svc2.csdl")
143 | (try File.Delete schemaFile3 with _ -> ())
144 | instantiateTypeProviderAndCheckOneHostedType(useMsPrefix, Some schemaFile3, None, [| "ODataServiceApplied" |])
145 |
146 | // schemaFile3 should now exist
147 | test "eoinew0c9e" (File.Exists schemaFile3)
148 | testIt false // Typeprovider name = FSharp.Data.TypeProviders
149 | testIt true // Typeprovider name = Microsoft.FSharp.Data.TypeProviders
150 |
151 |
--------------------------------------------------------------------------------
/tests/FSharp.Data.TypeProviders.Tests/SqlDataConnection/DB/NORTHWND.MDF:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fsprojects/FSharp.Data.TypeProviders/fb942edbcbe038b8c5d6f6ca1f5fb36ba93d1748/tests/FSharp.Data.TypeProviders.Tests/SqlDataConnection/DB/NORTHWND.MDF
--------------------------------------------------------------------------------
/tests/FSharp.Data.TypeProviders.Tests/SqlDataConnection/ExampleResolutionFolder/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/tests/FSharp.Data.TypeProviders.Tests/SqlDataConnection/SqlDataConnectionTests.fs:
--------------------------------------------------------------------------------
1 | // #Conformance #TypeProviders #SqlDataConnection
2 |
3 | #if COMPILED
4 | module FSharp.Data.TypeProviders.Tests.SqlDataConnectionTests
5 | #else
6 | #r "nuget: FSharp.Data.TypeProviders"
7 | #r "System.Management.dll"
8 | #endif
9 |
10 |
11 | open Microsoft.FSharp.Core.CompilerServices
12 | open System
13 | open System.IO
14 | open NUnit.Framework
15 |
16 | []
17 | module Infrastructure =
18 | let reportFailure () = stderr.WriteLine " NO"; Assert.Fail("test failed")
19 | let test s b = stderr.Write(s:string); if b then stderr.WriteLine " OK" else reportFailure()
20 | let check s v1 v2 = stderr.Write(s:string); if v1 = v2 then stderr.WriteLine " OK" else Assert.Fail(sprintf "... FAILURE: expected %A, got %A " v2 v1)
21 |
22 | let (++) a b = Path.Combine(a,b)
23 |
24 | let isSQLExpressInstalled =
25 | lazy
26 | let edition = "Express Edition"
27 | let instance = "MSSQL$SQLEXPRESS"
28 |
29 | try
30 | let getSqlExpress =
31 | new System.Management.ManagementObjectSearcher("root\\Microsoft\\SqlServer\\ComputerManagement10",
32 | "select * from SqlServiceAdvancedProperty where SQLServiceType = 1 and ServiceName = '" + instance + "' and (PropertyName = 'SKUNAME' or PropertyName = 'SPLEVEL')")
33 |
34 | // If nothing is returned, SQL Express isn't installed.
35 | getSqlExpress.Get().Count <> 0
36 | with
37 | | _ -> false
38 |
39 |
40 | let checkHostedType (hostedType: System.Type) =
41 | //let hostedType = hostedAppliedType1
42 | test "ceklc09wlkm1a" (hostedType.Assembly <> typeof.Assembly)
43 | test "ceklc09wlkm1b" (hostedType.Assembly.FullName.StartsWith "tmp")
44 |
45 | check "ceklc09wlkm2" hostedType.DeclaringType null
46 | check "ceklc09wlkm3" hostedType.DeclaringMethod null
47 | check "ceklc09wlkm4" hostedType.FullName "FSharp.Data.TypeProviders.SqlDataConnectionApplied"
48 | check "ceklc09wlkm5" (hostedType.GetConstructors()) [| |]
49 | check "ceklc09wlkm6" (hostedType.GetCustomAttributesData().Count) 1
50 | check "ceklc09wlkm6" (hostedType.GetCustomAttributesData().[0].Constructor.DeclaringType.FullName) typeof.FullName
51 | check "ceklc09wlkm7" (hostedType.GetEvents()) [| |]
52 | check "ceklc09wlkm8" (hostedType.GetFields()) [| |]
53 | check "ceklc09wlkm9" [ for m in hostedType.GetMethods() -> m.Name ] [ "GetDataContext" ; "GetDataContext"; "GetDataContext" ]
54 | let m0 = hostedType.GetMethods().[0]
55 | let m1 = hostedType.GetMethods().[1]
56 | let m2 = hostedType.GetMethods().[2]
57 | check "ceklc09wlkm9b" (m0.GetParameters().Length) 0
58 | check "ceklc09wlkm9b" (m1.GetParameters().Length) 1
59 | check "ceklc09wlkm9b" (m2.GetParameters().Length) 1
60 | check "ceklc09wlkm9b" (m0.ReturnType.Name) "Northwnd"
61 | check "ceklc09wlkm9b" (m0.ReturnType.FullName) "FSharp.Data.TypeProviders.SqlDataConnectionApplied+ServiceTypes+SimpleDataContextTypes+Northwnd"
62 | check "ceklc09wlkm10" (hostedType.GetProperties()) [| |]
63 | check "ceklc09wlkm11" (hostedType.GetNestedTypes().Length) 1
64 | check "ceklc09wlkm12"
65 | (set [ for x in hostedType.GetNestedTypes() -> x.Name ])
66 | (set ["ServiceTypes"])
67 |
68 | let hostedServiceTypes = hostedType.GetNestedTypes().[0]
69 | check "ceklc09wlkm12b" (hostedServiceTypes.GetMethods()) [| |]
70 | check "ceklc09wlkm12c" (hostedServiceTypes.GetNestedTypes().Length) 38
71 |
72 | let hostedSimpleDataContextTypes = hostedServiceTypes.GetNestedType("SimpleDataContextTypes")
73 | check "ceklc09wlkm12d" (hostedSimpleDataContextTypes.GetMethods()) [| |]
74 | check "ceklc09wlkm12e" (hostedSimpleDataContextTypes.GetNestedTypes().Length) 1
75 | check "ceklc09wlkm12e" [ for x in hostedSimpleDataContextTypes.GetNestedTypes() -> x.Name] ["Northwnd"]
76 |
77 | check "ceklc09wlkm12"
78 | (set [ for x in hostedServiceTypes.GetNestedTypes() -> x.Name ])
79 | (set ["Northwnd"; "SimpleDataContextTypes"; "AlphabeticalListOfProduct"; "Category"; "CategorySalesFor1997"; "CurrentProductList"; "CustomerAndSuppliersByCity";
80 | "CustomerCustomerDemo"; "CustomerDemographic"; "Customer"; "Employee"; "EmployeeTerritory";
81 | "Invoice"; "OrderDetail"; "OrderDetailsExtended"; "OrderSubtotal"; "Order"; "OrdersQry";
82 | "ProductSalesFor1997"; "Product"; "ProductsAboveAveragePrice"; "ProductsByCategory";
83 | "QuarterlyOrder"; "Region"; "SalesByCategory"; "SalesTotalsByAmount"; "Shipper";
84 | "SummaryOfSalesByQuarter"; "SummaryOfSalesByYear"; "Supplier"; "Territory"; "CustOrderHistResult";
85 | "CustOrdersDetailResult"; "CustOrdersOrdersResult"; "EmployeeSalesByCountryResult"; "SalesByYearResult";
86 | "SalesByCategoryResult"; "TenMostExpensiveProductsResult"])
87 |
88 | let customersType = (hostedServiceTypes.GetNestedTypes() |> Seq.find (fun t -> t.Name = "Customer"))
89 | check "ceklc09wlkm13" (customersType.GetProperties().Length) 13
90 |
91 |
92 | let instantiateTypeProviderAndCheckOneHostedType(useMsPrefix, connectionStringName, configFile, useDataDirectory, dataDirectory, useLocalSchemaFile: string option, useForceUpdate: bool option, typeFullPath: string[], resolutionFolder:string option) =
93 | let assemblyFile = typeof.Assembly.CodeBase.Replace("file:///","").Replace("/","\\")
94 | test "cnlkenkewe" (File.Exists assemblyFile)
95 |
96 | // If/when we care about the "target framework", this mock function will have to be fully implemented
97 | let systemRuntimeContainsType s =
98 | Console.WriteLine (sprintf "Call systemRuntimeContainsType(%s) returning dummy value 'true'" s)
99 | true
100 |
101 | let tpConfig = new TypeProviderConfig(systemRuntimeContainsType, ResolutionFolder=__SOURCE_DIRECTORY__, RuntimeAssembly=assemblyFile, ReferencedAssemblies=[| |], TemporaryFolder=Path.GetTempPath(), IsInvalidationSupported=false, IsHostedExecution=true)
102 | use typeProvider1 = (new FSharp.Data.TypeProviders.DesignTime.DataProviders( tpConfig ) :> ITypeProvider)
103 | let invalidateEventCount = ref 0
104 |
105 | typeProvider1.Invalidate.Add(fun _ -> incr invalidateEventCount)
106 |
107 | // Load a type provider instance for the type and restart
108 | let hostedNamespace1 = typeProvider1.GetNamespaces() |> Seq.find (fun t -> t.NamespaceName = if useMsPrefix then "Microsoft.FSharp.Data.TypeProviders" else "FSharp.Data.TypeProviders")
109 |
110 | check "eenewioinw" (set [ for i in hostedNamespace1.GetTypes() -> i.Name ]) (set ["DbmlFile"; "EdmxFile"; "ODataService"; "SqlDataConnection";"SqlEntityConnection";"WsdlService"])
111 |
112 | let hostedType1 = hostedNamespace1.ResolveTypeName("SqlDataConnection")
113 | let hostedType1StaticParameters = typeProvider1.GetStaticParameters(hostedType1)
114 | check "eenewioinw2"
115 | (set [ for i in hostedType1StaticParameters -> i.Name ])
116 | (set ["ConnectionString"; "ConnectionStringName"; "DataDirectory"; "ResolutionFolder"; "ConfigFile"; "LocalSchemaFile";
117 | "ForceUpdate"; "Pluralize"; "Views"; "Functions"; "StoredProcedures"; "Timeout";
118 | "ContextTypeName"; "Serializable" ])
119 |
120 | let northwind = "NORTHWND.mdf"
121 | let northwindLog = "NORTHWND_log.ldf"
122 | let northwindFile =
123 | match resolutionFolder with
124 | | None ->
125 | match dataDirectory with
126 | | None ->
127 | Path.Combine(__SOURCE_DIRECTORY__, northwind)
128 | | Some dd ->
129 | let ddAbs = if Path.IsPathRooted dd then dd else Path.Combine(__SOURCE_DIRECTORY__, dd)
130 | if not(Directory.Exists ddAbs) then Directory.CreateDirectory ddAbs |> ignore
131 | Path.Combine(ddAbs, northwind)
132 |
133 | | Some rf ->
134 | let rfAbs = if Path.IsPathRooted rf then rf else Path.Combine(__SOURCE_DIRECTORY__, rf)
135 | if not(Directory.Exists rfAbs) then Directory.CreateDirectory rfAbs |> ignore
136 | match dataDirectory with
137 | | None ->
138 | Path.Combine(rf, northwind)
139 | | Some dd ->
140 | let ddAbs = if Path.IsPathRooted dd then dd else Path.Combine(rfAbs, dd)
141 | if not(Directory.Exists ddAbs) then Directory.CreateDirectory ddAbs |> ignore
142 | Path.Combine(ddAbs,northwind)
143 |
144 |
145 | if not(File.Exists(northwindFile)) then
146 | File.Copy(__SOURCE_DIRECTORY__ + @"\DB\northwnd.mdf", northwindFile, false)
147 | File.SetAttributes(northwindFile, FileAttributes.Normal)
148 |
149 |
150 | let connectionString =
151 | if useDataDirectory then
152 | if isSQLExpressInstalled.Value then
153 | @"AttachDBFileName = '|DataDirectory|\" + northwind + "';Server='.\SQLEXPRESS';User Instance=true;Integrated Security=SSPI"
154 | else
155 | "AttachDBFileName = '|DataDirectory|\\" + northwind + "';Server='(localdb)\\MSSQLLocalDB'"
156 | else
157 | if isSQLExpressInstalled.Value then
158 | @"AttachDBFileName = '" + northwindFile + "';Server='.\SQLEXPRESS';User Instance=true;Integrated Security=SSPI"
159 | else
160 | "AttachDBFileName = '" + northwindFile + "';Server='(localdb)\\MSSQLLocalDB'"
161 |
162 | match connectionStringName with
163 | | None -> ()
164 | | Some connectionStringName ->
165 | let configFileBase =
166 | match configFile with
167 | | None -> "app.config"
168 | | Some nm -> nm
169 | let configFileName =
170 | match resolutionFolder with
171 | | None ->
172 | if Path.IsPathRooted configFileBase then configFileBase else __SOURCE_DIRECTORY__ ++ configFileBase
173 | | Some rf ->
174 | let rfAbs = if Path.IsPathRooted rf then rf else Path.Combine(__SOURCE_DIRECTORY__, rf)
175 | Path.Combine(rfAbs,configFileBase)
176 | File.WriteAllText(configFileName,
177 | sprintf """
178 |
179 |
180 |
181 |
184 |
185 |
186 |
187 |
188 |
189 |
190 | """
191 | connectionStringName
192 | connectionString)
193 | let staticParameterValues =
194 | [| for x in hostedType1StaticParameters ->
195 | (match x.Name with
196 | | "ConnectionString" when connectionStringName.IsNone -> box connectionString
197 | | "Pluralize" -> box true
198 | | "ConnectionStringName" when connectionStringName.IsSome -> box connectionStringName.Value
199 | | "ResolutionFolder" when resolutionFolder.IsSome -> box resolutionFolder.Value
200 | | "DataDirectory" when dataDirectory.IsSome -> box dataDirectory.Value
201 | | "ConfigFile" when configFile.IsSome -> box configFile.Value
202 | | "ContextTypeName" -> box "Northwnd"
203 | | "LocalSchemaFile" when useLocalSchemaFile.IsSome -> box useLocalSchemaFile.Value
204 | | "ForceUpdate" when useForceUpdate.IsSome -> box useForceUpdate.Value
205 | | "Timeout" -> box 60
206 | | _ -> box x.RawDefaultValue) |]
207 | Console.WriteLine (sprintf "instantiating database type... may take a while for db to attach, code generation tool to run and csc.exe to run...")
208 |
209 | try
210 | let hostedAppliedType1 = typeProvider1.ApplyStaticArguments(hostedType1, typeFullPath, staticParameterValues)
211 |
212 | checkHostedType hostedAppliedType1
213 | with
214 | | e ->
215 | Console.WriteLine (sprintf "%s" (e.ToString()))
216 | reportFailure()
217 |
218 | []
219 | let ``SqlData.Tests 1`` () =
220 | let testIt useMsBuild =
221 | // Database not yet installed on appveyor
222 | if System.Environment.GetEnvironmentVariable("APPVEYOR") = null then
223 | instantiateTypeProviderAndCheckOneHostedType(useMsBuild, None, None, false, None, None, None, [| "SqlDataConnectionApplied" |], None)
224 | testIt false // Typeprovider name = FSharp.Data.TypeProviders
225 | testIt true // Typeprovider name = Microsoft.FSharp.Data.TypeProviders
226 |
227 | []
228 | let ``SqlData Tests 2`` () =
229 | let testIt useMsBuild =
230 | if System.Environment.GetEnvironmentVariable("APPVEYOR") = null then
231 | // Database not yet installed on appveyor
232 | // Use an implied app.config config file, use the current directory as the DataDirectory
233 | instantiateTypeProviderAndCheckOneHostedType(useMsBuild, Some "ConnectionString1", None, true, None, None, None, [| "SqlDataConnectionApplied" |], None)
234 | testIt false // Typeprovider name = FSharp.Data.TypeProviders
235 | testIt true // Typeprovider name = Microsoft.FSharp.Data.TypeProviders
236 |
237 | []
238 | let ``SqlData Tests 3`` () =
239 | let testIt useMsBuild =
240 | if System.Environment.GetEnvironmentVariable("APPVEYOR") = null then
241 | // Database not yet installed on appveyor
242 | // Use a config file, use an explicit relative DataDirectory
243 | instantiateTypeProviderAndCheckOneHostedType(useMsBuild, Some "ConnectionString2", Some "app.config", true, Some "DataDirectory", None, None, [| "SqlDataConnectionApplied" |], None)
244 | testIt false // Typeprovider name = FSharp.Data.TypeProviders
245 | testIt true // Typeprovider name = Microsoft.FSharp.Data.TypeProviders
246 |
247 | []
248 | let ``SqlData Tests 4`` () =
249 | let testIt useMsBuild =
250 | if System.Environment.GetEnvironmentVariable("APPVEYOR") = null then
251 | // Database not yet installed on appveyor
252 | // Use a config file, use an explicit relative DataDirectory and an explicit ResolutionFolder.
253 | instantiateTypeProviderAndCheckOneHostedType(useMsBuild, Some "ConnectionString2", Some "app.config", true, Some "DataDirectory", None, None, [| "SqlDataConnectionApplied" |], Some "ExampleResolutionFolder")
254 | testIt false // Typeprovider name = FSharp.Data.TypeProviders
255 | testIt true // Typeprovider name = Microsoft.FSharp.Data.TypeProviders
256 |
257 | []
258 | let ``SqlData Tests 5`` () =
259 | let testIt useMsBuild =
260 | if System.Environment.GetEnvironmentVariable("APPVEYOR") = null then
261 | // Database not yet installed on appveyor
262 | // Use an absolute config file, use an absolute DataDirectory
263 | instantiateTypeProviderAndCheckOneHostedType(useMsBuild, Some "ConnectionString3", Some (__SOURCE_DIRECTORY__ + @"\test.config"), true, Some (__SOURCE_DIRECTORY__ + @"\DataDirectory"), None, None, [| "SqlDataConnectionApplied" |], None)
264 | testIt false // Typeprovider name = FSharp.Data.TypeProviders
265 | testIt true // Typeprovider name = Microsoft.FSharp.Data.TypeProviders
266 |
267 | []
268 | let ``SqlData Tests 6`` () =
269 | let testIt useMsBuild =
270 | if System.Environment.GetEnvironmentVariable("APPVEYOR") = null then
271 | // Database not yet installed on appveyor
272 | let schemaFile2 = Path.Combine(__SOURCE_DIRECTORY__, "nwind2.dbml")
273 | (try File.Delete schemaFile2 with _ -> ())
274 | instantiateTypeProviderAndCheckOneHostedType(useMsBuild, None, None, false, None, Some (Path.Combine(__SOURCE_DIRECTORY__, "nwind2.dbml")), Some true, [| "SqlDataConnectionApplied" |], None)
275 | // schemaFile2 should now exist
276 | test "eoinew0c9e" (File.Exists schemaFile2)
277 |
278 | // Reuse the DBML just created
279 | instantiateTypeProviderAndCheckOneHostedType(useMsBuild, None, None, false, None, Some (Path.Combine(__SOURCE_DIRECTORY__, "nwind2.dbml")), Some false, [| "SqlDataConnectionApplied" |], None)
280 | // schemaFile2 should now still exist
281 | test "eoinew0c9e" (File.Exists schemaFile2)
282 |
283 | // // A relative path should work....
284 | // instantiateTypeProviderAndCheckOneHostedType(useMsBuild, Some "nwind2.dbml", Some false)
285 | // // schemaFile2 should now still exist
286 | // check "eoinew0c9e" (File.Exists schemaFile2)
287 | testIt false // Typeprovider name = FSharp.Data.TypeProviders
288 | testIt true // Typeprovider name = Microsoft.FSharp.Data.TypeProviders
289 |
290 | []
291 | let ``SqlData Tests 7`` () =
292 | let testIt useMsBuild =
293 | // Database not yet installed on appveyor
294 | if System.Environment.GetEnvironmentVariable("APPVEYOR") = null then
295 | let schemaFile3 = Path.Combine(__SOURCE_DIRECTORY__, "nwind3.dbml")
296 | (try File.Delete schemaFile3 with _ -> ())
297 | instantiateTypeProviderAndCheckOneHostedType(useMsBuild, None, None, false, None, Some schemaFile3, None, [| "SqlDataConnectionApplied" |], None)
298 |
299 | // schemaFile3 should now exist
300 | test "eoinew0c9e" (File.Exists schemaFile3)
301 | testIt false // Typeprovider name = FSharp.Data.TypeProviders
302 | testIt true // Typeprovider name = Microsoft.FSharp.Data.TypeProviders
303 |
--------------------------------------------------------------------------------
/tests/FSharp.Data.TypeProviders.Tests/SqlEntityConnection/DB/NORTHWND.MDF:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fsprojects/FSharp.Data.TypeProviders/fb942edbcbe038b8c5d6f6ca1f5fb36ba93d1748/tests/FSharp.Data.TypeProviders.Tests/SqlEntityConnection/DB/NORTHWND.MDF
--------------------------------------------------------------------------------
/tests/FSharp.Data.TypeProviders.Tests/SqlEntityConnection/SqlEntityConnectionTests.fs:
--------------------------------------------------------------------------------
1 | // #Conformance #TypeProviders #SqlEntityConnection
2 | #if COMPILED
3 | module FSharp.Data.TypeProviders.Tests.SqlEntityConnectionTests
4 | #else
5 | #r "nuget: FSharp.Data.TypeProviders"
6 | #r "System.Management.dll"
7 | #endif
8 |
9 | open Microsoft.FSharp.Core.CompilerServices
10 | open System
11 | open System.IO
12 | open NUnit.Framework
13 |
14 | []
15 | module Infrastructure =
16 | let reportFailure () = stderr.WriteLine " NO"; Assert.Fail("test failed")
17 | let test s b = stderr.Write(s:string); if b then stderr.WriteLine " OK" else reportFailure()
18 | let check s v1 v2 = stderr.Write(s:string); if v1 = v2 then stderr.WriteLine " OK" else Assert.Fail(sprintf "... FAILURE: expected %A, got %A " v2 v1)
19 |
20 |
21 | let isSQLExpressInstalled =
22 | lazy
23 | let edition = "Express Edition"
24 | let instance = "MSSQL$SQLEXPRESS"
25 |
26 | try
27 | let getSqlExpress =
28 | new System.Management.ManagementObjectSearcher("root\\Microsoft\\SqlServer\\ComputerManagement10",
29 | "select * from SqlServiceAdvancedProperty where SQLServiceType = 1 and ServiceName = '" + instance + "' and (PropertyName = 'SKUNAME' or PropertyName = 'SPLEVEL')")
30 |
31 | // If nothing is returned, SQL Express isn't installed.
32 | getSqlExpress.Get().Count <> 0
33 | with
34 | | _ -> false
35 |
36 | let checkHostedType (expectedContextTypeName, hostedType: System.Type) =
37 | //let hostedType = hostedAppliedType1
38 |
39 | test "ceklc09wlkm1a" (hostedType.Assembly <> typeof.Assembly)
40 | test "ceklc09wlkm1b" (hostedType.Assembly.FullName.StartsWith "tmp")
41 |
42 | check "ceklc09wlkm2" hostedType.DeclaringType null
43 | check "ceklc09wlkm3" hostedType.DeclaringMethod null
44 | check "ceklc09wlkm4" hostedType.FullName ("SqlEntityConnection1.SqlEntityConnectionApplied")
45 | check "ceklc09wlkm5" (hostedType.GetConstructors()) [| |]
46 | check "ceklc09wlkm6" (hostedType.GetCustomAttributesData().Count) 1
47 | check "ceklc09wlkm6" (hostedType.GetCustomAttributesData().[0].Constructor.DeclaringType.FullName) typeof.FullName
48 | check "ceklc09wlkm7" (hostedType.GetEvents()) [| |]
49 | check "ceklc09wlkm8" (hostedType.GetFields()) [| |]
50 | check "ceklc09wlkm9" [ for m in hostedType.GetMethods() -> m.Name ] [ "GetDataContext" ;"GetDataContext" ]
51 | let m0 = hostedType.GetMethods().[0]
52 | let m1 = hostedType.GetMethods().[1]
53 | check "ceklc09wlkm9b" (m0.GetParameters().Length) 0
54 | check "ceklc09wlkm9c" (m1.GetParameters().Length) 1
55 | check "ceklc09wlkm9d" (m0.ReturnType.Name) expectedContextTypeName
56 | check "ceklc09wlkm9e" (m0.ReturnType.FullName) ("SqlEntityConnection1.SqlEntityConnectionApplied+ServiceTypes+SimpleDataContextTypes+" + expectedContextTypeName)
57 | check "ceklc09wlkm10" (hostedType.GetProperties()) [| |]
58 | check "ceklc09wlkm11" (hostedType.GetNestedTypes().Length) 1
59 | check "ceklc09wlkm12"
60 | (set [ for x in hostedType.GetNestedTypes() -> x.Name ])
61 | (set ["ServiceTypes"])
62 |
63 | let hostedServiceTypes = hostedType.GetNestedTypes().[0]
64 | check "ceklc09wlkm12b" (hostedServiceTypes.GetMethods()) [| |]
65 | check "ceklc09wlkm12c" (hostedServiceTypes.GetNestedTypes().Length) 28
66 |
67 | let hostedSimpleDataContextTypes = hostedServiceTypes.GetNestedType("SimpleDataContextTypes")
68 | check "ceklc09wlkm12d" (hostedSimpleDataContextTypes.GetMethods()) [| |]
69 | check "ceklc09wlkm12e" (hostedSimpleDataContextTypes.GetNestedTypes().Length) 1
70 | check "ceklc09wlkm12e" [ for x in hostedSimpleDataContextTypes.GetNestedTypes() -> x.Name] [expectedContextTypeName]
71 |
72 | check "ceklc09wlkm12"
73 | (set [ for x in hostedServiceTypes.GetNestedTypes() -> x.Name ])
74 | (set
75 | (["Territory"; "Supplier"; "Summary_of_Sales_by_Year";
76 | "Summary_of_Sales_by_Quarter"; "Shipper"; "Sales_Totals_by_Amount";
77 | "Sales_by_Category"; "Region"; "Products_by_Category";
78 | "Products_Above_Average_Price"; "Product_Sales_for_1997"; "Product";
79 | "Orders_Qry"; "Order_Subtotal"; "Order_Details_Extended"; "Order_Detail";
80 | "Order"; "Invoice"; "Employee"; "CustomerDemographic";
81 | "Customer_and_Suppliers_by_City"; "Customer"; "Current_Product_List";
82 | "Category_Sales_for_1997"; "Category"; "Alphabetical_list_of_product"; ] @
83 | [expectedContextTypeName] @
84 | [ "SimpleDataContextTypes"]))
85 |
86 | let customersType = (hostedServiceTypes.GetNestedTypes() |> Seq.find (fun t -> t.Name = "Customer"))
87 | check "ceklc09wlkm13" (customersType.GetProperties().Length) 15
88 |
89 | let (++) a b = Path.Combine(a,b)
90 |
91 | let instantiateTypeProviderAndCheckOneHostedType(useMsPrefix, connectionStringName, configFile, useDataDirectory, dataDirectory, entityContainer: string option, localSchemaFile: string option, useForceUpdate: bool option, typeFullPath: string[], resolutionFolder: string option) =
92 | let expectedContextTypeName = match entityContainer with None -> "EntityContainer" | Some s -> s
93 | let assemblyFile = typeof.Assembly.CodeBase.Replace("file:///","").Replace("/","\\")
94 | test "cnlkenkewe" (File.Exists assemblyFile)
95 |
96 | // If/when we care about the "target framework", this mock function will have to be fully implemented
97 | let systemRuntimeContainsType s =
98 | Console.WriteLine (sprintf "Call systemRuntimeContainsType(%s) returning dummy value 'true'" s)
99 | true
100 |
101 | let tpConfig = new TypeProviderConfig(systemRuntimeContainsType, ResolutionFolder=__SOURCE_DIRECTORY__, RuntimeAssembly=assemblyFile, ReferencedAssemblies=[| |], TemporaryFolder=Path.GetTempPath(), IsInvalidationSupported=false, IsHostedExecution=true)
102 | use typeProvider1 = (new FSharp.Data.TypeProviders.DesignTime.DataProviders( tpConfig ) :> ITypeProvider)
103 | let invalidateEventCount = ref 0
104 |
105 | typeProvider1.Invalidate.Add(fun _ -> incr invalidateEventCount)
106 |
107 | // Load a type provider instance for the type and restart
108 | let hostedNamespace1 = typeProvider1.GetNamespaces() |> Seq.find (fun t -> t.NamespaceName = if useMsPrefix then "Microsoft.FSharp.Data.TypeProviders" else "FSharp.Data.TypeProviders")
109 |
110 | check "eenewioinw" (set [ for i in hostedNamespace1.GetTypes() -> i.Name ]) (set ["DbmlFile"; "EdmxFile"; "ODataService"; "SqlDataConnection";"SqlEntityConnection";"WsdlService"])
111 |
112 | let hostedType1 = hostedNamespace1.ResolveTypeName("SqlEntityConnection")
113 | let hostedType1StaticParameters = typeProvider1.GetStaticParameters(hostedType1)
114 | check "eenewioinw2"
115 | (set [ for i in hostedType1StaticParameters -> i.Name ])
116 | (set ["ConnectionString"; "ConnectionStringName"; "ResolutionFolder"; "DataDirectory"; "ConfigFile"; "ForceUpdate"; "Provider"; "EntityContainer"; "LocalSchemaFile"; "Pluralize"; "SuppressForeignKeyProperties"] )
117 |
118 |
119 | let northwind = "NORTHWND.mdf"
120 | let northwindFile =
121 | match resolutionFolder with
122 | | None ->
123 | match dataDirectory with
124 | | None ->
125 | Path.Combine(__SOURCE_DIRECTORY__, northwind)
126 | | Some dd ->
127 | let ddAbs = if Path.IsPathRooted dd then dd else Path.Combine(__SOURCE_DIRECTORY__, dd)
128 | if not(Directory.Exists ddAbs) then Directory.CreateDirectory ddAbs |> ignore
129 | Path.Combine(ddAbs, northwind)
130 |
131 | | Some rf ->
132 | let rfAbs = if Path.IsPathRooted rf then rf else Path.Combine(__SOURCE_DIRECTORY__, rf)
133 | if not(Directory.Exists rfAbs) then Directory.CreateDirectory rfAbs |> ignore
134 | match dataDirectory with
135 | | None ->
136 | Path.Combine(rf, northwind)
137 | | Some dd ->
138 | let ddAbs = if Path.IsPathRooted dd then dd else Path.Combine(rfAbs, dd)
139 | if not(Directory.Exists ddAbs) then Directory.CreateDirectory ddAbs |> ignore
140 | Path.Combine(ddAbs,northwind)
141 |
142 |
143 | if not(File.Exists(northwindFile)) then
144 | File.Copy(__SOURCE_DIRECTORY__ ++ "DB" ++ "northwnd.mdf", northwindFile, false)
145 | File.SetAttributes(northwindFile, FileAttributes.Normal)
146 |
147 |
148 | let connectionString =
149 | if useDataDirectory then
150 | if isSQLExpressInstalled.Value then
151 | @"AttachDBFileName = '|DataDirectory|\" + northwind + "';Server='.\SQLEXPRESS';User Instance=true;Integrated Security=SSPI"
152 | else
153 | "AttachDBFileName = '|DataDirectory|\\" + northwind + "';Server='(localdb)\\MSSQLLocalDB'"
154 | else
155 | if isSQLExpressInstalled.Value then
156 | @"AttachDBFileName = '" + System.IO.Path.Combine(__SOURCE_DIRECTORY__, northwindFile) + "';Server='.\SQLEXPRESS';User Instance=true;Integrated Security=SSPI"
157 | else
158 | "AttachDBFileName = '" + System.IO.Path.Combine(__SOURCE_DIRECTORY__, northwindFile) + "';Server='(localdb)\\MSSQLLocalDB'"
159 |
160 | match connectionStringName with
161 | | None -> ()
162 | | Some connectionStringName ->
163 | let configFileBase =
164 | match configFile with
165 | | None -> "app.config"
166 | | Some nm -> nm
167 | let configFileName =
168 | match resolutionFolder with
169 | | None ->
170 | if Path.IsPathRooted configFileBase then configFileBase else __SOURCE_DIRECTORY__ ++ configFileBase
171 | | Some rf ->
172 | let rfAbs = if Path.IsPathRooted rf then rf else Path.Combine(__SOURCE_DIRECTORY__, rf)
173 | Path.Combine(rfAbs,configFileBase)
174 | System.IO.File.WriteAllText(configFileName,
175 | sprintf """
176 |
177 |
178 |
179 |
182 |
183 |
184 |
185 |
186 |
187 |
188 | """
189 | connectionStringName
190 | connectionString)
191 | let staticParameterValues =
192 | [| for x in hostedType1StaticParameters ->
193 | (match x.Name with
194 | | "ConnectionString" when connectionStringName.IsNone -> box connectionString
195 | | "ConnectionStringName" when connectionStringName.IsSome -> box connectionStringName.Value
196 | | "DataDirectory" when dataDirectory.IsSome -> box dataDirectory.Value
197 | | "ConfigFile" when configFile.IsSome -> box configFile.Value
198 | | "Pluralize" -> box true
199 | | "EntityContainer" when entityContainer.IsSome -> box entityContainer.Value
200 | | "SuppressForeignKeyProperties" -> box false
201 | | "LocalSchemaFile" when localSchemaFile.IsSome -> box localSchemaFile.Value
202 | | "ForceUpdate" when useForceUpdate.IsSome -> box useForceUpdate.Value
203 | | _ -> box x.RawDefaultValue) |]
204 | Console.WriteLine (sprintf "instantiating database type... may take a while for db to attach, code generation tool to run and csc.exe to run...")
205 | try
206 | let hostedAppliedType1 = typeProvider1.ApplyStaticArguments(hostedType1, typeFullPath, staticParameterValues)
207 |
208 | checkHostedType (expectedContextTypeName,hostedAppliedType1 )
209 | with
210 | | e ->
211 | Console.WriteLine (sprintf "%s" (e.ToString()))
212 | reportFailure()
213 |
214 | []
215 | let ``SqlEntity Tests 1`` () =
216 | let testIt useMsPrefix =
217 | // Database not yet installed on appveyor
218 | if System.Environment.GetEnvironmentVariable("APPVEYOR") = null then
219 | instantiateTypeProviderAndCheckOneHostedType(useMsPrefix, None, None, false, None, None, None, None, [| "SqlEntityConnectionApplied" |], None)
220 | testIt false // Typeprovider name = FSharp.Data.TypeProviders
221 | testIt true // Typeprovider name = Microsoft.FSharp.Data.TypeProviders
222 |
223 | []
224 | let ``SqlEntity Tests 2`` () =
225 | let testIt useMsPrefix =
226 | // Database not yet installed on appveyor
227 | if System.Environment.GetEnvironmentVariable("APPVEYOR") = null then
228 | // Use an implied app.config config file, use the current directory as the DataDirectory
229 | instantiateTypeProviderAndCheckOneHostedType(useMsPrefix, Some "ConnectionString1", None, true, None, None, None, None, [| "SqlEntityConnectionApplied" |], None)
230 | testIt false // Typeprovider name = FSharp.Data.TypeProviders
231 | testIt true // Typeprovider name = Microsoft.FSharp.Data.TypeProviders
232 |
233 | []
234 | let ``SqlEntity Tests 3`` () =
235 | let testIt useMsPrefix =
236 | // Database not yet installed on appveyor
237 | if System.Environment.GetEnvironmentVariable("APPVEYOR") = null then
238 | // Use a config file, use an explicit relative DataDirectory
239 | instantiateTypeProviderAndCheckOneHostedType(useMsPrefix, Some "ConnectionString2", Some "app.config", true, Some "DataDirectory", None, None, None, [| "SqlEntityConnectionApplied" |], None)
240 | testIt false // Typeprovider name = FSharp.Data.TypeProviders
241 | testIt true // Typeprovider name = Microsoft.FSharp.Data.TypeProviders
242 |
243 | []
244 | let ``SqlEntity Tests 4`` () =
245 | let testIt useMsPrefix =
246 | // Database not yet installed on appveyor
247 | if System.Environment.GetEnvironmentVariable("APPVEYOR") = null then
248 | // Use an absolute config file, use an absoltue DataDirectory
249 | instantiateTypeProviderAndCheckOneHostedType(useMsPrefix, Some "ConnectionString3", Some (__SOURCE_DIRECTORY__ ++ "test.config"), true, Some (__SOURCE_DIRECTORY__ ++ "DataDirectory"), None, None, None, [| "SqlEntityConnectionApplied" |], None)
250 | testIt false // Typeprovider name = FSharp.Data.TypeProviders
251 | testIt true // Typeprovider name = Microsoft.FSharp.Data.TypeProviders
252 |
253 |
254 | []
255 | let ``SqlEntity Tests 5`` () =
256 | let testIt useMsPrefix =
257 | // Database not yet installed on appveyor
258 | if System.Environment.GetEnvironmentVariable("APPVEYOR") = null then
259 | let schemaFile2 = Path.Combine(__SOURCE_DIRECTORY__, "nwind2.ssdl")
260 | (try File.Delete schemaFile2 with _ -> ())
261 | instantiateTypeProviderAndCheckOneHostedType(useMsPrefix, None, None, false, None, None, Some (Path.Combine(__SOURCE_DIRECTORY__, "nwind2.ssdl")), Some true, [| "SqlEntityConnectionApplied" |], None)
262 | // schemaFile2 should now exist
263 | test "eoinew0c9e" (File.Exists schemaFile2)
264 |
265 | // Reuse the SSDL just created
266 | instantiateTypeProviderAndCheckOneHostedType(useMsPrefix, None, None, false, None, None, Some (Path.Combine(__SOURCE_DIRECTORY__, "nwind2.ssdl")), Some false, [| "SqlEntityConnectionApplied" |], None)
267 | // schemaFile2 should now still exist
268 | test "eoinew0c9e" (File.Exists schemaFile2)
269 |
270 | // // A relative path should work....
271 | // instantiateTypeProviderAndCheckOneHostedType(useMsPrefix, Some "nwind2.ssdl", Some false)
272 | // // schemaFile2 should now still exist
273 | // check "eoinew0c9e" (File.Exists schemaFile2)
274 | testIt false // Typeprovider name = FSharp.Data.TypeProviders
275 | testIt true // Typeprovider name = Microsoft.FSharp.Data.TypeProviders
276 |
277 | []
278 | let ``SqlEntity Tests 6`` () =
279 | let testIt useMsPrefix =
280 | // Database not yet installed on appveyor
281 | if System.Environment.GetEnvironmentVariable("APPVEYOR") = null then
282 | let schemaFile3 = Path.Combine(__SOURCE_DIRECTORY__, "nwind3.ssdl")
283 | (try File.Delete schemaFile3 with _ -> ())
284 | instantiateTypeProviderAndCheckOneHostedType(useMsPrefix, None, None, false, None, None, Some schemaFile3, None, [| "SqlEntityConnectionApplied" |],None)
285 |
286 | // schemaFile3 should now exist
287 | test "eoinew0c9e" (File.Exists schemaFile3)
288 | testIt false // Typeprovider name = FSharp.Data.TypeProviders
289 | testIt true // Typeprovider name = Microsoft.FSharp.Data.TypeProviders
290 |
291 | []
292 | let ``SqlEntity Tests 7`` () =
293 | let testIt useMsPrefix =
294 | // Database not yet installed on appveyor
295 | if System.Environment.GetEnvironmentVariable("APPVEYOR") = null then
296 | let schemaFile4 = Path.Combine(__SOURCE_DIRECTORY__, "nwind4.ssdl")
297 | (try File.Delete schemaFile4 with _ -> ())
298 | instantiateTypeProviderAndCheckOneHostedType(useMsPrefix, None, None, false, None, Some "MyEntityContainer", Some schemaFile4, None, [| "SqlEntityConnectionApplied" |], None)
299 |
300 | // schemaFile4 should now exist
301 | test "eoinew0c9e" (File.Exists schemaFile4)
302 |
303 | testIt false // Typeprovider name = FSharp.Data.TypeProviders
304 | testIt true // Typeprovider name = Microsoft.FSharp.Data.TypeProviders
305 |
--------------------------------------------------------------------------------
/tests/FSharp.Data.TypeProviders.Tests/SqlEntityConnection/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/tests/FSharp.Data.TypeProviders.Tests/SqlEntityConnection/test.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/tests/FSharp.Data.TypeProviders.Tests/WsdlService/WsdlServiceTests.fs:
--------------------------------------------------------------------------------
1 | // #Conformance #TypeProviders #WsdlService
2 | #if COMPILED
3 | module FSharp.Data.TypeProviders.Tests.WsdlServiceTests
4 | #else
5 | #r "nuget: FSharp.Data.TypeProviders"
6 | #endif
7 |
8 | open Microsoft.FSharp.Core.CompilerServices
9 | open System
10 | open System.IO
11 | open NUnit.Framework
12 |
13 | []
14 | module Infrastructure =
15 | let reportFailure () = stderr.WriteLine " NO"; Assert.Fail("test failed")
16 | let test s b = stderr.Write(s:string); if b then stderr.WriteLine " OK" else reportFailure()
17 | let check s v1 v2 = stderr.Write(s:string); if v1 = v2 then stderr.WriteLine " OK" else Assert.Fail(sprintf "... FAILURE: expected %A, got %A " v2 v1)
18 |
19 |
20 | []
21 | type WsdlServiceTest(serviceUri, prefix, useMsPrefix, checkHostedType) =
22 |
23 | let check caption a b = Infrastructure.check (prefix + caption) a b
24 | let test caption v = Infrastructure.test (prefix + caption) v
25 |
26 | let InstantiateTypeProvider (useLocalSchemaFile : string option, useForceUpdate : bool option, typeFullPath : string[]) =
27 | let assemblyFile = typeof.Assembly.CodeBase.Replace("file:///","").Replace("/","\\")
28 | test "cnlkenkewe" (File.Exists assemblyFile)
29 |
30 | // If/when we care about the "target framework", this mock function will have to be fully implemented
31 | let systemRuntimeContainsType s =
32 | Console.WriteLine (sprintf "Call systemRuntimeContainsType(%s) returning dummy value 'true'" s)
33 | true
34 |
35 | let tpConfig = new TypeProviderConfig(systemRuntimeContainsType, ResolutionFolder=__SOURCE_DIRECTORY__, RuntimeAssembly=assemblyFile, ReferencedAssemblies=[| |], TemporaryFolder=Path.GetTempPath(), IsInvalidationSupported=true, IsHostedExecution=true)
36 | use typeProvider1 = (new FSharp.Data.TypeProviders.DesignTime.DataProviders( tpConfig ) :> ITypeProvider)
37 |
38 | let invalidateEventCount = ref 0
39 |
40 | typeProvider1.Invalidate.Add(fun _ -> incr invalidateEventCount)
41 |
42 | // Load a type provider instance for the type and restart
43 | let hostedNamespace1 = typeProvider1.GetNamespaces() |> Seq.find (fun t -> t.NamespaceName = if useMsPrefix then "Microsoft.FSharp.Data.TypeProviders" else "FSharp.Data.TypeProviders")
44 |
45 | check "eenewioinw" (set [ for i in hostedNamespace1.GetTypes() -> i.Name ]) (set ["DbmlFile"; "EdmxFile"; "ODataService"; "SqlDataConnection";"SqlEntityConnection";"WsdlService"])
46 |
47 | let hostedType1 = hostedNamespace1.ResolveTypeName("WsdlService")
48 | let hostedType1StaticParameters = typeProvider1.GetStaticParameters(hostedType1)
49 | check "eenewioinw2"
50 | (set [ for i in hostedType1StaticParameters -> i.Name ])
51 | (set ["ServiceUri"; "LocalSchemaFile"; "ResolutionFolder"; "ForceUpdate"; "Serializable"; "MessageContract"; "EnableDataBinding"; "Async"; "CollectionType"; "Wrapped"; "SvcUtilPath"])
52 |
53 | let staticParameterValues =
54 | [| for x in hostedType1StaticParameters ->
55 | (match x.Name with
56 | | "ServiceUri" -> box serviceUri
57 | | "LocalSchemaFile" when useLocalSchemaFile.IsSome -> box useLocalSchemaFile.Value
58 | | "ForceUpdate" when useForceUpdate.IsSome -> box useForceUpdate.Value
59 | | _ -> box x.RawDefaultValue) |]
60 |
61 | for p in Seq.zip hostedType1StaticParameters staticParameterValues do
62 | Console.WriteLine (sprintf "%A" p)
63 | Console.WriteLine (sprintf "instantiating service type... may take a while for WSDL service metadata to be downloaded, code generation tool to run and csc.exe to run...")
64 | typeProvider1.ApplyStaticArguments(hostedType1, typeFullPath, staticParameterValues)
65 |
66 | member this.Run() =
67 | InstantiateTypeProvider( None, None, [| "WsdlServiceApplied" |] ) |> checkHostedType
68 |
69 | let sfile = "sfile.wsdlschema"
70 | let fullPath s = Path.Combine(__SOURCE_DIRECTORY__, s)
71 | let schemaFile = fullPath sfile
72 |
73 | (try File.Delete schemaFile with _ -> ())
74 | InstantiateTypeProvider(Some sfile, Some true, [| "WsdlServiceApplied" |]) |> checkHostedType
75 | // schemaFile should now exist
76 | test "eoinew0c9e1" (File.Exists schemaFile)
77 |
78 | let writeTime = File.GetLastWriteTime(schemaFile)
79 | // Reuse the WsdlSchema just created
80 | InstantiateTypeProvider(Some sfile, Some false, [| "WsdlServiceApplied" |]) |> checkHostedType
81 | // schemaFile should still exist
82 | test "eoinew0c9e" (File.Exists schemaFile)
83 | check "LastWriteTime_1" (File.GetLastWriteTime(schemaFile)) writeTime
84 |
85 | let sfile2 = "sfile2.wsdlschema"
86 | let schemaFile2 = fullPath sfile2
87 | (try File.Delete schemaFile2 with _ -> ())
88 |
89 | let check(prefix2) =
90 | // schemaFile2 should now exist
91 | test (prefix2 + "eoinew0c9e") (File.Exists schemaFile2)
92 |
93 | (*
94 | // rename schema file
95 | let renamedFile = fullPath "renamed"
96 | // delete existing file
97 | try File.Delete renamedFile with _ -> ()
98 | System.Threading.SpinWait.SpinUntil((fun () -> File.Exists(schemaFile2)), 10000)
99 | |> ignore
100 | test (prefix2 + "SchemaFileExists") (File.Exists schemaFile2)
101 | *)
102 |
103 | InstantiateTypeProvider(Some sfile2, Some false, [| "WsdlServiceApplied" |]) |> checkHostedType
104 | check "noncorrupt-"
105 |
106 |
107 | (*
108 | // corrupt source file
109 | let initial = File.ReadAllText(sfile2)
110 | let text = "123" + File.ReadAllText(sfile2)
111 | File.WriteAllText(sfile2, text)
112 | try
113 | InstantiateTypeProvider(Some sfile2, Some false, [| "WsdlServiceApplied" |]) |> ignore
114 | test "Exception_Expected" false
115 | with
116 | e -> ()
117 | // read all text and verify that it was not overwritten
118 | let newText = File.ReadAllText(sfile2)
119 | test "FileWasNotChanged" (text = newText)
120 |
121 | *)
122 |
123 |
124 | type SimpleWsdlTest(useMsPrefix) =
125 | inherit WsdlServiceTest("http://api.microsofttranslator.com/V2/Soap.svc", SimpleWsdlTest.Prefix, useMsPrefix, SimpleWsdlTest.CheckHostedType)
126 |
127 | static let check caption a b = Infrastructure.check (SimpleWsdlTest.Prefix + caption) a b
128 | static let test caption v = Infrastructure.test (SimpleWsdlTest.Prefix + caption) v
129 |
130 | static member Prefix = "simple-"
131 | static member CheckHostedType(hostedType) =
132 | test "09wlkm1a" (hostedType.Assembly <> typeof.Assembly)
133 | test "09wlkm1b" (hostedType.Assembly.FullName.StartsWith "tmp")
134 |
135 | check "09wlkm2" hostedType.DeclaringType null
136 | check "09wlkm3" hostedType.DeclaringMethod null
137 | check "09wlkm4" hostedType.FullName "WsdlService1.WsdlServiceApplied"
138 | check "09wlkm5" (hostedType.GetConstructors()) [| |]
139 | check "09wlkm6" (hostedType.GetCustomAttributesData().Count) 1
140 | check "09wlkm6" (hostedType.GetCustomAttributesData().[0].Constructor.DeclaringType.FullName) typeof.FullName
141 | check "09wlkm7" (hostedType.GetEvents()) [| |]
142 | check "09wlkm8" (hostedType.GetFields()) [| |]
143 | check "09wlkm9" (hostedType.GetMethods() |> Array.map (fun m -> m.Name)) [| "GetBasicHttpBinding_LanguageService"; "GetBasicHttpBinding_LanguageService"|]
144 | check "09wlkm10" (hostedType.GetProperties()) [| |]
145 | check "09wlkm11"
146 | (set [ for x in hostedType.GetNestedTypes() -> x.Name ])
147 | (set ["ServiceTypes"] )
148 |
149 | let serviceTypes = hostedType.GetNestedTypes().[0]
150 |
151 | check "09wlkm11" (serviceTypes.GetNestedTypes().Length) 5
152 | check "09wlkm12"
153 | (set [ for x in serviceTypes.GetNestedTypes() -> x.Name ])
154 | (set ["LanguageService"; "LanguageServiceChannel"; "LanguageServiceClient"; "Microsoft"; "SimpleDataContextTypes" ] )
155 |
156 | let languageServiceType = (serviceTypes.GetNestedTypes() |> Seq.find (fun t -> t.Name = "LanguageService"))
157 | check "09wlkm13" (languageServiceType.GetProperties().Length) 0
158 |
159 |
160 | type XIgniteWsdlTest(useMsPrefix) =
161 | inherit WsdlServiceTest("http://www.xignite.com/xFutures.asmx?WSDL", XIgniteWsdlTest.Prefix, useMsPrefix, XIgniteWsdlTest.CheckHostedType)
162 |
163 | static let check caption a b = Infrastructure.check (XIgniteWsdlTest.Prefix + caption) a b
164 | static let test caption v = Infrastructure.test (XIgniteWsdlTest.Prefix + caption) v
165 |
166 | static member Prefix = "xignite-"
167 |
168 | static member CheckHostedType (hostedType: System.Type) =
169 | test "09wlkm1ad233" (hostedType.Assembly <> typeof.Assembly)
170 | test "09wlkm1b2ed1" (hostedType.Assembly.FullName.StartsWith "tmp")
171 |
172 | check "09wlkm2" hostedType.DeclaringType null
173 | check "09wlkm3" hostedType.DeclaringMethod null
174 | check "09wlkm4" hostedType.FullName "WsdlService1.WsdlServiceApplied"
175 | check "09wlkm5" (hostedType.GetConstructors()) [| |]
176 | check "09wlkm6" (hostedType.GetCustomAttributesData().Count) 1
177 | check "09wlkm6" (hostedType.GetCustomAttributesData().[0].Constructor.DeclaringType.FullName) typeof.FullName
178 | check "09wlkm7" (hostedType.GetEvents()) [| |]
179 | check "09wlkm8" (hostedType.GetFields()) [| |]
180 | check "09wlkm9" (hostedType.GetMethods() |> Array.map (fun m -> m.Name)) [| "GetXigniteFuturesSoap"; "GetXigniteFuturesSoap"; "GetXigniteFuturesSoap12";"GetXigniteFuturesSoap12"|]
181 | check "09wlkm10" (hostedType.GetProperties()) [| |]
182 |
183 | let serviceTypes = hostedType.GetNestedTypes().[0]
184 |
185 |
186 | check "09wlkm11a" (serviceTypes.GetNestedTypes().Length >= 1) true
187 | check "09wlkm11b" (serviceTypes.GetNestedType("www") <> null) true
188 | check "09wlkm11c" (serviceTypes.GetNestedType("www").GetNestedType("xignite") <> null) true
189 | check "09wlkm11d" (serviceTypes.GetNestedType("www").GetNestedType("xignite").GetNestedType("com") <> null) true
190 | check "09wlkm11e" (serviceTypes.GetNestedType("www").GetNestedType("xignite").GetNestedType("com").GetNestedType("services") <> null) true
191 | check "09wlkm11f" (serviceTypes.GetNestedType("www").GetNestedType("xignite").GetNestedType("com").GetNestedType("services").GetNestedTypes().Length >= 1) true
192 | check "09wlkm11g" [ for x in serviceTypes.GetNestedTypes() do if not x.IsNested && x.Namespace = null then yield x.Name ].Length 175
193 |
194 |
195 | []
196 | let ``WSDL Tests 1`` () =
197 | (new SimpleWsdlTest(false)).Run() // Typeprovider name = FSharp.Data.TypeProviders
198 | (new SimpleWsdlTest(true)).Run() // Typeprovider name = Microsoft.FSharp.Data.TypeProviders
199 |
200 | []
201 | let ``WSDL Tests 2`` () =
202 | (new XIgniteWsdlTest(false)).Run() // Typeprovider name = FSharp.Data.TypeProviders
203 | (new XIgniteWsdlTest(true)).Run() // Typeprovider name = Microsoft.FSharp.Data.TypeProviders
204 |
205 |
206 |
--------------------------------------------------------------------------------
/tests/FSharp.Data.TypeProviders.Tests/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | True
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/tests/FSharp.Data.TypeProviders.Tests/paket.references:
--------------------------------------------------------------------------------
1 | FSharp.Core
2 | group Test
3 | Microsoft.NET.Test.Sdk
4 | NUnit
5 | NUnit3TestAdapter
6 | coverlet.collector
--------------------------------------------------------------------------------
/tests/FSharp.Data.TypeProviders.UsageTests/EdmxFile/EdmxFileTests.fs:
--------------------------------------------------------------------------------
1 | // #Conformance #TypeProviders #EdmxFile
2 | #if COMPILED
3 | module FSharp.Data.TypeProviders.UsageTests.EdmxFile
4 | #else
5 | #r "../../bin/FSharp.Data.TypeProviders.dll"
6 | #endif
7 |
8 |
9 | open FSharp.Data.TypeProviders
10 |
11 | type internal Edmx1 = EdmxFile< @"EdmxFile\EdmxFiles\SampleModel01.edmx">
12 |
13 | let internal container = new Edmx1.SampleModel01.SampleModel01Container()
14 |
--------------------------------------------------------------------------------
/tests/FSharp.Data.TypeProviders.UsageTests/EdmxFile/EdmxFiles/SampleModel01.edmx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/tests/FSharp.Data.TypeProviders.UsageTests/FSharp.Data.TypeProviders.UsageTests.fsproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net472
5 | false
6 | false
7 | true
8 |
9 |
10 |
11 |
12 | EdmxFileTests.fs
13 |
14 |
15 | ODataServiceTests.fs
16 |
17 |
18 | SqlDataConnectionTests.fs
19 |
20 |
21 | SqlEntityConnectionTests.fs
22 |
23 |
24 | WsdlServiceTests.fs
25 |
26 |
27 |
28 |
29 |
30 |
31 | EdmxFileTests.fs
32 |
33 |
34 | ODataServiceTests.fs
35 |
36 |
37 | SqlDataConnectionTests.fs
38 |
39 |
40 | SqlEntityConnectionTests.fs
41 |
42 |
43 | WsdlServiceTests.fs
44 |
45 |
46 |
47 |
48 |
49 | ..\..\bin\net472\FSharp.Data.TypeProviders.dll
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/tests/FSharp.Data.TypeProviders.UsageTests/ODataService/ODataServiceTests.fs:
--------------------------------------------------------------------------------
1 | // #Conformance #TypeProviders #ODataService
2 |
3 | #if COMPILED
4 | module FSharp.Data.TypeProviders.UsageTests.OdataServiceTests
5 | #else
6 | #r "../../bin/FSharp.Data.TypeProviders.dll"
7 | #endif
8 |
9 | open FSharp.Data.TypeProviders
10 |
11 | type OData1= ODataService< @"http://services.odata.org/V2/OData/OData.svc/">
12 |
13 | type ST = OData1.ServiceTypes
14 | type Address = OData1.ServiceTypes.Address
15 | module M =
16 | let ctx = OData1.GetDataContext()
17 |
18 | (*
19 | type OData2 = Microsoft.FSharp.Data.TypeProviders.ODataService< @"http://services.odata.org/V2/OData/OData.svc/">
20 |
21 | module M2 =
22 | let ctx = OData2.GetDataContext()
23 | *)
24 |
25 |
--------------------------------------------------------------------------------
/tests/FSharp.Data.TypeProviders.UsageTests/SqlDataConnection/DB/NORTHWND.MDF:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fsprojects/FSharp.Data.TypeProviders/fb942edbcbe038b8c5d6f6ca1f5fb36ba93d1748/tests/FSharp.Data.TypeProviders.UsageTests/SqlDataConnection/DB/NORTHWND.MDF
--------------------------------------------------------------------------------
/tests/FSharp.Data.TypeProviders.UsageTests/SqlDataConnection/SqlDataConnectionTests.fs:
--------------------------------------------------------------------------------
1 | // #Conformance #TypeProviders #SqlDataConnection
2 |
3 | #if COMPILED
4 | module FSharp.Data.TypeProviders.UsageTests.SqlDataConnectionTests
5 | #else
6 | #r "nuget: FSharp.Data.TypeProviders"
7 | #r "System.Management.dll"
8 | #endif
9 |
10 |
11 | open FSharp.Data.TypeProviders
12 |
13 | //let [] SERVER = @".\SQLEXPRESS"
14 | let [] SERVER2 = @"(localdb)\MSSQLLocalDB"
15 | let [] CONN = "AttachDBFileName = '" + __SOURCE_DIRECTORY__ + @"\DB\NORTHWND.MDF';Server='" + SERVER2 + "'"
16 |
17 | type SqlData1 = SqlDataConnection< CONN>
18 |
19 | let ctxt = SqlData1.GetDataContext()
20 |
--------------------------------------------------------------------------------
/tests/FSharp.Data.TypeProviders.UsageTests/SqlEntityConnection/DB/NORTHWND.MDF:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fsprojects/FSharp.Data.TypeProviders/fb942edbcbe038b8c5d6f6ca1f5fb36ba93d1748/tests/FSharp.Data.TypeProviders.UsageTests/SqlEntityConnection/DB/NORTHWND.MDF
--------------------------------------------------------------------------------
/tests/FSharp.Data.TypeProviders.UsageTests/SqlEntityConnection/SqlEntityConnectionTests.fs:
--------------------------------------------------------------------------------
1 | // #Conformance #TypeProviders #SqlEntityConnection
2 | #if COMPILED
3 | module FSharp.Data.TypeProviders.UsageTests.SqlEntityConnectionTests
4 | #else
5 | #r "nuget: FSharp.Data.TypeProviders"
6 | #r "System.Management.dll"
7 | #endif
8 |
9 |
10 | open FSharp.Data.TypeProviders
11 |
12 | //let [] SERVER = @".\SQLEXPRESS"
13 | let [] SERVER2 = @"(localdb)\MSSQLLocalDB"
14 | let [] CONN = "AttachDBFileName = '" + __SOURCE_DIRECTORY__ + @"\DB\NORTHWND.MDF';Server='" + SERVER2 + "'"
15 |
16 | type internal SqlEntity1 = SqlEntityConnection< CONN>
17 |
18 | let internal ctxt = SqlEntity1.GetDataContext()
19 |
--------------------------------------------------------------------------------
/tests/FSharp.Data.TypeProviders.UsageTests/WsdlService/WsdlServiceTests.fs:
--------------------------------------------------------------------------------
1 | // #Conformance #TypeProviders #WsdlService
2 | #if COMPILED
3 | module FSharp.Data.TypeProviders.UsageTests.WsdlServiceTests
4 | #else
5 | #r "nuget: FSharp.Data.TypeProviders"
6 | #endif
7 |
8 |
9 | open FSharp.Data.TypeProviders
10 |
11 | type Wsdl1 = WsdlService<"http://api.microsofttranslator.com/V2/Soap.svc">
12 |
13 | let ctxt = Wsdl1.GetBasicHttpBinding_LanguageService()
14 |
--------------------------------------------------------------------------------
/tests/FSharp.Data.TypeProviders.UsageTests/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | True
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/tests/FSharp.Data.TypeProviders.UsageTests/paket.references:
--------------------------------------------------------------------------------
1 | FSharp.Core
2 | group Test
3 | EntityFramework
4 | Microsoft.NET.Test.Sdk
5 | NUnit
6 | NUnit3TestAdapter
7 | coverlet.collector
8 |
--------------------------------------------------------------------------------