Merge branch 'master' of https://github.com/Microsoft/visualfsharp into dev15-sxs
This commit is contained in:
Коммит
dabdaa042d
|
@ -88,3 +88,4 @@ Although the primary focus of this repo is F# for Windows and the Visual Studio
|
|||
|
||||
Keep up with the Visual F# Team and the development of the Visual F# Tools by following us [@VisualFSharp](https://twitter.com/VisualFSharp) or subscribing to our [team blog](http://blogs.msdn.com/b/fsharpteam/).
|
||||
|
||||
|
||||
|
|
|
@ -72,6 +72,8 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Build", "src\fsharp\
|
|||
EndProject
|
||||
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Fsc", "src\fsharp\Fsc\Fsc.fsproj", "{C94C257C-3C0A-4858-B5D8-D746498D1F08}"
|
||||
EndProject
|
||||
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Data.TypeProviders", "src\fsharp\FSharp.Data.TypeProviders\FSharp.Data.TypeProviders.fsproj", "{CB7D20C4-6506-406D-9144-5342C3595F03}"
|
||||
EndProject
|
||||
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Compiler.Interactive.Settings", "src\fsharp\FSharp.Compiler.Interactive.Settings\FSharp.Compiler.Interactive.Settings.fsproj", "{649FA588-F02E-457C-9FCF-87E46407481E}"
|
||||
EndProject
|
||||
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FsiAnyCPU", "src\fsharp\fsiAnyCpu\FsiAnyCPU.fsproj", "{8B3E283D-B5FE-4055-9D80-7E3A32F3967B}"
|
||||
|
@ -120,12 +122,20 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AppConfig", "vsintegration\
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeFile", "vsintegration\ItemTemplates\CodeFile\CodeFile.csproj", "{12AC2813-E895-4AAA-AE6C-94E21DA09F64}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ODataServiceConnection", "vsintegration\ItemTemplates\ODataServiceConnection\ODataServiceConnection.csproj", "{17716AF4-D439-4C74-8326-475FB1847DF2}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptFile", "vsintegration\ItemTemplates\ScriptFile\ScriptFile.csproj", "{A333B85A-DC23-49B6-9797-B89A7951E92D}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SignatureFile", "vsintegration\ItemTemplates\SignatureFile\SignatureFile.csproj", "{E3FDD4AC-46B6-4B9F-B672-317D1202CC50}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SqlDataConnection", "vsintegration\ItemTemplates\SqlDataConnection\SqlDataConnection.csproj", "{35E83EDF-CC5A-441D-8949-17AACC463CA4}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SqlEntityConnection", "vsintegration\ItemTemplates\SqlEntityConnection\SqlEntityConnection.csproj", "{A2CDA945-EF31-4C37-A063-BD1E2B3938EB}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TextFile", "vsintegration\ItemTemplates\TextFile\TextFile.csproj", "{D11FC318-8F5D-4C8C-9287-AB40A016D13C}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WsdlServiceConnection", "vsintegration\ItemTemplates\WsdlServiceConnection\WsdlServiceConnection.csproj", "{7FDF9571-B7DF-4F09-BD5E-12BDDF4FA520}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XMLFile", "vsintegration\ItemTemplates\XMLFile\XMLFile.csproj", "{1FB1DD07-06AA-45B4-B5AC-20FF5BEE98B6}"
|
||||
EndProject
|
||||
Global
|
||||
|
@ -1099,6 +1109,26 @@ Global
|
|||
{12AC2813-E895-4AAA-AE6C-94E21DA09F64}.VSRelease|Any CPU.Build.0 = VSRelease|Any CPU
|
||||
{12AC2813-E895-4AAA-AE6C-94E21DA09F64}.VSRelease|x86.ActiveCfg = VSRelease|Any CPU
|
||||
{12AC2813-E895-4AAA-AE6C-94E21DA09F64}.VSRelease|x86.Build.0 = VSRelease|Any CPU
|
||||
{17716AF4-D439-4C74-8326-475FB1847DF2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{17716AF4-D439-4C74-8326-475FB1847DF2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{17716AF4-D439-4C74-8326-475FB1847DF2}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{17716AF4-D439-4C74-8326-475FB1847DF2}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{17716AF4-D439-4C74-8326-475FB1847DF2}.Proto|Any CPU.ActiveCfg = Proto|Any CPU
|
||||
{17716AF4-D439-4C74-8326-475FB1847DF2}.Proto|Any CPU.Build.0 = Proto|Any CPU
|
||||
{17716AF4-D439-4C74-8326-475FB1847DF2}.Proto|x86.ActiveCfg = Proto|Any CPU
|
||||
{17716AF4-D439-4C74-8326-475FB1847DF2}.Proto|x86.Build.0 = Proto|Any CPU
|
||||
{17716AF4-D439-4C74-8326-475FB1847DF2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{17716AF4-D439-4C74-8326-475FB1847DF2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{17716AF4-D439-4C74-8326-475FB1847DF2}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{17716AF4-D439-4C74-8326-475FB1847DF2}.Release|x86.Build.0 = Release|Any CPU
|
||||
{17716AF4-D439-4C74-8326-475FB1847DF2}.VSDebug|Any CPU.ActiveCfg = VSDebug|Any CPU
|
||||
{17716AF4-D439-4C74-8326-475FB1847DF2}.VSDebug|Any CPU.Build.0 = VSDebug|Any CPU
|
||||
{17716AF4-D439-4C74-8326-475FB1847DF2}.VSDebug|x86.ActiveCfg = VSDebug|Any CPU
|
||||
{17716AF4-D439-4C74-8326-475FB1847DF2}.VSDebug|x86.Build.0 = VSDebug|Any CPU
|
||||
{17716AF4-D439-4C74-8326-475FB1847DF2}.VSRelease|Any CPU.ActiveCfg = VSRelease|Any CPU
|
||||
{17716AF4-D439-4C74-8326-475FB1847DF2}.VSRelease|Any CPU.Build.0 = VSRelease|Any CPU
|
||||
{17716AF4-D439-4C74-8326-475FB1847DF2}.VSRelease|x86.ActiveCfg = VSRelease|Any CPU
|
||||
{17716AF4-D439-4C74-8326-475FB1847DF2}.VSRelease|x86.Build.0 = VSRelease|Any CPU
|
||||
{A333B85A-DC23-49B6-9797-B89A7951E92D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A333B85A-DC23-49B6-9797-B89A7951E92D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A333B85A-DC23-49B6-9797-B89A7951E92D}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
|
@ -1139,6 +1169,46 @@ Global
|
|||
{E3FDD4AC-46B6-4B9F-B672-317D1202CC50}.VSRelease|Any CPU.Build.0 = VSRelease|Any CPU
|
||||
{E3FDD4AC-46B6-4B9F-B672-317D1202CC50}.VSRelease|x86.ActiveCfg = VSRelease|Any CPU
|
||||
{E3FDD4AC-46B6-4B9F-B672-317D1202CC50}.VSRelease|x86.Build.0 = VSRelease|Any CPU
|
||||
{35E83EDF-CC5A-441D-8949-17AACC463CA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{35E83EDF-CC5A-441D-8949-17AACC463CA4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{35E83EDF-CC5A-441D-8949-17AACC463CA4}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{35E83EDF-CC5A-441D-8949-17AACC463CA4}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{35E83EDF-CC5A-441D-8949-17AACC463CA4}.Proto|Any CPU.ActiveCfg = Proto|Any CPU
|
||||
{35E83EDF-CC5A-441D-8949-17AACC463CA4}.Proto|Any CPU.Build.0 = Proto|Any CPU
|
||||
{35E83EDF-CC5A-441D-8949-17AACC463CA4}.Proto|x86.ActiveCfg = Proto|Any CPU
|
||||
{35E83EDF-CC5A-441D-8949-17AACC463CA4}.Proto|x86.Build.0 = Proto|Any CPU
|
||||
{35E83EDF-CC5A-441D-8949-17AACC463CA4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{35E83EDF-CC5A-441D-8949-17AACC463CA4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{35E83EDF-CC5A-441D-8949-17AACC463CA4}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{35E83EDF-CC5A-441D-8949-17AACC463CA4}.Release|x86.Build.0 = Release|Any CPU
|
||||
{35E83EDF-CC5A-441D-8949-17AACC463CA4}.VSDebug|Any CPU.ActiveCfg = VSDebug|Any CPU
|
||||
{35E83EDF-CC5A-441D-8949-17AACC463CA4}.VSDebug|Any CPU.Build.0 = VSDebug|Any CPU
|
||||
{35E83EDF-CC5A-441D-8949-17AACC463CA4}.VSDebug|x86.ActiveCfg = VSDebug|Any CPU
|
||||
{35E83EDF-CC5A-441D-8949-17AACC463CA4}.VSDebug|x86.Build.0 = VSDebug|Any CPU
|
||||
{35E83EDF-CC5A-441D-8949-17AACC463CA4}.VSRelease|Any CPU.ActiveCfg = VSRelease|Any CPU
|
||||
{35E83EDF-CC5A-441D-8949-17AACC463CA4}.VSRelease|Any CPU.Build.0 = VSRelease|Any CPU
|
||||
{35E83EDF-CC5A-441D-8949-17AACC463CA4}.VSRelease|x86.ActiveCfg = VSRelease|Any CPU
|
||||
{35E83EDF-CC5A-441D-8949-17AACC463CA4}.VSRelease|x86.Build.0 = VSRelease|Any CPU
|
||||
{A2CDA945-EF31-4C37-A063-BD1E2B3938EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A2CDA945-EF31-4C37-A063-BD1E2B3938EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A2CDA945-EF31-4C37-A063-BD1E2B3938EB}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{A2CDA945-EF31-4C37-A063-BD1E2B3938EB}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{A2CDA945-EF31-4C37-A063-BD1E2B3938EB}.Proto|Any CPU.ActiveCfg = Proto|Any CPU
|
||||
{A2CDA945-EF31-4C37-A063-BD1E2B3938EB}.Proto|Any CPU.Build.0 = Proto|Any CPU
|
||||
{A2CDA945-EF31-4C37-A063-BD1E2B3938EB}.Proto|x86.ActiveCfg = Proto|Any CPU
|
||||
{A2CDA945-EF31-4C37-A063-BD1E2B3938EB}.Proto|x86.Build.0 = Proto|Any CPU
|
||||
{A2CDA945-EF31-4C37-A063-BD1E2B3938EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A2CDA945-EF31-4C37-A063-BD1E2B3938EB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A2CDA945-EF31-4C37-A063-BD1E2B3938EB}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{A2CDA945-EF31-4C37-A063-BD1E2B3938EB}.Release|x86.Build.0 = Release|Any CPU
|
||||
{A2CDA945-EF31-4C37-A063-BD1E2B3938EB}.VSDebug|Any CPU.ActiveCfg = VSDebug|Any CPU
|
||||
{A2CDA945-EF31-4C37-A063-BD1E2B3938EB}.VSDebug|Any CPU.Build.0 = VSDebug|Any CPU
|
||||
{A2CDA945-EF31-4C37-A063-BD1E2B3938EB}.VSDebug|x86.ActiveCfg = VSDebug|Any CPU
|
||||
{A2CDA945-EF31-4C37-A063-BD1E2B3938EB}.VSDebug|x86.Build.0 = VSDebug|Any CPU
|
||||
{A2CDA945-EF31-4C37-A063-BD1E2B3938EB}.VSRelease|Any CPU.ActiveCfg = VSRelease|Any CPU
|
||||
{A2CDA945-EF31-4C37-A063-BD1E2B3938EB}.VSRelease|Any CPU.Build.0 = VSRelease|Any CPU
|
||||
{A2CDA945-EF31-4C37-A063-BD1E2B3938EB}.VSRelease|x86.ActiveCfg = VSRelease|Any CPU
|
||||
{A2CDA945-EF31-4C37-A063-BD1E2B3938EB}.VSRelease|x86.Build.0 = VSRelease|Any CPU
|
||||
{D11FC318-8F5D-4C8C-9287-AB40A016D13C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D11FC318-8F5D-4C8C-9287-AB40A016D13C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D11FC318-8F5D-4C8C-9287-AB40A016D13C}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
|
@ -1159,6 +1229,26 @@ Global
|
|||
{D11FC318-8F5D-4C8C-9287-AB40A016D13C}.VSRelease|Any CPU.Build.0 = VSRelease|Any CPU
|
||||
{D11FC318-8F5D-4C8C-9287-AB40A016D13C}.VSRelease|x86.ActiveCfg = VSRelease|Any CPU
|
||||
{D11FC318-8F5D-4C8C-9287-AB40A016D13C}.VSRelease|x86.Build.0 = VSRelease|Any CPU
|
||||
{7FDF9571-B7DF-4F09-BD5E-12BDDF4FA520}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7FDF9571-B7DF-4F09-BD5E-12BDDF4FA520}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7FDF9571-B7DF-4F09-BD5E-12BDDF4FA520}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{7FDF9571-B7DF-4F09-BD5E-12BDDF4FA520}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{7FDF9571-B7DF-4F09-BD5E-12BDDF4FA520}.Proto|Any CPU.ActiveCfg = Proto|Any CPU
|
||||
{7FDF9571-B7DF-4F09-BD5E-12BDDF4FA520}.Proto|Any CPU.Build.0 = Proto|Any CPU
|
||||
{7FDF9571-B7DF-4F09-BD5E-12BDDF4FA520}.Proto|x86.ActiveCfg = Proto|Any CPU
|
||||
{7FDF9571-B7DF-4F09-BD5E-12BDDF4FA520}.Proto|x86.Build.0 = Proto|Any CPU
|
||||
{7FDF9571-B7DF-4F09-BD5E-12BDDF4FA520}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7FDF9571-B7DF-4F09-BD5E-12BDDF4FA520}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7FDF9571-B7DF-4F09-BD5E-12BDDF4FA520}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{7FDF9571-B7DF-4F09-BD5E-12BDDF4FA520}.Release|x86.Build.0 = Release|Any CPU
|
||||
{7FDF9571-B7DF-4F09-BD5E-12BDDF4FA520}.VSDebug|Any CPU.ActiveCfg = VSDebug|Any CPU
|
||||
{7FDF9571-B7DF-4F09-BD5E-12BDDF4FA520}.VSDebug|Any CPU.Build.0 = VSDebug|Any CPU
|
||||
{7FDF9571-B7DF-4F09-BD5E-12BDDF4FA520}.VSDebug|x86.ActiveCfg = VSDebug|Any CPU
|
||||
{7FDF9571-B7DF-4F09-BD5E-12BDDF4FA520}.VSDebug|x86.Build.0 = VSDebug|Any CPU
|
||||
{7FDF9571-B7DF-4F09-BD5E-12BDDF4FA520}.VSRelease|Any CPU.ActiveCfg = VSRelease|Any CPU
|
||||
{7FDF9571-B7DF-4F09-BD5E-12BDDF4FA520}.VSRelease|Any CPU.Build.0 = VSRelease|Any CPU
|
||||
{7FDF9571-B7DF-4F09-BD5E-12BDDF4FA520}.VSRelease|x86.ActiveCfg = VSRelease|Any CPU
|
||||
{7FDF9571-B7DF-4F09-BD5E-12BDDF4FA520}.VSRelease|x86.Build.0 = VSRelease|Any CPU
|
||||
{1FB1DD07-06AA-45B4-B5AC-20FF5BEE98B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1FB1DD07-06AA-45B4-B5AC-20FF5BEE98B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1FB1DD07-06AA-45B4-B5AC-20FF5BEE98B6}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
|
@ -1216,6 +1306,7 @@ Global
|
|||
{956BBE41-ABD1-4DBA-9F3B-BA1C9821C98C} = {3F044931-FB83-4433-B934-AE66AB27B278}
|
||||
{702A7979-BCF9-4C41-853E-3ADFC9897890} = {B8DDA694-7939-42E3-95E5-265C2217C142}
|
||||
{C94C257C-3C0A-4858-B5D8-D746498D1F08} = {3881429D-A97A-49EB-B7AE-A82BA5FE9C77}
|
||||
{CB7D20C4-6506-406D-9144-5342C3595F03} = {3058BC79-8E79-4645-B05D-48CC182FA8A6}
|
||||
{649FA588-F02E-457C-9FCF-87E46407481E} = {B8DDA694-7939-42E3-95E5-265C2217C142}
|
||||
{8B3E283D-B5FE-4055-9D80-7E3A32F3967B} = {B8DDA694-7939-42E3-95E5-265C2217C142}
|
||||
{D0E98C0D-490B-4C61-9329-0862F6E87645} = {B8DDA694-7939-42E3-95E5-265C2217C142}
|
||||
|
@ -1236,9 +1327,13 @@ Global
|
|||
{F6DAEE9A-8BE1-4C4A-BC83-09215517C7DA} = {4C7B48D7-19AF-4AE7-9D1D-3BB289D5480D}
|
||||
{6BA13AA4-C25F-480F-856B-8E8000299A72} = {F6DAEE9A-8BE1-4C4A-BC83-09215517C7DA}
|
||||
{12AC2813-E895-4AAA-AE6C-94E21DA09F64} = {F6DAEE9A-8BE1-4C4A-BC83-09215517C7DA}
|
||||
{17716AF4-D439-4C74-8326-475FB1847DF2} = {F6DAEE9A-8BE1-4C4A-BC83-09215517C7DA}
|
||||
{A333B85A-DC23-49B6-9797-B89A7951E92D} = {F6DAEE9A-8BE1-4C4A-BC83-09215517C7DA}
|
||||
{E3FDD4AC-46B6-4B9F-B672-317D1202CC50} = {F6DAEE9A-8BE1-4C4A-BC83-09215517C7DA}
|
||||
{35E83EDF-CC5A-441D-8949-17AACC463CA4} = {F6DAEE9A-8BE1-4C4A-BC83-09215517C7DA}
|
||||
{A2CDA945-EF31-4C37-A063-BD1E2B3938EB} = {F6DAEE9A-8BE1-4C4A-BC83-09215517C7DA}
|
||||
{D11FC318-8F5D-4C8C-9287-AB40A016D13C} = {F6DAEE9A-8BE1-4C4A-BC83-09215517C7DA}
|
||||
{7FDF9571-B7DF-4F09-BD5E-12BDDF4FA520} = {F6DAEE9A-8BE1-4C4A-BC83-09215517C7DA}
|
||||
{1FB1DD07-06AA-45B4-B5AC-20FF5BEE98B6} = {F6DAEE9A-8BE1-4C4A-BC83-09215517C7DA}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
@ -31,6 +31,7 @@ set BUILD_NET40=1
|
|||
set BUILD_CORECLR=0
|
||||
set BUILD_PORTABLE=0
|
||||
set BUILD_VS=0
|
||||
set BUILD_FSHARP_DATA_TYPEPROVIDERS=0
|
||||
set BUILD_CONFIG=release
|
||||
set BUILD_CONFIG_LOWERCASE=release
|
||||
|
||||
|
@ -79,6 +80,7 @@ if /i '%ARG%' == 'all' (
|
|||
set BUILD_PROTO=1
|
||||
set BUILD_PORTABLE=1
|
||||
set BUILD_VS=1
|
||||
set BUILD_FSHARP_DATA_TYPEPROVIDERS=1
|
||||
set TEST_COMPILERUNIT=1
|
||||
set TEST_PORTABLE_COREUNIT=1
|
||||
set TEST_VS=1
|
||||
|
@ -92,6 +94,7 @@ if /i '%ARG%' == 'ci' (
|
|||
set BUILD_CORECLR=1
|
||||
set BUILD_PORTABLE=1
|
||||
set BUILD_VS=1
|
||||
set BUILD_FSHARP_DATA_TYPEPROVIDERS=1
|
||||
|
||||
set TEST_COMPILERUNIT=1
|
||||
set TEST_NET40_COREUNIT=1
|
||||
|
@ -109,6 +112,7 @@ if /i '%ARG%' == 'ci_part1' (
|
|||
set BUILD_CORECLR=1
|
||||
set BUILD_PORTABLE=1
|
||||
set BUILD_VS=1
|
||||
set BUILD_FSHARP_DATA_TYPEPROVIDERS=1
|
||||
|
||||
set TEST_COMPILERUNIT=1
|
||||
set TEST_NET40_COREUNIT=1
|
||||
|
@ -121,6 +125,7 @@ if /i '%ARG%' == 'ci_part1' (
|
|||
if /i '%ARG%' == 'ci_part2' (
|
||||
set SKIP_EXPENSIVE_TESTS=1
|
||||
set BUILD_PORTABLE=1
|
||||
set BUILD_FSHARP_DATA_TYPEPROVIDERS=1
|
||||
set TEST_FSHARPQA_SUITE=1
|
||||
set TEST_FSHARP_SUITE=1
|
||||
)
|
||||
|
@ -175,6 +180,7 @@ echo BUILD_NET40=%BUILD_NET40%
|
|||
echo BUILD_CORECLR=%BUILD_CORECLR%
|
||||
echo BUILD_PORTABLE=%BUILD_PORTABLE%
|
||||
echo BUILD_VS=%BUILD_VS%
|
||||
echo BUILD_FSHARP_DATA_TYPEPROVIDERS=%BUILD_FSHARP_DATA_TYPEPROVIDERS%
|
||||
echo BUILD_CONFIG=%BUILD_CONFIG%
|
||||
echo BUILD_CONFIG_LOWERCASE=%BUILD_CONFIG_LOWERCASE%
|
||||
echo.
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<Choose>
|
||||
<When Condition="'$(ProjectLanguage)' == 'FSharp'">
|
||||
<Choose>
|
||||
<When Condition="'$(AssemblyName)' == 'FSharp.Core' or '$(AssemblyName)' == 'FSharp.Build' or '$(AssemblyName)' == 'FSharp.Compiler' or '$(AssemblyName)' == 'FSharp.Compiler.Interactive.Settings' or '$(AssemblyName)' == 'FSharp.Compiler.Server.Shared' or '$(AssemblyName)' == 'fsc' or '$(AssemblyName)' == 'fsi' or '$(AssemblyName)' == 'FsiAnyCPU' or '$(AssemblyName)' == 'FSharp.Compiler.Unittests'" >
|
||||
<When Condition="'$(AssemblyName)' == 'FSharp.Core' or '$(AssemblyName)' == 'FSharp.Build' or '$(AssemblyName)' == 'FSharp.Compiler' or '$(AssemblyName)' == 'FSharp.Compiler.Interactive.Settings' or '$(AssemblyName)' == 'FSharp.Compiler.Server.Shared' or '$(AssemblyName)' == 'fsc' or '$(AssemblyName)' == 'fsi' or '$(AssemblyName)' == 'FsiAnyCPU' or '$(AssemblyName)' == 'FSharp.Data.TypeProviders' or '$(AssemblyName)' == 'FSharp.Compiler.Unittests'" >
|
||||
<PropertyGroup Condition="'$(AssemblyName)' == 'FSharp.Core' and ('$(TargetFramework)' == 'portable47' or '$(TargetFramework)' == 'portable7' or '$(TargetFramework)' == 'portable78' or '$(TargetFramework)' == 'portable259' or '$(TargetFramework)' == 'coreclr')">
|
||||
<IsPortableProfile>true</IsPortableProfile>
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -1193,7 +1193,6 @@ type ILGenericParameterDef =
|
|||
|
||||
type ILGenericParameterDefs = ILGenericParameterDef list
|
||||
|
||||
// REVIEW: fold this into ILMethodDef
|
||||
[<NoComparison; NoEquality; Sealed>]
|
||||
type ILLazyMethodBody =
|
||||
member Contents : MethodBody
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
namespace Microsoft.FSharp
|
||||
open System.Reflection
|
||||
open System.Runtime.InteropServices
|
||||
|
||||
[<assembly:AssemblyDescription("FSharp.Data.TypeProviders.dll")>]
|
||||
[<assembly:AssemblyCompany("Microsoft Corporation")>]
|
||||
[<assembly:AssemblyTitle("FSharp.Data.TypeProviders.dll")>]
|
||||
[<assembly:AssemblyCopyright("\169 Microsoft Corporation. All rights reserved.")>]
|
||||
[<assembly:AssemblyProduct("Microsoft\174 F#")>]
|
||||
[<assembly:ComVisible(false)>]
|
||||
do()
|
||||
|
||||
#if NO_STRONG_NAMES
|
||||
[<assembly:System.Runtime.CompilerServices.InternalsVisibleTo("VisualFSharp.Unittests")>]
|
||||
#else
|
||||
[<assembly:System.Runtime.CompilerServices.InternalsVisibleTo("VisualFSharp.Unittests, PublicKey=002400000480000094000000060200000024000052534131000400000100010007D1FA57C4AED9F0A32E84AA0FAEFD0DE9E8FD6AEC8F87FB03766C834C99921EB23BE79AD9D5DCC1DD9AD236132102900B723CF980957FC4E177108FC607774F29E8320E92EA05ECE4E821C0A5EFE8F1645C4C0C93C1AB99285D622CAA652C1DFAD63D745D6F2DE5F17E5EAF0FC4963D261C8A12436518206DC093344D5AD293")>]
|
||||
#endif
|
||||
do()
|
|
@ -0,0 +1,19 @@
|
|||
<!-- Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -->
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"
|
||||
ToolsVersion="4.0">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework Condition="'$(TargetFramework)'==''">net40</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Type providers assembly -->
|
||||
<ItemGroup Condition=" '$(TargetFramework)' != 'sl3-wp' and '$(TargetFramework)' != 'sl5'">
|
||||
<ProjectFiles Include="fsharp/FSharp.Data.TypeProviders/FSharp.Data.TypeProviders.fsproj"/>
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="root.traversal.targets"/>
|
||||
|
||||
<!-- Insert any customizations for targets here -->
|
||||
|
||||
</Project>
|
||||
|
|
@ -27,6 +27,8 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Compiler.Server.Shar
|
|||
EndProject
|
||||
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Core.Unittests", "fsharp\FSharp.Core.Unittests\FSharp.Core.Unittests.fsproj", "{88E2D422-6852-46E3-A740-83E391DC7973}"
|
||||
EndProject
|
||||
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Data.TypeProviders", "fsharp\FSharp.Data.TypeProviders\FSharp.Data.TypeProviders.fsproj", "{CB7D20C4-6506-406D-9144-5342C3595F03}"
|
||||
EndProject
|
||||
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FsiAnyCPU", "fsharp\fsiAnyCpu\FsiAnyCPU.fsproj", "{8B3E283D-B5FE-4055-9D80-7E3A32F3967B}"
|
||||
EndProject
|
||||
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Compiler.Unittests", "fsharp\FSharp.Compiler.Unittests\FSharp.Compiler.Unittests.fsproj", "{A8D9641A-9170-4CF4-8FE0-6DB8C134E1B5}"
|
||||
|
@ -75,6 +77,10 @@ Global
|
|||
{88E2D422-6852-46E3-A740-83E391DC7973}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{88E2D422-6852-46E3-A740-83E391DC7973}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{88E2D422-6852-46E3-A740-83E391DC7973}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{CB7D20C4-6506-406D-9144-5342C3595F03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{CB7D20C4-6506-406D-9144-5342C3595F03}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{CB7D20C4-6506-406D-9144-5342C3595F03}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{CB7D20C4-6506-406D-9144-5342C3595F03}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{8B3E283D-B5FE-4055-9D80-7E3A32F3967B}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{8B3E283D-B5FE-4055-9D80-7E3A32F3967B}.Release|Any CPU.ActiveCfg = Release|x86
|
||||
{A8D9641A-9170-4CF4-8FE0-6DB8C134E1B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -->
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<DefineConstants>$(DefineConstants);TPEMIT_INTERNAL_AND_MINIMAL_FOR_TYPE_CONTAINERS</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.ServiceModel" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<FilesToLocalize Include="$(OutDir)$(AssemblyName).dll">
|
||||
<TranslationFile>$(FSharpSourcesRoot)\..\loc\lcl\{Lang}\$(AssemblyName).dll.lcl</TranslationFile>
|
||||
<LciCommentFile>$(FSharpSourcesRoot)\..\loc\lci\$(AssemblyName).dll.lci</LciCommentFile>
|
||||
<HasLceComments>false</HasLceComments>
|
||||
<InProject>false</InProject>
|
||||
</FilesToLocalize>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<FsSrGen Include="$(FSharpSourcesRoot)\fsharp\FSharp.Data.TypeProviders\FSData.txt" >
|
||||
<Link>FSData.txt</Link>
|
||||
<Visible>true</Visible>
|
||||
</FsSrGen>
|
||||
<Compile Include="$(FSharpSourcesRoot)\fsharp\FSharp.Data.TypeProviders\Util.fsi">
|
||||
<Link>Util.fsi</Link>
|
||||
<Visible>true</Visible>
|
||||
</Compile>
|
||||
<Compile Include="$(FSharpSourcesRoot)\fsharp\FSharp.Data.TypeProviders\Util.fs">
|
||||
<Link>Util.fs</Link>
|
||||
<Visible>true</Visible>
|
||||
</Compile>
|
||||
<Compile Include="$(FSharpSourcesRoot)\fsharp\FSharp.Data.TypeProviders\InternalsVisibleTo.fs">
|
||||
<Link>InternalsVisibleTo.fs</Link>
|
||||
<Visible>true</Visible>
|
||||
</Compile>
|
||||
<Compile Include="$(FSharpSourcesRoot)\fsharp\FSharp.Data.TypeProviders\TypeProviderEmit.fsi">
|
||||
<Link>TypeProviderEmit.fsi</Link>
|
||||
<Visible>true</Visible>
|
||||
</Compile>
|
||||
<Compile Include="$(FSharpSourcesRoot)\fsharp\FSharp.Data.TypeProviders\TypeProviderEmit.fs">
|
||||
<Link>TypeProviderEmit.fs</Link>
|
||||
<Visible>true</Visible>
|
||||
</Compile>
|
||||
<Compile Include="$(FSharpSourcesRoot)\fsharp\FSharp.Data.TypeProviders\TypeProvidersImpl.fs">
|
||||
<Link>TypeProvidersImpl.fs</Link>
|
||||
<Visible>true</Visible>
|
||||
</Compile>
|
||||
<Compile Include="$(FSharpSourcesRoot)\fsharp\FSharp.Data.TypeProviders\TypeProviders.fs">
|
||||
<Link>TypeProviders.fs</Link>
|
||||
<Visible>true</Visible>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="GatherBinariesToBeSigned" AfterTargets="Localize">
|
||||
<ItemGroup>
|
||||
<BinariesToBeSigned Include="$(OutDir)$(AssemblyName).dll" />
|
||||
<BinariesToBeSigned Include="$(OutDir)localize\**\$(AssemblyName).resources.dll" />
|
||||
<FilesToSign Include="@(BinariesToBeSigned)">
|
||||
<Authenticode>Microsoft</Authenticode>
|
||||
<StrongName>StrongName</StrongName>
|
||||
</FilesToSign>
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
</Project>
|
|
@ -0,0 +1,48 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -->
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<FSharpSourcesRoot>..\..</FSharpSourcesRoot>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(FSharpSourcesRoot)\FSharpSource.Settings.targets" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<OutputType>Library</OutputType>
|
||||
<AssemblyName>FSharp.Data.TypeProviders</AssemblyName>
|
||||
<AllowCrossTargeting>true</AllowCrossTargeting>
|
||||
<TargetFrameworkVersion Condition=" '$(TargetFrameworkVersion)' == '' ">v4.0</TargetFrameworkVersion>
|
||||
<ProjectGuid>{cb7d20c4-6506-406d-9144-5342c3595f03}</ProjectGuid>
|
||||
<OtherFlags>$(OtherFlags) --warnon:1182</OtherFlags>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(FSharpSourcesRoot)\fsharp\FSharp.Data.TypeProviders\FSharp.Data.TypeProviders.Shared.fsproj"
|
||||
Condition="'$(TargetFramework)' != 'sl5' AND
|
||||
'$(TargetFramework)' != 'portable47' AND
|
||||
'$(TargetFramework)' != 'sl3-wp'" />
|
||||
<ItemGroup>
|
||||
<!--This is used for compiling the runtime type provider DLL for WP7, Silverlight etc. -->
|
||||
<!--This is the only file used. -->
|
||||
<Compile Include="$(FSharpSourcesRoot)\fsharp\FSharp.Data.TypeProviders\TypeProviderRuntimeAttribute.fs" Condition="'$(TargetFramework)' == 'net20' or '$(TargetFramework)' == 'sl3-wp' or '$(TargetFramework)'=='sl4' ">
|
||||
<Link>TypeProviderRuntimeAttribute.fs</Link>
|
||||
<Visible>true</Visible>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="$(FSharpSourcesRoot)\assemblyinfo\assemblyinfo.FSharp.Data.TypeProviders.dll.fs">
|
||||
<Link>assemblyinfo.FSharp.Data.TypeProviders.dll.fs</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="mscorlib" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.ServiceModel" />
|
||||
<ProjectReference Include="$(FSharpSourcesRoot)\fsharp\FSharp.Core\FSharp.Core.fsproj" >
|
||||
<Project>{DED3BBD7-53F4-428A-8C9F-27968E768605}</Project>
|
||||
<Name>FSharp.Core</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(FSharpSourcesRoot)\FSharpSource.targets"/>
|
||||
</Project>
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
namespace Microsoft.FSharp
|
||||
open System.Reflection
|
||||
[<assembly:System.Runtime.CompilerServices.InternalsVisibleTo("VisualFSharp.Unittests, PublicKey=002400000480000094000000060200000024000052534131000400000100010007D1FA57C4AED9F0A32E84AA0FAEFD0DE9E8FD6AEC8F87FB03766C834C99921EB23BE79AD9D5DCC1DD9AD236132102900B723CF980957FC4E177108FC607774F29E8320E92EA05ECE4E821C0A5EFE8F1645C4C0C93C1AB99285D622CAA652C1DFAD63D745D6F2DE5F17E5EAF0FC4963D261C8A12436518206DC093344D5AD293")>]
|
||||
|
||||
|
||||
do()
|
||||
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,267 @@
|
|||
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#if TPEMIT_INTERNAL_AND_MINIMAL_FOR_TYPE_CONTAINERS
|
||||
namespace Internal.Utilities.TypeProvider.Emit
|
||||
#else
|
||||
namespace Microsoft.FSharp.TypeProvider.Emit
|
||||
#endif
|
||||
open System
|
||||
open System.Reflection
|
||||
open System.Linq.Expressions
|
||||
open Microsoft.FSharp.Core.CompilerServices
|
||||
|
||||
|
||||
/// Represents an erased provided parameter
|
||||
#if TPEMIT_INTERNAL_AND_MINIMAL_FOR_TYPE_CONTAINERS
|
||||
type internal ProvidedParameter =
|
||||
#else
|
||||
type ProvidedParameter =
|
||||
#endif
|
||||
inherit System.Reflection.ParameterInfo
|
||||
new : parameterName: string * parameterType: Type * ?isOut:bool * ?optionalValue:obj -> ProvidedParameter
|
||||
|
||||
|
||||
/// Represents an erased provided constructor.
|
||||
#if TPEMIT_INTERNAL_AND_MINIMAL_FOR_TYPE_CONTAINERS
|
||||
type internal ProvidedConstructor =
|
||||
#else
|
||||
type ProvidedConstructor =
|
||||
#endif
|
||||
inherit System.Reflection.ConstructorInfo
|
||||
|
||||
/// Create a new provided constructor. It is not initially associated with any specific provided type definition.
|
||||
new : parameters: ProvidedParameter list -> ProvidedConstructor
|
||||
|
||||
/// Add XML documentation information to this provided constructor
|
||||
member AddXmlDoc : xmlDoc: string -> unit
|
||||
|
||||
/// Add XML documentation information to this provided constructor, where the computation of the documentation is delayed until necessary
|
||||
member AddXmlDocDelayed : xmlDocFunction: (unit -> string) -> unit
|
||||
|
||||
/// Add XML documentation information to this provided constructor, where the documentation is re-computed every time it is required.
|
||||
member AddXmlDocComputed : xmlDocFunction: (unit -> string) -> unit
|
||||
|
||||
/// Set the quotation used to compute the implementation of invocations of this constructor.
|
||||
member InvokeCode : (Quotations.Expr list -> Quotations.Expr) with set
|
||||
|
||||
/// Set the function used to compute the implementation of invocations of this constructor.
|
||||
member InvokeCodeInternal : (Quotations.Expr[] -> Quotations.Expr) with get,set
|
||||
|
||||
/// Add definition location information to the provided constructor.
|
||||
member AddDefinitionLocation : line:int * column:int * filePath:string -> unit
|
||||
|
||||
|
||||
#if TPEMIT_INTERNAL_AND_MINIMAL_FOR_TYPE_CONTAINERS
|
||||
type internal ProvidedMethod =
|
||||
#else
|
||||
type ProvidedMethod =
|
||||
#endif
|
||||
inherit System.Reflection.MethodInfo
|
||||
|
||||
/// Create a new provided method. It is not initially associated with any specific provided type definition.
|
||||
new : methodName:string * parameters: ProvidedParameter list * returnType: Type -> ProvidedMethod
|
||||
|
||||
/// Add XML documentation information to this provided constructor
|
||||
member AddXmlDoc : xmlDoc: string -> unit
|
||||
|
||||
/// Add XML documentation information to this provided constructor, where the computation of the documentation is delayed until necessary
|
||||
member AddXmlDocDelayed : xmlDocFunction: (unit -> string) -> unit
|
||||
|
||||
/// Add XML documentation information to this provided constructor, where the computation of the documentation is delayed until necessary
|
||||
/// The documentation is re-computed every time it is required.
|
||||
member AddXmlDocComputed : xmlDocFunction: (unit -> string) -> unit
|
||||
|
||||
/// Set the method attributes of the method. By default these are simple 'MethodAttributes.Public'
|
||||
member SetMethodAttrs : attributes:MethodAttributes -> unit
|
||||
|
||||
/// Get or set a flag indicating if the property is static.
|
||||
member IsStaticMethod : bool with get, set
|
||||
|
||||
/// Set the quotation used to compute the implementation of invocations of this method.
|
||||
member InvokeCode : (Quotations.Expr list -> Quotations.Expr) with set
|
||||
|
||||
/// Set the function used to compute the implementation of invocations of this method.
|
||||
member InvokeCodeInternal : (Quotations.Expr[] -> Quotations.Expr) with get,set
|
||||
|
||||
|
||||
/// Add definition location information to the provided type definition.
|
||||
member AddDefinitionLocation : line:int * column:int * filePath:string -> unit
|
||||
|
||||
|
||||
/// Represents an erased provided property.
|
||||
#if TPEMIT_INTERNAL_AND_MINIMAL_FOR_TYPE_CONTAINERS
|
||||
type internal ProvidedProperty =
|
||||
#else
|
||||
type ProvidedProperty =
|
||||
#endif
|
||||
inherit System.Reflection.PropertyInfo
|
||||
|
||||
/// Create a new provided type. It is not initially associated with any specific provided type definition.
|
||||
new : propertyName: string * propertyType: Type * ?parameters:ProvidedParameter list -> ProvidedProperty
|
||||
|
||||
/// Add XML documentation information to this provided constructor
|
||||
member AddXmlDoc : xmlDoc: string -> unit
|
||||
|
||||
/// Add XML documentation information to this provided constructor, where the computation of the documentation is delayed until necessary
|
||||
member AddXmlDocDelayed : xmlDocFunction: (unit -> string) -> unit
|
||||
|
||||
/// Add XML documentation information to this provided constructor, where the computation of the documentation is delayed until necessary
|
||||
/// The documentation is re-computed every time it is required.
|
||||
member AddXmlDocComputed : xmlDocFunction: (unit -> string) -> unit
|
||||
|
||||
/// Get or set a flag indicating if the property is static.
|
||||
member IsStatic : bool with set
|
||||
|
||||
/// Set the quotation used to compute the implementation of invocations of this constructor.
|
||||
member GetterCode : (Quotations.Expr list -> Quotations.Expr) with set
|
||||
|
||||
/// Set the function used to compute the implementation of invocations of this constructor.
|
||||
member GetterCodeInternal : (Quotations.Expr[] -> Quotations.Expr) with get,set
|
||||
|
||||
/// Set the function used to compute the implementation of invocations of the property setter
|
||||
member SetterCode : (Quotations.Expr list -> Quotations.Expr) with set
|
||||
|
||||
/// Set the function used to compute the implementation of invocations of this constructor.
|
||||
member SetterCodeInternal : (Quotations.Expr[] -> Quotations.Expr) with get,set
|
||||
|
||||
/// Add definition location information to the provided type definition.
|
||||
member AddDefinitionLocation : line:int * column:int * filePath:string -> unit
|
||||
|
||||
#if TPEMIT_INTERNAL_AND_MINIMAL_FOR_TYPE_CONTAINERS
|
||||
#else
|
||||
/// Represents an erased provided property.
|
||||
[<Class>]
|
||||
type ProvidedMeasureBuilder =
|
||||
|
||||
/// The ProvidedMeasureBuilder for building measures.
|
||||
static member Default : ProvidedMeasureBuilder
|
||||
|
||||
/// e.g. 1
|
||||
member One : System.Type
|
||||
/// e.g. m * kg
|
||||
member Product : measure1: System.Type * measure1: System.Type -> System.Type
|
||||
/// e.g. 1 / kg
|
||||
member Inverse : denominator: System.Type -> System.Type
|
||||
|
||||
/// e.g. kg / m
|
||||
member Ratio : numerator: System.Type * denominator: System.Type -> System.Type
|
||||
|
||||
/// e.g. m * m
|
||||
member Square : ``measure``: System.Type -> System.Type
|
||||
|
||||
/// the SI unit from the F# core library, where the string is in capitals and US spelling, e.g. Meter
|
||||
member SI : string -> System.Type
|
||||
|
||||
/// e.g. float<kg>, Vector<int, kg>
|
||||
member AnnotateType : basic: System.Type * argument: System.Type list -> System.Type
|
||||
|
||||
#endif //TPEMIT_INTERNAL_AND_MINIMAL_FOR_TYPE_CONTAINERS
|
||||
|
||||
/// Represents an erased provided parameter
|
||||
#if TPEMIT_INTERNAL_AND_MINIMAL_FOR_TYPE_CONTAINERS
|
||||
type internal ProvidedStaticParameter =
|
||||
#else
|
||||
type ProvidedStaticParameter =
|
||||
#endif
|
||||
inherit System.Reflection.ParameterInfo
|
||||
new : parameterName: string * parameterType:Type * ?parameterDefaultValue:obj -> ProvidedStaticParameter
|
||||
|
||||
/// Represents an erased provided type definition.
|
||||
#if TPEMIT_INTERNAL_AND_MINIMAL_FOR_TYPE_CONTAINERS
|
||||
type internal ProvidedTypeDefinition =
|
||||
#else
|
||||
type ProvidedTypeDefinition =
|
||||
#endif
|
||||
inherit System.Type
|
||||
|
||||
/// Create a new provided type definition in a namespace.
|
||||
new : assembly: Assembly * namespaceName: string * className: string * baseType: Type option -> ProvidedTypeDefinition
|
||||
|
||||
/// Create a new provided type definition, to be located as a nested type in some type definition.
|
||||
new : className : string * baseType: Type option -> ProvidedTypeDefinition
|
||||
|
||||
/// Add the given type as an implemented interface.
|
||||
member AddInterfaceImplementation : interfaceType: Type -> unit
|
||||
|
||||
/// Specifies that the given method body implements the given method declaration.
|
||||
member DefineMethodOverride : methodInfoBody: ProvidedMethod * methodInfoDeclaration: MethodInfo -> unit
|
||||
|
||||
/// Add XML documentation information to this provided constructor
|
||||
member AddXmlDoc : xmlDoc: string -> unit
|
||||
|
||||
/// Add XML documentation information to this provided constructor, where the computation of the documentation is delayed until necessary.
|
||||
/// The documentation is only computed once.
|
||||
member AddXmlDocDelayed : xmlDocFunction: (unit -> string) -> unit
|
||||
|
||||
/// Add XML documentation information to this provided constructor, where the computation of the documentation is delayed until necessary
|
||||
/// The documentation is re-computed every time it is required.
|
||||
member AddXmlDocComputed : xmlDocFunction: (unit -> string) -> unit
|
||||
|
||||
/// Set the attributes on the provided type. This fully replaces the default TypeAttributes.
|
||||
member SetAttributes : System.Reflection.TypeAttributes -> unit
|
||||
|
||||
/// Add a method, property, nested type or other member to a ProvidedTypeDefinition
|
||||
member AddMember : memberInfo:MemberInfo -> unit
|
||||
/// Add a set of members to a ProvidedTypeDefinition
|
||||
member AddMembers : memberInfos:list<#MemberInfo> -> unit
|
||||
|
||||
/// Add a member to a ProvidedTypeDefinition, delaying computation of the members until required by the compilation context.
|
||||
member AddMemberDelayed : memberFunction:(unit -> #MemberInfo) -> unit
|
||||
|
||||
/// Add a set of members to a ProvidedTypeDefinition, delaying computation of the members until required by the compilation context.
|
||||
member AddMembersDelayed : (unit -> list<#MemberInfo>) -> unit
|
||||
|
||||
/// Add the types of the generated assembly as generative types, where types in namespaces get hierarchically positioned as nested types.
|
||||
member AddAssemblyTypesAsNestedTypesDelayed : assemblyFunction:(unit -> System.Reflection.Assembly) -> unit
|
||||
|
||||
// Parametric types
|
||||
member DefineStaticParameters : parameters: ProvidedStaticParameter list * instantiationFunction: (string -> obj[] -> ProvidedTypeDefinition) -> unit
|
||||
|
||||
/// Add definition location information to the provided type definition.
|
||||
member AddDefinitionLocation : line:int * column:int * filePath:string -> unit
|
||||
|
||||
/// Suppress System.Object entries in intellisense menus in instances of this provided type
|
||||
member HideObjectMethods : bool with set
|
||||
/// Emit the given provided type definition and its nested type definitions into an assembly
|
||||
/// and adjust the 'Assembly' property of all provided type definitions to return that
|
||||
/// assembly.
|
||||
///
|
||||
/// The assembly is only emitted when the Assembly property on the root type is accessed for the first time.
|
||||
member ConvertToGenerated : assemblyFileName:string * ?reportAssembly: (Assembly * byte[] -> unit) -> unit
|
||||
|
||||
/// Get or set a flag indicating if the ProvidedTypeDefinition is erased
|
||||
member IsErased : bool with get,set
|
||||
|
||||
/// Get or set a flag indicating if the ProvidedTypeDefinition has type-relocation suppressed
|
||||
[<Experimental("SuppressRelocation is a workaround and likely to be removed")>]
|
||||
member SuppressRelocation : bool with get,set
|
||||
|
||||
#if PROVIDER_TRANSFORMATIONS
|
||||
[<Sealed;Class;AbstractClass>]
|
||||
type ProviderTransformations =
|
||||
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
|
||||
#endif
|
||||
|
||||
#if TPEMIT_INTERNAL_AND_MINIMAL_FOR_TYPE_CONTAINERS
|
||||
#else
|
||||
type TypeProviderForNamespaces =
|
||||
/// A base type providing default implementations of type provider functionality when all provided types are of type ProvidedTypeDefinition
|
||||
// A TypeProvider boiler plate type.
|
||||
// 1. Inherit supplying the "providedNamespaces"
|
||||
// 2. Add [<Microsoft.FSharp.Core.CompilerServices.TypeProvider>] to type.
|
||||
// 3. Add [<assembly:TypeProviderAssembly>] do() to assembly.
|
||||
|
||||
/// Initializes a type provider to provide the types in the given namespace.
|
||||
new : namespaceName:string * types: ProvidedTypeDefinition list -> TypeProviderForNamespaces
|
||||
|
||||
/// Initializes a type provider
|
||||
new : unit -> TypeProviderForNamespaces
|
||||
|
||||
/// Add a namespace of provided types.
|
||||
member AddNamespace : namespaceName:string * types: ProvidedTypeDefinition list -> unit
|
||||
|
||||
/// Invalidate the information provided by the provider
|
||||
member Invalidate : unit -> unit
|
||||
|
||||
interface ITypeProvider
|
||||
#endif
|
|
@ -0,0 +1,11 @@
|
|||
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
namespace Microsoft.FSharp.Data.TypeProviders.DesignTime
|
||||
|
||||
open Microsoft.FSharp.Core.CompilerServices
|
||||
|
||||
// This says that this assembly is a runtime DLL for a particular platform, where the design-time
|
||||
// DLL is found alongside this DLL and has the given name.
|
||||
[<assembly:TypeProviderAssemblyAttribute("FSharp.Data.TypeProviders.DesignTime.dll") >]
|
||||
do()
|
||||
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,896 @@
|
|||
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
namespace Microsoft.FSharp.Data.TypeProviders.DesignTime
|
||||
|
||||
open System
|
||||
open System.IO
|
||||
open System.Reflection
|
||||
open System.Collections.Generic
|
||||
open System.Linq
|
||||
open System.Xml.Linq
|
||||
open System.Net
|
||||
open System.Configuration
|
||||
open Microsoft.FSharp.Data.TypeProviders.Utility
|
||||
|
||||
[<AutoOpen>]
|
||||
module internal Utilities =
|
||||
|
||||
let validateSchemaFileExtension localSchemaFile ext =
|
||||
// treat extensions that differ only in case as equal
|
||||
if not (Path.GetExtension(localSchemaFile).Equals("."+ext, StringComparison.OrdinalIgnoreCase)) then
|
||||
failwith (FSData.SR.errorInvalidExtensionSchema(Path.GetFileName(localSchemaFile),ext))
|
||||
|
||||
/// Use a local schema file if the 'localSchemaFile' parameter is present (IsNullOrWhiteSpace). Otherwise,
|
||||
/// use a temporary file to hold the metadata description of the service. Always force the update
|
||||
/// of the file if 'forceUpdate' is true and the downloaded contents have changed.
|
||||
let tryUseLocalSchemaFile (localSchemaFile, forceUpdate, ext) loader =
|
||||
let useTempFile = String.IsNullOrWhiteSpace localSchemaFile
|
||||
let schemaFile = if useTempFile then Util.TemporaryFile ext else Util.ExistingFile localSchemaFile
|
||||
|
||||
// Check if the extension of LocalSchema matches the given "ext"
|
||||
if not useTempFile then validateSchemaFileExtension localSchemaFile ext
|
||||
|
||||
if useTempFile || forceUpdate || not (File.Exists schemaFile.Path) then
|
||||
let metadataText = Util.TemporaryFile ext |> loader
|
||||
|
||||
// Only write if it's actually changed
|
||||
if useTempFile || (try File.ReadAllText schemaFile.Path with _ -> null) <> metadataText then
|
||||
try
|
||||
File.WriteAllText(schemaFile.Path, metadataText)
|
||||
with :? System.IO.IOException as e -> failwith (FSData.SR.errorWritingLocalSchemaFile(e.Message))
|
||||
|
||||
schemaFile
|
||||
|
||||
// tricky moment that error message can spread through multiple lines
|
||||
// so we:
|
||||
// - walk through lines until we met first line with error code, save this line
|
||||
// - traverse lines till the next error code (or EOF). append every line to the buffer
|
||||
// - flush buffer on every line with error code (or at the end)
|
||||
let private selectLines hasErrorCode (arr : string[]) =
|
||||
|
||||
// sqlmetal\edmgen pads inner exceptions with tabs so if line starts with tab - this is not beginning of the message
|
||||
// svcutil pads inner exceptions with ' ' so this is not message start as well
|
||||
let (|MessageStart|_|) line =
|
||||
if not (System.String.IsNullOrEmpty line) && line.[0] <> '\t' && not (line.StartsWith " ") && hasErrorCode line then Some () else None
|
||||
|
||||
let (|EmptyLine|_|) line =
|
||||
if String.IsNullOrEmpty line then Some () else None
|
||||
|
||||
[|
|
||||
let buf = System.Text.StringBuilder()
|
||||
for line in arr do
|
||||
match line with
|
||||
| MessageStart ->
|
||||
// return accumulated result with the prevous message
|
||||
if buf.Length <> 0 then
|
||||
yield buf.ToString()
|
||||
buf.Length <- 0
|
||||
// start new message
|
||||
buf.Append(line.Trim()) |> ignore
|
||||
| EmptyLine ->
|
||||
// // we assume that messages cannot contain embedded empty lines so empty line terminates current message
|
||||
if buf.Length <> 0 then
|
||||
yield buf.ToString()
|
||||
buf.Length <- 0
|
||||
| l ->
|
||||
// if we already started writing the message - then interleave lines in buffer with spaces
|
||||
// if buffer.Length = 0 - this means that we previous error has already ended but MessageStart for the new one wasn't yet met.
|
||||
// in this case we discard this line - it is probably header or footer of output
|
||||
if buf.Length <> 0 then
|
||||
buf
|
||||
.Append(" ")
|
||||
.Append(l.Trim()) |> ignore
|
||||
|
||||
// flush remaining content
|
||||
if buf.Length <> 0 then
|
||||
yield buf.ToString()
|
||||
|]
|
||||
|
||||
// Defines the main pattern for matching messages.
|
||||
// taken from vsproject\xmake\shared\canonicalerror.cs
|
||||
let private canonicalMessageRegex =
|
||||
new System.Text.RegularExpressions.Regex
|
||||
(
|
||||
// Beginning of line and any amount of whitespace.
|
||||
@"^\s*" +
|
||||
// Match a [optional project number prefix 'ddd>'], single letter + colon + remaining filename, or
|
||||
// string with no colon followed by a colon.
|
||||
@"(((?<ORIGIN>(((\d+>)?[a-zA-Z]?:[^:]*)|([^:]*))):)" +
|
||||
// Origin may also be empty. In this case there's no trailing colon.
|
||||
"|())" +
|
||||
// Match the empty string or a string without a colon that ends with a space
|
||||
"(?<SUBCATEGORY>(()|([^:]*? )))" +
|
||||
// Match 'error' or 'warning'.
|
||||
@"(?<CATEGORY>(error|warning))" +
|
||||
// Match anything starting with a space that's not a colon/space, followed by a colon.
|
||||
// Error code is optional in which case "error"/"warning" can be followed immediately by a colon.
|
||||
@"( \s*(?<CODE>[^: ]*))?\s*:" +
|
||||
// Whatever's left on this line, including colons.
|
||||
"(?<TEXT>.*)$",
|
||||
System.Text.RegularExpressions.RegexOptions.IgnoreCase ||| System.Text.RegularExpressions.RegexOptions.Compiled
|
||||
)
|
||||
|
||||
// Defines the additional pattern for matching messages which may contain localized strings.
|
||||
// Note that the string "error|warning" from canonicalMessageRegex is simply replaced by "\w+"
|
||||
// to match both any localized strings and PLOC'd strings.
|
||||
// It has some group misalignment for PLOC'd strings, but as a whole, it works as expected.
|
||||
let private structuralMessageRegex =
|
||||
new System.Text.RegularExpressions.Regex
|
||||
(
|
||||
// Beginning of line and any amount of whitespace.
|
||||
@"^\s*" +
|
||||
// Match a [optional project number prefix 'ddd>'], single letter + colon + remaining filename, or
|
||||
// string with no colon followed by a colon.
|
||||
@"(((?<ORIGIN>(((\d+>)?[a-zA-Z]?:[^:]*)|([^:]*))):)" +
|
||||
// Origin may also be empty. In this case there's no trailing colon.
|
||||
"|())" +
|
||||
// Match the empty string or a string without a colon that ends with a space
|
||||
"(?<SUBCATEGORY>(()|([^:]*? )))" +
|
||||
// Match localized 'error' or 'warning'.
|
||||
@"(?<CATEGORY>(\w+))" +
|
||||
// Match anything starting with a space that's not a colon/space, followed by a colon.
|
||||
// Error code is optional in which case "error"/"warning" can be followed immediately by a colon.
|
||||
// constraints for CODE here is more restrictive than in cannonical case - here we match only alphanumeric chars
|
||||
@"( \s*(?<CODE>\w*))?\s*:" +
|
||||
// Whatever's left on this line, including colons.
|
||||
"(?<TEXT>.*)$",
|
||||
System.Text.RegularExpressions.RegexOptions.IgnoreCase ||| System.Text.RegularExpressions.RegexOptions.Compiled
|
||||
)
|
||||
|
||||
let formatErr (stdout: string[]) (stderr: string[]) : unit =
|
||||
let getErrors s =
|
||||
Array.ofSeq s
|
||||
|> selectLines (fun s ->
|
||||
if canonicalMessageRegex.IsMatch s then true
|
||||
else
|
||||
// structural regex can produce false positives when line contain ':' chars
|
||||
// to reduce amount of false positives we'll mangle the most frequent scenario when ':' can be met - urls.
|
||||
// In addition, "!" which wraps PLOC'd strings will be also replaced to "_" to make the matching easier.
|
||||
let escapedLine = s.Replace("://", "_").Replace("!","_")
|
||||
structuralMessageRegex.IsMatch escapedLine
|
||||
)
|
||||
|> Array.map Failure
|
||||
let exns =
|
||||
Array.concat
|
||||
[
|
||||
getErrors stdout
|
||||
getErrors stderr
|
||||
]
|
||||
assert (exns.Length <> 0)
|
||||
raise (AggregateException exns)
|
||||
|
||||
/// Run SQLMetal and strip out a decent error message
|
||||
let sqlmetal args = Util.shell (Path.GetTempPath(), Util.sdkUtil "SqlMetal.exe", args, Some formatErr)
|
||||
|
||||
let inline handleReadingSchemaError (e : exn) =
|
||||
match e with
|
||||
| :? AggregateException as ae ->
|
||||
let inners =
|
||||
ae.InnerExceptions
|
||||
|> Seq.map (fun e -> Failure(FSData.SR.errorReadingSchema(e.Message)))
|
||||
|> Seq.toArray
|
||||
|
||||
raise(AggregateException(inners))
|
||||
| e -> failwith (FSData.SR.errorReadingSchema(e.Message))
|
||||
|
||||
// will exists forever - but I guess we can live with it as the leak is minor
|
||||
// CSharpCodeProvider is IDisposable -
|
||||
// Dispose is inherited from Component: removes component from the ISite and unsubscribes from events - we don't use any of this features
|
||||
let private csCodeProvider = new Microsoft.CSharp.CSharpCodeProvider()
|
||||
|
||||
let validateDataContextClassName name =
|
||||
if not(String.IsNullOrWhiteSpace name) && not (csCodeProvider.IsValidIdentifier name) then
|
||||
failwith (FSData.SR.invalidDataContextClassName(name))
|
||||
|
||||
type UC = System.Globalization.UnicodeCategory
|
||||
|
||||
let sanitizeDataContextFileName (name : string) =
|
||||
if String.IsNullOrEmpty name then failwith (FSData.SR.invalidDataContextClassName(name))
|
||||
|
||||
/// tests if specified character is valid start character for C# identifier
|
||||
let isValidStartChar c = Char.IsLetter c || c = '_'
|
||||
|
||||
/// tests if specified character is valid non-start character for C# identifier
|
||||
let isValidNonStartChar c =
|
||||
if Char.IsLetterOrDigit c || c = '_' then true
|
||||
else
|
||||
match Char.GetUnicodeCategory(c) with
|
||||
| UC.NonSpacingMark | UC.ConnectorPunctuation | UC.SpacingCombiningMark -> true
|
||||
| _ -> false
|
||||
|
||||
let buf = System.Text.StringBuilder()
|
||||
|
||||
let name =
|
||||
// convert given identifier to the uniform representation
|
||||
// 1. make it all lower-cased
|
||||
// 2. convert all word starting letters to upper-case + remove whitespaces
|
||||
let name = name.ToLower()
|
||||
let buf = System.Text.StringBuilder()
|
||||
let rec capitalizeFirstLetters i convertNextLetterToUpper =
|
||||
if i >= name.Length then buf.ToString()
|
||||
else
|
||||
let c = name.[i]
|
||||
if Char.IsWhiteSpace c then
|
||||
// whitespace - set convertNextLetterToUpper to true and proceed to the next character (thus removing whitespace from the result buffer)
|
||||
capitalizeFirstLetters (i + 1) true
|
||||
else
|
||||
// check if we see whitespace before.
|
||||
// if yes and current character is letter - it should be converted it to upper case before appending character to the result buffer
|
||||
let c = if Char.IsLetter c && convertNextLetterToUpper then Char.ToUpper c else c
|
||||
buf.Append(c) |> ignore
|
||||
capitalizeFirstLetters (i + 1) false
|
||||
|
||||
capitalizeFirstLetters 0 true
|
||||
|
||||
let startIndex =
|
||||
let first = name.[0]
|
||||
if isValidStartChar first then
|
||||
// if first character is valid start character for C# identifier => append it to the result buffer
|
||||
buf.Append(first) |> ignore
|
||||
1
|
||||
elif isValidNonStartChar first then
|
||||
// first character in name is not valid start character but valid as non-start. => it should be prepended with '_'
|
||||
buf.Append('_').Append(first) |> ignore
|
||||
1
|
||||
else
|
||||
// first character is invalid for usage in C# identifier => let loop below do all job (this char will be replaced with '_')
|
||||
0
|
||||
|
||||
// check char by char if they can be used in C# identifier. invalid characters are replaced with '_'
|
||||
for i=startIndex to (name.Length - 1) do
|
||||
let c = name.[i]
|
||||
let c = if isValidNonStartChar c then c else '_'
|
||||
buf.Append(c) |> ignore
|
||||
|
||||
// pad result with underscores if it occasionaly matches some C# keyword or reserved word
|
||||
csCodeProvider.CreateValidIdentifier(buf.ToString())
|
||||
|
||||
module internal ConfigFiles =
|
||||
|
||||
type ConfigFileSearchResult =
|
||||
| StandardFound of string
|
||||
| CustomFound of string
|
||||
| StandardNotFound
|
||||
| CustomNotFound of string
|
||||
|
||||
/// searches for the configuration file that will be used by TP
|
||||
/// designTimeDirectory- root folder
|
||||
/// configFileName - full path to the custom configuration file
|
||||
let findConfigFile (designTimeDirectory, configFileName) =
|
||||
if String.IsNullOrWhiteSpace configFileName then
|
||||
let appConfig = System.IO.Path.Combine(designTimeDirectory,"app.config")
|
||||
let webConfig = System.IO.Path.Combine(designTimeDirectory,"web.config")
|
||||
if System.IO.File.Exists appConfig then StandardFound appConfig
|
||||
elif System.IO.File.Exists webConfig then StandardFound webConfig
|
||||
else StandardNotFound
|
||||
else
|
||||
if System.IO.File.Exists configFileName then
|
||||
CustomFound configFileName
|
||||
else
|
||||
CustomNotFound configFileName
|
||||
|
||||
[<RequireQualifiedAccess>]
|
||||
type ConnectionStringReadResult =
|
||||
| Ok of ConnectionStringSettings
|
||||
| NotFound
|
||||
| Error of exn
|
||||
|
||||
/// reads ConnectionStringSettings with name <connectionStringName> from the specified file
|
||||
/// returns either ConnectionStringReadResult.Ok (cs : ConnectionStringSettings) (cs is not null)
|
||||
/// or ConnectionStringReadResult.NotFound if configuration file doesn't contain ConnectionStringSettings with specified name
|
||||
/// or ConnectionStringReadResult.Error if reading of the file ends with error
|
||||
let tryReadConnectionString (configFileName : string, connectionStringName : string) =
|
||||
try
|
||||
// copy original file to avoid its locking
|
||||
let text = System.IO.File.ReadAllText configFileName
|
||||
use tmpConfigFile = Util.TemporaryFile "config"
|
||||
do System.IO.File.WriteAllText(tmpConfigFile.Path,text)
|
||||
let map = ExeConfigurationFileMap(ExeConfigFilename = tmpConfigFile.Path)
|
||||
let config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);
|
||||
|
||||
let connString = config.ConnectionStrings.ConnectionStrings.[connectionStringName]
|
||||
if connString <> null then ConnectionStringReadResult.Ok connString
|
||||
else ConnectionStringReadResult.NotFound
|
||||
with exn ->
|
||||
ConnectionStringReadResult.Error exn
|
||||
|
||||
|
||||
let computeStaticConnectionString (name,checkForSqlClientProvider, connectionString, connectionStringName, configFileName, absoluteDataDirectoryParam, designTimeDirectory) =
|
||||
let connectionString, usingConfigFileInfo =
|
||||
if String.IsNullOrWhiteSpace connectionString then
|
||||
|
||||
let configFileName, configFileBaseNameOpt =
|
||||
match findConfigFile (designTimeDirectory, configFileName) with
|
||||
| StandardFound path ->
|
||||
let name = Path.GetFileName path
|
||||
path, Some name
|
||||
| CustomFound path -> path, None
|
||||
| StandardNotFound -> failwith (FSData.SR.noConfigFileFound1())
|
||||
| CustomNotFound name -> failwith (FSData.SR.noConfigFileFound2(name))
|
||||
|
||||
if String.IsNullOrWhiteSpace connectionStringName then
|
||||
failwith (FSData.SR.noConnectionStringOrConnectionStringName(name))
|
||||
|
||||
let mkReadConnectionStringError msg =
|
||||
FSData.SR.errorWhileReadingConnectionStringInConfigFile (connectionStringName, configFileName, msg)
|
||||
|> Choice2Of2
|
||||
|
||||
let result =
|
||||
match tryReadConnectionString(configFileName, connectionStringName) with
|
||||
| ConnectionStringReadResult.Ok connString ->
|
||||
if checkForSqlClientProvider && connString.ProviderName <> "System.Data.SqlClient" then
|
||||
Choice2Of2 (FSData.SR.invalidProviderInConfigFile (connString.ProviderName, connectionStringName, configFileName))
|
||||
|
||||
else
|
||||
let result = connString.ConnectionString
|
||||
if String.IsNullOrWhiteSpace result then
|
||||
Choice2Of2 (FSData.SR.invalidConnectionStringInConfigFile (result, connectionStringName, configFileName))
|
||||
else
|
||||
Choice1Of2 result
|
||||
| ConnectionStringReadResult.NotFound ->
|
||||
FSData.SR.connectionStringNotFound(connectionStringName)
|
||||
|> mkReadConnectionStringError
|
||||
|
||||
| ConnectionStringReadResult.Error exn ->
|
||||
mkReadConnectionStringError exn.Message
|
||||
|
||||
match result with
|
||||
| Choice1Of2 r -> r, Some (connectionStringName, configFileBaseNameOpt)
|
||||
| Choice2Of2 msg -> failwith msg
|
||||
else
|
||||
if not (String.IsNullOrWhiteSpace connectionStringName) then
|
||||
failwith (FSData.SR.notBothConnectionStringOrConnectionStringName())
|
||||
connectionString, None
|
||||
|
||||
// Always do |DataDirectory| substitution
|
||||
let connectionString =
|
||||
let absoluteDataDirectory =
|
||||
if String.IsNullOrWhiteSpace absoluteDataDirectoryParam then
|
||||
designTimeDirectory
|
||||
else
|
||||
if not (System.IO.Directory.Exists absoluteDataDirectoryParam) then
|
||||
failwith (FSData.SR.dataDirectoryNotFound(absoluteDataDirectoryParam))
|
||||
absoluteDataDirectoryParam
|
||||
connectionString.Replace("|DataDirectory|", absoluteDataDirectory)
|
||||
|
||||
connectionString, usingConfigFileInfo
|
||||
|
||||
module internal Dbml =
|
||||
|
||||
let buildType (dbmlFileContent: string, contextTypeName:string, serializable:bool) =
|
||||
|
||||
validateDataContextClassName contextTypeName
|
||||
|
||||
// Remove the Database/Connection element if exist, which can be created by the O/R Designer
|
||||
// Its attributes, "SettingsObjectName" and "SettingsPropertyName" can cause sqlmetal to generate a problematic csharp file
|
||||
let dbmlFileContent =
|
||||
if dbmlFileContent.Contains("Connection") then
|
||||
let xdoc = XDocument.Parse dbmlFileContent
|
||||
xdoc.Elements()
|
||||
|> Seq.filter (fun xnode -> xnode.Name.LocalName = "Database")
|
||||
|> Seq.choose (fun xnode ->
|
||||
match xnode.Elements(xnode.Name.Namespace + "Connection") with
|
||||
| null -> None
|
||||
| s -> Some (s))
|
||||
|> Seq.iter (fun xchild -> xchild.Remove())
|
||||
xdoc.ToString()
|
||||
else dbmlFileContent
|
||||
|
||||
use csFile = Util.TemporaryFile "cs"
|
||||
use dbmlFile = Util.TemporaryFile "dbml"
|
||||
File.WriteAllText (dbmlFile.Path, dbmlFileContent)
|
||||
|
||||
let sqlMetalArgs =
|
||||
let command = sprintf "/code:\"%s\" /language:C# \"%s\"" csFile.Path dbmlFile.Path
|
||||
let command = if not (String.IsNullOrWhiteSpace contextTypeName) then sprintf "%s /context:\"%s\" " command contextTypeName else command
|
||||
let command = if serializable then sprintf "%s /serialization:Unidirectional" command else command
|
||||
command
|
||||
|
||||
sqlmetal sqlMetalArgs
|
||||
|
||||
let assemblyFile = Util.TemporaryFile "dll" // TODO: load in-memory and clean up this file
|
||||
|
||||
let cscCommand = sprintf "/nologo /target:library /out:\"%s\" \"%s\"" assemblyFile.Path csFile.Path
|
||||
Util.shell(Path.GetTempPath(), Util.cscExe(), cscCommand, None)
|
||||
|
||||
assemblyFile
|
||||
|
||||
module internal SqlConnection =
|
||||
|
||||
let getDbml (dbmlFile: Util.FileResource, connString, flagPluralize, flagViews, flagFunctions, flagStoredProcs, flagTimeout, contextTypeName) =
|
||||
|
||||
validateDataContextClassName contextTypeName
|
||||
|
||||
let sqlMetalArgs =
|
||||
let command = sprintf "/conn:\"%s\" /dbml:\"%s\"" connString dbmlFile.Path
|
||||
let command = if flagPluralize then sprintf "%s /pluralize" command else command
|
||||
let command = if flagViews then sprintf "%s /views" command else command
|
||||
let command = if flagFunctions then sprintf "%s /functions" command else command
|
||||
let command = if flagStoredProcs then sprintf "%s /sprocs" command else command
|
||||
let command = if not (String.IsNullOrWhiteSpace contextTypeName) then sprintf "%s /context:\"%s\" " command contextTypeName else command
|
||||
let command = sprintf "%s /timeout:%d" command flagTimeout
|
||||
command
|
||||
sqlmetal sqlMetalArgs
|
||||
File.ReadAllText dbmlFile.Path
|
||||
|
||||
|
||||
let buildType (connectionString, connectionStringName:string, configFileName:string, absoluteDataDirectory:string, localSchemaFile:string, forceUpdate:bool, flagPluralize, flagViews, flagFunctions, flagStoredProcs, flagTimeout, contextTypeName, serializable, designTimeDirectory) =
|
||||
let connectionString, usingConfigFileInfo = ConfigFiles.computeStaticConnectionString ("SqlDataConnection", true, connectionString, connectionStringName, configFileName, absoluteDataDirectory, designTimeDirectory)
|
||||
|
||||
// parses connection string on components, validates only syntax
|
||||
let connStringBuilder = System.Data.Common.DbConnectionStringBuilder()
|
||||
connStringBuilder.ConnectionString <- connectionString
|
||||
let contextTypeName =
|
||||
// if context is not explicitly set - try to infer context name from database filename
|
||||
if String.IsNullOrWhiteSpace(contextTypeName) then
|
||||
let dbFileNameOpt =
|
||||
// SqlCE allows usage of both 'Data Source' and 'DataSource' names and treats them as equivalent
|
||||
// however SqlMetal doesn't recognize 'DataSource' and always looks for 'Data Source'
|
||||
// so to figure out if given connection string is SqlCE - we'll get value of 'Data Source' and check if it ends with .sdf
|
||||
// NOTE: we cannot just use SqlConnectionStringBuilder because it rejects some SqlCE specific parameter names
|
||||
match connStringBuilder.TryGetValue ("Data Source") with
|
||||
| true, (:? string as ds) when ds.EndsWith(".sdf", System.StringComparison.OrdinalIgnoreCase) -> Some ds // SqlCE
|
||||
| _ ->
|
||||
// SqlServer
|
||||
let sqlConnString = System.Data.SqlClient.SqlConnectionStringBuilder(connectionString)
|
||||
if not (String.IsNullOrEmpty sqlConnString.AttachDBFilename) then
|
||||
Some (sqlConnString.AttachDBFilename)
|
||||
else
|
||||
None
|
||||
|
||||
match dbFileNameOpt with
|
||||
| Some f -> Path.GetFileNameWithoutExtension f |> sanitizeDataContextFileName
|
||||
| None -> contextTypeName
|
||||
else
|
||||
contextTypeName
|
||||
|
||||
use dbmlFile =
|
||||
tryUseLocalSchemaFile
|
||||
(localSchemaFile, forceUpdate, "dbml")
|
||||
(fun dbmlFile ->
|
||||
try
|
||||
getDbml (dbmlFile,connectionString, flagPluralize, flagViews, flagFunctions, flagStoredProcs, flagTimeout, contextTypeName)
|
||||
with
|
||||
e -> handleReadingSchemaError e)
|
||||
|
||||
use csFile = Util.TemporaryFile "cs"
|
||||
let sqlMetalArgs =
|
||||
let command = sprintf "/code:\"%s\" /language:C# \"%s\"" csFile.Path dbmlFile.Path
|
||||
let command = if not (String.IsNullOrWhiteSpace contextTypeName) then sprintf "%s /context:\"%s\" " command contextTypeName else command
|
||||
let command = if serializable then sprintf "%s /serialization:Unidirectional" command else command
|
||||
command
|
||||
sqlmetal sqlMetalArgs
|
||||
|
||||
let assemblyFile = Util.TemporaryFile "dll" // TODO: load in-memory and clean up this file
|
||||
|
||||
let cscCommand = sprintf "/nologo /target:library /out:\"%s\" \"%s\"" assemblyFile.Path csFile.Path
|
||||
Util.shell(Path.GetTempPath(), Util.cscExe(), cscCommand, None)
|
||||
|
||||
assemblyFile, usingConfigFileInfo
|
||||
|
||||
|
||||
|
||||
|
||||
module internal DataSvcUtil =
|
||||
|
||||
type MetadataError = FixedQueryNotSupported | DataQualityServiceNotSupported
|
||||
module Metadata =
|
||||
|
||||
let private edmx = XNamespace.Get "http://schemas.microsoft.com/ado/2007/06/edmx"
|
||||
let private dr = XNamespace.Get "http://schemas.microsoft.com/dallas/2010/04"
|
||||
let private edm08 = XNamespace.Get "http://schemas.microsoft.com/ado/2009/08/edm"
|
||||
let private edm05 = XNamespace.Get "http://schemas.microsoft.com/ado/2007/05/edm"
|
||||
|
||||
let private get (name : XName) (c : XContainer) =
|
||||
match c.Element name with
|
||||
| null -> None
|
||||
| el -> Some (el :> XContainer)
|
||||
|
||||
/// Analyzes given metadata file and tries to find evidence of specific cases that may cause datasvcutil to fail
|
||||
let TryPredictError (path : string) =
|
||||
try
|
||||
let xdoc = XDocument.Load(path)
|
||||
let error =
|
||||
defaultArg (get (edmx + "Edmx") xdoc) (xdoc :> XContainer)
|
||||
|> get (edmx + "DataServices")
|
||||
|> Option.bind (fun ds ->
|
||||
match get (edm08 + "Schema") ds with
|
||||
| Some el -> Some (el, edm08)
|
||||
| None ->
|
||||
|
||||
match get (edm05 + "Schema") ds with
|
||||
| Some el -> Some (el, edm05)
|
||||
| None -> None
|
||||
)
|
||||
|> Option.bind (fun (schema, ns) ->
|
||||
// check if metadata contains node
|
||||
// <Using Namespace="Microsoft.DQS">
|
||||
// this indicates that target service implements DataQuality API - datasvcutil cannot consume it correctly
|
||||
let isDQS =
|
||||
match get (ns + "Using") schema with
|
||||
| Some (:? XElement as e) ->
|
||||
match e.Attribute(XName.Get "Namespace") with
|
||||
| null -> false
|
||||
| attr -> attr.Value = "Microsoft.DQS"
|
||||
| _ -> false
|
||||
|
||||
if isDQS then Some DataQualityServiceNotSupported
|
||||
else
|
||||
|
||||
// check all EntityType nodes
|
||||
// if all of them has <Property Queryable='false'> - then it may indicate that service support fixed query
|
||||
let entityTypes = schema.Elements(ns + "EntityType")
|
||||
let isFixed =
|
||||
entityTypes.Elements (ns + "Property")
|
||||
|> Seq.forall (fun el ->
|
||||
let attr = el.Attribute(dr + "Queryable")
|
||||
attr <> null && attr.Value = "false"
|
||||
)
|
||||
|
||||
if isFixed then Some FixedQueryNotSupported
|
||||
else None
|
||||
)
|
||||
error
|
||||
with _ -> None // swallow this error (if datasvcutil will fail - we'll report errors from the output)
|
||||
|
||||
/// Add the default service URI to the generated CS file by inserting it as the argument
|
||||
/// to the default data context constructor, also drop the namespace declaration.
|
||||
let addDefaultUriToDataSvcUtilCSharpFile uri csFile =
|
||||
let csText = File.ReadAllLines csFile
|
||||
|
||||
let (|DataContextClass|_|) (line:string) =
|
||||
let trimmed = line.Trim('{',' ','\t')
|
||||
let starting = "public partial class "
|
||||
let ending = "System.Data.Services.Client.DataServiceContext"
|
||||
if trimmed.StartsWith starting && trimmed.Contains ":" && trimmed.EndsWith ending then
|
||||
let s = trimmed.Substring starting.Length
|
||||
Some (s.Substring(0, s.IndexOf ' '), line.Contains "{")
|
||||
else None
|
||||
|
||||
let doctoredText =
|
||||
[| // Was the last line a namespace?
|
||||
let prevNS = ref false
|
||||
let foundDataContextClass = ref None
|
||||
for line in csText do
|
||||
match line with
|
||||
| _ when prevNS.Value -> prevNS := false // note, the line after the namespace is dropped
|
||||
| _ when line.StartsWith "namespace" -> prevNS := true // note, the namespace declaration is dropped
|
||||
|
||||
| DataContextClass (className, endsWithBrace) ->
|
||||
foundDataContextClass := Some (className, endsWithBrace)
|
||||
yield line
|
||||
| _ ->
|
||||
match line.Trim(), foundDataContextClass.Value with
|
||||
| "{", Some(className, false)
|
||||
| "", Some(className, true) ->
|
||||
yield line
|
||||
yield sprintf "public %s() : this(new global::System.Uri(\"%s\")) {}" className uri
|
||||
foundDataContextClass := None
|
||||
|
||||
| _ when line <> "}" -> yield line
|
||||
| _ -> ()
|
||||
|]
|
||||
File.WriteAllLines(csFile, doctoredText)
|
||||
|
||||
let buildTypeFromMetadataUri (uri : string, localSchemaFile:string, forceUpdate:bool, dataServiceCollection) =
|
||||
|
||||
use csdlFile =
|
||||
tryUseLocalSchemaFile (localSchemaFile, forceUpdate, "csdl") (fun _ ->
|
||||
try
|
||||
let metadataUri =
|
||||
if uri.EndsWith "/" then uri + "$metadata"
|
||||
else uri + "/$metadata"
|
||||
let metadataText =
|
||||
use c = new WebClient(UseDefaultCredentials=true) // TODO: consider adding schema credentials here
|
||||
c.DownloadString metadataUri
|
||||
metadataText
|
||||
with e -> handleReadingSchemaError e)
|
||||
|
||||
let expectedError = Metadata.TryPredictError csdlFile.Path
|
||||
|
||||
use csFile = Util.TemporaryFile "cs"
|
||||
let dataSvcUtilArgs =
|
||||
let args = sprintf "/nologo /in:\"%s\" /out:\"%s\" /language:CSharp /version:2.0" csdlFile.Path csFile.Path
|
||||
let args = if dataServiceCollection then sprintf "%s /DataServiceCollection" args else args
|
||||
args
|
||||
try
|
||||
Util.shell(Path.GetTempPath(), Util.dataSvcUtilExe(), dataSvcUtilArgs, Some formatErr)
|
||||
with
|
||||
_ ->
|
||||
// check if we expect errors in this file
|
||||
match expectedError with
|
||||
| Some FixedQueryNotSupported -> failwith (FSData.SR.fixedQueriesNotSupported())
|
||||
| Some DataQualityServiceNotSupported -> failwith (FSData.SR.dqsServicesNotSupported())
|
||||
| None -> reraise()
|
||||
|
||||
addDefaultUriToDataSvcUtilCSharpFile uri csFile.Path
|
||||
|
||||
let assemblyFile = Util.TemporaryFile "dll" // TODO: load in-memory and clean up this file
|
||||
|
||||
let cscCommand = sprintf "/nologo /target:library /r:System.Data.Services.Client.dll /out:\"%s\" \"%s\"" assemblyFile.Path csFile.Path
|
||||
Util.shell(Path.GetTempPath(), Util.cscExe(), cscCommand, None)
|
||||
assemblyFile
|
||||
|
||||
|
||||
module internal SvcUtil =
|
||||
|
||||
let serviceMetadataFilesXName = XName.Get "ServiceMetadataFiles"
|
||||
let serviceMetadataFileXName = XName.Get "ServiceMetadataFile"
|
||||
let fileNameXName = XName.Get "name"
|
||||
|
||||
/// assumes that destFolder is already created
|
||||
let private unpackFolder (sourceFile : string) (destFolder : string) =
|
||||
let xml = XDocument.Load sourceFile
|
||||
for fileNode in xml.Root.Elements(serviceMetadataFileXName) do
|
||||
let name = fileNode.Attribute(fileNameXName)
|
||||
let resultPath = Path.Combine(destFolder, name.Value)
|
||||
let root =
|
||||
fileNode.Elements()
|
||||
|> Seq.tryFind(fun _ -> true) // pick first element
|
||||
match root with
|
||||
| Some root -> root.Save(resultPath)
|
||||
| None -> failwith (FSData.SR.serviceMetadataFileElementIsEmpty())
|
||||
|
||||
let private packFolder sourceFolder (destFile : string) patterns =
|
||||
let root =XElement(serviceMetadataFilesXName)
|
||||
let doc = XDocument(root)
|
||||
|
||||
let append pat =
|
||||
for f in Directory.GetFiles(sourceFolder, pat) do
|
||||
let xml = XDocument.Load(f)
|
||||
let node = XElement(serviceMetadataFileXName)
|
||||
let fileName = Path.GetFileName f
|
||||
// add attribute with the name of source file
|
||||
node.Add(XAttribute(fileNameXName, fileName))
|
||||
// append file content
|
||||
node.Add(xml.Root)
|
||||
|
||||
root.Add(node)
|
||||
|
||||
for pat in patterns do
|
||||
append pat
|
||||
|
||||
doc.Save(destFile)
|
||||
|
||||
let validateWsdlUri uri =
|
||||
if String.IsNullOrWhiteSpace uri then
|
||||
failwith (FSData.SR.invalidWsdlUri())
|
||||
|
||||
let buildTypeFromWsdlUri (namespaceName, wsdlUri : string, localSchemaFile:string, forceUpdate:bool, messageContract, enableDataBinding, serializable, async, collectionType) =
|
||||
|
||||
validateWsdlUri wsdlUri
|
||||
|
||||
use metadataDir =
|
||||
let tempFolder = Util.TemporaryDirectory()
|
||||
|
||||
let schemaFileSet = not (String.IsNullOrWhiteSpace localSchemaFile)
|
||||
let schemaFileExists = schemaFileSet && ( try File.Exists(localSchemaFile) with _ -> false )
|
||||
|
||||
if schemaFileSet then validateSchemaFileExtension localSchemaFile "wsdlschema"
|
||||
|
||||
// downloads metadata to the specified temp folder
|
||||
// if localSchemaFile is set - pack downloaded content as localSchemaFile
|
||||
let downloadMetadata () =
|
||||
if (try System.IO.Directory.Exists tempFolder.Path with _ -> false) then
|
||||
(try System.IO.Directory.Delete (tempFolder.Path, true) with _ -> ())
|
||||
if not (System.IO.Directory.Exists tempFolder.Path) then
|
||||
System.IO.Directory.CreateDirectory tempFolder.Path |> ignore
|
||||
let svcUtilArgs =
|
||||
let args = sprintf "/nologo /t:metadata \"%s\"" wsdlUri
|
||||
args
|
||||
|
||||
Util.shell(tempFolder.Path, Util.svcUtilExe(), svcUtilArgs, Some formatErr)
|
||||
|
||||
if schemaFileSet then
|
||||
packFolder tempFolder.Path localSchemaFile ["*.wsdl"; "*.xsd"]
|
||||
|
||||
if not (schemaFileExists) || forceUpdate then
|
||||
downloadMetadata()
|
||||
else
|
||||
// reraise exceptions if local schema file is corrupted
|
||||
try
|
||||
unpackFolder localSchemaFile tempFolder.Path
|
||||
with
|
||||
e -> failwith (FSData.SR.errorReadingSchema(e.Message))
|
||||
|
||||
|
||||
tempFolder
|
||||
|
||||
use configFile = Util.TemporaryFile "config" //Util.ExistingFile (System.IO.Path.Combine(metadataDir.Path, configFileName))
|
||||
use csFile = Util.TemporaryFile "cs"
|
||||
|
||||
let svcUtilArgs =
|
||||
let args = sprintf "/nologo /out:\"%s\" /config:\"%s\" /language:CSharp /serializer:Auto /fault" csFile.Path configFile.Path
|
||||
let args = if System.IO.Directory.EnumerateFiles(metadataDir.Path, "*.wsdl") |> Seq.isEmpty then args else sprintf "%s \"%s\"" args (Path.Combine(metadataDir.Path,"*.wsdl"))
|
||||
let args = if System.IO.Directory.EnumerateFiles(metadataDir.Path, "*.xsd") |> Seq.isEmpty then args else sprintf "%s \"%s\"" args (Path.Combine(metadataDir.Path,"*.xsd"))
|
||||
let args = if messageContract then sprintf "%s /messageContract" args else args
|
||||
let args = if enableDataBinding then sprintf "%s /enableDataBinding" args else args
|
||||
let args = if serializable then sprintf "%s /serializable" args else args
|
||||
let args = if async then sprintf "%s /async" args else args
|
||||
let args = if not (String.IsNullOrWhiteSpace collectionType) then sprintf "%s /collectionType:%s" args collectionType else args
|
||||
args
|
||||
|
||||
Util.shell(Path.GetTempPath(), Util.svcUtilExe(), svcUtilArgs, Some formatErr)
|
||||
|
||||
let assemblyFile = Util.TemporaryFile "dll" // TODO: load in-memory and clean up this file
|
||||
|
||||
let cscCommand = sprintf "/nologo /target:library /resource:\"%s\",%s.config,public /out:\"%s\" \"%s\"" configFile.Path namespaceName assemblyFile.Path csFile.Path
|
||||
Util.shell(Path.GetTempPath(), Util.cscExe(), cscCommand, None)
|
||||
|
||||
let endPointNames =
|
||||
try
|
||||
let config = ConfigurationManager.OpenMappedExeConfiguration(ExeConfigurationFileMap(ExeConfigFilename = configFile.Path), ConfigurationUserLevel.None);
|
||||
[ for ep in ((config.GetSectionGroup "system.serviceModel").Sections.["client"] :?> System.ServiceModel.Configuration.ClientSection).Endpoints do
|
||||
yield ep.Name ]
|
||||
with _ ->
|
||||
[]
|
||||
|
||||
assemblyFile, endPointNames
|
||||
|
||||
module internal Edmx =
|
||||
type private EdmxNamespaceGroup = { Edmx : XNamespace; Edm : XNamespace; Ssdl :XNamespace; Msl : XNamespace; RequireDotNet45 : bool }
|
||||
let private makeGroup (edmx : string, edm : string, ssdl : string, msl : string, requireDotNet45)=
|
||||
{ Edmx = XNamespace.Get edmx
|
||||
Edm = XNamespace.Get edm
|
||||
Ssdl = XNamespace.Get ssdl
|
||||
Msl = XNamespace.Get msl
|
||||
RequireDotNet45 = requireDotNet45 }
|
||||
|
||||
let private ns45 =
|
||||
makeGroup
|
||||
(
|
||||
"http://schemas.microsoft.com/ado/2009/11/edmx",
|
||||
"http://schemas.microsoft.com/ado/2009/11/edm",
|
||||
"http://schemas.microsoft.com/ado/2009/11/edm/ssdl",
|
||||
"http://schemas.microsoft.com/ado/2009/11/mapping/cs",
|
||||
true
|
||||
)
|
||||
|
||||
let private ns40 =
|
||||
makeGroup
|
||||
(
|
||||
"http://schemas.microsoft.com/ado/2008/10/edmx",
|
||||
"http://schemas.microsoft.com/ado/2008/09/edm",
|
||||
"http://schemas.microsoft.com/ado/2009/02/edm/ssdl",
|
||||
"http://schemas.microsoft.com/ado/2008/09/mapping/cs",
|
||||
false
|
||||
)
|
||||
|
||||
let private ns20 =
|
||||
makeGroup
|
||||
(
|
||||
"http://schemas.microsoft.com/ado/2007/06/edmx",
|
||||
"http://schemas.microsoft.com/ado/2006/04/edm",
|
||||
"http://schemas.microsoft.com/ado/2006/04/edm/ssdl",
|
||||
"urn:schemas-microsoft-com:windows:storage:mapping:CS",
|
||||
false
|
||||
)
|
||||
|
||||
let loadEdmxFile path =
|
||||
let getElement (c : XContainer) (name : string) (ns : XNamespace) =
|
||||
match c.Element (ns + name) with
|
||||
| null -> failwith (FSData.SR.fileDoesNotContainXMLElement(path, name))
|
||||
| el -> el
|
||||
|
||||
let xdoc =
|
||||
match XDocument.Load path with
|
||||
| null -> failwith (FSData.SR.failedToLoadFileAsXML(path))
|
||||
| xdoc -> xdoc
|
||||
let extractEdmxComponents (nsGroup : EdmxNamespaceGroup) =
|
||||
let edmxNode = getElement xdoc "Edmx" nsGroup.Edmx
|
||||
let runtimeNode = getElement edmxNode "Runtime" nsGroup.Edmx
|
||||
let csdlNode =
|
||||
let conceptualModelNode = getElement runtimeNode "ConceptualModels" nsGroup.Edmx
|
||||
getElement conceptualModelNode "Schema" nsGroup.Edm
|
||||
let ssdlNode =
|
||||
let storageModelNode = getElement runtimeNode "StorageModels" nsGroup.Edmx
|
||||
getElement storageModelNode "Schema" nsGroup.Ssdl
|
||||
let mslNode =
|
||||
let mappingsNode = getElement runtimeNode "Mappings" nsGroup.Edmx
|
||||
getElement mappingsNode "Mapping" nsGroup.Msl
|
||||
(csdlNode.ToString()), (ssdlNode.ToString()), (mslNode.ToString()), nsGroup.RequireDotNet45
|
||||
|
||||
// tries to process given edmx using supplied set of namespace groups
|
||||
let rec load = function
|
||||
| [] -> assert false; failwith "impossible"
|
||||
| x::xs ->
|
||||
try extractEdmxComponents x
|
||||
with e ->
|
||||
match xs with
|
||||
| [] -> reraise() // we were not able to load file - raise exception
|
||||
| _ -> load xs
|
||||
load [ns45; ns40; ns20]
|
||||
|
||||
let buildTypeFromEdmxFile (edmxFile, isTargetingDotNet45) =
|
||||
|
||||
use csDir = Util.TemporaryDirectory()
|
||||
let baseContainerName = Path.GetFileNameWithoutExtension edmxFile
|
||||
let csFile = Path.Combine(csDir.Path, baseContainerName + ".cs")
|
||||
|
||||
let csdlFileName = baseContainerName + ".csdl"
|
||||
let mslFileName = baseContainerName + ".msl"
|
||||
let ssdlFileName = baseContainerName + ".ssdl"
|
||||
|
||||
let csdlFile = Path.Combine(csDir.Path, csdlFileName)
|
||||
let mslFile = Path.Combine(csDir.Path, mslFileName)
|
||||
let ssdlFile = Path.Combine(csDir.Path, ssdlFileName)
|
||||
let csdlContent, ssdlContent, mslContent, requireDotNet45 = loadEdmxFile edmxFile
|
||||
|
||||
if requireDotNet45 && not isTargetingDotNet45 then
|
||||
failwith (FSData.SR.edmxFileRequiresDotNet45(edmxFile))
|
||||
|
||||
File.WriteAllText(csdlFile, csdlContent)
|
||||
File.WriteAllText(mslFile, mslContent)
|
||||
File.WriteAllText(ssdlFile, ssdlContent)
|
||||
|
||||
let edmGenArgs =
|
||||
let args = sprintf "/mode:EntityClassGeneration /incsdl:\"%s\" /outobjectlayer:\"%s\" /nologo" csdlFile csFile
|
||||
let args = if isTargetingDotNet45 then sprintf "%s /targetversion:4.5" args else args
|
||||
args
|
||||
|
||||
Util.shell(csDir.Path, Util.edmGenExe(), edmGenArgs, Some formatErr)
|
||||
let assemblyFile = Util.TemporaryFile "dll" // TODO: load in-memory and clean up this file
|
||||
|
||||
let cscCommand = sprintf "/nologo /resource:\"%s\",\"%s\" /resource:\"%s\",\"%s\" /resource:\"%s\",\"%s\" /target:library /r:System.Data.Entity.dll /out:\"%s\" \"%s\"" csdlFile csdlFileName mslFile mslFileName ssdlFile ssdlFileName assemblyFile.Path csFile
|
||||
|
||||
Util.shell(csDir.Path, Util.cscExe(), cscCommand, None)
|
||||
assemblyFile
|
||||
|
||||
module internal SqlEntityConnection =
|
||||
|
||||
let getSsdl (namespaceName, ssdlFile: Util.FileResource, provider, connString, flagPluralize, flagSuppressForeignKeyProperties, isTargetingDotNet45) =
|
||||
let edmGenArgs =
|
||||
let args = sprintf "/namespace:\"%s\" /project:\"%s\" /outssdl:\"%s\" /mode:FullGeneration /connectionstring:\"%s\" " namespaceName (Path.GetFileNameWithoutExtension ssdlFile.Path) ssdlFile.Path connString
|
||||
let args = if not (String.IsNullOrWhiteSpace provider) then sprintf "%s /provider:%s" args provider else args
|
||||
let args = if flagPluralize then sprintf "%s /pluralize" args else args
|
||||
let args = if flagSuppressForeignKeyProperties then sprintf "%s /SuppressForeignKeyProperties" args else args
|
||||
let args = if isTargetingDotNet45 then sprintf "%s /targetversion:4.5" args else args
|
||||
args
|
||||
Util.shell(System.IO.Path.GetDirectoryName ssdlFile.Path, Util.edmGenExe(), edmGenArgs, Some formatErr)
|
||||
File.ReadAllText ssdlFile.Path
|
||||
|
||||
|
||||
let computeEntityContainerName (entityContainer:string) =
|
||||
if String.IsNullOrWhiteSpace entityContainer then
|
||||
"EntityContainer"
|
||||
else
|
||||
entityContainer
|
||||
|
||||
let buildType (namespaceName, connectionString, connectionStringName, configFileName, absoluteDataDirectory, localSchemaFile:string, provider:string, entityContainer:string, forceUpdate:bool, flagPluralize, flagSuppressForeignKeyProperties, designTimeDirectory, isTargetingDotNet45) =
|
||||
let connectionString, usingConfigFileInfo = ConfigFiles.computeStaticConnectionString ("SqlEntityConnection", false, connectionString, connectionStringName, configFileName, absoluteDataDirectory, designTimeDirectory)
|
||||
let entityContainer = computeEntityContainerName entityContainer
|
||||
use ssdlFile =
|
||||
tryUseLocalSchemaFile
|
||||
(localSchemaFile, forceUpdate, "ssdl")
|
||||
(fun ssdlFile ->
|
||||
try
|
||||
getSsdl (namespaceName, ssdlFile, provider, connectionString, flagPluralize, flagSuppressForeignKeyProperties, isTargetingDotNet45)
|
||||
with
|
||||
e -> handleReadingSchemaError e)
|
||||
|
||||
use csFile = Util.TemporaryFile "cs"
|
||||
use csdlFile = Util.TemporaryFile "csdl"
|
||||
use mslFile = Util.TemporaryFile "msl"
|
||||
use viewsFile = Util.TemporaryFile "Views.cs"
|
||||
|
||||
let edmGenArgs =
|
||||
let args = sprintf "/mode:FromSsdlGeneration /entitycontainer:\"%s\" /namespace:\"%s\" /project:\"%s\" /inssdl:\"%s\" /outobjectlayer:\"%s\" /outcsdl:\"%s\" /outmsl:\"%s\" /outviews:\"%s\" /language:CSharp" entityContainer namespaceName (Path.GetFileNameWithoutExtension ssdlFile.Path) ssdlFile.Path csFile.Path csdlFile.Path mslFile.Path viewsFile.Path
|
||||
let args = if not (String.IsNullOrWhiteSpace provider) then sprintf "%s /provider:%s" args provider else args
|
||||
let args = if flagPluralize then sprintf "%s /pluralize" args else args
|
||||
let args = if flagSuppressForeignKeyProperties then sprintf "%s /SuppressForeignKeyProperties" args else args
|
||||
let args = if isTargetingDotNet45 then sprintf "%s /targetversion:4.5" args else args
|
||||
args
|
||||
Util.shell(System.IO.Path.GetDirectoryName ssdlFile.Path, Util.edmGenExe(), edmGenArgs, Some formatErr)
|
||||
|
||||
let assemblyFile = Util.TemporaryFile "dll"
|
||||
|
||||
let csdlFileName = namespaceName + ".csdl"
|
||||
let mslFileName = namespaceName + ".msl"
|
||||
let ssdlFileName = namespaceName + ".ssdl"
|
||||
|
||||
let cscCommand = sprintf "/r:System.Data.Entity.dll /nologo /resource:\"%s\",\"%s\" /resource:\"%s\",\"%s\" /resource:\"%s\",\"%s\" /nologo /target:library /out:\"%s\" \"%s\"" csdlFile.Path csdlFileName mslFile.Path mslFileName ssdlFile.Path ssdlFileName assemblyFile.Path csFile.Path
|
||||
Util.shell(Path.GetTempPath(), Util.cscExe(), cscCommand, None)
|
||||
|
||||
assemblyFile, usingConfigFileInfo
|
||||
|
||||
|
|
@ -0,0 +1,223 @@
|
|||
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
namespace Microsoft.FSharp.Data.TypeProviders.Utility
|
||||
|
||||
module internal Util =
|
||||
open System
|
||||
open System.IO
|
||||
open System.Collections.Generic
|
||||
open System.Reflection
|
||||
|
||||
type ProcessResult = { exitCode : int; stdout : string[] ; stderr : string[] }
|
||||
|
||||
let executeProcess (workingDirectory,exe,cmdline) =
|
||||
try
|
||||
// External tools (like edmgen.exe) run as part of default OS locale/codepage/LCID. We need to ensure we translate their output
|
||||
// accordingly, by setting up the correct encoding on the stdout/stderr streams.
|
||||
let encodingToTranslateToolOutput = System.Text.Encoding.Default
|
||||
|
||||
let psi = new System.Diagnostics.ProcessStartInfo(exe,cmdline)
|
||||
psi.WorkingDirectory <- workingDirectory
|
||||
psi.UseShellExecute <- false
|
||||
psi.RedirectStandardOutput <- true
|
||||
psi.RedirectStandardError <- true
|
||||
psi.CreateNoWindow <- true
|
||||
psi.StandardOutputEncoding <- encodingToTranslateToolOutput
|
||||
psi.StandardErrorEncoding <- encodingToTranslateToolOutput
|
||||
let p = System.Diagnostics.Process.Start(psi)
|
||||
let output = ResizeArray()
|
||||
let error = ResizeArray()
|
||||
|
||||
// nulls are skipped because they act as signal that redirected stream is closed and not as part of output data
|
||||
p.OutputDataReceived.Add(fun args -> if args.Data <> null then output.Add(args.Data))
|
||||
p.ErrorDataReceived.Add(fun args -> if args.Data <> null then error.Add(args.Data))
|
||||
p.BeginErrorReadLine()
|
||||
p.BeginOutputReadLine()
|
||||
p.WaitForExit()
|
||||
{ exitCode = p.ExitCode; stdout = output.ToArray(); stderr = error.ToArray() }
|
||||
with
|
||||
| :? System.IO.FileNotFoundException
|
||||
| :? System.ComponentModel.Win32Exception -> failwith (FSData.SR.requiredToolNotFound(exe))
|
||||
| _ -> reraise()
|
||||
|
||||
let shell (workingDirectory,exe,cmdline,formatError) =
|
||||
// printfn "execute: %s %s" exe cmdline
|
||||
let result = executeProcess(workingDirectory,exe,cmdline)
|
||||
if result.exitCode > 0 then
|
||||
//failwithf "The command\n%s %s\n failed.\n\nError:%s\n\nOutput: %s\n" exe cmdline result.stderr result.stdout
|
||||
match formatError with
|
||||
| None ->
|
||||
let merge lines = String.concat Environment.NewLine lines
|
||||
failwith ((merge result.stderr) + Environment.NewLine + (merge result.stdout))
|
||||
| Some f -> f result.stdout result.stderr
|
||||
else
|
||||
// printfn "<--command-->\n%s %s\n<-- success --><-- stdout -->\n%s<-- stderr -->\n%s\n" exe cmdline result.stdout result.stderr
|
||||
()
|
||||
|
||||
let cscExe () =
|
||||
let toolPath =
|
||||
//if System.Runtime.InteropServices.RuntimeEnvironment.GetSystemVersion().StartsWith("v4.0") then
|
||||
System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()
|
||||
//else
|
||||
// Path.Combine(System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory(), @"..\v3.5")
|
||||
Path.Combine(toolPath, "csc.exe")
|
||||
|
||||
|
||||
let dataSvcUtilExe () =
|
||||
let toolPath =
|
||||
//if System.Runtime.InteropServices.RuntimeEnvironment.GetSystemVersion().StartsWith("v4.0") then
|
||||
System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()
|
||||
//else
|
||||
// Path.Combine(System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory(), @"..\v4.0.30319")
|
||||
Path.Combine(toolPath, "DataSvcUtil.exe")
|
||||
|
||||
|
||||
let edmGenExe () =
|
||||
let toolPath = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()
|
||||
Path.Combine(toolPath, "edmgen.exe")
|
||||
|
||||
|
||||
|
||||
|
||||
let sdkPath () =
|
||||
|
||||
let tryResult (key: Microsoft.Win32.RegistryKey) =
|
||||
match key with
|
||||
| null -> None
|
||||
| _ ->
|
||||
let installFolder = key.GetValue("InstallationFolder") :?> string
|
||||
if Directory.Exists installFolder then
|
||||
Some installFolder
|
||||
else
|
||||
None
|
||||
// Annoyingly, the F# 2.0 decoding of 'use key = ...' on a registry key doesn't use an null check on the
|
||||
// key before calling Dispose. THis is because the key type doesn't use the IDisposable pattern.
|
||||
let useKey keyName f =
|
||||
// Look for WinSDK reg keys under the 32bit view of the registry.
|
||||
let reg32view = Microsoft.Win32.RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, Microsoft.Win32.RegistryView.Registry32)
|
||||
let key = reg32view.OpenSubKey keyName
|
||||
try f key
|
||||
finally
|
||||
match key with
|
||||
| null -> ()
|
||||
| _ -> key.Dispose()
|
||||
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
|
||||
|
||||
let SDK_REGPATHS = [ @"Software\Microsoft\Microsoft SDKs\NETFXSDK\4.6\WinSDK-NetFx40Tools"
|
||||
@"Software\Microsoft\Microsoft SDKs\Windows\v8.1A\WinSDK-NetFx40Tools"
|
||||
@"Software\Microsoft\Microsoft SDKs\Windows\v8.0A\WinSDK-NetFx40Tools"
|
||||
@"Software\Microsoft\Microsoft SDKs\Windows\v7.1\WinSDK-NetFx40Tools"
|
||||
@"Software\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDK-NetFx40Tools" ]
|
||||
|
||||
SDK_REGPATHS
|
||||
|> Seq.tryPick (fun p -> useKey p tryResult)
|
||||
|> function
|
||||
| Some p -> p
|
||||
| _ -> raise <| System.NotSupportedException(FSData.SR.unsupportedFramework())
|
||||
|
||||
let sdkUtil name = Path.Combine(sdkPath(), name)
|
||||
|
||||
let svcUtilExe () = sdkUtil "svcutil.exe"
|
||||
let xsdExe () = sdkUtil "xsd.exe"
|
||||
|
||||
type FileResource =
|
||||
abstract member Path : string
|
||||
inherit IDisposable
|
||||
|
||||
let ExistingFile(fileName : string) =
|
||||
{ new FileResource with
|
||||
member this.Path = fileName
|
||||
interface IDisposable with
|
||||
member this.Dispose() = () }
|
||||
|
||||
let TemporaryFile(extension : string) =
|
||||
let filename =
|
||||
let fs = Path.GetTempFileName()
|
||||
let fs' = Path.ChangeExtension(fs, extension)
|
||||
if fs <> fs' then
|
||||
File.Delete fs
|
||||
fs'
|
||||
|
||||
{ new FileResource with
|
||||
member this.Path = filename
|
||||
interface IDisposable with
|
||||
member this.Dispose() = File.Delete(filename) }
|
||||
|
||||
type DirectoryResource =
|
||||
abstract member Path : string
|
||||
inherit IDisposable
|
||||
|
||||
let TemporaryDirectory() =
|
||||
let dirName =
|
||||
let fs = Path.GetTempFileName()
|
||||
File.Delete fs
|
||||
Directory.CreateDirectory fs |> ignore
|
||||
fs
|
||||
|
||||
{ new DirectoryResource with
|
||||
member this.Path = dirName
|
||||
interface IDisposable with
|
||||
member this.Dispose() =
|
||||
for f in Directory.EnumerateFiles dirName do File.Delete f
|
||||
Directory.Delete dirName }
|
||||
|
||||
let ExistingDirectory(dirName : string) =
|
||||
{ new DirectoryResource with
|
||||
member this.Path = dirName
|
||||
interface IDisposable with
|
||||
member this.Dispose() = () }
|
||||
|
||||
type MemoizationTable<'T,'U when 'T : equality>(f) =
|
||||
let createdDB = new Dictionary<'T,'U>()
|
||||
member x.Contents = (createdDB :> IDictionary<_,_>)
|
||||
member x.Apply typeName =
|
||||
let found,result = createdDB.TryGetValue typeName
|
||||
if found then
|
||||
result
|
||||
else
|
||||
let ty = f typeName
|
||||
createdDB.[typeName] <- ty
|
||||
ty
|
||||
|
||||
open System.Threading
|
||||
|
||||
let WithExclusiveAccessToFile (fileName : string) f =
|
||||
// file name is not specified - run function directly
|
||||
if String.IsNullOrWhiteSpace fileName then f()
|
||||
else
|
||||
// convert filename to the uniform representation: full path + no backslashes + upper case
|
||||
|
||||
// MSDN: In Silverlight for Windows Phone, private object namespaces are not supported.
|
||||
// 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.
|
||||
// In Silverlight for Windows Phone you can use a backslash (\) in the name parameter.
|
||||
let fileName = Path.GetFullPath(fileName)
|
||||
let fileName = fileName.Replace('\\', '_')
|
||||
let fileName = fileName.ToUpper()
|
||||
|
||||
// MSDN: On a server that is running Terminal Services, a named system mutex can have two levels of visibility.
|
||||
// If its name begins with the prefix "Global\", the mutex is visible in all terminal server sessions.
|
||||
// Since we use mutex to protect access to file - use Global prefix to cover all terminal sessions
|
||||
let fileName = @"Global\" + fileName
|
||||
use mutex =
|
||||
let mutable createdNew = false
|
||||
let mutex = new Mutex(initiallyOwned = true, name = fileName, createdNew = &createdNew)
|
||||
// createdNew = true - we created and immediately acquired mutex - can continue
|
||||
// createdNew = false - mutex already exists and we do not own it - must wait until it is released
|
||||
if createdNew then mutex
|
||||
else
|
||||
try
|
||||
mutex.WaitOne() |> ignore
|
||||
mutex
|
||||
with
|
||||
| :? AbandonedMutexException ->
|
||||
// if thread that owns mutex was terminated abnormally - then WaitOne will raise AbandonedMutexException
|
||||
// MSDN: The next thread to request ownership of the mutex can handle this exception and proceed,
|
||||
// provided that the integrity of the data structures can be verified.
|
||||
// Current thread still owns mutex so we can return it
|
||||
mutex
|
||||
| _ ->
|
||||
mutex.Dispose()
|
||||
reraise()
|
||||
try f()
|
||||
finally mutex.ReleaseMutex()
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
namespace Microsoft.FSharp.Data.TypeProviders.Utility
|
||||
module internal Util =
|
||||
open System
|
||||
open System.Reflection
|
||||
open System.Collections.Generic
|
||||
|
||||
type ProcessResult = { exitCode : int; stdout : string[]; stderr : string[] }
|
||||
val executeProcess : workingDirectory: string * exe:string * cmdline:string -> ProcessResult
|
||||
/// Throws on failure
|
||||
val shell : workingDirectory: string * exe:string * cmdline:string * formatError:(string[] -> string[] -> unit) option -> unit
|
||||
|
||||
val cscExe : unit -> string
|
||||
val dataSvcUtilExe : unit -> string
|
||||
val edmGenExe : unit -> string
|
||||
val svcUtilExe : unit -> string
|
||||
|
||||
val sdkUtil : string -> string
|
||||
|
||||
type FileResource =
|
||||
abstract member Path : string
|
||||
inherit IDisposable
|
||||
|
||||
val TemporaryFile : extension:string -> FileResource
|
||||
val ExistingFile : fileName:string -> FileResource
|
||||
|
||||
type DirectoryResource =
|
||||
abstract member Path : string
|
||||
inherit IDisposable
|
||||
|
||||
val TemporaryDirectory : unit -> DirectoryResource
|
||||
val ExistingDirectory : dirName:string -> DirectoryResource
|
||||
|
||||
type MemoizationTable<'T,'U when 'T : equality> =
|
||||
new : ('T -> 'U) -> MemoizationTable<'T,'U>
|
||||
member Apply : 'T -> 'U
|
||||
member Contents : IDictionary<'T, 'U>
|
||||
|
||||
val WithExclusiveAccessToFile : string -> (unit -> 'T)-> 'T
|
||||
|
|
@ -45,6 +45,7 @@ rem Disable strong-name validation for F# binaries built from open source that a
|
|||
%SN32% -Vr FSharp.Build,b03f5f7f11d50a3a
|
||||
%SN32% -Vr FSharp.Compiler.Interactive.Settings,b03f5f7f11d50a3a
|
||||
%SN32% -Vr FSharp.Compiler.Hosted,b03f5f7f11d50a3a
|
||||
%SN32% -Vr FSharp.Data.TypeProviders,b03f5f7f11d50a3a
|
||||
|
||||
%SN32% -Vr fsc,b03f5f7f11d50a3a
|
||||
%SN32% -Vr fsi,b03f5f7f11d50a3a
|
||||
|
@ -69,6 +70,7 @@ if /i "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
|
|||
%SN64% -Vr FSharp.Build,b03f5f7f11d50a3a
|
||||
%SN64% -Vr FSharp.Compiler.Interactive.Settings,b03f5f7f11d50a3a
|
||||
%SN64% -Vr FSharp.Compiler.Hosted,b03f5f7f11d50a3a
|
||||
%SN64% -Vr FSharp.Data.TypeProviders,b03f5f7f11d50a3a
|
||||
|
||||
%SN64% -Vr fsc,b03f5f7f11d50a3a
|
||||
%SN64% -Vr fsi,b03f5f7f11d50a3a
|
||||
|
|
|
@ -236,6 +236,7 @@ if exist "%FSCBinPath%\..\..\portable47\bin\FSharp.Core.dll" set FSCOREDLLPORTAB
|
|||
if exist "%FSCBinPath%\..\..\portable7\bin\FSharp.Core.dll" set FSCOREDLLNETCOREPATH=%FSCBinPath%\..\..\portable7\bin
|
||||
IF exist "%FSCBinPath%\..\..\portable78\bin\FSharp.Core.dll" set FSCOREDLLNETCORE78PATH=%FSCBinPath%\..\..\portable78\bin
|
||||
IF exist "%FSCBinPath%\..\..\portable259\bin\FSharp.Core.dll" set FSCOREDLLNETCORE259PATH=%FSCBinPath%\..\..\portable259\bin
|
||||
if exist "%FSCBinPath%\FSharp.Data.TypeProviders.dll" set FSDATATPPATH=%FSCBinPath%
|
||||
|
||||
set FSCOREDLLPATH=%FSCOREDLLPATH%\FSharp.Core.dll
|
||||
set FSCOREDLL20PATH=%FSCOREDLL20PATH%\FSharp.Core.dll
|
||||
|
@ -243,6 +244,7 @@ set FSCOREDLLPORTABLEPATH=%FSCOREDLLPORTABLEPATH%\FSharp.Core.dll
|
|||
set FSCOREDLLNETCOREPATH=%FSCOREDLLNETCOREPATH%\FSharp.Core.dll
|
||||
set FSCOREDLLNETCORE78PATH=%FSCOREDLLNETCORE78PATH%\FSharp.Core.dll
|
||||
set FSCOREDLLNETCORE259PATH=%FSCOREDLLNETCORE259PATH%\FSharp.Core.dll
|
||||
set FSDATATPPATH=%FSDATATPPATH%\FSharp.Data.TypeProviders.dll
|
||||
set FSCOREDLLVPREVPATH=%FSCOREDLLVPREVPATH%\FSharp.Core.dll
|
||||
|
||||
for /d %%i in (%WINDIR%\Microsoft.NET\Framework\v4.0.?????) do set CORDIR=%%i
|
||||
|
|
|
@ -277,6 +277,7 @@ IF EXIST "%FSCBinPath%\..\..\portable47\bin\FSharp.Core.dll" set FSCOREDLLPORTAB
|
|||
IF EXIST "%FSCBinPath%\..\..\portable7\bin\FSharp.Core.dll" set FSCOREDLLNETCOREPATH=%FSCBinPath%\..\..\portable7\bin
|
||||
IF EXIST "%FSCBinPath%\..\..\portable78\bin\FSharp.Core.dll" set FSCOREDLLNETCORE78PATH=%FSCBinPath%\..\..\portable78\bin
|
||||
IF EXIST "%FSCBinPath%\..\..\portable259\bin\FSharp.Core.dll" set FSCOREDLLNETCORE259PATH=%FSCBinPath%\..\..\portable259\bin
|
||||
IF EXIST "%FSCBinPath%\FSharp.Data.TypeProviders.dll" set FSDATATPPATH=%FSCBinPath%
|
||||
|
||||
set FSCOREDLLPATH=%FSCOREDLLPATH%\FSharp.Core.dll
|
||||
set FSCOREDLL20PATH=%FSCOREDLL20PATH%\FSharp.Core.dll
|
||||
|
|
|
@ -90,6 +90,11 @@ let private GetFSLibPaths env osArch fscBinPath =
|
|||
| Some d when fileExists (d/"FSharp.Core.dll") -> FSCOREDLLNETCORE259PATH <- d
|
||||
| Some _ | None -> ()
|
||||
|
||||
// IF EXIST "%FSCBinPath%\FSharp.Data.TypeProviders.dll" set FSDATATPPATH=%FSCBinPath%
|
||||
match fscBinPath with
|
||||
| Some d when fileExists (d/"FSharp.Data.TypeProviders.dll") -> FSDATATPPATH <- d
|
||||
| Some _ | None -> ()
|
||||
|
||||
// set FSCOREDLLPATH=%FSCOREDLLPATH%\FSharp.Core.dll
|
||||
FSCOREDLLPATH <- FSCOREDLLPATH/"FSharp.Core.dll"
|
||||
// set FSCOREDLL20PATH=%FSCOREDLL20PATH%\FSharp.Core.dll
|
||||
|
@ -102,6 +107,8 @@ let private GetFSLibPaths env osArch fscBinPath =
|
|||
FSCOREDLLNETCORE78PATH <- FSCOREDLLNETCORE78PATH/"FSharp.Core.dll"
|
||||
// set FSCOREDLLNETCORE259PATH=%FSCOREDLLNETCORE259PATH%\FSharp.Core.dll
|
||||
FSCOREDLLNETCORE259PATH <- FSCOREDLLNETCORE259PATH/"FSharp.Core.dll"
|
||||
// set FSDATATPPATH=%FSDATATPPATH%\FSharp.Data.TypeProviders.dll
|
||||
FSDATATPPATH <- FSDATATPPATH/"FSharp.Data.TypeProviders.dll"
|
||||
// set FSCOREDLLVPREVPATH=%FSCOREDLLVPREVPATH%\FSharp.Core.dll
|
||||
FSCOREDLLVPREVPATH <- FSCOREDLLVPREVPATH/"FSharp.Core.dll"
|
||||
|
||||
|
|
|
@ -91,6 +91,7 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="typeProviders\build-typeprovider-test.fs" />
|
||||
<Compile Include="typeProviders\builtin\copyFSharpDataTypeProviderDLL.fs" />
|
||||
<Compile Include="typeProviders\tests_typeProviders.fs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
@if "%_echo%"=="" echo off
|
||||
|
||||
setlocal
|
||||
|
||||
REM Configure the sample, i.e. where to find the F# compiler and C# compiler.
|
||||
if EXIST build.ok DEL /f /q build.ok
|
||||
|
||||
call %~d0%~p0..\..\..\config.bat
|
||||
|
||||
if NOT "%FSC:NOTAVAIL=X%" == "%FSC%" (
|
||||
ECHO Skipping test for FSI.EXE
|
||||
goto Skip
|
||||
)
|
||||
|
||||
|
||||
rem fsc.exe building
|
||||
|
||||
|
||||
"%FSC%" %fsc_flags% -o:test.exe -g test.fsx
|
||||
@if ERRORLEVEL 1 goto Error
|
||||
|
||||
"%PEVERIFY%" test.exe
|
||||
@if ERRORLEVEL 1 goto Error
|
||||
|
||||
"%FSC%" %fsc_flags% --optimize -o:test--optimize.exe -g test.fsx
|
||||
@if ERRORLEVEL 1 goto Error
|
||||
|
||||
"%PEVERIFY%" test--optimize.exe
|
||||
@if ERRORLEVEL 1 goto Error
|
||||
|
||||
REM ==
|
||||
REM == Disabled until Don checks in the missing files
|
||||
REM ==
|
||||
GOTO :SkipMultiPartTests
|
||||
"%FSC%" %fsc_flags% -a -o:testlib.dll -r:System.Data.Services.Client.dll -r:FSharp.Data.TypeProviders.dll -g test-part1.fs @if ERRORLEVEL 1 goto Error
|
||||
|
||||
"%PEVERIFY%" testlib.dll
|
||||
@if ERRORLEVEL 1 goto Error
|
||||
|
||||
"%FSC%" %fsc_flags% -r:testlib.dll -o:testapp.exe -r:System.Data.Services.Client.dll -g test-part2.fs
|
||||
@if ERRORLEVEL 1 goto Error
|
||||
|
||||
"%PEVERIFY%" testapp.exe
|
||||
@if ERRORLEVEL 1 goto Error
|
||||
|
||||
"%FSC%" %fsc_flags% -o:testtwoparts.exe -r:System.Data.Services.Client.dll -r:FSharp.Data.TypeProviders.dll -g test-part1.fs test-part2.fs
|
||||
@if ERRORLEVEL 1 goto Error
|
||||
|
||||
"%PEVERIFY%" testtwoparts.exe
|
||||
@if ERRORLEVEL 1 goto Error
|
||||
|
||||
:SkipMultiPartTests
|
||||
|
||||
:Ok
|
||||
echo Built fsharp %~f0 ok.
|
||||
echo. > build.ok
|
||||
endlocal
|
||||
exit /b 0
|
||||
|
||||
:Skip
|
||||
echo Skipped %~f0
|
||||
endlocal
|
||||
exit /b 0
|
||||
|
||||
|
||||
:Error
|
||||
endlocal
|
||||
exit /b %ERRORLEVEL%
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
@if "%_echo%"=="" echo off
|
||||
|
||||
setlocal
|
||||
dir build.ok > NUL ) || (
|
||||
@echo 'build.ok' not found.
|
||||
goto :ERROR
|
||||
)
|
||||
|
||||
call %~d0%~p0..\..\..\config.bat
|
||||
|
||||
REM fsi.exe testing
|
||||
|
||||
|
||||
echo TestC
|
||||
|
||||
if exist test.ok (del /f /q test.ok)
|
||||
"%FSI%" %fsi_flags% test.fsx
|
||||
if NOT EXIST test.ok goto SetError
|
||||
|
||||
REM fsc.exe testing
|
||||
|
||||
echo TestD
|
||||
if exist test.ok (del /f /q test.ok)
|
||||
%CLIX% test.exe
|
||||
@if ERRORLEVEL 1 goto Error
|
||||
if NOT EXIST test.ok goto SetError
|
||||
|
||||
if exist test.ok (del /f /q test.ok)
|
||||
%CLIX% test--optimize.exe
|
||||
@if ERRORLEVEL 1 goto Error
|
||||
if NOT EXIST test.ok goto SetError
|
||||
|
||||
REM ==
|
||||
REM == Disabled until Don checks in the missing files
|
||||
REM ==
|
||||
GOTO :SkipMultiPartTests
|
||||
|
||||
if exist test.ok (del /f /q test.ok)
|
||||
%CLIX% testapp.exe
|
||||
@if ERRORLEVEL 1 goto Error
|
||||
if NOT EXIST test.ok goto SetError
|
||||
|
||||
if exist test.ok (del /f /q test.ok)
|
||||
%CLIX% testtwoparts.exe
|
||||
@if ERRORLEVEL 1 goto Error
|
||||
if NOT EXIST test.ok goto SetError
|
||||
|
||||
if exist test.ok (del /f /q test.ok)
|
||||
%CLIX% testapp.exe
|
||||
@if ERRORLEVEL 1 goto Error
|
||||
if NOT EXIST test.ok goto SetError
|
||||
|
||||
if exist test.ok (del /f /q test.ok)
|
||||
%CLIX% testtwoparts.exe
|
||||
@if ERRORLEVEL 1 goto Error
|
||||
if NOT EXIST test.ok goto SetError
|
||||
:SkipMultiPartTests
|
||||
|
||||
:Ok
|
||||
echo Ran fsharp %~f0 ok.
|
||||
endlocal
|
||||
exit /b 0
|
||||
|
||||
:Skip
|
||||
echo Skipped %~f0
|
||||
endlocal
|
||||
exit /b 0
|
||||
|
||||
|
||||
:Error
|
||||
echo Test Script Failed (perhaps test did not emit test.ok signal file?)
|
||||
endlocal
|
||||
exit /b %ERRORLEVEL%
|
||||
|
||||
|
||||
:SETERROR
|
||||
set NonexistentErrorLevel 2> nul
|
||||
goto Error
|
|
@ -0,0 +1,145 @@
|
|||
// #Quotations
|
||||
#nowarn "57"
|
||||
#r "System.Data.Services.Client.dll"
|
||||
#r "FSharp.Data.TypeProviders.dll"
|
||||
|
||||
open Microsoft.FSharp.Linq
|
||||
open Microsoft.FSharp.Data.TypeProviders
|
||||
open System
|
||||
open Microsoft.FSharp.Quotations
|
||||
open Microsoft.FSharp.Quotations.ExprShape
|
||||
open Microsoft.FSharp.Linq.RuntimeHelpers
|
||||
|
||||
[<AutoOpen>]
|
||||
module Infrastructure =
|
||||
let mutable failures = []
|
||||
let reportFailure s =
|
||||
stderr.WriteLine " NO"; failures <- s :: failures
|
||||
|
||||
let argv = System.Environment.GetCommandLineArgs()
|
||||
let SetCulture() =
|
||||
if argv.Length > 2 && argv.[1] = "--culture" then
|
||||
let cultureString = argv.[2]
|
||||
let culture = new System.Globalization.CultureInfo(cultureString)
|
||||
stdout.WriteLine ("Running under culture "+culture.ToString()+"...");
|
||||
System.Threading.Thread.CurrentThread.CurrentCulture <- culture
|
||||
|
||||
do SetCulture()
|
||||
|
||||
let check s v1 v2 =
|
||||
if v1 = v2 then
|
||||
printfn "test %s...passed " s
|
||||
else
|
||||
failures <- failures @ [(s, box v1, box v2)]
|
||||
printfn "test %s...failed, expected \n\t%A\ngot\n\t%A" s v2 v1
|
||||
|
||||
let test s b = check s b true
|
||||
let qmap f (x:System.Linq.IQueryable<_>) = x |> Seq.map f |> System.Linq.Queryable.AsQueryable
|
||||
|
||||
let checkCommuteSeq s (q1: System.Linq.IQueryable<'T>) q2 =
|
||||
check s (q1 |> Seq.toList) (q2 |> Seq.toList)
|
||||
|
||||
let checkCommuteVal s q1 q2 =
|
||||
check s q1 q2
|
||||
|
||||
|
||||
type Northwest = ODataService< "http://services.odata.org/V2/Northwind/Northwind.svc/",LocalSchemaFile="schema1.csdl",ForceUpdate=false >
|
||||
|
||||
module Test = begin end
|
||||
|
||||
module DuplicateTypes =
|
||||
|
||||
type Northwest = ODataService< "http://services.odata.org/V2/Northwind/Northwind.svc/",LocalSchemaFile="schema2.csdl",ForceUpdate=false >
|
||||
|
||||
|
||||
|
||||
type Northwest2 = ODataService< "http://services.odata.org/V2/Northwind/Northwind.svc/",LocalSchemaFile="schema3.csdl",ForceUpdate=false >
|
||||
|
||||
|
||||
open System
|
||||
open Microsoft.FSharp.Quotations
|
||||
open Microsoft.FSharp.Quotations.ExprShape
|
||||
open Microsoft.FSharp.Linq
|
||||
open Microsoft.FSharp.Linq.RuntimeHelpers
|
||||
|
||||
module Queryable =
|
||||
|
||||
let db = Northwest.GetDataContext()
|
||||
let urlCapture = new System.Text.StringBuilder()
|
||||
db.DataContext.SendingRequest.Add (fun x -> printfn "yurl = %A" x.Request.RequestUri; urlCapture.Append x.Request.RequestUri |> ignore)
|
||||
|
||||
let checkODataUrlTextForValue s (q1: unit -> 'T) (text:string) =
|
||||
urlCapture.Clear() |> ignore
|
||||
q1() |> ignore
|
||||
let url = urlCapture.ToString()
|
||||
check s url text
|
||||
|
||||
|
||||
|
||||
let allCustomersQuery =
|
||||
checkODataUrlTextForValue "vwe4yuwe09uu"
|
||||
(fun () -> query { for c in db.Customers do select c } |> Seq.length)
|
||||
"http://services.odata.org/V2/Northwind/Northwind.svc/Customers()"
|
||||
|
||||
|
||||
let allEmployeesQuery =
|
||||
checkODataUrlTextForValue "vwe4yuwe09uu"
|
||||
(fun () -> query { for c in db.Employees do select c } |> Seq.length)
|
||||
"http://services.odata.org/V2/Northwind/Northwind.svc/Employees()"
|
||||
|
||||
let allProductsQuery =
|
||||
checkODataUrlTextForValue "vwe4yuwe09uu"
|
||||
(fun () -> query { for c in db.Products do select c } |> Seq.length)
|
||||
"http://services.odata.org/V2/Northwind/Northwind.svc/Products()"
|
||||
|
||||
|
||||
let allOrdersQuery =
|
||||
checkODataUrlTextForValue "vwe4yuwe09uu"
|
||||
(fun () -> query { for c in db.Orders do select c } |> Seq.length)
|
||||
"http://services.odata.org/V2/Northwind/Northwind.svc/Orders()"
|
||||
|
||||
|
||||
let firstFiveOrders =
|
||||
checkODataUrlTextForValue "vwe4yuwe09uu"
|
||||
(fun () -> query { for c in db.Orders do take 5; select c } |> Seq.length)
|
||||
"http://services.odata.org/V2/Northwind/Northwind.svc/Orders()?$top=5"
|
||||
|
||||
|
||||
|
||||
let ordersSortedByShipDateLatestFirst =
|
||||
checkODataUrlTextForValue "vwe4yuwe09uu"
|
||||
(fun () -> query { for o in db.Orders do sortByNullableDescending o.ShippedDate; select (o.OrderID, o.ShippedDate) } |> Seq.length)
|
||||
"http://services.odata.org/V2/Northwind/Northwind.svc/Orders()?$orderby=ShippedDate desc&$select=OrderID,ShippedDate"
|
||||
|
||||
|
||||
let ordersSortedByShipDateEarliestFirst =
|
||||
checkODataUrlTextForValue "vwe4yuwe09uu"
|
||||
(fun () -> query { for o in db.Orders do sortByNullable o.ShippedDate; select (o.OrderID, o.ShippedDate) } |> Seq.length)
|
||||
"http://services.odata.org/V2/Northwind/Northwind.svc/Orders()?$orderby=ShippedDate&$select=OrderID,ShippedDate"
|
||||
|
||||
|
||||
let ordersSortedByCustomerIDAndShipDateLatestFirst=
|
||||
checkODataUrlTextForValue "vwe4yuwe09uu"
|
||||
(fun () -> query { for o in db.Orders do sortBy o.CustomerID; thenByNullableDescending o.ShippedDate; select (o.CustomerID, o.OrderID, o.ShippedDate) } |> Seq.length)
|
||||
"http://services.odata.org/V2/Northwind/Northwind.svc/Orders()?$orderby=CustomerID,ShippedDate desc&$select=CustomerID,OrderID,ShippedDate"
|
||||
|
||||
|
||||
|
||||
|
||||
let ordersSortedByCustomerIDAndShipDateEarliestFirst=
|
||||
checkODataUrlTextForValue "vwe4yuwe09uu"
|
||||
(fun () -> query { for o in db.Orders do sortBy o.CustomerID; thenByNullable o.ShippedDate; select (o.CustomerID, o.OrderID, o.ShippedDate) } |> Seq.length)
|
||||
"http://services.odata.org/V2/Northwind/Northwind.svc/Orders()?$orderby=CustomerID,ShippedDate&$select=CustomerID,OrderID,ShippedDate"
|
||||
|
||||
#if COMPILED
|
||||
[<System.STAThread>]
|
||||
do()
|
||||
#endif
|
||||
|
||||
let _ =
|
||||
if not failures.IsEmpty then (printfn "Test Failed, failures = %A" failures; exit 1)
|
||||
else (stdout.WriteLine "Test Passed";
|
||||
System.IO.File.WriteAllText("test.ok","ok");
|
||||
exit 0)
|
||||
|
||||
|
|
@ -1929,6 +1929,78 @@ module QueriesOverIQueryable =
|
|||
|
||||
|
||||
|
||||
module QueriesOverOData =
|
||||
|
||||
let build cfg dir = attempt {
|
||||
|
||||
let exec p = Command.exec dir cfg.EnvironmentVariables { Output = Inherit; Input = None; } p >> checkResult
|
||||
let fsc = Printf.ksprintf (Commands.fsc exec cfg.FSC)
|
||||
let peverify = Commands.peverify exec cfg.PEVERIFY "/nologo"
|
||||
|
||||
// "%FSC%" %fsc_flags% -o:test.exe -g test.fsx
|
||||
do! fsc "%s -o:test.exe -g" cfg.fsc_flags ["test.fsx"]
|
||||
|
||||
// "%PEVERIFY%" test.exe
|
||||
do! peverify "test.exe"
|
||||
|
||||
// "%FSC%" %fsc_flags% --optimize -o:test--optimize.exe -g test.fsx
|
||||
do! fsc "%s --optimize -o:test--optimize.exe -g" cfg.fsc_flags ["test.fsx"]
|
||||
|
||||
// "%PEVERIFY%" test--optimize.exe
|
||||
do! peverify "test--optimize.exe"
|
||||
|
||||
}
|
||||
|
||||
let run cfg dir = attempt {
|
||||
|
||||
let exec p = Command.exec dir cfg.EnvironmentVariables { Output = Inherit; Input = None; } p >> checkResult
|
||||
let fsi = Printf.ksprintf (Commands.fsi exec cfg.FSI)
|
||||
let fileguard = (Commands.getfullpath dir) >> FileGuard.create
|
||||
|
||||
// REM fsi.exe testing
|
||||
// echo TestC
|
||||
log "TestC"
|
||||
|
||||
// if exist test.ok (del /f /q test.ok)
|
||||
use testOkFile = fileguard "test.ok"
|
||||
// "%FSI%" %fsi_flags% test.fsx
|
||||
do! fsi "%s" cfg.fsi_flags ["test.fsx"]
|
||||
// if NOT EXIST test.ok goto SetError
|
||||
do! testOkFile |> NUnitConf.checkGuardExists
|
||||
|
||||
// REM fsc.exe testing
|
||||
// echo TestD
|
||||
log "TestD"
|
||||
|
||||
// if exist test.ok (del /f /q test.ok)
|
||||
use testOkFile2 = fileguard "test.ok"
|
||||
// %CLIX% test.exe
|
||||
do! exec ("."/"test.exe") ""
|
||||
// if NOT EXIST test.ok goto SetError
|
||||
do! testOkFile2 |> NUnitConf.checkGuardExists
|
||||
|
||||
|
||||
// if exist test.ok (del /f /q test.ok)
|
||||
use testOkFile3 = fileguard "test.ok"
|
||||
// %CLIX% test--optimize.exe
|
||||
do! exec ("."/"test--optimize.exe") ""
|
||||
// if NOT EXIST test.ok goto SetError
|
||||
do! testOkFile3 |> NUnitConf.checkGuardExists
|
||||
|
||||
}
|
||||
|
||||
[<Test; FSharpSuiteTest("core/queriesOverOData")>]
|
||||
let queriesOverOData () = check (attempt {
|
||||
let { Directory = dir; Config = cfg } = testContext ()
|
||||
|
||||
do! build cfg dir
|
||||
|
||||
do! run cfg dir
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
module QuotesDebugInfo =
|
||||
|
||||
let build cfg dir = attempt {
|
||||
|
|
|
@ -33,4 +33,6 @@ wedgeAssembly/providedJ.dll
|
|||
wedgeAssembly/providedK.dll
|
||||
wedgeAssembly/provider.dll
|
||||
|
||||
builtin/SqlDataConnection/DataDirectory
|
||||
builtin/SqlDataConnection/ExampleResolutionFolder
|
||||
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
FSharp.Data.TypeProviders.dll
|
||||
|
||||
EdmxFile/SampleModel01.edmx
|
||||
|
||||
EdmxFile/*.exe.config
|
||||
EdmxFile/*.dll.config
|
||||
|
||||
ODataService/*.exe.config
|
||||
ODataService/*.dll.config
|
||||
ODataService/svc.csdl
|
||||
ODataService/svc2.csdl
|
||||
|
||||
SqlDataConnection/*.exe.config
|
||||
SqlDataConnection/*.dll.config
|
||||
SqlDataConnection/app.config
|
||||
SqlDataConnection/NORTHWND.mdf
|
||||
SqlDataConnection/NORTHWND_log.ldf
|
||||
SqlDataConnection/nwind2.dbml
|
||||
SqlDataConnection/nwind3.dbml
|
||||
SqlDataConnection/test.config
|
||||
|
||||
SqlEntityConnection/*.exe.config
|
||||
SqlEntityConnection/*.dll.config
|
||||
|
||||
WsdlService/*.exe.config
|
||||
WsdlService/*.dll.config
|
||||
WsdlService/sfile.wsdlschema
|
||||
WsdlService/sfile2.wsdlschema
|
|
@ -0,0 +1,87 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<edmx:Edmx Version="2.0" xmlns:edmx="http://schemas.microsoft.com/ado/2008/10/edmx">
|
||||
<!-- EF Runtime content -->
|
||||
<edmx:Runtime>
|
||||
<!-- SSDL content -->
|
||||
<edmx:StorageModels>
|
||||
<Schema xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl" Namespace="SampleModel01.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2005">
|
||||
<EntityContainer Name="SampleModel01TargetContainer" >
|
||||
</EntityContainer>
|
||||
</Schema>
|
||||
</edmx:StorageModels>
|
||||
<!-- CSDL content -->
|
||||
<edmx:ConceptualModels>
|
||||
<Schema xmlns="http://schemas.microsoft.com/ado/2008/09/edm" xmlns:cg="http://schemas.microsoft.com/ado/2006/04/codegeneration" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" Namespace="SampleModel01" Alias="Self" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation">
|
||||
<EntityContainer Name="SampleModel01Container" annotation:LazyLoadingEnabled="true">
|
||||
<EntitySet Name="Orders" EntityType="SampleModel01.Orders" />
|
||||
<EntitySet Name="Persons" EntityType="SampleModel01.Persons" />
|
||||
<AssociationSet Name="CustomersOrders" Association="SampleModel01.CustomersOrders">
|
||||
<End Role="Customers" EntitySet="Persons" />
|
||||
<End Role="Orders" EntitySet="Orders" />
|
||||
</AssociationSet>
|
||||
</EntityContainer>
|
||||
<EntityType Name="Customers" BaseType="SampleModel01.Persons">
|
||||
<Property Type="Int32" Name="Id" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
|
||||
<NavigationProperty Name="Orders" Relationship="SampleModel01.CustomersOrders" FromRole="Customers" ToRole="Orders" />
|
||||
</EntityType>
|
||||
<EntityType Name="Orders">
|
||||
<Key>
|
||||
<PropertyRef Name="Id" />
|
||||
</Key>
|
||||
<Property Type="Int32" Name="Id" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
|
||||
<Property Type="Int32" Name="CustomersId" Nullable="false" />
|
||||
<NavigationProperty Name="Customer" Relationship="SampleModel01.CustomersOrders" FromRole="Orders" ToRole="Customers" />
|
||||
</EntityType>
|
||||
<EntityType Name="Persons">
|
||||
<Key>
|
||||
<PropertyRef Name="ID" />
|
||||
</Key>
|
||||
<Property Type="Int32" Name="ID" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
|
||||
<Property Type="String" Name="FirstName" Nullable="false" />
|
||||
<Property Type="String" Name="LastName" Nullable="false" />
|
||||
</EntityType>
|
||||
<Association Name="CustomersOrders">
|
||||
<End Type="SampleModel01.Customers" Role="Customers" Multiplicity="1" />
|
||||
<End Type="SampleModel01.Orders" Role="Orders" Multiplicity="*" />
|
||||
</Association>
|
||||
</Schema>
|
||||
</edmx:ConceptualModels>
|
||||
<!-- C-S mapping content -->
|
||||
<edmx:Mappings>
|
||||
<Mapping xmlns="http://schemas.microsoft.com/ado/2008/09/mapping/cs" Space="C-S">
|
||||
<Alias Key="Model" Value="SampleModel01" />
|
||||
<Alias Key="Target" Value="SampleModel01.Store" />
|
||||
<EntityContainerMapping CdmEntityContainer="SampleModel01Container" StorageEntityContainer="SampleModel01TargetContainer">
|
||||
</EntityContainerMapping>
|
||||
</Mapping>
|
||||
</edmx:Mappings>
|
||||
</edmx:Runtime>
|
||||
<!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
|
||||
<edmx:Designer xmlns="http://schemas.microsoft.com/ado/2008/10/edmx">
|
||||
<edmx:Connection>
|
||||
<DesignerInfoPropertySet>
|
||||
<DesignerProperty Name="MetadataArtifactProcessing" Value="EmbedInOutputAssembly" />
|
||||
</DesignerInfoPropertySet>
|
||||
</edmx:Connection>
|
||||
<edmx:Options>
|
||||
<DesignerInfoPropertySet>
|
||||
<DesignerProperty Name="ValidateOnBuild" Value="true" />
|
||||
<DesignerProperty Name="EnablePluralization" Value="True" />
|
||||
</DesignerInfoPropertySet>
|
||||
</edmx:Options>
|
||||
<!-- Diagram content (shape and connector positions) -->
|
||||
<edmx:Diagrams>
|
||||
<Diagram Name="SampleModel01" >
|
||||
<EntityTypeShape EntityType="SampleModel01.Customers" Width="1.5" PointX="3.3072142933063273" PointY="8.50035328068787" />
|
||||
<InheritanceConnector EntityType="SampleModel01.Customers" />
|
||||
<EntityTypeShape EntityType="SampleModel01.Orders" Width="1.5" PointX="3.25" PointY="6.5" Height="1.4279589843749996" />
|
||||
<EntityTypeShape EntityType="SampleModel01.Persons" Width="1.5" PointX="8.4623833040065986" PointY="12.312999537360389" />
|
||||
<AssociationConnector Association="SampleModel01.CustomersOrders" >
|
||||
<ConnectorPoint PointX="2.25" PointY="5.9374994999999995" />
|
||||
<ConnectorPoint PointX="4" PointY="5.9374994999999995" />
|
||||
<ConnectorPoint PointX="4" PointY="6.5" />
|
||||
</AssociationConnector>
|
||||
</Diagram>
|
||||
</edmx:Diagrams>
|
||||
</edmx:Designer>
|
||||
</edmx:Edmx>
|
|
@ -0,0 +1,8 @@
|
|||
@if "%_echo%"=="" echo off
|
||||
|
||||
call %~d0%~p0..\copyFSharpDataTypeProviderDLL.cmd
|
||||
|
||||
call %~d0%~p0..\..\..\single-test-build.bat
|
||||
|
||||
exit /b %ERRORLEVEL%
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
@if "%_echo%"=="" echo off
|
||||
|
||||
call %~d0%~p0..\..\..\single-test-run.bat
|
||||
|
||||
exit /b %ERRORLEVEL%
|
||||
|
||||
|
|
@ -0,0 +1,143 @@
|
|||
// #Conformance #TypeProviders #EdmxFile
|
||||
#r "FSharp.Data.TypeProviders.dll"
|
||||
|
||||
open Microsoft.FSharp.Core.CompilerServices
|
||||
open System.IO
|
||||
|
||||
[<AutoOpen>]
|
||||
module Infrastructure =
|
||||
let failures = ref false
|
||||
let reportFailure () = stderr.WriteLine " NO"; failures := true
|
||||
let test s b = stderr.Write(s:string); if b then stderr.WriteLine " OK" else reportFailure()
|
||||
let check s v1 v2 = stderr.Write(s:string); if v1 = v2 then stderr.WriteLine " OK" else eprintf "... FAILURE: expected %A, got %A " v2 v1; reportFailure()
|
||||
|
||||
let argv = System.Environment.GetCommandLineArgs()
|
||||
let SetCulture() =
|
||||
if argv.Length > 2 && argv.[1] = "--culture" then begin
|
||||
let cultureString = argv.[2] in
|
||||
let culture = new System.Globalization.CultureInfo(cultureString) in
|
||||
stdout.WriteLine ("Running under culture "+culture.ToString()+"...");
|
||||
System.Threading.Thread.CurrentThread.CurrentCulture <- culture
|
||||
end
|
||||
|
||||
do SetCulture()
|
||||
|
||||
module CheckEdmxfileTypeProvider =
|
||||
|
||||
let checkHostedType (hostedType: System.Type) =
|
||||
test "ceklc09wlkm1a" (hostedType.Assembly <> typeof<Microsoft.FSharp.Data.TypeProviders.DesignTime.DataProviders>.Assembly)
|
||||
test "ceklc09wlkm1b" (hostedType.Assembly.FullName.StartsWith "tmp")
|
||||
|
||||
check "ceklc09wlkm2" hostedType.DeclaringType null
|
||||
check "ceklc09wlkm3" hostedType.DeclaringMethod null
|
||||
check "ceklc09wlkm4" hostedType.FullName "SampleModel01.EdmxFileApplied"
|
||||
check "ceklc09wlkm5" (hostedType.GetConstructors()) [| |]
|
||||
check "ceklc09wlkm6" (hostedType.GetCustomAttributesData().Count) 1
|
||||
check "ceklc09wlkm6" (hostedType.GetCustomAttributesData().[0].Constructor.DeclaringType.FullName) typeof<TypeProviderXmlDocAttribute>.FullName
|
||||
check "ceklc09wlkm7" (hostedType.GetEvents()) [| |]
|
||||
check "ceklc09wlkm8" (hostedType.GetFields()) [| |]
|
||||
check "ceklc09wlkm9" (hostedType.GetMethods()) [| |]
|
||||
check "ceklc09wlkm10" (hostedType.GetProperties()) [| |]
|
||||
check "ceklc09wlkm11" (hostedType.GetNestedTypes().Length) 1
|
||||
check "ceklc09wlkm12"
|
||||
(set [ for x in hostedType.GetNestedTypes() -> x.Name ])
|
||||
(set ["SampleModel01"])
|
||||
|
||||
let hostedServiceTypes = hostedType.GetNestedTypes().[0]
|
||||
check "ceklc09wlkm12b" (hostedServiceTypes.GetMethods()) [| |]
|
||||
check "ceklc09wlkm12c"
|
||||
(set [ for x in hostedServiceTypes.GetNestedTypes() -> x.Name ])
|
||||
(set ["Customers"; "Orders"; "Persons"; "SampleModel01Container"])
|
||||
|
||||
// Deep check on one type: Customers
|
||||
let customersType = (hostedServiceTypes.GetNestedTypes() |> Seq.find (fun t -> t.Name = "Customers"))
|
||||
check "ceklc09wlkm131" (set [ for x in customersType.GetProperties() -> x.Name ]) (set [| "Id"; "Orders"; "ID"; "FirstName"; "LastName"; "EntityState"; "EntityKey" |])
|
||||
check "ceklc09wlkm133a" (set [ for x in customersType.GetFields() -> x.Name ]) (set [| |])
|
||||
check "ceklc09wlkm133b" (set [ for x in customersType.GetFields(System.Reflection.BindingFlags.Static ||| System.Reflection.BindingFlags.Public ||| System.Reflection.BindingFlags.FlattenHierarchy) -> x.Name ])
|
||||
(set [ "EntityKeyPropertyName"] )
|
||||
check "ceklc09wlkm134" (set [ for x in customersType.GetMethods() -> x.Name ])
|
||||
(set ["CreateCustomers"; "get_Id"; "set_Id"; "get_Orders"; "set_Orders"; "get_ID"; "set_ID"; "get_FirstName"; "set_FirstName"; "get_LastName"; "set_LastName";
|
||||
"get_EntityState"; "get_EntityKey"; "set_EntityKey"; "add_PropertyChanged"; "remove_PropertyChanged"; "add_PropertyChanging"; "remove_PropertyChanging"; "ToString"; "Equals";
|
||||
"GetHashCode"; "GetType"] )
|
||||
check "ceklc09wlkm135" (set [ for x in customersType.GetMethods(System.Reflection.BindingFlags.Static ||| System.Reflection.BindingFlags.Public ||| System.Reflection.BindingFlags.FlattenHierarchy) -> x.Name ])
|
||||
(set [ "CreateCustomers"; "CreatePersons"; "Equals"; "ReferenceEquals" ] )
|
||||
check "ceklc09wlkm136" (customersType.GetNestedTypes()) [||]
|
||||
|
||||
// Not so deep check on another type: SampleModel01Container
|
||||
let SampleModel01ContainerType = (hostedServiceTypes.GetNestedTypes() |> Seq.find (fun t -> t.Name = "SampleModel01Container"))
|
||||
check "ceklc09wlkm141" (set [ for x in SampleModel01ContainerType.GetProperties() -> x.Name ]) (set [|"Orders"; "Persons"; "Connection"; "DefaultContainerName"; "MetadataWorkspace"; "ObjectStateManager"; "CommandTimeout"; "ContextOptions"|])
|
||||
check "ceklc09wlkm142" (SampleModel01ContainerType.GetFields()) [||]
|
||||
check "ceklc09wlkm144" (set [ for x in SampleModel01ContainerType.GetMethods() -> x.Name ])
|
||||
(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"|])
|
||||
check "ceklc09wlkm146" (SampleModel01ContainerType.GetNestedTypes()) [||]
|
||||
|
||||
|
||||
let instantiateTypeProviderAndCheckOneHostedType( edmxfile : string, typeFullPath ) =
|
||||
|
||||
let assemblyFile = typeof<Microsoft.FSharp.Data.TypeProviders.DesignTime.DataProviders>.Assembly.CodeBase.Replace("file:///","").Replace("/","\\")
|
||||
test "CheckFSharpDataTypeProvidersDLLExist" (File.Exists assemblyFile)
|
||||
|
||||
// If/when we care about the "target framework", this mock function will have to be fully implemented
|
||||
let systemRuntimeContainsType s =
|
||||
printfn "Call systemRuntimeContainsType(%s) returning dummy value 'true'" s
|
||||
true
|
||||
|
||||
let tpConfig = new TypeProviderConfig(systemRuntimeContainsType, ResolutionFolder=__SOURCE_DIRECTORY__, RuntimeAssembly=assemblyFile, ReferencedAssemblies=[| |], TemporaryFolder=Path.GetTempPath(), IsInvalidationSupported=false, IsHostedExecution=true)
|
||||
use typeProvider1 = (new Microsoft.FSharp.Data.TypeProviders.DesignTime.DataProviders( tpConfig ) :> ITypeProvider)
|
||||
|
||||
// Setup machinery to keep track of the "invalidate event" (see below)
|
||||
let invalidateEventCount = ref 0
|
||||
typeProvider1.Invalidate.Add(fun _ -> incr invalidateEventCount)
|
||||
|
||||
// Load a type provider instance for the type and restart
|
||||
let hostedNamespace1 = typeProvider1.GetNamespaces() |> Seq.find (fun t -> t.NamespaceName = "Microsoft.FSharp.Data.TypeProviders")
|
||||
|
||||
check "CheckAllTPsAreThere" (set [ for i in hostedNamespace1.GetTypes() -> i.Name ]) (set ["DbmlFile"; "EdmxFile"; "ODataService"; "SqlDataConnection";"SqlEntityConnection";"WsdlService"])
|
||||
|
||||
let hostedType1 = hostedNamespace1.ResolveTypeName("EdmxFile")
|
||||
let hostedType1StaticParameters = typeProvider1.GetStaticParameters(hostedType1)
|
||||
check "VerifyStaticParam"
|
||||
(set [ for i in hostedType1StaticParameters -> i.Name ])
|
||||
(set [ "File"; "ResolutionFolder" ])
|
||||
|
||||
let staticParameterValues =
|
||||
[| for x in hostedType1StaticParameters ->
|
||||
(match x.Name with
|
||||
| "File" -> box edmxfile
|
||||
| _ -> box x.RawDefaultValue) |]
|
||||
printfn "instantiating type... may take a while for code generation tool to run and csc.exe to run..."
|
||||
let hostedAppliedType1 = typeProvider1.ApplyStaticArguments(hostedType1, typeFullPath, staticParameterValues)
|
||||
|
||||
checkHostedType hostedAppliedType1
|
||||
|
||||
// Write replacement text into the file and check that the invalidation event is triggered....
|
||||
let file1NewContents = System.IO.File.ReadAllText(edmxfile).Replace("Customer", "Client") // Rename 'Customer' to 'Client'
|
||||
do File.WriteAllText(edmxfile, file1NewContents)
|
||||
|
||||
// Wait for invalidate event to fire....
|
||||
for i in 0 .. 30 do
|
||||
if !invalidateEventCount = 0 then
|
||||
System.Threading.Thread.Sleep 100
|
||||
|
||||
check "VerifyInvalidateEventFired" !invalidateEventCount 1
|
||||
|
||||
// Test with absolute path
|
||||
// Copy the .edmx used for tests to avoid trashing our original (we may overwrite it when testing the event)
|
||||
let edmxfile = Path.Combine(__SOURCE_DIRECTORY__, "SampleModel01.edmx")
|
||||
System.IO.File.Copy(Path.Combine(__SOURCE_DIRECTORY__, @"EdmxFiles\SampleModel01.edmx"), edmxfile, true)
|
||||
System.IO.File.SetAttributes(edmxfile, System.IO.FileAttributes.Normal)
|
||||
instantiateTypeProviderAndCheckOneHostedType(edmxfile, [| "EdmxFileApplied" |])
|
||||
|
||||
// Test with relative path
|
||||
// Copy the .edmx used for tests to avoid trashing our original (we may overwrite it when testing the event)
|
||||
System.IO.File.Copy(Path.Combine(__SOURCE_DIRECTORY__, @"EdmxFiles\SampleModel01.edmx"), edmxfile, true)
|
||||
System.IO.File.SetAttributes(edmxfile, System.IO.FileAttributes.Normal)
|
||||
instantiateTypeProviderAndCheckOneHostedType( System.IO.Path.GetFileName(edmxfile), [| "EdmxFileApplied" |])
|
||||
|
||||
let _ =
|
||||
if !failures then (stdout.WriteLine "Test Failed"; exit 1)
|
||||
|
||||
do (stdout.WriteLine "Test Passed";
|
||||
File.WriteAllText("test.ok","ok");
|
||||
exit 0)
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
@if "%_echo%"=="" echo off
|
||||
|
||||
call %~d0%~p0..\copyFSharpDataTypeProviderDLL.cmd
|
||||
|
||||
call %~d0%~p0..\..\..\single-test-build.bat
|
||||
|
||||
exit /b %ERRORLEVEL%
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
@if "%_echo%"=="" echo off
|
||||
|
||||
call %~d0%~p0..\..\..\single-test-run.bat
|
||||
|
||||
exit /b %ERRORLEVEL%
|
||||
|
||||
|
|
@ -0,0 +1,149 @@
|
|||
// #Conformance #TypeProviders #ODataService
|
||||
#r "FSharp.Data.TypeProviders.dll"
|
||||
|
||||
open Microsoft.FSharp.Core.CompilerServices
|
||||
open System.IO
|
||||
|
||||
[<AutoOpen>]
|
||||
module Infrastructure =
|
||||
let failures = ref false
|
||||
let reportFailure () = stderr.WriteLine " NO"; failures := true
|
||||
let test s b = stderr.Write(s:string); if b then stderr.WriteLine " OK" else reportFailure()
|
||||
let check s v1 v2 = stderr.Write(s:string); if v1 = v2 then stderr.WriteLine " OK" else eprintf "... FAILURE: expected %A, got %A " v2 v1; reportFailure()
|
||||
|
||||
let argv = System.Environment.GetCommandLineArgs()
|
||||
let SetCulture() =
|
||||
if argv.Length > 2 && argv.[1] = "--culture" then begin
|
||||
let cultureString = argv.[2] in
|
||||
let culture = new System.Globalization.CultureInfo(cultureString) in
|
||||
stdout.WriteLine ("Running under culture "+culture.ToString()+"...");
|
||||
System.Threading.Thread.CurrentThread.CurrentCulture <- culture
|
||||
end
|
||||
|
||||
do SetCulture()
|
||||
|
||||
module CheckODataServiceTypeProvider =
|
||||
|
||||
let checkHostedType (hostedType: System.Type) =
|
||||
//let hostedType = hostedAppliedType1
|
||||
test "ceklc09wlkm1a" (hostedType.Assembly <> typeof<Microsoft.FSharp.Data.TypeProviders.DesignTime.DataProviders>.Assembly)
|
||||
test "ceklc09wlkm1b" (hostedType.Assembly.FullName.StartsWith "tmp")
|
||||
|
||||
check "ceklc09wlkm2" hostedType.DeclaringType null
|
||||
check "ceklc09wlkm3" hostedType.DeclaringMethod null
|
||||
check "ceklc09wlkm4" hostedType.FullName "Microsoft.FSharp.Data.TypeProviders.ODataServiceApplied"
|
||||
check "ceklc09wlkm5" (hostedType.GetConstructors()) [| |]
|
||||
check "ceklc09wlkm6" (hostedType.GetCustomAttributesData().Count) 1
|
||||
check "ceklc09wlkm6" (hostedType.GetCustomAttributesData().[0].Constructor.DeclaringType.FullName) typeof<TypeProviderXmlDocAttribute>.FullName
|
||||
check "ceklc09wlkm7" (hostedType.GetEvents()) [| |]
|
||||
check "ceklc09wlkm8" (hostedType.GetFields()) [| |]
|
||||
check "ceklc09wlkm9" [ for m in hostedType.GetMethods() -> m.Name ] [ "GetDataContext" ; "GetDataContext" ]
|
||||
let m1 = hostedType.GetMethods().[0]
|
||||
let m2 = hostedType.GetMethods().[1]
|
||||
check "ceklc09wlkm9b" (m1.GetParameters().Length) 0
|
||||
check "ceklc09wlkm9b" (m2.GetParameters().Length) 1
|
||||
check "ceklc09wlkm9b" (m1.ReturnType.Name) "DemoService"
|
||||
check "ceklc09wlkm9c" (m1.ReturnType.FullName) ("Microsoft.FSharp.Data.TypeProviders.ODataServiceApplied+ServiceTypes+SimpleDataContextTypes+DemoService")
|
||||
|
||||
check "ceklc09wlkm9d" (m1.ReturnType.GetProperties().Length) 5
|
||||
check "ceklc09wlkm9e" (set [ for p in m1.ReturnType.GetProperties() -> p.Name ]) (set ["Categories"; "Credentials"; "DataContext"; "Products"; "Suppliers"])
|
||||
check "ceklc09wlkm9f" (set [ for p in m1.ReturnType.GetProperties() -> p.PropertyType.Name ]) (set ["DataServiceQuery`1"; "DataServiceQuery`1";"DataServiceQuery`1";"ICredentials"; "DataServiceContext"])
|
||||
|
||||
// We expose some getters and 1 setter on the simpler data context
|
||||
check "ceklc09wlkm9g" (m1.ReturnType.GetMethods().Length) 6
|
||||
check "ceklc09wlkm9h" (set [ for p in m1.ReturnType.GetMethods() -> p.Name ]) (set ["get_Categories"; "get_Credentials"; "get_DataContext"; "get_Products"; "get_Suppliers"; "set_Credentials"])
|
||||
|
||||
check "ceklc09wlkm10" (hostedType.GetProperties()) [| |]
|
||||
check "ceklc09wlkm11" (hostedType.GetNestedTypes().Length) 1
|
||||
check "ceklc09wlkm12"
|
||||
(set [ for x in hostedType.GetNestedTypes() -> x.Name ])
|
||||
(set ["ServiceTypes"])
|
||||
|
||||
let hostedServiceTypes = hostedType.GetNestedTypes().[0]
|
||||
|
||||
check "ceklc09wlkm11" (hostedServiceTypes.GetNestedTypes().Length) 6
|
||||
check "ceklc09wlkm12"
|
||||
(set [ for x in hostedServiceTypes.GetNestedTypes() -> x.Name ])
|
||||
(set ["Address"; "Category"; "DemoService"; "Product"; "SimpleDataContextTypes"; "Supplier"])
|
||||
|
||||
let productType = (hostedServiceTypes.GetNestedTypes() |> Seq.find (fun t -> t.Name = "Product"))
|
||||
check "ceklc09wlkm13" (productType.GetProperties().Length) 9
|
||||
|
||||
check "ceklc09wlkm14"
|
||||
(set [ for x in productType.GetProperties() -> x.Name ])
|
||||
(set ["ID"; "Name"; "Description"; "ReleaseDate"; "DiscontinuedDate"; "Rating"; "Price"; "Category"; "Supplier"])
|
||||
|
||||
let instantiateTypeProviderAndCheckOneHostedType(useLocalSchemaFile: string option, useForceUpdate: bool option, typeFullPath:string[]) =
|
||||
//let useLocalSchemaFile : string option = None
|
||||
//let useForceUpdate : bool option = None
|
||||
let assemblyFile = typeof<Microsoft.FSharp.Data.TypeProviders.DesignTime.DataProviders>.Assembly.CodeBase.Replace("file:///","").Replace("/","\\")
|
||||
test "cnlkenkewe" (File.Exists assemblyFile)
|
||||
|
||||
// If/when we care about the "target framework", this mock function will have to be fully implemented
|
||||
let systemRuntimeContainsType s =
|
||||
printfn "Call systemRuntimeContainsType(%s) returning dummy value 'true'" s
|
||||
true
|
||||
|
||||
let tpConfig = new TypeProviderConfig(systemRuntimeContainsType, ResolutionFolder=__SOURCE_DIRECTORY__, RuntimeAssembly=assemblyFile, ReferencedAssemblies=[| |], TemporaryFolder=Path.GetTempPath(), IsInvalidationSupported=false, IsHostedExecution=true)
|
||||
use typeProvider1 = (new Microsoft.FSharp.Data.TypeProviders.DesignTime.DataProviders( tpConfig ) :> ITypeProvider)
|
||||
|
||||
let invalidateEventCount = ref 0
|
||||
|
||||
typeProvider1.Invalidate.Add(fun _ -> incr invalidateEventCount)
|
||||
|
||||
// Load a type provider instance for the type and restart
|
||||
let hostedNamespace1 = typeProvider1.GetNamespaces() |> Seq.find (fun t -> t.NamespaceName = "Microsoft.FSharp.Data.TypeProviders")
|
||||
|
||||
check "eenewioinw" (set [ for i in hostedNamespace1.GetTypes() -> i.Name ]) (set ["DbmlFile"; "EdmxFile"; "ODataService"; "SqlDataConnection";"SqlEntityConnection";"WsdlService"])
|
||||
|
||||
let hostedType1 = hostedNamespace1.ResolveTypeName("ODataService")
|
||||
let hostedType1StaticParameters = typeProvider1.GetStaticParameters(hostedType1)
|
||||
check "eenewioinw2"
|
||||
(set [ for i in hostedType1StaticParameters -> i.Name ])
|
||||
(set ["ServiceUri"; "LocalSchemaFile"; "ForceUpdate"; "ResolutionFolder"; "DataServiceCollection"])
|
||||
|
||||
let serviceUri = "http://services.odata.org/V2/OData/OData.svc/"
|
||||
let staticParameterValues =
|
||||
[| for x in hostedType1StaticParameters ->
|
||||
(match x.Name with
|
||||
| "ServiceUri" -> box serviceUri
|
||||
| "LocalSchemaFile" when useLocalSchemaFile.IsSome -> box useLocalSchemaFile.Value
|
||||
| "ForceUpdate" when useForceUpdate.IsSome -> box useForceUpdate.Value
|
||||
| _ -> box x.RawDefaultValue) |]
|
||||
printfn "instantiating service type... may take a while for OData service metadata to be downloaded, code generation tool to run and csc.exe to run..."
|
||||
try
|
||||
let hostedAppliedType1 = typeProvider1.ApplyStaticArguments(hostedType1, typeFullPath, staticParameterValues)
|
||||
|
||||
checkHostedType hostedAppliedType1
|
||||
with
|
||||
| e ->
|
||||
printfn "%s" (e.ToString())
|
||||
reportFailure()
|
||||
|
||||
instantiateTypeProviderAndCheckOneHostedType(None, None, [| "ODataServiceApplied" |])
|
||||
|
||||
let schemaFile2 = Path.Combine(__SOURCE_DIRECTORY__, "svc.csdl")
|
||||
(try File.Delete schemaFile2 with _ -> ())
|
||||
instantiateTypeProviderAndCheckOneHostedType(Some (Path.Combine(__SOURCE_DIRECTORY__, "svc.csdl")), Some true, [| "ODataServiceApplied" |])
|
||||
// schemaFile2 should now exist
|
||||
check "eoinew0c9e" (File.Exists schemaFile2)
|
||||
|
||||
// Reuse the CSDL just created
|
||||
instantiateTypeProviderAndCheckOneHostedType(Some (Path.Combine(__SOURCE_DIRECTORY__, "svc.csdl")), Some false, [| "ODataServiceApplied" |])
|
||||
// schemaFile2 should now still exist
|
||||
check "eoinew0c9e" (File.Exists schemaFile2)
|
||||
|
||||
let schemaFile3 = Path.Combine(__SOURCE_DIRECTORY__, "svc2.csdl")
|
||||
(try File.Delete schemaFile3 with _ -> ())
|
||||
instantiateTypeProviderAndCheckOneHostedType(Some schemaFile3, None, [| "ODataServiceApplied" |])
|
||||
|
||||
// schemaFile3 should now exist
|
||||
check "eoinew0c9e" (File.Exists schemaFile3)
|
||||
|
||||
let _ =
|
||||
if !failures then (stdout.WriteLine "Test Failed"; exit 1)
|
||||
|
||||
do (stdout.WriteLine "Test Passed";
|
||||
File.WriteAllText("test.ok","ok");
|
||||
exit 0)
|
||||
|
Двоичный файл не отображается.
|
@ -0,0 +1,8 @@
|
|||
@if "%_echo%"=="" echo off
|
||||
|
||||
call %~d0%~p0..\copyFSharpDataTypeProviderDLL.cmd
|
||||
|
||||
call %~d0%~p0..\..\..\single-test-build.bat
|
||||
|
||||
exit /b %ERRORLEVEL%
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
@if "%_echo%"=="" echo off
|
||||
|
||||
call %~d0%~p0..\..\..\..\config.bat
|
||||
|
||||
IF /I "%INSTALL_SKU%" NEQ "ULTIMATE" (
|
||||
echo Test not supported except on Ultimate
|
||||
exit /b 0
|
||||
)
|
||||
|
||||
IF EXIST test.exe (
|
||||
echo Running test.exe to warm up SQL
|
||||
test.exe > nul 2> nul
|
||||
)
|
||||
|
||||
call %~d0%~p0..\..\..\single-test-run.bat
|
||||
|
||||
exit /b %ERRORLEVEL%
|
|
@ -0,0 +1,255 @@
|
|||
// #Conformance #TypeProviders #SqlDataConnection
|
||||
#r "FSharp.Data.TypeProviders.dll"
|
||||
#r "System.Management.dll"
|
||||
|
||||
open Microsoft.FSharp.Core.CompilerServices
|
||||
open System.IO
|
||||
|
||||
[<AutoOpen>]
|
||||
module Infrastructure =
|
||||
let failures = ref false
|
||||
let reportFailure () = stderr.WriteLine " NO"; failures := true
|
||||
let test s b = stderr.Write(s:string); if b then stderr.WriteLine " OK" else reportFailure()
|
||||
let check s v1 v2 = stderr.Write(s:string); if v1 = v2 then stderr.WriteLine " OK" else eprintf "... FAILURE: expected %A, got %A " v2 v1; reportFailure()
|
||||
|
||||
let argv = System.Environment.GetCommandLineArgs()
|
||||
let SetCulture() =
|
||||
if argv.Length > 2 && argv.[1] = "--culture" then begin
|
||||
let cultureString = argv.[2] in
|
||||
let culture = new System.Globalization.CultureInfo(cultureString) in
|
||||
stdout.WriteLine ("Running under culture "+culture.ToString()+"...");
|
||||
System.Threading.Thread.CurrentThread.CurrentCulture <- culture
|
||||
end
|
||||
|
||||
do SetCulture()
|
||||
|
||||
module CheckSqlConnectionTypeProvider =
|
||||
|
||||
let isSQLExpressInstalled =
|
||||
let edition = "Express Edition"
|
||||
let instance = "MSSQL$SQLEXPRESS"
|
||||
|
||||
try
|
||||
let getSqlExpress =
|
||||
new System.Management.ManagementObjectSearcher("root\\Microsoft\\SqlServer\\ComputerManagement10",
|
||||
"select * from SqlServiceAdvancedProperty where SQLServiceType = 1 and ServiceName = '" + instance + "' and (PropertyName = 'SKUNAME' or PropertyName = 'SPLEVEL')")
|
||||
|
||||
// If nothing is returned, SQL Express isn't installed.
|
||||
getSqlExpress.Get().Count <> 0
|
||||
with
|
||||
| _ -> false
|
||||
|
||||
|
||||
let checkHostedType (hostedType: System.Type) =
|
||||
//let hostedType = hostedAppliedType1
|
||||
test "ceklc09wlkm1a" (hostedType.Assembly <> typeof<Microsoft.FSharp.Data.TypeProviders.DesignTime.DataProviders>.Assembly)
|
||||
test "ceklc09wlkm1b" (hostedType.Assembly.FullName.StartsWith "tmp")
|
||||
|
||||
check "ceklc09wlkm2" hostedType.DeclaringType null
|
||||
check "ceklc09wlkm3" hostedType.DeclaringMethod null
|
||||
check "ceklc09wlkm4" hostedType.FullName "Microsoft.FSharp.Data.TypeProviders.SqlDataConnectionApplied"
|
||||
check "ceklc09wlkm5" (hostedType.GetConstructors()) [| |]
|
||||
check "ceklc09wlkm6" (hostedType.GetCustomAttributesData().Count) 1
|
||||
check "ceklc09wlkm6" (hostedType.GetCustomAttributesData().[0].Constructor.DeclaringType.FullName) typeof<TypeProviderXmlDocAttribute>.FullName
|
||||
check "ceklc09wlkm7" (hostedType.GetEvents()) [| |]
|
||||
check "ceklc09wlkm8" (hostedType.GetFields()) [| |]
|
||||
check "ceklc09wlkm9" [ for m in hostedType.GetMethods() -> m.Name ] [ "GetDataContext" ; "GetDataContext" ]
|
||||
let m0 = hostedType.GetMethods().[0]
|
||||
let m1 = hostedType.GetMethods().[1]
|
||||
check "ceklc09wlkm9b" (m0.GetParameters().Length) 0
|
||||
check "ceklc09wlkm9b" (m1.GetParameters().Length) 1
|
||||
check "ceklc09wlkm9b" (m0.ReturnType.Name) "Northwnd"
|
||||
check "ceklc09wlkm9b" (m0.ReturnType.FullName) "Microsoft.FSharp.Data.TypeProviders.SqlDataConnectionApplied+ServiceTypes+SimpleDataContextTypes+Northwnd"
|
||||
check "ceklc09wlkm10" (hostedType.GetProperties()) [| |]
|
||||
check "ceklc09wlkm11" (hostedType.GetNestedTypes().Length) 1
|
||||
check "ceklc09wlkm12"
|
||||
(set [ for x in hostedType.GetNestedTypes() -> x.Name ])
|
||||
(set ["ServiceTypes"])
|
||||
|
||||
let hostedServiceTypes = hostedType.GetNestedTypes().[0]
|
||||
check "ceklc09wlkm12b" (hostedServiceTypes.GetMethods()) [| |]
|
||||
check "ceklc09wlkm12c" (hostedServiceTypes.GetNestedTypes().Length) 38
|
||||
|
||||
let hostedSimpleDataContextTypes = hostedServiceTypes.GetNestedType("SimpleDataContextTypes")
|
||||
check "ceklc09wlkm12d" (hostedSimpleDataContextTypes.GetMethods()) [| |]
|
||||
check "ceklc09wlkm12e" (hostedSimpleDataContextTypes.GetNestedTypes().Length) 1
|
||||
check "ceklc09wlkm12e" [ for x in hostedSimpleDataContextTypes.GetNestedTypes() -> x.Name] ["Northwnd"]
|
||||
|
||||
check "ceklc09wlkm12"
|
||||
(set [ for x in hostedServiceTypes.GetNestedTypes() -> x.Name ])
|
||||
(set ["Northwnd"; "SimpleDataContextTypes"; "AlphabeticalListOfProduct"; "Category"; "CategorySalesFor1997"; "CurrentProductList"; "CustomerAndSuppliersByCity";
|
||||
"CustomerCustomerDemo"; "CustomerDemographic"; "Customer"; "Employee"; "EmployeeTerritory";
|
||||
"Invoice"; "OrderDetail"; "OrderDetailsExtended"; "OrderSubtotal"; "Order"; "OrdersQry";
|
||||
"ProductSalesFor1997"; "Product"; "ProductsAboveAveragePrice"; "ProductsByCategory";
|
||||
"QuarterlyOrder"; "Region"; "SalesByCategory"; "SalesTotalsByAmount"; "Shipper";
|
||||
"SummaryOfSalesByQuarter"; "SummaryOfSalesByYear"; "Supplier"; "Territory"; "CustOrderHistResult";
|
||||
"CustOrdersDetailResult"; "CustOrdersOrdersResult"; "EmployeeSalesByCountryResult"; "SalesByYearResult";
|
||||
"SalesByCategoryResult"; "TenMostExpensiveProductsResult"])
|
||||
|
||||
let customersType = (hostedServiceTypes.GetNestedTypes() |> Seq.find (fun t -> t.Name = "Customer"))
|
||||
check "ceklc09wlkm13" (customersType.GetProperties().Length) 13
|
||||
|
||||
|
||||
let instantiateTypeProviderAndCheckOneHostedType(connectionStringName, configFile, useDataDirectory, dataDirectory, useLocalSchemaFile: string option, useForceUpdate: bool option, typeFullPath: string[], resolutionFolder:string option) =
|
||||
let assemblyFile = typeof<Microsoft.FSharp.Data.TypeProviders.DesignTime.DataProviders>.Assembly.CodeBase.Replace("file:///","").Replace("/","\\")
|
||||
test "cnlkenkewe" (File.Exists assemblyFile)
|
||||
|
||||
// If/when we care about the "target framework", this mock function will have to be fully implemented
|
||||
let systemRuntimeContainsType s =
|
||||
printfn "Call systemRuntimeContainsType(%s) returning dummy value 'true'" s
|
||||
true
|
||||
|
||||
let tpConfig = new TypeProviderConfig(systemRuntimeContainsType, ResolutionFolder=__SOURCE_DIRECTORY__, RuntimeAssembly=assemblyFile, ReferencedAssemblies=[| |], TemporaryFolder=Path.GetTempPath(), IsInvalidationSupported=false, IsHostedExecution=true)
|
||||
use typeProvider1 = (new Microsoft.FSharp.Data.TypeProviders.DesignTime.DataProviders( tpConfig ) :> ITypeProvider)
|
||||
|
||||
let invalidateEventCount = ref 0
|
||||
|
||||
typeProvider1.Invalidate.Add(fun _ -> incr invalidateEventCount)
|
||||
|
||||
// Load a type provider instance for the type and restart
|
||||
let hostedNamespace1 = typeProvider1.GetNamespaces() |> Seq.find (fun t -> t.NamespaceName = "Microsoft.FSharp.Data.TypeProviders")
|
||||
|
||||
check "eenewioinw" (set [ for i in hostedNamespace1.GetTypes() -> i.Name ]) (set ["DbmlFile"; "EdmxFile"; "ODataService"; "SqlDataConnection";"SqlEntityConnection";"WsdlService"])
|
||||
|
||||
let hostedType1 = hostedNamespace1.ResolveTypeName("SqlDataConnection")
|
||||
let hostedType1StaticParameters = typeProvider1.GetStaticParameters(hostedType1)
|
||||
check "eenewioinw2"
|
||||
(set [ for i in hostedType1StaticParameters -> i.Name ])
|
||||
(set ["ConnectionString"; "ConnectionStringName"; "DataDirectory"; "ResolutionFolder"; "ConfigFile"; "LocalSchemaFile";
|
||||
"ForceUpdate"; "Pluralize"; "Views"; "Functions"; "StoredProcedures"; "Timeout";
|
||||
"ContextTypeName"; "Serializable" ])
|
||||
|
||||
let northwind = "NORTHWND.mdf"
|
||||
let northwindLog = "NORTHWND_log.ldf"
|
||||
let northwindFile =
|
||||
let baseFile =
|
||||
match dataDirectory with
|
||||
| None -> northwind
|
||||
| Some dd -> System.IO.Path.Combine(dd,northwind)
|
||||
match resolutionFolder with
|
||||
| None ->
|
||||
match dataDirectory with
|
||||
| None -> ()
|
||||
| Some dd -> if not(System.IO.Directory.Exists dd) then System.IO.Directory.CreateDirectory dd |> ignore
|
||||
baseFile
|
||||
| Some rf ->
|
||||
if not(System.IO.Directory.Exists rf) then System.IO.Directory.CreateDirectory rf |> ignore
|
||||
match dataDirectory with
|
||||
| None -> ()
|
||||
| Some dd -> let dd = System.IO.Path.Combine(rf,dd) in if not(System.IO.Directory.Exists dd) then System.IO.Directory.CreateDirectory dd |> ignore
|
||||
System.IO.Path.Combine(rf,baseFile)
|
||||
|
||||
|
||||
if not(System.IO.File.Exists(northwindFile)) then
|
||||
System.IO.File.Copy("DB\\northwnd.mdf", northwindFile, false)
|
||||
System.IO.File.SetAttributes(northwindFile, System.IO.FileAttributes.Normal)
|
||||
|
||||
|
||||
let connectionString =
|
||||
if useDataDirectory then
|
||||
if isSQLExpressInstalled then
|
||||
@"AttachDBFileName = '|DataDirectory|\" + northwind + "';Server='.\SQLEXPRESS';User Instance=true;Integrated Security=SSPI"
|
||||
else
|
||||
"AttachDBFileName = '|DataDirectory|\\" + northwind + "';Server='(localdb)\\MSSQLLocalDB'"
|
||||
else
|
||||
if isSQLExpressInstalled then
|
||||
@"AttachDBFileName = '" + System.IO.Path.Combine(__SOURCE_DIRECTORY__, northwindFile) + "';Server='.\SQLEXPRESS';User Instance=true;Integrated Security=SSPI"
|
||||
else
|
||||
"AttachDBFileName = '" + System.IO.Path.Combine(__SOURCE_DIRECTORY__, northwindFile) + "';Server='(localdb)\\MSSQLLocalDB'"
|
||||
|
||||
match connectionStringName with
|
||||
| None -> ()
|
||||
| Some connectionStringName ->
|
||||
let configFileName = match configFile with None -> "app.config" | Some nm -> nm
|
||||
let configFileName =
|
||||
match resolutionFolder with
|
||||
| None -> configFileName
|
||||
| Some rf ->
|
||||
System.IO.Path.Combine(rf,configFileName)
|
||||
System.IO.File.WriteAllText(configFileName,
|
||||
sprintf """<?xml version="1.0"?>
|
||||
|
||||
<configuration>
|
||||
<connectionStrings>
|
||||
<add name="%s"
|
||||
connectionString="%s"
|
||||
providerName="System.Data.SqlClient" />
|
||||
</connectionStrings>
|
||||
|
||||
<system.webServer>
|
||||
<modules runAllManagedModulesForAllRequests="true"/>
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
"""
|
||||
connectionStringName
|
||||
connectionString)
|
||||
let staticParameterValues =
|
||||
[| for x in hostedType1StaticParameters ->
|
||||
(match x.Name with
|
||||
| "ConnectionString" when connectionStringName.IsNone -> box connectionString
|
||||
| "Pluralize" -> box true
|
||||
| "ConnectionStringName" when connectionStringName.IsSome -> box connectionStringName.Value
|
||||
| "ResolutionFolder" when resolutionFolder.IsSome -> box resolutionFolder.Value
|
||||
| "DataDirectory" when dataDirectory.IsSome -> box dataDirectory.Value
|
||||
| "ConfigFile" when configFile.IsSome -> box configFile.Value
|
||||
| "ContextTypeName" -> box "Northwnd"
|
||||
| "LocalSchemaFile" when useLocalSchemaFile.IsSome -> box useLocalSchemaFile.Value
|
||||
| "ForceUpdate" when useForceUpdate.IsSome -> box useForceUpdate.Value
|
||||
| "Timeout" -> box 60
|
||||
| _ -> box x.RawDefaultValue) |]
|
||||
printfn "instantiating database type... may take a while for db to attach, code generation tool to run and csc.exe to run..."
|
||||
|
||||
try
|
||||
let hostedAppliedType1 = typeProvider1.ApplyStaticArguments(hostedType1, typeFullPath, staticParameterValues)
|
||||
|
||||
checkHostedType hostedAppliedType1
|
||||
with
|
||||
| e ->
|
||||
printfn "%s" (e.ToString())
|
||||
reportFailure()
|
||||
|
||||
instantiateTypeProviderAndCheckOneHostedType(None, None, false, None, None, None, [| "SqlDataConnectionApplied" |], None)
|
||||
|
||||
// Use an implied app.config config file, use the current directory as the DataDirectory
|
||||
instantiateTypeProviderAndCheckOneHostedType(Some "ConnectionString1", None, true, None, None, None, [| "SqlDataConnectionApplied" |], None)
|
||||
|
||||
// Use a config file, use an explicit relative DataDirectory
|
||||
instantiateTypeProviderAndCheckOneHostedType(Some "ConnectionString2", Some "app.config", true, Some "DataDirectory", None, None, [| "SqlDataConnectionApplied" |], None)
|
||||
|
||||
// Use a config file, use an explicit relative DataDirectory and an explicit ResolutionFolder.
|
||||
instantiateTypeProviderAndCheckOneHostedType(Some "ConnectionString2", Some "app.config", true, Some "DataDirectory", None, None, [| "SqlDataConnectionApplied" |], Some "ExampleResolutionFolder")
|
||||
|
||||
|
||||
// Use an absolute config file, use an absolute DataDirectory
|
||||
instantiateTypeProviderAndCheckOneHostedType(Some "ConnectionString3", Some (__SOURCE_DIRECTORY__ + @"\test.config"), true, Some (__SOURCE_DIRECTORY__ + @"\DataDirectory"), None, None, [| "SqlDataConnectionApplied" |], None)
|
||||
|
||||
let schemaFile2 = Path.Combine(__SOURCE_DIRECTORY__, "nwind2.dbml")
|
||||
(try File.Delete schemaFile2 with _ -> ())
|
||||
instantiateTypeProviderAndCheckOneHostedType(None, None, false, None, Some (Path.Combine(__SOURCE_DIRECTORY__, "nwind2.dbml")), Some true, [| "SqlDataConnectionApplied" |], None)
|
||||
// schemaFile2 should now exist
|
||||
check "eoinew0c9e" (File.Exists schemaFile2)
|
||||
|
||||
// Reuse the DBML just created
|
||||
instantiateTypeProviderAndCheckOneHostedType(None, None, false, None, Some (Path.Combine(__SOURCE_DIRECTORY__, "nwind2.dbml")), Some false, [| "SqlDataConnectionApplied" |], None)
|
||||
// schemaFile2 should now still exist
|
||||
check "eoinew0c9e" (File.Exists schemaFile2)
|
||||
|
||||
// // A relative path should work....
|
||||
// instantiateTypeProviderAndCheckOneHostedType(Some "nwind2.dbml", Some false)
|
||||
// // schemaFile2 should now still exist
|
||||
// check "eoinew0c9e" (File.Exists schemaFile2)
|
||||
|
||||
let schemaFile3 = Path.Combine(__SOURCE_DIRECTORY__, "nwind3.dbml")
|
||||
(try File.Delete schemaFile3 with _ -> ())
|
||||
instantiateTypeProviderAndCheckOneHostedType(None, None, false, None, Some schemaFile3, None, [| "SqlDataConnectionApplied" |], None)
|
||||
|
||||
// schemaFile3 should now exist
|
||||
check "eoinew0c9e" (File.Exists schemaFile3)
|
||||
|
||||
let _ =
|
||||
if !failures then (stdout.WriteLine "Test Failed"; exit 1)
|
||||
|
||||
do (stdout.WriteLine "Test Passed";
|
||||
File.WriteAllText("test.ok","ok");
|
||||
exit 0)
|
||||
|
Двоичный файл не отображается.
|
@ -0,0 +1,8 @@
|
|||
@if "%_echo%"=="" echo off
|
||||
|
||||
call %~d0%~p0..\copyFSharpDataTypeProviderDLL.cmd
|
||||
|
||||
call %~d0%~p0..\..\..\single-test-build.bat
|
||||
|
||||
exit /b %ERRORLEVEL%
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
@if "%_echo%"=="" echo off
|
||||
call %~d0%~p0..\..\..\..\config.bat
|
||||
|
||||
IF /I "%INSTALL_SKU%" NEQ "ULTIMATE" (
|
||||
echo Test not supported except on Ultimate
|
||||
exit /b 0
|
||||
)
|
||||
|
||||
call %~d0%~p0..\..\..\single-test-run.bat
|
||||
|
||||
exit /b %ERRORLEVEL%
|
||||
|
||||
|
|
@ -0,0 +1,243 @@
|
|||
// #Conformance #TypeProviders #SqlEntityConnection
|
||||
#r "FSharp.Data.TypeProviders.dll"
|
||||
#r "System.Management.dll"
|
||||
|
||||
open Microsoft.FSharp.Core.CompilerServices
|
||||
open System.IO
|
||||
|
||||
[<AutoOpen>]
|
||||
module Infrastructure =
|
||||
let failures = ref false
|
||||
let reportFailure () = stderr.WriteLine " NO"; failures := true
|
||||
let test s b = stderr.Write(s:string); if b then stderr.WriteLine " OK" else reportFailure()
|
||||
let check s v1 v2 = stderr.Write(s:string); if v1 = v2 then stderr.WriteLine " OK" else eprintf "... FAILURE: expected %A, got %A " v2 v1; reportFailure()
|
||||
|
||||
let argv = System.Environment.GetCommandLineArgs()
|
||||
let SetCulture() =
|
||||
if argv.Length > 2 && argv.[1] = "--culture" then begin
|
||||
let cultureString = argv.[2] in
|
||||
let culture = new System.Globalization.CultureInfo(cultureString) in
|
||||
stdout.WriteLine ("Running under culture "+culture.ToString()+"...");
|
||||
System.Threading.Thread.CurrentThread.CurrentCulture <- culture
|
||||
end
|
||||
|
||||
do SetCulture()
|
||||
|
||||
module CheckSqlEntityConnectionTypeProvider =
|
||||
|
||||
let isSQLExpressInstalled =
|
||||
let edition = "Express Edition"
|
||||
let instance = "MSSQL$SQLEXPRESS"
|
||||
|
||||
try
|
||||
let getSqlExpress =
|
||||
new System.Management.ManagementObjectSearcher("root\\Microsoft\\SqlServer\\ComputerManagement10",
|
||||
"select * from SqlServiceAdvancedProperty where SQLServiceType = 1 and ServiceName = '" + instance + "' and (PropertyName = 'SKUNAME' or PropertyName = 'SPLEVEL')")
|
||||
|
||||
// If nothing is returned, SQL Express isn't installed.
|
||||
getSqlExpress.Get().Count <> 0
|
||||
with
|
||||
| _ -> false
|
||||
|
||||
let checkHostedType (expectedContextTypeName, hostedType: System.Type) =
|
||||
//let hostedType = hostedAppliedType1
|
||||
|
||||
test "ceklc09wlkm1a" (hostedType.Assembly <> typeof<Microsoft.FSharp.Data.TypeProviders.DesignTime.DataProviders>.Assembly)
|
||||
test "ceklc09wlkm1b" (hostedType.Assembly.FullName.StartsWith "tmp")
|
||||
|
||||
check "ceklc09wlkm2" hostedType.DeclaringType null
|
||||
check "ceklc09wlkm3" hostedType.DeclaringMethod null
|
||||
check "ceklc09wlkm4" hostedType.FullName ("SqlEntityConnection1.SqlEntityConnectionApplied")
|
||||
check "ceklc09wlkm5" (hostedType.GetConstructors()) [| |]
|
||||
check "ceklc09wlkm6" (hostedType.GetCustomAttributesData().Count) 1
|
||||
check "ceklc09wlkm6" (hostedType.GetCustomAttributesData().[0].Constructor.DeclaringType.FullName) typeof<TypeProviderXmlDocAttribute>.FullName
|
||||
check "ceklc09wlkm7" (hostedType.GetEvents()) [| |]
|
||||
check "ceklc09wlkm8" (hostedType.GetFields()) [| |]
|
||||
check "ceklc09wlkm9" [ for m in hostedType.GetMethods() -> m.Name ] [ "GetDataContext" ;"GetDataContext" ]
|
||||
let m0 = hostedType.GetMethods().[0]
|
||||
let m1 = hostedType.GetMethods().[1]
|
||||
check "ceklc09wlkm9b" (m0.GetParameters().Length) 0
|
||||
check "ceklc09wlkm9c" (m1.GetParameters().Length) 1
|
||||
check "ceklc09wlkm9d" (m0.ReturnType.Name) expectedContextTypeName
|
||||
check "ceklc09wlkm9e" (m0.ReturnType.FullName) ("SqlEntityConnection1.SqlEntityConnectionApplied+ServiceTypes+SimpleDataContextTypes+" + expectedContextTypeName)
|
||||
check "ceklc09wlkm10" (hostedType.GetProperties()) [| |]
|
||||
check "ceklc09wlkm11" (hostedType.GetNestedTypes().Length) 1
|
||||
check "ceklc09wlkm12"
|
||||
(set [ for x in hostedType.GetNestedTypes() -> x.Name ])
|
||||
(set ["ServiceTypes"])
|
||||
|
||||
let hostedServiceTypes = hostedType.GetNestedTypes().[0]
|
||||
check "ceklc09wlkm12b" (hostedServiceTypes.GetMethods()) [| |]
|
||||
check "ceklc09wlkm12c" (hostedServiceTypes.GetNestedTypes().Length) 28
|
||||
|
||||
let hostedSimpleDataContextTypes = hostedServiceTypes.GetNestedType("SimpleDataContextTypes")
|
||||
check "ceklc09wlkm12d" (hostedSimpleDataContextTypes.GetMethods()) [| |]
|
||||
check "ceklc09wlkm12e" (hostedSimpleDataContextTypes.GetNestedTypes().Length) 1
|
||||
check "ceklc09wlkm12e" [ for x in hostedSimpleDataContextTypes.GetNestedTypes() -> x.Name] [expectedContextTypeName]
|
||||
|
||||
check "ceklc09wlkm12"
|
||||
(set [ for x in hostedServiceTypes.GetNestedTypes() -> x.Name ])
|
||||
(set
|
||||
(["Territory"; "Supplier"; "Summary_of_Sales_by_Year";
|
||||
"Summary_of_Sales_by_Quarter"; "Shipper"; "Sales_Totals_by_Amount";
|
||||
"Sales_by_Category"; "Region"; "Products_by_Category";
|
||||
"Products_Above_Average_Price"; "Product_Sales_for_1997"; "Product";
|
||||
"Orders_Qry"; "Order_Subtotal"; "Order_Details_Extended"; "Order_Detail";
|
||||
"Order"; "Invoice"; "Employee"; "CustomerDemographic";
|
||||
"Customer_and_Suppliers_by_City"; "Customer"; "Current_Product_List";
|
||||
"Category_Sales_for_1997"; "Category"; "Alphabetical_list_of_product"; ] @
|
||||
[expectedContextTypeName] @
|
||||
[ "SimpleDataContextTypes"]))
|
||||
|
||||
let customersType = (hostedServiceTypes.GetNestedTypes() |> Seq.find (fun t -> t.Name = "Customer"))
|
||||
check "ceklc09wlkm13" (customersType.GetProperties().Length) 15
|
||||
|
||||
|
||||
let instantiateTypeProviderAndCheckOneHostedType(connectionStringName, configFile, useDataDirectory, dataDirectory, entityContainer: string option, localSchemaFile: string option, useForceUpdate: bool option, typeFullPath: string[]) =
|
||||
let expectedContextTypeName = match entityContainer with None -> "EntityContainer" | Some s -> s
|
||||
let assemblyFile = typeof<Microsoft.FSharp.Data.TypeProviders.DesignTime.DataProviders>.Assembly.CodeBase.Replace("file:///","").Replace("/","\\")
|
||||
test "cnlkenkewe" (File.Exists assemblyFile)
|
||||
|
||||
// If/when we care about the "target framework", this mock function will have to be fully implemented
|
||||
let systemRuntimeContainsType s =
|
||||
printfn "Call systemRuntimeContainsType(%s) returning dummy value 'true'" s
|
||||
true
|
||||
|
||||
let tpConfig = new TypeProviderConfig(systemRuntimeContainsType, ResolutionFolder=__SOURCE_DIRECTORY__, RuntimeAssembly=assemblyFile, ReferencedAssemblies=[| |], TemporaryFolder=Path.GetTempPath(), IsInvalidationSupported=false, IsHostedExecution=true)
|
||||
use typeProvider1 = (new Microsoft.FSharp.Data.TypeProviders.DesignTime.DataProviders( tpConfig ) :> ITypeProvider)
|
||||
|
||||
let invalidateEventCount = ref 0
|
||||
|
||||
typeProvider1.Invalidate.Add(fun _ -> incr invalidateEventCount)
|
||||
|
||||
// Load a type provider instance for the type and restart
|
||||
let hostedNamespace1 = typeProvider1.GetNamespaces() |> Seq.find (fun t -> t.NamespaceName = "Microsoft.FSharp.Data.TypeProviders")
|
||||
|
||||
check "eenewioinw" (set [ for i in hostedNamespace1.GetTypes() -> i.Name ]) (set ["DbmlFile"; "EdmxFile"; "ODataService"; "SqlDataConnection";"SqlEntityConnection";"WsdlService"])
|
||||
|
||||
let hostedType1 = hostedNamespace1.ResolveTypeName("SqlEntityConnection")
|
||||
let hostedType1StaticParameters = typeProvider1.GetStaticParameters(hostedType1)
|
||||
check "eenewioinw2"
|
||||
(set [ for i in hostedType1StaticParameters -> i.Name ])
|
||||
(set ["ConnectionString"; "ConnectionStringName"; "ResolutionFolder"; "DataDirectory"; "ConfigFile"; "ForceUpdate"; "Provider"; "EntityContainer"; "LocalSchemaFile"; "Pluralize"; "SuppressForeignKeyProperties"] )
|
||||
|
||||
|
||||
let northwind = "NORTHWND.mdf"
|
||||
let northwindFile =
|
||||
match dataDirectory with
|
||||
| None -> northwind
|
||||
| Some dd ->
|
||||
if not(System.IO.Directory.Exists dd) then System.IO.Directory.CreateDirectory dd |> ignore
|
||||
System.IO.Path.Combine(dd,northwind)
|
||||
|
||||
if not(System.IO.File.Exists(northwindFile)) then
|
||||
System.IO.File.Copy("DB\\northwnd.mdf", northwindFile, false)
|
||||
System.IO.File.SetAttributes(northwindFile, System.IO.FileAttributes.Normal)
|
||||
|
||||
|
||||
let connectionString =
|
||||
if useDataDirectory then
|
||||
if isSQLExpressInstalled then
|
||||
@"AttachDBFileName = '|DataDirectory|\" + northwind + "';Server='.\SQLEXPRESS';User Instance=true;Integrated Security=SSPI"
|
||||
else
|
||||
"AttachDBFileName = '|DataDirectory|\\" + northwind + "';Server='(localdb)\\MSSQLLocalDB'"
|
||||
else
|
||||
if isSQLExpressInstalled then
|
||||
@"AttachDBFileName = '" + System.IO.Path.Combine(__SOURCE_DIRECTORY__, northwindFile) + "';Server='.\SQLEXPRESS';User Instance=true;Integrated Security=SSPI"
|
||||
else
|
||||
"AttachDBFileName = '" + System.IO.Path.Combine(__SOURCE_DIRECTORY__, northwindFile) + "';Server='(localdb)\\MSSQLLocalDB'"
|
||||
|
||||
match connectionStringName with
|
||||
| None -> ()
|
||||
| Some connectionStringName ->
|
||||
let configFileName = match configFile with None -> "app.config" | Some nm -> nm
|
||||
System.IO.File.WriteAllText(configFileName,
|
||||
sprintf """<?xml version="1.0"?>
|
||||
|
||||
<configuration>
|
||||
<connectionStrings>
|
||||
<add name="%s"
|
||||
connectionString="%s"
|
||||
providerName="System.Data.SqlClient" />
|
||||
</connectionStrings>
|
||||
|
||||
<system.webServer>
|
||||
<modules runAllManagedModulesForAllRequests="true"/>
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
"""
|
||||
connectionStringName
|
||||
connectionString)
|
||||
let staticParameterValues =
|
||||
[| for x in hostedType1StaticParameters ->
|
||||
(match x.Name with
|
||||
| "ConnectionString" when connectionStringName.IsNone -> box connectionString
|
||||
| "ConnectionStringName" when connectionStringName.IsSome -> box connectionStringName.Value
|
||||
| "DataDirectory" when dataDirectory.IsSome -> box dataDirectory.Value
|
||||
| "ConfigFile" when configFile.IsSome -> box configFile.Value
|
||||
| "Pluralize" -> box true
|
||||
| "EntityContainer" when entityContainer.IsSome -> box entityContainer.Value
|
||||
| "SuppressForeignKeyProperties" -> box false
|
||||
| "LocalSchemaFile" when localSchemaFile.IsSome -> box localSchemaFile.Value
|
||||
| "ForceUpdate" when useForceUpdate.IsSome -> box useForceUpdate.Value
|
||||
| _ -> box x.RawDefaultValue) |]
|
||||
printfn "instantiating database type... may take a while for db to attach, code generation tool to run and csc.exe to run..."
|
||||
try
|
||||
let hostedAppliedType1 = typeProvider1.ApplyStaticArguments(hostedType1, typeFullPath, staticParameterValues)
|
||||
|
||||
checkHostedType (expectedContextTypeName,hostedAppliedType1 )
|
||||
with
|
||||
| e ->
|
||||
printfn "%s" (e.ToString())
|
||||
reportFailure()
|
||||
|
||||
instantiateTypeProviderAndCheckOneHostedType(None, None, false, None, None, None, None, [| "SqlEntityConnectionApplied" |])
|
||||
|
||||
// Use an implied app.config config file, use the current directory as the DataDirectory
|
||||
instantiateTypeProviderAndCheckOneHostedType(Some "ConnectionString1", None, true, None, None, None, None, [| "SqlEntityConnectionApplied" |])
|
||||
|
||||
// Use a config file, use an explicit relative DataDirectory
|
||||
instantiateTypeProviderAndCheckOneHostedType(Some "ConnectionString2", Some "app.config", true, Some "DataDirectory", None, None, None, [| "SqlEntityConnectionApplied" |])
|
||||
|
||||
// Use an absolute config file, use an absoltue DataDirectory
|
||||
instantiateTypeProviderAndCheckOneHostedType(Some "ConnectionString3", Some (__SOURCE_DIRECTORY__ + @"\test.config"), true, Some (__SOURCE_DIRECTORY__ + @"\DataDirectory"), None, None, None, [| "SqlEntityConnectionApplied" |])
|
||||
|
||||
|
||||
let schemaFile2 = Path.Combine(__SOURCE_DIRECTORY__, "nwind2.ssdl")
|
||||
(try File.Delete schemaFile2 with _ -> ())
|
||||
instantiateTypeProviderAndCheckOneHostedType(None, None, false, None, None, Some (Path.Combine(__SOURCE_DIRECTORY__, "nwind2.ssdl")), Some true, [| "SqlEntityConnectionApplied" |])
|
||||
// schemaFile2 should now exist
|
||||
check "eoinew0c9e" (File.Exists schemaFile2)
|
||||
|
||||
// Reuse the SSDL just created
|
||||
instantiateTypeProviderAndCheckOneHostedType(None, None, false, None, None, Some (Path.Combine(__SOURCE_DIRECTORY__, "nwind2.ssdl")), Some false, [| "SqlEntityConnectionApplied" |])
|
||||
// schemaFile2 should now still exist
|
||||
check "eoinew0c9e" (File.Exists schemaFile2)
|
||||
|
||||
// // A relative path should work....
|
||||
// instantiateTypeProviderAndCheckOneHostedType(Some "nwind2.ssdl", Some false)
|
||||
// // schemaFile2 should now still exist
|
||||
// check "eoinew0c9e" (File.Exists schemaFile2)
|
||||
|
||||
let schemaFile3 = Path.Combine(__SOURCE_DIRECTORY__, "nwind3.ssdl")
|
||||
(try File.Delete schemaFile3 with _ -> ())
|
||||
instantiateTypeProviderAndCheckOneHostedType(None, None, false, None, None, Some schemaFile3, None, [| "SqlEntityConnectionApplied" |])
|
||||
|
||||
// schemaFile3 should now exist
|
||||
check "eoinew0c9e" (File.Exists schemaFile3)
|
||||
|
||||
let schemaFile4 = Path.Combine(__SOURCE_DIRECTORY__, "nwind4.ssdl")
|
||||
(try File.Delete schemaFile4 with _ -> ())
|
||||
instantiateTypeProviderAndCheckOneHostedType(None, None, false, None, Some "MyEntityContainer", Some schemaFile4, None, [| "SqlEntityConnectionApplied" |])
|
||||
|
||||
// schemaFile4 should now exist
|
||||
check "eoinew0c9e" (File.Exists schemaFile4)
|
||||
|
||||
|
||||
let _ =
|
||||
if !failures then (stdout.WriteLine "Test Failed"; exit 1)
|
||||
|
||||
do (stdout.WriteLine "Test Passed";
|
||||
File.WriteAllText("test.ok","ok");
|
||||
exit 0)
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
@if "%_echo%"=="" echo off
|
||||
|
||||
call %~d0%~p0..\copyFSharpDataTypeProviderDLL.cmd
|
||||
|
||||
call %~d0%~p0..\..\..\single-test-build.bat
|
||||
|
||||
exit /b %ERRORLEVEL%
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
@if "%_echo%"=="" echo off
|
||||
|
||||
call %~d0%~p0..\..\..\single-test-run.bat
|
||||
|
||||
exit /b %ERRORLEVEL%
|
||||
|
||||
|
|
@ -0,0 +1,210 @@
|
|||
// #Conformance #TypeProviders #WsdlService
|
||||
#r "FSharp.Data.TypeProviders.dll"
|
||||
|
||||
open Microsoft.FSharp.Core.CompilerServices
|
||||
open System.IO
|
||||
|
||||
module Infrastructure =
|
||||
let failures = ref false
|
||||
let reportFailure () = stderr.WriteLine " NO"; failures := true
|
||||
let test s b = stderr.Write(s:string); if b then stderr.WriteLine " OK" else reportFailure()
|
||||
let check s v1 v2 = stderr.Write(s:string); if v1 = v2 then stderr.WriteLine " OK" else eprintf "... FAILURE: expected %A, got %A " v2 v1; reportFailure()
|
||||
|
||||
let argv = System.Environment.GetCommandLineArgs()
|
||||
let SetCulture() =
|
||||
if argv.Length > 2 && argv.[1] = "--culture" then begin
|
||||
let cultureString = argv.[2] in
|
||||
let culture = new System.Globalization.CultureInfo(cultureString) in
|
||||
stdout.WriteLine ("Running under culture "+culture.ToString()+"...");
|
||||
System.Threading.Thread.CurrentThread.CurrentCulture <- culture
|
||||
end
|
||||
|
||||
do SetCulture()
|
||||
|
||||
[<AbstractClass>]
|
||||
type WsdlServiceTest(serviceUri, prefix) =
|
||||
|
||||
let check caption a b = Infrastructure.check (prefix + caption) a b
|
||||
let test caption v = Infrastructure.test (prefix + caption) v
|
||||
|
||||
abstract CheckHostedType: System.Type -> unit
|
||||
|
||||
member this.InstantiateTypeProviderAndPerformCheck(useLocalSchemaFile : string option, useForceUpdate : bool option, typeFullPath : string[], f) =
|
||||
let assemblyFile = typeof<Microsoft.FSharp.Data.TypeProviders.DesignTime.DataProviders>.Assembly.CodeBase.Replace("file:///","").Replace("/","\\")
|
||||
test "cnlkenkewe" (File.Exists assemblyFile)
|
||||
|
||||
// If/when we care about the "target framework", this mock function will have to be fully implemented
|
||||
let systemRuntimeContainsType s =
|
||||
printfn "Call systemRuntimeContainsType(%s) returning dummy value 'true'" s
|
||||
true
|
||||
|
||||
let tpConfig = new TypeProviderConfig(systemRuntimeContainsType, ResolutionFolder=__SOURCE_DIRECTORY__, RuntimeAssembly=assemblyFile, ReferencedAssemblies=[| |], TemporaryFolder=Path.GetTempPath(), IsInvalidationSupported=true, IsHostedExecution=true)
|
||||
use typeProvider1 = (new Microsoft.FSharp.Data.TypeProviders.DesignTime.DataProviders( tpConfig ) :> ITypeProvider)
|
||||
|
||||
let invalidateEventCount = ref 0
|
||||
|
||||
typeProvider1.Invalidate.Add(fun _ -> incr invalidateEventCount)
|
||||
|
||||
// Load a type provider instance for the type and restart
|
||||
let hostedNamespace1 = typeProvider1.GetNamespaces() |> Seq.find (fun t -> t.NamespaceName = "Microsoft.FSharp.Data.TypeProviders")
|
||||
|
||||
check "eenewioinw" (set [ for i in hostedNamespace1.GetTypes() -> i.Name ]) (set ["DbmlFile"; "EdmxFile"; "ODataService"; "SqlDataConnection";"SqlEntityConnection";"WsdlService"])
|
||||
|
||||
let hostedType1 = hostedNamespace1.ResolveTypeName("WsdlService")
|
||||
let hostedType1StaticParameters = typeProvider1.GetStaticParameters(hostedType1)
|
||||
check "eenewioinw2"
|
||||
(set [ for i in hostedType1StaticParameters -> i.Name ])
|
||||
(set ["ServiceUri"; "LocalSchemaFile"; "ResolutionFolder"; "ForceUpdate"; "Serializable"; "MessageContract"; "EnableDataBinding"; "Async"; "CollectionType";])
|
||||
|
||||
let staticParameterValues =
|
||||
[| for x in hostedType1StaticParameters ->
|
||||
(match x.Name with
|
||||
| "ServiceUri" -> box serviceUri
|
||||
| "LocalSchemaFile" when useLocalSchemaFile.IsSome -> box useLocalSchemaFile.Value
|
||||
| "ForceUpdate" when useForceUpdate.IsSome -> box useForceUpdate.Value
|
||||
| _ -> box x.RawDefaultValue) |]
|
||||
|
||||
for p in Seq.zip hostedType1StaticParameters staticParameterValues do
|
||||
printfn "%A" p
|
||||
printfn "instantiating service type... may take a while for WSDL service metadata to be downloaded, code generation tool to run and csc.exe to run..."
|
||||
let hostedAppliedType1 = typeProvider1.ApplyStaticArguments(hostedType1, typeFullPath, staticParameterValues)
|
||||
this.CheckHostedType(hostedAppliedType1)
|
||||
|
||||
f()
|
||||
|
||||
member this.InstantiateTypeProviderAndCheckOneHostedType(useLocalSchemaFile: string option, useForceUpdate: bool option, typeFullPath: string[] ) =
|
||||
this.InstantiateTypeProviderAndPerformCheck(useLocalSchemaFile, useForceUpdate, typeFullPath, ignore)
|
||||
|
||||
member this.Run() =
|
||||
this.InstantiateTypeProviderAndCheckOneHostedType( None, None, [| "WsdlServiceApplied" |] )
|
||||
|
||||
let sfile = "sfile.wsdlschema"
|
||||
let fullPath s = Path.Combine(__SOURCE_DIRECTORY__, s)
|
||||
let schemaFile = fullPath sfile
|
||||
|
||||
(try File.Delete schemaFile with _ -> ())
|
||||
this.InstantiateTypeProviderAndCheckOneHostedType(Some sfile, Some true, [| "WsdlServiceApplied" |])
|
||||
// schemaFile should now exist
|
||||
test "eoinew0c9e1" (File.Exists schemaFile)
|
||||
|
||||
let writeTime = File.GetLastWriteTime(schemaFile)
|
||||
// Reuse the WsdlSchema just created
|
||||
this.InstantiateTypeProviderAndCheckOneHostedType(Some sfile, Some false, [| "WsdlServiceApplied" |])
|
||||
// schemaFile should still exist
|
||||
test "eoinew0c9e" (File.Exists schemaFile)
|
||||
check "LastWriteTime_1" (File.GetLastWriteTime(schemaFile)) writeTime
|
||||
|
||||
let sfile2 = "sfile2.wsdlschema"
|
||||
let schemaFile2 = fullPath sfile2
|
||||
(try File.Delete schemaFile2 with _ -> ())
|
||||
|
||||
let check() =
|
||||
// schemaFile2 should now exist
|
||||
test "eoinew0c9e" (File.Exists schemaFile2)
|
||||
|
||||
// rename schema file
|
||||
let renamedFile = fullPath "renamed"
|
||||
// delete existing file
|
||||
try File.Delete renamedFile with _ -> ()
|
||||
System.Threading.SpinWait.SpinUntil((fun () -> File.Exists(schemaFile2)), 10000)
|
||||
|> ignore
|
||||
test "SchemaFileExists" (File.Exists schemaFile2)
|
||||
this.InstantiateTypeProviderAndPerformCheck(Some sfile2, Some false, [| "WsdlServiceApplied" |], check)
|
||||
|
||||
// corrupt source file
|
||||
let initial = File.ReadAllText(sfile2)
|
||||
let text = "123" + File.ReadAllText(sfile2)
|
||||
File.WriteAllText(sfile2, text)
|
||||
try
|
||||
this.InstantiateTypeProviderAndPerformCheck(Some sfile2, Some false, [| "WsdlServiceApplied" |], check)
|
||||
test "Exception_Expected" false
|
||||
with
|
||||
e -> ()
|
||||
// read all text and verify that it was not overwritten
|
||||
let newText = File.ReadAllText(sfile2)
|
||||
test "FileWasNotChanged" (text = newText)
|
||||
|
||||
|
||||
module CheckWsdlServiceTypeProvider =
|
||||
let private prefix = "ceklc"
|
||||
type SimpleWsdlTest() =
|
||||
inherit WsdlServiceTest("http://api.microsofttranslator.com/V2/Soap.svc", prefix)
|
||||
|
||||
let check caption a b = Infrastructure.check (prefix + caption) a b
|
||||
let test caption v = Infrastructure.test (prefix + caption) v
|
||||
|
||||
override this.CheckHostedType(hostedType) =
|
||||
//let hostedType = hostedAppliedType1
|
||||
test "09wlkm1a" (hostedType.Assembly <> typeof<Microsoft.FSharp.Data.TypeProviders.DesignTime.DataProviders>.Assembly)
|
||||
test "09wlkm1b" (hostedType.Assembly.FullName.StartsWith "tmp")
|
||||
|
||||
check "09wlkm2" hostedType.DeclaringType null
|
||||
check "09wlkm3" hostedType.DeclaringMethod null
|
||||
check "09wlkm4" hostedType.FullName "WsdlService1.WsdlServiceApplied"
|
||||
check "09wlkm5" (hostedType.GetConstructors()) [| |]
|
||||
check "09wlkm6" (hostedType.GetCustomAttributesData().Count) 1
|
||||
check "09wlkm6" (hostedType.GetCustomAttributesData().[0].Constructor.DeclaringType.FullName) typeof<TypeProviderXmlDocAttribute>.FullName
|
||||
check "09wlkm7" (hostedType.GetEvents()) [| |]
|
||||
check "09wlkm8" (hostedType.GetFields()) [| |]
|
||||
check "09wlkm9" (hostedType.GetMethods() |> Array.map (fun m -> m.Name)) [| "GetBasicHttpBinding_LanguageService"; "GetBasicHttpBinding_LanguageService"|]
|
||||
check "09wlkm10" (hostedType.GetProperties()) [| |]
|
||||
check "09wlkm11"
|
||||
(set [ for x in hostedType.GetNestedTypes() -> x.Name ])
|
||||
(set ["ServiceTypes"] )
|
||||
|
||||
let serviceTypes = hostedType.GetNestedTypes().[0]
|
||||
|
||||
check "09wlkm11" (serviceTypes.GetNestedTypes().Length) 5
|
||||
check "09wlkm12"
|
||||
(set [ for x in serviceTypes.GetNestedTypes() -> x.Name ])
|
||||
(set ["LanguageService"; "LanguageServiceChannel"; "LanguageServiceClient"; "Microsoft"; "SimpleDataContextTypes" ] )
|
||||
|
||||
let languageServiceType = (serviceTypes.GetNestedTypes() |> Seq.find (fun t -> t.Name = "LanguageService"))
|
||||
check "09wlkm13" (languageServiceType.GetProperties().Length) 0
|
||||
|
||||
(new SimpleWsdlTest()).Run()
|
||||
|
||||
module CheckWsdlServiceTypeProviderXIgniteFutures =
|
||||
let prefix = "qceklc"
|
||||
type XIgniteWsdlTest() =
|
||||
inherit WsdlServiceTest("http://www.xignite.com/xFutures.asmx?WSDL", prefix)
|
||||
let prefix = "xignite"
|
||||
let check caption a b = Infrastructure.check (prefix + caption) a b
|
||||
let test caption v = Infrastructure.test (prefix + caption) v
|
||||
|
||||
override this.CheckHostedType (hostedType: System.Type) =
|
||||
test "09wlkm1ad233" (hostedType.Assembly <> typeof<Microsoft.FSharp.Data.TypeProviders.DesignTime.DataProviders>.Assembly)
|
||||
test "09wlkm1b2ed1" (hostedType.Assembly.FullName.StartsWith "tmp")
|
||||
|
||||
check "09wlkm2" hostedType.DeclaringType null
|
||||
check "09wlkm3" hostedType.DeclaringMethod null
|
||||
check "09wlkm4" hostedType.FullName "WsdlService1.WsdlServiceApplied"
|
||||
check "09wlkm5" (hostedType.GetConstructors()) [| |]
|
||||
check "09wlkm6" (hostedType.GetCustomAttributesData().Count) 1
|
||||
check "09wlkm6" (hostedType.GetCustomAttributesData().[0].Constructor.DeclaringType.FullName) typeof<TypeProviderXmlDocAttribute>.FullName
|
||||
check "09wlkm7" (hostedType.GetEvents()) [| |]
|
||||
check "09wlkm8" (hostedType.GetFields()) [| |]
|
||||
check "09wlkm9" (hostedType.GetMethods() |> Array.map (fun m -> m.Name)) [| "GetXigniteFuturesSoap"; "GetXigniteFuturesSoap"; "GetXigniteFuturesSoap12";"GetXigniteFuturesSoap12"|]
|
||||
check "09wlkm10" (hostedType.GetProperties()) [| |]
|
||||
|
||||
let serviceTypes = hostedType.GetNestedTypes().[0]
|
||||
|
||||
|
||||
check "09wlkm11a" (serviceTypes.GetNestedTypes().Length >= 1) true
|
||||
check "09wlkm11b" (serviceTypes.GetNestedType("www") <> null) true
|
||||
check "09wlkm11c" (serviceTypes.GetNestedType("www").GetNestedType("xignite") <> null) true
|
||||
check "09wlkm11d" (serviceTypes.GetNestedType("www").GetNestedType("xignite").GetNestedType("com") <> null) true
|
||||
check "09wlkm11e" (serviceTypes.GetNestedType("www").GetNestedType("xignite").GetNestedType("com").GetNestedType("services") <> null) true
|
||||
check "09wlkm11f" (serviceTypes.GetNestedType("www").GetNestedType("xignite").GetNestedType("com").GetNestedType("services").GetNestedTypes().Length >= 1) true
|
||||
check "09wlkm11g" [ for x in serviceTypes.GetNestedTypes() do if not x.IsNested && x.Namespace = null then yield x.Name ].Length 175
|
||||
|
||||
(new XIgniteWsdlTest()).Run()
|
||||
|
||||
|
||||
let _ =
|
||||
if !Infrastructure.failures then (stdout.WriteLine "Test Failed"; exit 1)
|
||||
|
||||
do (stdout.WriteLine "Test Passed";
|
||||
File.WriteAllText("test.ok","ok");
|
||||
exit 0)
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
REM == Find out OS architecture, no matter what cmd prompt
|
||||
SET OSARCH=%PROCESSOR_ARCHITECTURE%
|
||||
IF NOT "%PROCESSOR_ARCHITEW6432%"=="" SET OSARCH=%PROCESSOR_ARCHITEW6432%
|
||||
|
||||
REM == Find out path to native 'Program Files 32bit', no matter what
|
||||
REM == architecture we are running on and no matter what command
|
||||
REM == prompt we came from.
|
||||
IF /I "%OSARCH%"=="x86" set X86_PROGRAMFILES=%ProgramFiles%
|
||||
IF /I "%OSARCH%"=="AMD64" set X86_PROGRAMFILES=%ProgramFiles(x86)%
|
||||
|
||||
REM == Set path to FSharp.Data.TypeProviders.dll
|
||||
REM == This binary is frozen at 4.3.0.0 version
|
||||
set FSDATATYPEPROVIDERSPATH=%X86_PROGRAMFILES%\Reference Assemblies\Microsoft\FSharp\.NETFramework\v4.0\4.3.0.0\Type Providers\FSharp.Data.TypeProviders.dll
|
||||
IF EXIST "%FSCBinPath%\FSharp.Data.TypeProviders.dll" set FSDATATYPEPROVIDERSPATH=%FSCBinPath%\FSharp.Data.TypeProviders.dll
|
||||
|
||||
REM == Copy the FSharp.Data.TypeProvider.dll
|
||||
REM == Note: we need this because we are doing white box testing
|
||||
IF EXIST "%FSDATATYPEPROVIDERSPATH%" copy /y "%FSDATATYPEPROVIDERSPATH%" .
|
||||
|
||||
REM == Copy in config files with needed binding redirects
|
||||
xcopy /RY "%~dp0test.exe.config" "%cd%\test.exe.config*"
|
||||
xcopy /RY "%~dp0test.exe.config" "%cd%\testX64.exe.config*"
|
||||
xcopy /RY "%~dp0test.exe.config" "%cd%\test--optimize.exe.config*"
|
||||
xcopy /RY "%~dp0test.exe.config" "%cd%\test--optimize-lib.dll.config*"
|
||||
xcopy /RY "%~dp0test.exe.config" "%cd%\test--optimize-client-of-lib.exe.config*"
|
||||
xcopy /RY "%~dp0test.exe.config" "%cd%\test--optminus--debug.exe.config*"
|
||||
xcopy /RY "%~dp0test.exe.config" "%cd%\test--optplus--debug.exe.config*"
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
module CopyFSharpDataTypeProviderDLL
|
||||
|
||||
open System
|
||||
open System.IO
|
||||
open NUnit.Framework
|
||||
|
||||
open FSharpTestSuiteTypes
|
||||
open PlatformHelpers
|
||||
open NUnitConf
|
||||
|
||||
let copy (cfg: TestConfig) (dir: string) = attempt {
|
||||
let fileExists = Commands.fileExists dir >> Option.isSome
|
||||
let getfullpath = Commands.getfullpath dir
|
||||
|
||||
let copy_y a = Commands.copy_y dir a >> checkResult
|
||||
|
||||
// REM == Find out OS architecture, no matter what cmd prompt
|
||||
// SET OSARCH=%PROCESSOR_ARCHITECTURE%
|
||||
// IF NOT "%PROCESSOR_ARCHITEW6432%"=="" SET OSARCH=%PROCESSOR_ARCHITEW6432%
|
||||
let osArch = WindowsPlatform.osArch cfg.EnvironmentVariables
|
||||
|
||||
// REM == Find out path to native 'Program Files 32bit', no matter what
|
||||
// REM == architecture we are running on and no matter what command
|
||||
// REM == prompt we came from.
|
||||
// IF /I "%OSARCH%"=="x86" set X86_PROGRAMFILES=%ProgramFiles%
|
||||
// IF /I "%OSARCH%"=="AMD64" set X86_PROGRAMFILES=%ProgramFiles(x86)%
|
||||
let x86ProgramFiles = WindowsPlatform.x86ProgramFilesDirectory cfg.EnvironmentVariables osArch
|
||||
|
||||
// REM == Set path to FSharp.Data.TypeProviders.dll
|
||||
// REM == This binary is frozen at 4.3.0.0 version
|
||||
// set FSDATATYPEPROVIDERSPATH=%X86_PROGRAMFILES%\Reference Assemblies\Microsoft\FSharp\.NETFramework\v4.0\4.3.0.0\Type Providers\FSharp.Data.TypeProviders.dll
|
||||
// IF EXIST "%FSCBinPath%\FSharp.Data.TypeProviders.dll" set FSDATATYPEPROVIDERSPATH=%FSCBinPath%\FSharp.Data.TypeProviders.dll
|
||||
let FSDATATYPEPROVIDERSPATH =
|
||||
if fileExists (cfg.FSCBinPath/"FSharp.Data.TypeProviders.dll")
|
||||
then cfg.FSCBinPath/"FSharp.Data.TypeProviders.dll"
|
||||
else x86ProgramFiles/"Reference Assemblies"/"Microsoft"/"FSharp"/".NETFramework"/"v4.0"/"4.3.0.0"/"Type Providers"/"FSharp.Data.TypeProviders.dll"
|
||||
|
||||
|
||||
// REM == Copy the FSharp.Data.TypeProvider.dll
|
||||
// REM == Note: we need this because we are doing white box testing
|
||||
// IF EXIST "%FSDATATYPEPROVIDERSPATH%" copy /y "%FSDATATYPEPROVIDERSPATH%" .
|
||||
do! if fileExists FSDATATYPEPROVIDERSPATH
|
||||
then copy_y FSDATATYPEPROVIDERSPATH ("."/"FSharp.Data.TypeProviders.dll")
|
||||
else Success ()
|
||||
|
||||
// REM == Copy in config files with needed binding redirects
|
||||
let xcopy_ry a b =
|
||||
let removeReadonly p =
|
||||
let attr = File.GetAttributes(p)
|
||||
File.SetAttributes(p, attr &&& (~~~ FileAttributes.ReadOnly))
|
||||
|
||||
if fileExists b then removeReadonly (getfullpath b)
|
||||
copy_y a b
|
||||
|
||||
let ``test.exe.config`` = __SOURCE_DIRECTORY__/"test.exe.config"
|
||||
// xcopy /RY "%~dp0test.exe.config" "%cd%\test.exe.config*"
|
||||
do! xcopy_ry ``test.exe.config`` "test.exe.config"
|
||||
// xcopy /RY "%~dp0test.exe.config" "%cd%\testX64.exe.config*"
|
||||
do! xcopy_ry ``test.exe.config`` "testX64.exe.config"
|
||||
// xcopy /RY "%~dp0test.exe.config" "%cd%\test--optimize.exe.config*"
|
||||
do! xcopy_ry ``test.exe.config`` "test--optimize.exe.config"
|
||||
// xcopy /RY "%~dp0test.exe.config" "%cd%\test--optimize-lib.dll.config*"
|
||||
do! xcopy_ry ``test.exe.config`` "test--optimize-lib.dll.config"
|
||||
// xcopy /RY "%~dp0test.exe.config" "%cd%\test--optimize-client-of-lib.exe.config*"
|
||||
do! xcopy_ry ``test.exe.config`` "test--optimize-client-of-lib.exe.config"
|
||||
// xcopy /RY "%~dp0test.exe.config" "%cd%\test--optminus--debug.exe.config*"
|
||||
do! xcopy_ry ``test.exe.config`` "test--optminus--debug.exe.config"
|
||||
// xcopy /RY "%~dp0test.exe.config" "%cd%\test--optplus--debug.exe.config*"
|
||||
do! xcopy_ry ``test.exe.config`` "test--optplus--debug.exe.config"
|
||||
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<legacyUnhandledExceptionPolicy enabled="true" />
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="4.3.0.0-4.4.0.0" newVersion="4.4.1.0"/>
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
|
@ -4,7 +4,7 @@
|
|||
// To compile this function we must reference test_lib.dll. In the test (see build.bat) we reference
|
||||
// the _old_ test_lib.dll, which was compiled when referencing a type with one optional static parameter.
|
||||
// The provider is then recompiled to change the type to have two optional static parameters
|
||||
// (analogous to adding a static paramter to a type provider). This
|
||||
// (analogous to adding a static paramter to a provider in FSharp.Data.TypeProviders.dll). This
|
||||
// provider must function correctly in the sense that it is able to resolve
|
||||
// old metadata references that don't give a value to the new optional static parameter.
|
||||
// This is managed by the TP implementation in the F# compiler which fills in the static parameter
|
||||
|
|
|
@ -21,6 +21,89 @@ let requireVSUltimate cfg = attempt {
|
|||
// )
|
||||
}
|
||||
|
||||
module Builtin =
|
||||
|
||||
module EdmxFile =
|
||||
|
||||
[<Test; FSharpSuiteScriptPermutations("typeProviders/builtin/EdmxFile")>]
|
||||
let EdmxFile p = check (attempt {
|
||||
let { Directory = dir; Config = cfg } = testContext ()
|
||||
|
||||
//call %~d0%~p0..\copyFSharpDataTypeProviderDLL.cmd
|
||||
do! CopyFSharpDataTypeProviderDLL.copy cfg dir
|
||||
|
||||
do! SingleTestBuild.singleTestBuild cfg dir p
|
||||
|
||||
do! SingleTestRun.singleTestRun cfg dir p
|
||||
})
|
||||
|
||||
|
||||
module ODataService =
|
||||
|
||||
[<Test; FSharpSuiteScriptPermutations("typeProviders/builtin/ODataService")>]
|
||||
let oDataService p = check (attempt {
|
||||
let { Directory = dir; Config = cfg } = testContext ()
|
||||
|
||||
//call %~d0%~p0..\copyFSharpDataTypeProviderDLL.cmd
|
||||
do! CopyFSharpDataTypeProviderDLL.copy cfg dir
|
||||
|
||||
do! SingleTestBuild.singleTestBuild cfg dir p
|
||||
|
||||
do! SingleTestRun.singleTestRun cfg dir p
|
||||
})
|
||||
|
||||
|
||||
module SqlDataConnection =
|
||||
|
||||
[<Test; FSharpSuiteScriptPermutations("typeProviders/builtin/SqlDataConnection")>]
|
||||
let sqlDataConnection p = check (attempt {
|
||||
let p = FSC_OPT_PLUS_DEBUG
|
||||
let { Directory = dir; Config = cfg } = testContext ()
|
||||
|
||||
let exec p = Command.exec dir cfg.EnvironmentVariables { Output = Inherit; Input = None; } p >> checkResult
|
||||
let fileExists = Commands.fileExists dir >> Option.isSome
|
||||
|
||||
//call %~d0%~p0..\copyFSharpDataTypeProviderDLL.cmd
|
||||
do! CopyFSharpDataTypeProviderDLL.copy cfg dir
|
||||
|
||||
do! SingleTestBuild.singleTestBuild cfg dir p
|
||||
|
||||
// IF /I "%INSTALL_SKU%" NEQ "ULTIMATE" (
|
||||
// echo Test not supported except on Ultimate
|
||||
// exit /b 0
|
||||
// )
|
||||
do! requireVSUltimate cfg
|
||||
|
||||
// IF EXIST test.exe (
|
||||
// echo Running test.exe to warm up SQL
|
||||
// test.exe > nul 2> nul
|
||||
// )
|
||||
do! if fileExists "test.exe"
|
||||
then
|
||||
// echo Running test.exe to warm up SQL
|
||||
// test.exe > nul 2> nul
|
||||
exec ("."/"test.exe") ""
|
||||
else Success ()
|
||||
|
||||
do! SingleTestRun.singleTestRun cfg dir p
|
||||
})
|
||||
|
||||
module WsdlService =
|
||||
|
||||
[<Test; FSharpSuiteScriptPermutations("typeProviders/builtin/WsdlService")>]
|
||||
let wsdlService p = check (attempt {
|
||||
let { Directory = dir; Config = cfg } = testContext ()
|
||||
|
||||
//call %~d0%~p0..\copyFSharpDataTypeProviderDLL.cmd
|
||||
do! CopyFSharpDataTypeProviderDLL.copy cfg dir
|
||||
|
||||
do! SingleTestBuild.singleTestBuild cfg dir p
|
||||
|
||||
do! SingleTestRun.singleTestRun cfg dir p
|
||||
})
|
||||
|
||||
|
||||
|
||||
module DiamondAssembly =
|
||||
|
||||
let build cfg dir = attempt {
|
||||
|
|
|
@ -76,6 +76,17 @@ MT402020 Optimizations\AssemblyBoundary (InlineWithPrivateValuesStruct) --Ha
|
|||
!CURRENTUICULTURE1033 Printing (LazyValues02NetFx4.fsx) -- Testcase not fully loc
|
||||
!CURRENTUICULTURE1033 Printing (LazyValues03NetFx4.fsx) -- Testcase not fully loc
|
||||
CHK Stress (2766.fs) -- failed
|
||||
!CURRENTUICULTURE1033 ..\..\..\testsprivate\fsharpqa\Source\TypeProviders\BuiltIn\EdmxFile (E_StaticParamBlank.fsx) -- Testcase not fully loc
|
||||
!CURRENTUICULTURE1033 TypeProviders\BuiltIn\OdataService\Diagnostics (E_AssemblyIsNotAWebService.fsx) -- Testcase not fully loc
|
||||
!CURRENTUICULTURE1033 TypeProviders\BuiltIn\OdataService\Diagnostics (E_BackslashBackslash.fsx) -- Testcase not fully loc
|
||||
!CURRENTUICULTURE1033 TypeProviders\BuiltIn\OdataService\Diagnostics (E_Dot.fsx) -- Testcase not fully loc
|
||||
!CURRENTUICULTURE1033 TypeProviders\BuiltIn\OdataService\Diagnostics (E_DotDot.fsx) -- Testcase not fully loc
|
||||
!CURRENTUICULTURE1033 TypeProviders\BuiltIn\OdataService\Diagnostics (E_EmptyString.fsx) -- Testcase not fully loc
|
||||
!CURRENTUICULTURE1033 TypeProviders\BuiltIn\OdataService\Diagnostics (E_FsharpFile.fsx) -- Testcase not fully loc
|
||||
!CURRENTUICULTURE1033 TypeProviders\BuiltIn\OdataService\Diagnostics (E_HttpSite.fsx) -- Testcase not fully loc
|
||||
!CURRENTUICULTURE1033 ..\..\..\testsprivate\fsharpqa\Source\TypeProviders\BuiltIn\SqlEntityConnection\Diagnostics (E_LocWarningAndErrorsFromEdmGen.fsx) -- Testcase not fully loc
|
||||
!CURRENTUICULTURE1033 ..\..\..\testsprivate\fsharpqa\Source\TypeProviders\BuiltIn\WsdlService\Diagnostics (E_DotDot.fsx) -- Testcase not fully loc
|
||||
!CURRENTUICULTURE1033 ..\..\..\testsprivate\fsharpqa\Source\TypeProviders\BuiltIn\WsdlService\Diagnostics (E_UriFormatNotSupported.fsx) -- Testcase not fully loc
|
||||
!CURRENTUICULTURE1033 TypeProviders\Misc (E_IQueryableWithLocalSeq01.fs) -- Testcase not fully loc
|
||||
!CURRENTUICULTURE1033 TypeProviders\Misc (E_IQueryableWithLocalSeq02.fs) -- Testcase not fully loc
|
||||
!CURRENTUICULTURE1033 TypeProviders\Misc (E_ManyErrors01.fsx) -- DevDiv:311454
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
// Regression test for DevDiv:257720 - Improve diagnostics for TPs
|
||||
// TODO: Remove hardcoded path
|
||||
|
||||
open Microsoft.FSharp.Data.TypeProviders
|
||||
|
||||
// The type provider 'Microsoft.FSharp.Data.TypeProviders.DesignTime.DataProviders' reported an error: Error: No valid input files specified. Specify either metadata documents or assembly files Microsoft (R) Service Model Metadata Tool [Microsoft (R) Windows (R) Communication Foundation, Version 4.0.30319.17360] Copyright (c) Microsoft Corporation. All rights reserved. If you would like more help, type "svcutil /?"
|
||||
type T1 = ODataService< ServiceUri = @"\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll" >
|
||||
|
||||
//<Expects status="error" span="(7,11)" id="FS3033">The type provider 'Microsoft\.FSharp\.Data\.TypeProviders\.DesignTime\.DataProviders' reported an error: Error reading schema\. Could not find a part of the path '[a-zA-Z]:\\Windows\\Microsoft\.NET\\Framework\\v4\.0\.30319\\mscorlib\.dll\\\$metadata'\.$</Expects>
|
|
@ -0,0 +1,7 @@
|
|||
// Regression test for DevDiv:257720 - Improve diagnostics for TPs
|
||||
// See also DevDiv:316737 (the error message should be '\\' instead of '\')
|
||||
|
||||
open Microsoft.FSharp.Data.TypeProviders
|
||||
type T1 = ODataService< ServiceUri = "\\\\" >
|
||||
|
||||
//<Expects status="error" span="(5,11)" id="FS3033">The type provider 'Microsoft\.FSharp\.Data\.TypeProviders\.DesignTime\.DataProviders' reported an error: Error reading schema\. The UNC path should be of the form \\\\server\\share\.$</Expects>
|
|
@ -0,0 +1,6 @@
|
|||
// Regression test for DevDiv:257720 - Improve diagnostics for TPs
|
||||
|
||||
open Microsoft.FSharp.Data.TypeProviders
|
||||
type T1 = ODataService< ServiceUri = "." >
|
||||
|
||||
//<Expects status="error" span="(4,11)" id="FS3033">The type provider 'Microsoft\.FSharp\.Data\.TypeProviders\.DesignTime\.DataProviders' reported an error: Error reading schema\. Could not find file '.+\$metadata'\.$</Expects>
|
|
@ -0,0 +1,7 @@
|
|||
// Regression test for DevDiv:257720 - Improve diagnostics for TPs
|
||||
// See alse DevDiv:316738
|
||||
|
||||
open Microsoft.FSharp.Data.TypeProviders
|
||||
type T1 = ODataService< ServiceUri = ".." >
|
||||
|
||||
//<Expects status="error" span="(5,11)" id="FS3033">The type provider 'Microsoft\.FSharp\.Data\.TypeProviders\.DesignTime\.DataProviders' reported an error: Error reading schema\. Could not find file '.+\$metadata'\.$</Expects>
|
|
@ -0,0 +1,6 @@
|
|||
// Regression test for DevDiv:257720 - Improve diagnostics for TPs
|
||||
|
||||
open Microsoft.FSharp.Data.TypeProviders
|
||||
type T1 = ODataService< ServiceUri = "" >
|
||||
|
||||
//<Expects status="error" span="(4,11)" id="FS3033">The type provider 'Microsoft\.FSharp\.Data\.TypeProviders\.DesignTime\.DataProviders' reported an error: Error reading schema\. Could not find file '.+\$metadata'\.$</Expects>
|
|
@ -0,0 +1,11 @@
|
|||
// Regression test for DevDiv:257720 - Improve diagnostics for TPs
|
||||
|
||||
#if INTERACTIVE
|
||||
#r "System.ServiceModel"
|
||||
#r "FSharp.Data.TypeProviders"
|
||||
#endif
|
||||
|
||||
open Microsoft.FSharp.Data.TypeProviders
|
||||
type zillowMortgageRate = ODataService< @"https://api.datamarket.azure.com/Zillow/MortgageInformationAPIs/", ForceUpdate=true >
|
||||
|
||||
//<Expects status="error" span="(9,27)" id="FS3033">The type provider 'Microsoft\.FSharp\.Data\.TypeProviders\.DesignTime\.DataProviders' reported an error: The provided ServiceUri is for a data service that supports fixed queries\. The OData type provider does not support such services\.$</Expects>
|
|
@ -0,0 +1,6 @@
|
|||
// Regression test for DevDiv:257720 - Improve diagnostics for TPs
|
||||
|
||||
open Microsoft.FSharp.Data.TypeProviders
|
||||
type T1 = ODataService< ServiceUri = "E_FsharpFile.fsx" > // note: same name as this file.
|
||||
|
||||
//<Expects status="error" span="(4,11)" id="FS3033">The type provider 'Microsoft\.FSharp\.Data\.TypeProviders\.DesignTime\.DataProviders' reported an error: Error reading schema\. Could not find a part of the path '.+E_FsharpFile\.fsx\\\$metadata'\.$</Expects>
|
|
@ -0,0 +1,7 @@
|
|||
// Regression test for DevDiv:257720 - Improve diagnostics for TPs
|
||||
|
||||
open Microsoft.FSharp.Data.TypeProviders
|
||||
|
||||
type T1 = ODataService< ServiceUri = "http://www.bing.com/" >
|
||||
|
||||
//<Expects status="error" span="(5,11)" id="FS3033">The type provider 'Microsoft\.FSharp\.Data\.TypeProviders\.DesignTime\.DataProviders' reported an error: Error reading schema\. The remote server returned an error: \(404\) Not Found\.$</Expects>
|
|
@ -0,0 +1,15 @@
|
|||
// Regression test for DevDiv:257720 - Improve diagnostics for TPs
|
||||
|
||||
#if INTERACTIVE
|
||||
#r "System.Runtime.Serialization"
|
||||
#r "System.ServiceModel"
|
||||
#r "FSharp.Data.TypeProviders"
|
||||
#endif
|
||||
|
||||
open System.Runtime.Serialization
|
||||
open System.ServiceModel
|
||||
open Microsoft.FSharp.Data.TypeProviders
|
||||
|
||||
type T1 = ODataService< ServiceUri = null >
|
||||
|
||||
//<Expects status="error" span="(13,38)" id="FS3045">Invalid static argument to provided type\. Expected an argument of kind 'string'\.$</Expects>
|
|
@ -0,0 +1,6 @@
|
|||
// Regression test for DevDiv:257720 - Improve diagnostics for TPs
|
||||
|
||||
open Microsoft.FSharp.Data.TypeProviders
|
||||
type T1 = ODataService< ServiceUri = "file://qwerty/" >
|
||||
|
||||
//<Expects status="error" span="(4,11)" id="FS3033">The type provider 'Microsoft\.FSharp\.Data\.TypeProviders\.DesignTime\.DataProviders' reported an error: Error reading schema\..+</Expects>
|
|
@ -0,0 +1,11 @@
|
|||
NoMT SOURCE=E_AssemblyIsNotAWebService.fsx SCFLAGS="-r:FSharp.Data.TypeProviders.dll -r:System.ServiceModel.dll" # E_AssemblyIsNotAWebService.fsx
|
||||
NoMT SOURCE=E_BackslashBackslash.fsx SCFLAGS="-r:FSharp.Data.TypeProviders.dll -r:System.ServiceModel.dll" # E_BackslashBackslash.fsx
|
||||
NoMT SOURCE=E_Dot.fsx SCFLAGS="-r:FSharp.Data.TypeProviders.dll -r:System.ServiceModel.dll" # E_Dot.fsx
|
||||
NoMT SOURCE=E_DotDot.fsx SCFLAGS="-r:FSharp.Data.TypeProviders.dll -r:System.ServiceModel.dll" # E_DotDot.fsx
|
||||
NoMT SOURCE=E_EmptyString.fsx SCFLAGS="-r:FSharp.Data.TypeProviders.dll -r:System.ServiceModel.dll" # E_EmptyString.fsx
|
||||
NoMT SOURCE=E_FixedQueryNotSupported.fsx SCFLAGS="-r:FSharp.Data.TypeProviders.dll -r:System.ServiceModel.dll" # E_FixedQueryNotSupported.fsx
|
||||
NoMT SOURCE=E_FsharpFile.fsx SCFLAGS="-r:FSharp.Data.TypeProviders.dll -r:System.ServiceModel.dll" # E_FsharpFile.fsx
|
||||
NoMT SOURCE=E_HttpSite.fsx SCFLAGS="-r:FSharp.Data.TypeProviders.dll -r:System.ServiceModel.dll" # E_HttpSite.fsx
|
||||
NoMT SOURCE=E_NullString.fsx SCFLAGS="-r:FSharp.Data.TypeProviders.dll -r:System.ServiceModel.dll" # E_NullString.fsx
|
||||
Expensive,NoMT SOURCE=E_UriFormatNotSupported.fsx SCFLAGS="-r:FSharp.Data.TypeProviders.dll -r:System.ServiceModel.dll" # E_UriFormatNotSupported.fsx
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
// Verify the DataServiceCollection static param
|
||||
// DataServiceCollection = default (=false)
|
||||
|
||||
type T = Microsoft.FSharp.Data.TypeProviders.ODataService<
|
||||
ServiceUri = "http://services.odata.org/V2/OData/OData.svc/",
|
||||
LocalSchemaFile = "",
|
||||
ForceUpdate = true
|
||||
(* DataServiceCollection = false *) >
|
||||
|
||||
let t = T.GetDataContext()
|
||||
|
||||
let q =
|
||||
query {
|
||||
for l in t.Suppliers do
|
||||
head
|
||||
}
|
||||
|
||||
let w =
|
||||
match q.Products with
|
||||
| :? System.Data.Services.Client.DataServiceCollection<T.ServiceTypes.Product> -> (printf "FAIL: type is a System.Data.Services.Client.DataServiceCollection<T.ServiceTypes.Product>"; 1)
|
||||
| _ -> 0
|
||||
|
||||
exit w
|
|
@ -0,0 +1,23 @@
|
|||
// Verify the DataServiceCollection static param
|
||||
// DataServiceCollection = false
|
||||
|
||||
type T = Microsoft.FSharp.Data.TypeProviders.ODataService<
|
||||
ServiceUri = "http://services.odata.org/V2/OData/OData.svc/",
|
||||
LocalSchemaFile = "",
|
||||
ForceUpdate = true,
|
||||
DataServiceCollection = false >
|
||||
|
||||
let t = T.GetDataContext()
|
||||
|
||||
let q =
|
||||
query {
|
||||
for l in t.Suppliers do
|
||||
head
|
||||
}
|
||||
|
||||
let w =
|
||||
match q.Products with
|
||||
| :? System.Data.Services.Client.DataServiceCollection<T.ServiceTypes.Product> -> (printf "FAIL: type is a System.Data.Services.Client.DataServiceCollection<T.ServiceTypes.Product>"; 1)
|
||||
| _ -> 0
|
||||
|
||||
exit w
|
|
@ -0,0 +1,23 @@
|
|||
// Verify the DataServiceCollection static param
|
||||
// DataServiceCollection = true
|
||||
|
||||
type T = Microsoft.FSharp.Data.TypeProviders.ODataService<
|
||||
ServiceUri = "http://services.odata.org/V2/OData/OData.svc/",
|
||||
LocalSchemaFile = "",
|
||||
ForceUpdate = true,
|
||||
DataServiceCollection = true >
|
||||
|
||||
let t = T.GetDataContext()
|
||||
|
||||
let q =
|
||||
query {
|
||||
for l in t.Suppliers do
|
||||
head
|
||||
}
|
||||
|
||||
let w =
|
||||
match q.Products with
|
||||
| :? System.Data.Services.Client.DataServiceCollection<T.ServiceTypes.Product> -> 0
|
||||
| _ -> (printf "FAIL: type is a System.Data.Services.Client.DataServiceCollection<T.ServiceTypes.Product>"; 1)
|
||||
|
||||
exit w
|
|
@ -0,0 +1,6 @@
|
|||
//Dev11:255207, make sure we give a good error for AzureDataMarket sources that use fixed queries
|
||||
//<Expects status="error" span="(4,10-4,135)" id="FS3033">The type provider 'Microsoft\.FSharp\.Data\.TypeProviders\.DesignTime\.DataProviders' reported an error: The provided ServiceUri is for a data service that supports fixed queries\. The OData type provider does not support such services\.$</Expects>
|
||||
|
||||
type T = Microsoft.FSharp.Data.TypeProviders.ODataService<"https://api.datamarket.azure.com/data.ashx/Zillow/MortgageInformationAPIs">
|
||||
|
||||
exit 1
|
|
@ -0,0 +1,5 @@
|
|||
NoMT SOURCE=E_FixedQuerySource01.fs SCFLAGS="-r:FSharp.Data.TypeProviders.dll --test:ErrorRanges" # E_FixedQuerySource01.fs
|
||||
|
||||
NoMT SOURCE=DataServiceCollection_false.fs SCFLAGS="-r:FSharp.Data.TypeProviders.dll -r:System.Data.Services.dll -r:System.Data.Services.Client.dll" # DataServiceCollection_false.fs
|
||||
NoMT SOURCE=DataServiceCollection_true.fs SCFLAGS="-r:FSharp.Data.TypeProviders.dll -r:System.Data.Services.dll -r:System.Data.Services.Client.dll" # DataServiceCollection_true.fs
|
||||
NoMT SOURCE=DataServiceCollection_default.fs SCFLAGS="-r:FSharp.Data.TypeProviders.dll -r:System.Data.Services.dll -r:System.Data.Services.Client.dll" # DataServiceCollection_default.fs
|
|
@ -241,6 +241,27 @@ Conformance08 Conformance\UnitsOfMeasure\WithOOP
|
|||
|
||||
NoHostedCompiler,TypeProviders01 TypeProviders\Arrays
|
||||
NoHostedCompiler,TypeProviders01 TypeProviders\Attributes
|
||||
NoHostedCompiler,TypeProviders01 ..\..\..\testsprivate\fsharpqa\Source\TypeProviders\BuiltIn\EdmxFile
|
||||
NoHostedCompiler,TypeProviders01 TypeProviders\BuiltIn\OdataService\Diagnostics
|
||||
NoHostedCompiler,TypeProviders01 TypeProviders\BuiltIn\OdataService\StaticParam
|
||||
NoHostedCompiler,TypeProviders01 ..\..\..\testsprivate\fsharpqa\Source\TypeProviders\BuiltIn\SqlDataConnection\FunctionsAndSProc
|
||||
NoHostedCompiler,TypeProviders01 ..\..\..\testsprivate\fsharpqa\Source\TypeProviders\BuiltIn\SqlDataConnection\GeneratedSql
|
||||
NoHostedCompiler,TypeProviders01 ..\..\..\testsprivate\fsharpqa\Source\TypeProviders\BuiltIn\SqlDataConnection\StaticParams
|
||||
NoHostedCompiler,TypeProviders01 ..\..\..\testsprivate\fsharpqa\Source\TypeProviders\BuiltIn\SqlDataConnection\TypeRelocation
|
||||
NoHostedCompiler,TypeProviders01 ..\..\..\testsprivate\fsharpqa\Source\TypeProviders\BuiltIn\SqlEntityConnection\Diagnostics
|
||||
NoHostedCompiler,TypeProviders01 ..\..\..\testsprivate\fsharpqa\Source\TypeProviders\BuiltIn\SqlEntityConnection\GetDataContext
|
||||
|
||||
NoHostedCompiler,TypeProviders02 ..\..\..\testsprivate\fsharpqa\Source\TypeProviders\BuiltIn\SqlEntityConnection\StaticParams
|
||||
NoHostedCompiler,TypeProviders02 ..\..\..\testsprivate\fsharpqa\Source\TypeProviders\BuiltIn\SqlEntityConnection\TypeRelocation
|
||||
NoHostedCompiler,TypeProviders02 ..\..\..\testsprivate\fsharpqa\Source\TypeProviders\BuiltIn\WsdlService\Diagnostics
|
||||
NoHostedCompiler,TypeProviders02 ..\..\..\testsprivate\fsharpqa\Source\TypeProviders\BuiltIn\WsdlService\OutRefParams
|
||||
NoHostedCompiler,TypeProviders02 ..\..\..\testsprivate\fsharpqa\Source\TypeProviders\BuiltIn\WsdlService\Runtime\dev.virtualearth.net
|
||||
NoHostedCompiler,TypeProviders02 ..\..\..\testsprivate\fsharpqa\Source\TypeProviders\BuiltIn\WsdlService\Runtime\webservices.amazon.com
|
||||
NoHostedCompiler,TypeProviders02 ..\..\..\testsprivate\fsharpqa\Source\TypeProviders\BuiltIn\WsdlService\Runtime\www.w3schools.com
|
||||
NoHostedCompiler,TypeProviders02 ..\..\..\testsprivate\fsharpqa\Source\TypeProviders\BuiltIn\WsdlService\Runtime\www.xignite.com
|
||||
NoHostedCompiler,TypeProviders02 ..\..\..\testsprivate\fsharpqa\Source\TypeProviders\BuiltIn\WsdlService\SimpleDataContext
|
||||
|
||||
NoHostedCompiler,TypeProviders03 ..\..\..\testsprivate\fsharpqa\Source\TypeProviders\BuiltIn\WsdlService\StaticParams
|
||||
NoHostedCompiler,TypeProviders03 TypeProviders\Events
|
||||
NoHostedCompiler,TypeProviders03 TypeProviders\Fields\Literals
|
||||
NoHostedCompiler,TypeProviders03 TypeProviders\Generics
|
||||
|
|
|
@ -65,6 +65,9 @@ Core06,CoreQuotes fsharp\core\queriesLeafExpressionConvert
|
|||
Core06 fsharp\core\queriesNullableOperators
|
||||
Core06 fsharp\core\queriesOverIEnumerable
|
||||
Core06 fsharp\core\queriesOverIQueryable
|
||||
Core06 ..\testsprivate\fsharp\core\queriesOverIQueryableLinqToEntities
|
||||
Core06 ..\testsprivate\fsharp\core\queriesOverIQueryableLinqToSql
|
||||
Core06 fsharp\core\queriesOverOData
|
||||
Core06,CoreQuotes fsharp\core\quotes
|
||||
Core06 fsharp\core\quotesDebugInfo
|
||||
Core06 fsharp\core\quotesInMultipleModules
|
||||
|
@ -145,6 +148,12 @@ Samples07 ..\testsprivate\fsharp\samples\XNA\WindowsXNAGame
|
|||
Samples07 ..\testsprivate\fsharp\samples\XNA\XBox360Game
|
||||
|
||||
TypeProviders01 fsharp\typeProviders\helloWorld
|
||||
TypeProviders01 ..\testsprivate\fsharp\typeProviders\builtin\DbmlFile
|
||||
TypeProviders01 fsharp\typeProviders\builtin\EdmxFile
|
||||
TypeProviders01 fsharp\typeProviders\builtin\ODataService
|
||||
TypeProviders01 fsharp\typeProviders\builtin\SqlDataConnection
|
||||
TypeProviders01 fsharp\typeProviders\builtin\SqlEntityConnection
|
||||
TypeProviders01 fsharp\typeProviders\builtin\WsdlService
|
||||
TypeProviders01 fsharp\typeProviders\diamondAssembly
|
||||
TypeProviders01 fsharp\typeProviders\globalNamespace
|
||||
TypeProviders01 fsharp\typeProviders\helloWorldCSharp
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
// OData, meaning Open Data Protocol, is a protocol for transfer of data over the Internet.
|
||||
// Many data providers expose access to their data by publishing an OData web service.
|
||||
// You can access data from any OData source in F# using data types that are automatically
|
||||
// generated by the type provider. For more information, please go to
|
||||
// http://go.microsoft.com/fwlink/?LinkId=229208
|
||||
|
||||
module $safeitemrootname$
|
||||
|
||||
#if INTERACTIVE
|
||||
#r "System.Data.Services.Client"
|
||||
#r "FSharp.Data.TypeProviders"
|
||||
#endif
|
||||
|
||||
open System.Data.Services.Client
|
||||
open Microsoft.FSharp.Data.TypeProviders
|
||||
|
||||
// Consume demographics population and income OData service from Azure Marketplace. For more information, Please go to https://datamarket.azure.com/dataset/c7154924-7cab-47ac-97fb-7671376ff656
|
||||
type Demographics = Microsoft.FSharp.Data.TypeProviders.ODataService<ServiceUri = "https://api.datamarket.azure.com/Esri/KeyUSDemographicsTrial/">
|
||||
let ctx = Demographics.GetDataContext()
|
||||
|
||||
//To sign up for a Azure Marketplace account at https://datamarket.azure.com/account/info
|
||||
ctx.Credentials <- System.Net.NetworkCredential ("<your liveID>", "<your Azure Marketplace Key>")
|
||||
|
||||
let cities = query {
|
||||
for c in ctx.demog1 do
|
||||
where (c.StateName = "Washington")
|
||||
}
|
||||
|
||||
for c in cities do
|
||||
printfn "%A - %A" c.GeographyId c.PerCapitaIncome2010.Value
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<VSTemplate Version="3.0.0" Type="Item" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
|
||||
<TemplateData>
|
||||
<Name Package="{91A04A73-4F2C-4E7C-AD38-C1A68E7DA05C}" ID="5037" />
|
||||
<Description Package="{91A04A73-4F2C-4E7C-AD38-C1A68E7DA05C}" ID="5038" />
|
||||
<Icon Package="{91A04A73-4F2C-4E7C-AD38-C1A68E7DA05C}" ID="4014" />
|
||||
<TemplateID>Microsoft.FSharp.Data.ODataServiceConnection</TemplateID>
|
||||
<ProjectType>FSharp</ProjectType>
|
||||
<RequiredFrameworkVersion>4.0</RequiredFrameworkVersion>
|
||||
<SortOrder>80</SortOrder>
|
||||
<NumberOfParentCategoriesToRollUp>1</NumberOfParentCategoriesToRollUp>
|
||||
<DefaultName>ODataConnection.fs</DefaultName>
|
||||
</TemplateData>
|
||||
<TemplateContent>
|
||||
<References>
|
||||
<Reference>
|
||||
<Assembly>FSharp.Data.TypeProviders</Assembly>
|
||||
</Reference>
|
||||
<Reference>
|
||||
<Assembly>System.Data.Services.Client</Assembly>
|
||||
</Reference>
|
||||
</References>
|
||||
<ProjectItem ReplaceParameters="true" TargetFileName="$fileinputname$.fs">ODataServiceConnection.fs</ProjectItem>
|
||||
</TemplateContent>
|
||||
</VSTemplate>
|
|
@ -0,0 +1,27 @@
|
|||
// The SqlDataConnection (LINQ to SQL) TypeProvider allows you to write code that uses
|
||||
// a live connection to a database. For more information, please go to
|
||||
// http://go.microsoft.com/fwlink/?LinkId=229209
|
||||
|
||||
module $safeitemrootname$
|
||||
|
||||
#if INTERACTIVE
|
||||
#r "System.Data"
|
||||
#r "System.Data.Linq"
|
||||
#r "FSharp.Data.TypeProviders"
|
||||
#endif
|
||||
|
||||
open System.Data
|
||||
open System.Data.Linq
|
||||
open Microsoft.FSharp.Data.TypeProviders
|
||||
|
||||
// You can use Server Explorer to build your ConnectionString.
|
||||
type SqlConnection = Microsoft.FSharp.Data.TypeProviders.SqlDataConnection<ConnectionString = @"Data Source=(LocalDB)\v11.0;Initial Catalog=tempdb;Integrated Security=True">
|
||||
let db = SqlConnection.GetDataContext()
|
||||
|
||||
//let table = query {
|
||||
// for r in db.SomeTable do
|
||||
// select r
|
||||
// }
|
||||
//
|
||||
//for p in table do
|
||||
// printfn "%s" p.SomeProperty
|
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<VSTemplate Version="3.0.0" Type="Item" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
|
||||
<TemplateData>
|
||||
<Name Package="{91A04A73-4F2C-4E7C-AD38-C1A68E7DA05C}" ID="5041" />
|
||||
<Description Package="{91A04A73-4F2C-4E7C-AD38-C1A68E7DA05C}" ID="5042" />
|
||||
<Icon Package="{91A04A73-4F2C-4E7C-AD38-C1A68E7DA05C}" ID="4015" />
|
||||
<TemplateID>Microsoft.FSharp.Data.SQLDataConnection</TemplateID>
|
||||
<ProjectType>FSharp</ProjectType>
|
||||
<RequiredFrameworkVersion>4.0</RequiredFrameworkVersion>
|
||||
<SortOrder>70</SortOrder>
|
||||
<NumberOfParentCategoriesToRollUp>1</NumberOfParentCategoriesToRollUp>
|
||||
<DefaultName>SQLDataConnection.fs</DefaultName>
|
||||
</TemplateData>
|
||||
<TemplateContent>
|
||||
<References>
|
||||
<Reference>
|
||||
<Assembly>FSharp.Data.TypeProviders</Assembly>
|
||||
</Reference>
|
||||
<Reference>
|
||||
<Assembly>System.Data</Assembly>
|
||||
</Reference>
|
||||
<Reference>
|
||||
<Assembly>System.Data.Linq</Assembly>
|
||||
</Reference>
|
||||
</References>
|
||||
<ProjectItem ReplaceParameters="true" TargetFileName="$fileinputname$.fs">SqlDataConnection.fs</ProjectItem>
|
||||
</TemplateContent>
|
||||
</VSTemplate>
|
|
@ -0,0 +1,29 @@
|
|||
// The SqlEntityConnection (Entity Data Model) TypeProvider allows you to write code that uses
|
||||
// a live connection to a database that is represented by the Entity Data Model. For more information,
|
||||
// please go to
|
||||
// http://go.microsoft.com/fwlink/?LinkId=229210
|
||||
|
||||
module $safeitemrootname$
|
||||
|
||||
#if INTERACTIVE
|
||||
#r "System.Data"
|
||||
#r "System.Data.Entity"
|
||||
#r "FSharp.Data.TypeProviders"
|
||||
#endif
|
||||
|
||||
open System.Data
|
||||
open System.Data.Entity
|
||||
open Microsoft.FSharp.Data.TypeProviders
|
||||
|
||||
// You can use Server Explorer to build your ConnectionString.
|
||||
type internal SqlConnection = Microsoft.FSharp.Data.TypeProviders.SqlEntityConnection<ConnectionString = @"Data Source=(LocalDB)\v11.0;Initial Catalog=tempdb;Integrated Security=True">
|
||||
let internal db = SqlConnection.GetDataContext()
|
||||
|
||||
//let internal table = query {
|
||||
// for r in db.SomeTable do
|
||||
// select r
|
||||
// }
|
||||
//
|
||||
//for p in table do
|
||||
// printfn "%s" p.SomeProperty
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<VSTemplate Version="3.0.0" Type="Item" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
|
||||
<TemplateData>
|
||||
<Name Package="{91A04A73-4F2C-4E7C-AD38-C1A68E7DA05C}" ID="5043" />
|
||||
<Description Package="{91A04A73-4F2C-4E7C-AD38-C1A68E7DA05C}" ID="5044" />
|
||||
<Icon Package="{91A04A73-4F2C-4E7C-AD38-C1A68E7DA05C}" ID="4016" />
|
||||
<TemplateID>Microsoft.FSharp.Data.SQLEntityConnectionTypeProvider</TemplateID>
|
||||
<ProjectType>FSharp</ProjectType>
|
||||
<RequiredFrameworkVersion>4.0</RequiredFrameworkVersion>
|
||||
<SortOrder>75</SortOrder>
|
||||
<NumberOfParentCategoriesToRollUp>1</NumberOfParentCategoriesToRollUp>
|
||||
<DefaultName>SQLEntityConnection.fs</DefaultName>
|
||||
</TemplateData>
|
||||
<TemplateContent>
|
||||
<References>
|
||||
<Reference>
|
||||
<Assembly>FSharp.Data.TypeProviders</Assembly>
|
||||
</Reference>
|
||||
<Reference>
|
||||
<Assembly>System.Data</Assembly>
|
||||
</Reference>
|
||||
<Reference>
|
||||
<Assembly>System.Data.Entity</Assembly>
|
||||
</Reference>
|
||||
</References>
|
||||
<ProjectItem ReplaceParameters="true" TargetFileName="$fileinputname$.fs">SQLEntityConnection.fs</ProjectItem>
|
||||
</TemplateContent>
|
||||
</VSTemplate>
|
|
@ -0,0 +1,29 @@
|
|||
// The WsdlService type provider allows you to write code to consume a web service.
|
||||
// For more information, please go to
|
||||
// http://go.microsoft.com/fwlink/?LinkId=229211
|
||||
|
||||
module $safeitemrootname$
|
||||
|
||||
#if INTERACTIVE
|
||||
#r "System.Runtime.Serialization"
|
||||
#r "System.ServiceModel"
|
||||
#r "FSharp.Data.TypeProviders"
|
||||
#endif
|
||||
|
||||
open System.Runtime.Serialization
|
||||
open System.ServiceModel
|
||||
open Microsoft.FSharp.Data.TypeProviders
|
||||
|
||||
// You can sign up for a Bing service developer account at http://msdn.microsoft.com/en-us/library/gg605201.aspx
|
||||
let BING_APP_ID = "<your Bing Maps Developer Key>"
|
||||
|
||||
// Using Bing Map API routing service to calculate the driving distance between two Geolocations. http://www.microsoft.com/maps/developers/mapapps.aspx
|
||||
type RouteService = Microsoft.FSharp.Data.TypeProviders.WsdlService<ServiceUri = "http://dev.virtualearth.net/webservices/v1/routeservice/routeservice.svc?wsdl">
|
||||
type RouteCommon = RouteService.ServiceTypes.dev.virtualearth.net.webservices.v1.common
|
||||
type Route = RouteService.ServiceTypes.dev.virtualearth.net.webservices.v1.route
|
||||
|
||||
let startPoint = Route.Waypoint(Location = RouteCommon.Location(Latitude = 47.64012046, Longitude = -122.1297104))
|
||||
let endPoint = Route.Waypoint(Location = RouteCommon.Location(Latitude = 47.62049103, Longitude = -122.3492355))
|
||||
let routReq1 = new Route.RouteRequest(Waypoints = [|startPoint; endPoint|])
|
||||
routReq1.Credentials <- new RouteCommon.Credentials(ApplicationId = BING_APP_ID)
|
||||
RouteService.GetBasicHttpBinding_IRouteService().CalculateRoute(routReq1).Result.Summary.Distance |> printfn "Driving Distance = %A (miles)"
|
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<VSTemplate Version="3.0.0" Type="Item" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
|
||||
<TemplateData>
|
||||
<Name Package="{91A04A73-4F2C-4E7C-AD38-C1A68E7DA05C}" ID="5045" />
|
||||
<Description Package="{91A04A73-4F2C-4E7C-AD38-C1A68E7DA05C}" ID="5046" />
|
||||
<Icon Package="{91A04A73-4F2C-4E7C-AD38-C1A68E7DA05C}" ID="4014" />
|
||||
<TemplateID>Microsoft.FSharp.Data.WsdlServiceConnection</TemplateID>
|
||||
<ProjectType>FSharp</ProjectType>
|
||||
<RequiredFrameworkVersion>4.0</RequiredFrameworkVersion>
|
||||
<SortOrder>85</SortOrder>
|
||||
<NumberOfParentCategoriesToRollUp>1</NumberOfParentCategoriesToRollUp>
|
||||
<DefaultName>WsdlServiceConnection.fs</DefaultName>
|
||||
</TemplateData>
|
||||
<TemplateContent>
|
||||
<References>
|
||||
<Reference>
|
||||
<Assembly>FSharp.Data.TypeProviders</Assembly>
|
||||
</Reference>
|
||||
<Reference>
|
||||
<Assembly>System.ServiceModel</Assembly>
|
||||
</Reference>
|
||||
<Reference>
|
||||
<Assembly>System.Runtime.Serialization</Assembly>
|
||||
</Reference>
|
||||
</References>
|
||||
<ProjectItem ReplaceParameters="true" TargetFileName="$fileinputname$.fs">WsdlServiceConnection.fs</ProjectItem>
|
||||
</TemplateContent>
|
||||
</VSTemplate>
|
|
@ -601,6 +601,68 @@ module Events =
|
|||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Database access using type providers
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
module DatabaseAccess =
|
||||
|
||||
// The easiest way to access a SQL database from F# is to use F# type providers.
|
||||
// Add references to System.Data, System.Data.Linq, and FSharp.Data.TypeProviders.dll.
|
||||
// You can use Server Explorer to build your ConnectionString.
|
||||
|
||||
(*
|
||||
#r "System.Data"
|
||||
#r "System.Data.Linq"
|
||||
#r "FSharp.Data.TypeProviders"
|
||||
|
||||
open Microsoft.FSharp.Data.TypeProviders
|
||||
|
||||
type SqlConnection = SqlDataConnection<ConnectionString = @"Data Source=.\sqlexpress;Initial Catalog=tempdb;Integrated Security=True">
|
||||
let db = SqlConnection.GetDataContext()
|
||||
|
||||
let table =
|
||||
query { for r in db.Table do
|
||||
select r }
|
||||
*)
|
||||
|
||||
|
||||
// You can also use SqlEntityConnection instead of SqlDataConnection, which accesses the database using Entity Framework.
|
||||
|
||||
()
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// OData access using type providers
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
module OData =
|
||||
|
||||
(*
|
||||
open System.Data.Services.Client
|
||||
open Microsoft.FSharp.Data.TypeProviders
|
||||
|
||||
// Consume demographics population and income OData service from Azure Marketplace.
|
||||
// For more information, see http://go.microsoft.com/fwlink/?LinkId=239712
|
||||
type Demographics = Microsoft.FSharp.Data.TypeProviders.ODataService<ServiceUri = "https://api.datamarket.azure.com/Esri/KeyUSDemographicsTrial/">
|
||||
let ctx = Demographics.GetDataContext()
|
||||
|
||||
// Sign up for a Azure Marketplace account at https://datamarket.azure.com/account/info
|
||||
ctx.Credentials <- System.Net.NetworkCredential ("<your liveID>", "<your Azure Marketplace Key>")
|
||||
|
||||
let cities = query {
|
||||
for c in ctx.demog1 do
|
||||
where (c.StateName = "Washington")
|
||||
}
|
||||
|
||||
for c in cities do
|
||||
printfn "%A - %A" c.GeographyId c.PerCapitaIncome2010.Value
|
||||
*)
|
||||
|
||||
()
|
||||
|
||||
|
||||
|
||||
#if COMPILED
|
||||
module BoilerPlateForForm =
|
||||
|
|
|
@ -37,9 +37,6 @@
|
|||
</FsSrGen>
|
||||
<Compile Include="ProvidedTypes.fsi" />
|
||||
<Compile Include="ProvidedTypes.fs" />
|
||||
<FsSrGen Include="FSData.txt" />
|
||||
<Compile Include="TypeProviderEmit.fsi" />
|
||||
<Compile Include="TypeProviderEmit.fs" />
|
||||
<Compile Include="DummyProviderForLanguageServiceTesting.fs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(FSharpSourcesRoot)\FSharpSource.targets" />
|
||||
|
|
|
@ -32,6 +32,9 @@
|
|||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<FsSrGen Include="$(FSharpSourcesRoot)\fsharp\FSharp.Data.TypeProviders\FSData.txt" >
|
||||
<Link>FSData.txt</Link>
|
||||
</FsSrGen>
|
||||
<Compile Include="EmptyAssembly.fs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(FSharpSourcesRoot)\FSharpSource.targets" />
|
||||
|
|
|
@ -175,6 +175,105 @@ type UsingMSBuild() =
|
|||
let fsi = publicTypesInAsm @"FSharp.VS.FSI.dll"
|
||||
Assert.AreEqual(1, fsi)
|
||||
|
||||
[<Test>]
|
||||
member public this.``PublicSurfaceArea.DotNetReflectionAndTypeProviders``() =
|
||||
let tp = publicTypesInAsm @"FSharp.Data.TypeProviders.dll"
|
||||
Assert.AreEqual(1, tp) // the 'DataProviders' type that is decorated with [<TypeProvider>] must be public\
|
||||
let curDir = (new Uri(Assembly.GetExecutingAssembly().EscapedCodeBase)).LocalPath |> Path.GetDirectoryName
|
||||
let script = """
|
||||
open Microsoft.FSharp.Core.CompilerServices
|
||||
|
||||
let cfg = new TypeProviderConfig(fun _ -> true)
|
||||
cfg.IsInvalidationSupported <- false
|
||||
cfg.IsHostedExecution <- false
|
||||
cfg.ReferencedAssemblies <- Array.create 0 ""
|
||||
cfg.ResolutionFolder <- @"c:\"
|
||||
cfg.RuntimeAssembly <- ""
|
||||
cfg.TemporaryFolder <- ""
|
||||
|
||||
let tp = new Microsoft.FSharp.Data.TypeProviders.DesignTime.DataProviders(cfg)
|
||||
let ipn = tp :> IProvidedNamespace
|
||||
let itp = tp :> ITypeProvider
|
||||
|
||||
let types =
|
||||
[ "ODataService"
|
||||
"WsdlService"
|
||||
"SqlDataConnection"
|
||||
"SqlEntityConnection"
|
||||
"DbmlFile"
|
||||
"EdmxFile"
|
||||
]
|
||||
|
||||
for p in types do
|
||||
printfn "%s" p
|
||||
let pType = ipn.ResolveTypeName(p)
|
||||
let odataStaticArgs = itp.GetStaticParameters(pType)
|
||||
for sa in odataStaticArgs do
|
||||
printfn " %s:%s" sa.Name sa.ParameterType.Name
|
||||
"""
|
||||
let expected = """ODataService
|
||||
ServiceUri:String
|
||||
LocalSchemaFile:String
|
||||
ForceUpdate:Boolean
|
||||
ResolutionFolder:String
|
||||
DataServiceCollection:Boolean
|
||||
WsdlService
|
||||
ServiceUri:String
|
||||
LocalSchemaFile:String
|
||||
ForceUpdate:Boolean
|
||||
ResolutionFolder:String
|
||||
MessageContract:Boolean
|
||||
EnableDataBinding:Boolean
|
||||
Serializable:Boolean
|
||||
Async:Boolean
|
||||
CollectionType:String
|
||||
SqlDataConnection
|
||||
ConnectionString:String
|
||||
ConnectionStringName:String
|
||||
LocalSchemaFile:String
|
||||
ForceUpdate:Boolean
|
||||
Pluralize:Boolean
|
||||
Views:Boolean
|
||||
Functions:Boolean
|
||||
ConfigFile:String
|
||||
DataDirectory:String
|
||||
ResolutionFolder:String
|
||||
StoredProcedures:Boolean
|
||||
Timeout:Int32
|
||||
ContextTypeName:String
|
||||
Serializable:Boolean
|
||||
SqlEntityConnection
|
||||
ConnectionString:String
|
||||
ConnectionStringName:String
|
||||
LocalSchemaFile:String
|
||||
Provider:String
|
||||
EntityContainer:String
|
||||
ConfigFile:String
|
||||
DataDirectory:String
|
||||
ResolutionFolder:String
|
||||
ForceUpdate:Boolean
|
||||
Pluralize:Boolean
|
||||
SuppressForeignKeyProperties:Boolean
|
||||
DbmlFile
|
||||
File:String
|
||||
ResolutionFolder:String
|
||||
ContextTypeName:String
|
||||
Serializable:Boolean
|
||||
EdmxFile
|
||||
File:String
|
||||
ResolutionFolder:String
|
||||
"""
|
||||
File.WriteAllText(Path.Combine(curDir, "tmp.fsx"), script)
|
||||
let psi = System.Diagnostics.ProcessStartInfo(Path.Combine(curDir, "fsi.exe"), "-r:FSharp.Data.TypeProviders.dll tmp.fsx")
|
||||
psi.WorkingDirectory <- curDir
|
||||
psi.RedirectStandardOutput <- true
|
||||
psi.UseShellExecute <- false
|
||||
let p = System.Diagnostics.Process.Start(psi)
|
||||
let out = p.StandardOutput.ReadToEnd()
|
||||
p.WaitForExit()
|
||||
let out = out.Replace("\r\n", "\n")
|
||||
let expected = expected.Replace("\r\n", "\n")
|
||||
Assert.AreEqual(expected, out)
|
||||
|
||||
[<Test>]
|
||||
member public this.``ReconcileErrors.Test1``() =
|
||||
|
|
|
@ -0,0 +1,374 @@
|
|||
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
namespace Tests.DataTypeProviders
|
||||
|
||||
open System.IO
|
||||
open NUnit.Framework
|
||||
|
||||
module U = Microsoft.FSharp.Data.TypeProviders.DesignTime.Utilities
|
||||
module CF = Microsoft.FSharp.Data.TypeProviders.DesignTime.ConfigFiles
|
||||
module Util = Microsoft.FSharp.Data.TypeProviders.Utility.Util
|
||||
|
||||
[<TestFixture>]
|
||||
type ImplDetails() =
|
||||
|
||||
[<Test>]
|
||||
member public this.``SanitizeFileName``() =
|
||||
let tests =
|
||||
[
|
||||
"NorthWind", "Northwind"
|
||||
"1NorthWind", "_1northwind"
|
||||
"north (wind)", "North_wind_"
|
||||
"north wind", "NorthWind"
|
||||
"North(Wind)", "North_wind_"
|
||||
"(northwind)", "_northwind_"
|
||||
"^#$&5wind", "____5wind"
|
||||
]
|
||||
for (source, expected) in tests do
|
||||
let actual = U.sanitizeDataContextFileName source
|
||||
printfn "source: %s, expected %s, actual %s" source expected actual
|
||||
Assert.AreEqual(expected, actual)
|
||||
|
||||
[<Test>]
|
||||
member public this.``ParseCodegenToolErrors.RecognizeErrorLine``() =
|
||||
let tests =
|
||||
[
|
||||
// known localization related items
|
||||
[||], [|"error 7015: Parameter switch 'targetversion' is not valid."|], ["error 7015: Parameter switch 'targetversion' is not valid."]
|
||||
[||], [|"!stsMv!error 7015: !3eCOn!Parameter switch 'L' is not valid. 表c?字㌍!"|], ["!stsMv!error 7015: !3eCOn!Parameter switch 'L' is not valid. 表c?字㌍!"]
|
||||
[||], [|"에러 7015: Parameter switch 'targetversion' is not valid." |], ["에러 7015: Parameter switch 'targetversion' is not valid."]
|
||||
[||], [|"!pM1WE!Error: 表c!!i2yz2!Cannot read .. 表c?!"|], ["!pM1WE!Error: 表c!!i2yz2!Cannot read .. 表c?!"]
|
||||
[||], [|"エラー: . を読み取れません"|], ["エラー: . を読み取れません"]
|
||||
// regular
|
||||
[||], [|"Error: Cannot obtain Metadata from http://bing.com/" |], ["Error: Cannot obtain Metadata from http://bing.com/"]
|
||||
]
|
||||
|
||||
for (stdin, stderr, expectedErrs) in tests do
|
||||
try
|
||||
U.formatErr stdin stderr
|
||||
Assert.Fail("Should throw")
|
||||
with
|
||||
| :? System.AggregateException as ae ->
|
||||
let actualErrs = ae.InnerExceptions |> Seq.map (fun e -> e.Message) |> set
|
||||
let expectedErrs = set expectedErrs
|
||||
printfn "Expected: %A" expectedErrs
|
||||
printfn "Actual: %A" actualErrs
|
||||
Assert.IsTrue(actualErrs.Count = expectedErrs.Count)
|
||||
Assert.IsTrue((actualErrs - expectedErrs).Count = 0)
|
||||
| e -> sprintf "unexpected exception %A" e |> Assert.Fail
|
||||
|
||||
[<Test>]
|
||||
member public this.``ParseCodegenToolErrors.FalsePositives``() =
|
||||
let stdin =
|
||||
[|
|
||||
"Attempting to download metadata from 'http://bing.com/' using WS-Metadata Exchange or DISCO."
|
||||
"Microsoft (R) Service Model Metadata Tool"
|
||||
"[Microsoft (R) Windows (R) Communication Foundation, Version 4.0.30319.17360]"
|
||||
"Copyright (c) Microsoft Corporation. All rights reserved."
|
||||
""
|
||||
""
|
||||
""
|
||||
"If you would like more help, type \"svcutil /?\""
|
||||
|]
|
||||
let stderr =
|
||||
[|
|
||||
"Error: Cannot obtain Metadata from http://bing.com/ "
|
||||
""
|
||||
"If this is a Windows (R) Communication Foundation service to which you have access, please check that you have enabled metadata publishing at the specified address. For help enabling metadata publishing, please refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455."
|
||||
""
|
||||
"WS-Metadata Exchange Error"
|
||||
" URI: http://bing.com/"
|
||||
""
|
||||
" Metadata contains a reference that cannot be resolved: 'http://bing.com/'."
|
||||
""
|
||||
" The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 194 bytes of the response were: '<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html lang=\"en\" xml:lang=\"en\" xmlns=\"http://www.w3.org/1999/xhtml\"><head>'."
|
||||
""
|
||||
"HTTP GET Error"
|
||||
" URI: http://bing.com/"
|
||||
""
|
||||
" The HTML document does not contain Web service discovery information."
|
||||
""
|
||||
|]
|
||||
try
|
||||
U.formatErr stdin stderr
|
||||
Assert.Fail("Should throw")
|
||||
with
|
||||
| :? System.AggregateException as ae ->
|
||||
printfn "%A" ae
|
||||
Assert.IsTrue (ae.InnerExceptions.Count = 1, "One exception expected")
|
||||
Assert.IsTrue(ae.InnerExceptions.[0].Message = "Error: Cannot obtain Metadata from http://bing.com/")
|
||||
| e -> sprintf "unexpected exception %A" e |> Assert.Fail
|
||||
|
||||
[<Test>]
|
||||
member public this.``PathResolutionUtils.MakeAbsolute``() =
|
||||
use d = Util.TemporaryDirectory()
|
||||
let pru = Microsoft.FSharp.Data.TypeProviders.DesignTime.PathResolutionUtils(d.Path)
|
||||
|
||||
// NullOrEmpty
|
||||
Assert.AreEqual(null, pru.MakeAbsolute(d.Path, null), "null expected")
|
||||
Assert.AreEqual("", pru.MakeAbsolute(d.Path, ""), "empty string expected")
|
||||
|
||||
// rooted path
|
||||
let subFolder = Path.Combine(d.Path, "Subfolder")
|
||||
Assert.AreEqual(subFolder, pru.MakeAbsolute(d.Path, subFolder), "absolute path should be returned as is")
|
||||
|
||||
// relative path
|
||||
Assert.AreEqual(subFolder, pru.MakeAbsolute(d.Path, "Subfolder"), "relative path should be converted to absolute")
|
||||
|
||||
[<Test>]
|
||||
member public this.``PathResolutionUtils.GetAbsoluteDesignTimeDirectory``() =
|
||||
use d = Util.TemporaryDirectory()
|
||||
let pru = Microsoft.FSharp.Data.TypeProviders.DesignTime.PathResolutionUtils(d.Path)
|
||||
|
||||
// absolute path
|
||||
Assert.AreEqual(d.Path, pru.GetAbsoluteDesignTimeDirectory(d.Path), "absolute path should be returned as is")
|
||||
|
||||
// relative path
|
||||
let name = "Subfolder"
|
||||
let expected = Path.Combine(d.Path, name)
|
||||
Assert.AreEqual(expected, pru.GetAbsoluteDesignTimeDirectory(name), "relative path should be converted to absolute")
|
||||
|
||||
[<Test>]
|
||||
member public this.``PathResolutionUtils.GetConfigFileWatchSpec.ResolvedPathsInSpecs``() =
|
||||
let (++) a b = Path.Combine(a, b)
|
||||
(
|
||||
use d = Util.TemporaryDirectory()
|
||||
let pru = Microsoft.FSharp.Data.TypeProviders.DesignTime.PathResolutionUtils(d.Path)
|
||||
|
||||
// no connection string name set
|
||||
pru.GetConfigFileWatchSpec(null, null, null)
|
||||
|> List.length
|
||||
|> fun l -> Assert.AreEqual(0, l, "Connection string name not set => not watch specs expected")
|
||||
)
|
||||
|
||||
let check caption resFolder configFile f =
|
||||
printfn "Running %s" caption
|
||||
use d = Util.TemporaryDirectory()
|
||||
let pru = Microsoft.FSharp.Data.TypeProviders.DesignTime.PathResolutionUtils(d.Path)
|
||||
match pru.GetConfigFileWatchSpec(resFolder, configFile, "Name") with
|
||||
| [r] -> f (d, r)
|
||||
| x -> sprintf "%s - unexpected result %A" caption x |> Assert.Fail
|
||||
printfn "Finished %s" caption
|
||||
|
||||
|
||||
// NOT FOUND CASES:
|
||||
// no custom config file name set - file name should be d.Path + "*.webconfig"
|
||||
check "#1" null null <|
|
||||
fun (d, r) ->
|
||||
let expectedPath = d.Path ++ "*.config"
|
||||
Assert.AreEqual(expectedPath, r.Path)
|
||||
|
||||
// no custom config file name set + resolutionfolder is specified- result file name should be d.Path + resolutionFolder + "*.webconfig"
|
||||
check "#2" "Subfolder" null <|
|
||||
fun (d, r) ->
|
||||
let expectedPath = d.Path ++ "Subfolder" ++"*.config"
|
||||
Assert.AreEqual(expectedPath, r.Path)
|
||||
|
||||
// no custom config file name set + absolute resolutionfolder is specified- result file name should be resolutionFolder + "*.webconfig"
|
||||
(
|
||||
use root = Util.TemporaryDirectory()
|
||||
let absResolutionFolder = root.Path ++ "Subfolder2"
|
||||
check "#3" absResolutionFolder null <|
|
||||
fun (_, r) ->
|
||||
let expectedPath = absResolutionFolder ++"*.config"
|
||||
Assert.AreEqual(expectedPath, r.Path)
|
||||
)
|
||||
|
||||
// absolute custom config file name set - result file name should be absolute
|
||||
(
|
||||
use root = Util.TemporaryDirectory()
|
||||
let absoluteConfigPath = root.Path ++ "somefolder" ++ "custom.config"
|
||||
check "#4" null absoluteConfigPath <|
|
||||
fun (_, r) -> Assert.AreEqual(absoluteConfigPath, r.Path)
|
||||
)
|
||||
|
||||
// absolute custom config file name set - result file name should be absolute
|
||||
(
|
||||
use root = Util.TemporaryDirectory()
|
||||
let absoluteConfigPath = root.Path ++ "somefolder" ++ "custom.config"
|
||||
check "#4.1" "some name" absoluteConfigPath <|
|
||||
fun (_, r) -> Assert.AreEqual(absoluteConfigPath, r.Path)
|
||||
)
|
||||
|
||||
// resolutionFolder + relative custom config file name set - result file name should be d.Path + resFolder + config file name
|
||||
check "#5" "Subfolder" "custom.config" <|
|
||||
fun (d, r) ->
|
||||
let expected = d.Path ++ "Subfolder" ++ "custom.config"
|
||||
Assert.AreEqual(expected, r.Path)
|
||||
|
||||
// relative custom config file name set - result file name should be d.Path + config file name
|
||||
check "#6" null "custom.config" <|
|
||||
fun (d, r) ->
|
||||
let expected = d.Path ++ "custom.config"
|
||||
Assert.AreEqual(expected, r.Path)
|
||||
|
||||
// resolution folder is absolute and config filename is relative - result file name should be resolution folder + config file name
|
||||
(
|
||||
use root = Util.TemporaryDirectory()
|
||||
check "#7" root.Path "custom.config" <|
|
||||
fun (_, r) ->
|
||||
let expected = root.Path ++ "custom.config"
|
||||
Assert.AreEqual(expected, r.Path)
|
||||
)
|
||||
|
||||
// FOUND cases
|
||||
let checkFound caption resFolder configFile actualConfigPath =
|
||||
printfn "Running %s" caption
|
||||
use d = Util.TemporaryDirectory()
|
||||
let configPath = actualConfigPath d.Path
|
||||
|
||||
Directory.CreateDirectory(Path.GetDirectoryName configPath)
|
||||
|> ignore
|
||||
|
||||
File.WriteAllText(configPath, "")
|
||||
let pru = Microsoft.FSharp.Data.TypeProviders.DesignTime.PathResolutionUtils(d.Path)
|
||||
match pru.GetConfigFileWatchSpec(resFolder, configFile, "Name") with
|
||||
| [r] -> Assert.AreEqual(configPath, r.Path)
|
||||
| x -> sprintf "%s, unexpected result %A" caption x |> Assert.Fail
|
||||
let di = DirectoryInfo d.Path
|
||||
for subdir in di.GetDirectories() do
|
||||
subdir.Delete(true)
|
||||
|
||||
printfn "Finished %s" caption
|
||||
|
||||
// no res folder\no custom config
|
||||
checkFound "#8" null null <| fun d -> d ++ "app.config"
|
||||
// relative res folder\no custom config
|
||||
checkFound "#9" "subfolder" null <| fun d -> d ++ "subfolder\\web.config"
|
||||
// abs res folder\no custom config
|
||||
(
|
||||
use root = Util.TemporaryDirectory()
|
||||
checkFound "#10" root.Path null <| fun _ -> root.Path ++ "app.config"
|
||||
)
|
||||
|
||||
// no res folder\rel custom config
|
||||
(
|
||||
use root = Util.TemporaryDirectory()
|
||||
let custom = root.Path ++ "custom.config"
|
||||
checkFound "#11" null custom <| fun _ -> custom
|
||||
)
|
||||
|
||||
// no res folder\abs custom config
|
||||
(
|
||||
use root = Util.TemporaryDirectory()
|
||||
let custom = root.Path ++ "custom.config"
|
||||
checkFound "#11" null custom <| fun _ -> custom
|
||||
)
|
||||
|
||||
// relative res folder\relative custom config
|
||||
checkFound "#12" "custom" @"sub\custom.config" <| fun d -> d ++ "custom" ++ @"sub\custom.config"
|
||||
|
||||
// relative res folder\absolute custom config
|
||||
(
|
||||
use root = Util.TemporaryDirectory()
|
||||
let custom = root.Path ++ "custom.config"
|
||||
checkFound "#13" "custom" custom <| fun _ -> custom
|
||||
)
|
||||
|
||||
// abs res folder\absolute custom config
|
||||
(
|
||||
use resFolder = Util.TemporaryDirectory()
|
||||
use configFolder = Util.TemporaryDirectory()
|
||||
let custom = configFolder.Path ++ "custom.config"
|
||||
checkFound "#14" resFolder.Path custom <| fun _ -> custom
|
||||
)
|
||||
|
||||
[<Test>]
|
||||
member public this.``ConfigFiles.findConfigFile``() =
|
||||
let withTempFile name f =
|
||||
use d = Util.TemporaryDirectory()
|
||||
File.WriteAllText(Path.Combine(d.Path, name), "content")
|
||||
f d.Path
|
||||
let checkStandard name =
|
||||
withTempFile name <| fun folder ->
|
||||
printfn "folder %s" folder
|
||||
let r = CF.findConfigFile(folder, null)
|
||||
match r with
|
||||
| CF.StandardFound f -> Assert.IsTrue(Path.GetFileName(f) = name)
|
||||
| r -> sprintf "findConfigFile: StandardFound (%s) unexpected result when: %+A" name r |> Assert.Fail
|
||||
// check if app.config can be found
|
||||
checkStandard "app.config"
|
||||
// check if web.config can be found
|
||||
checkStandard "web.config"
|
||||
|
||||
// check if proper result is returned is failure case when custom configuration file is not specified
|
||||
(
|
||||
use td = Util.TemporaryDirectory()
|
||||
let r = CF.findConfigFile(td.Path, null)
|
||||
match r with
|
||||
| CF.StandardNotFound -> ()
|
||||
| r -> sprintf "findConfigFile: StandardNotFound - unexpected result: %+A" r |> Assert.Fail
|
||||
)
|
||||
|
||||
// check if custom.config can be found
|
||||
let customConfigName = "custom.config"
|
||||
withTempFile customConfigName <| fun folder ->
|
||||
let r = CF.findConfigFile(folder, Path.Combine(folder, customConfigName))
|
||||
match r with
|
||||
| CF.CustomFound f -> Assert.IsTrue(Path.GetFileName(f) = customConfigName)
|
||||
| r -> sprintf "findConfigFile: CustomFound (%s) unexpected result when: %+A" customConfigName r |> Assert.Fail
|
||||
|
||||
// check if proper result is returned is failure case when custom configuration file is specified
|
||||
(
|
||||
use td = Util.TemporaryDirectory()
|
||||
let r = CF.findConfigFile(td.Path, Path.Combine(td.Path, customConfigName))
|
||||
match r with
|
||||
| CF.CustomNotFound _ -> ()
|
||||
| r -> sprintf "findConfigFile: CustomNotFound - unexpected result: %+A" r |> Assert.Fail
|
||||
)
|
||||
|
||||
[<Test>]
|
||||
member public this.``ConfigFiles.tryReadConnectionString``() =
|
||||
// 1. no file found
|
||||
(
|
||||
use dir = Util.TemporaryDirectory()
|
||||
let r = CF.tryReadConnectionString(Path.Combine(dir.Path, "app.config"), "F")
|
||||
match r with
|
||||
| CF.ConnectionStringReadResult.Error (:? FileNotFoundException) -> ()
|
||||
| r -> sprintf "no file found: unexpected result - %+A" r |> Assert.Fail
|
||||
)
|
||||
|
||||
// 2. file exists but corrupted
|
||||
(
|
||||
use f = Util.TemporaryFile "app.config"
|
||||
File.WriteAllText(f.Path, "some text")
|
||||
let r = CF.tryReadConnectionString(f.Path, "F")
|
||||
match r with
|
||||
| CF.ConnectionStringReadResult.Error e -> printfn "%A" e
|
||||
| r -> sprintf "file exists but corrupted: unexpected result - %+A" r |> Assert.Fail
|
||||
)
|
||||
|
||||
// 3. file is correct but doesn't contain connection string
|
||||
(
|
||||
let configText = """
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
|
||||
</startup>
|
||||
</configuration>"""
|
||||
use f = Util.TemporaryFile "app.config"
|
||||
File.WriteAllText(f.Path, configText.Trim())
|
||||
let r = CF.tryReadConnectionString(f.Path, "F")
|
||||
match r with
|
||||
| CF.ConnectionStringReadResult.NotFound -> ()
|
||||
| r -> sprintf "file is correct but doesn't contain connection string: unexpected result - %+A" r |> Assert.Fail
|
||||
)
|
||||
|
||||
// 4. file is correct and it contains connection string
|
||||
(
|
||||
let configText = """
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<connectionStrings>
|
||||
<add name="S" connectionString="string"/>
|
||||
</connectionStrings>
|
||||
</configuration>"""
|
||||
use f = Util.TemporaryFile "app.config"
|
||||
File.WriteAllText(f.Path, configText.Trim())
|
||||
let r = CF.tryReadConnectionString(f.Path, "S")
|
||||
match r with
|
||||
| CF.ConnectionStringReadResult.Ok s -> Assert.AreEqual("string", s.ConnectionString)
|
||||
| r -> sprintf "file is correct but doesn't contain connection string: unexpected result - %+A" r |> Assert.Fail
|
||||
|
||||
)
|
|
@ -35,6 +35,7 @@
|
|||
<Compile Include="TestLib.ProjectSystem.fs" />
|
||||
<Compile Include="Tests.InternalCollections.fs" />
|
||||
<Compile Include="Tests.Build.fs" />
|
||||
<Compile Include="Tests.TypeProvidersImpl.fs" />
|
||||
<Compile Include="Tests.BaseLine.fs" />
|
||||
<Compile Include="Tests.TaskReporter.fs" />
|
||||
<Compile Include="Tests.Watson.fs" />
|
||||
|
@ -136,6 +137,11 @@
|
|||
<Project>{702a7979-bcf9-4c41-853e-3adfc9897890}</Project>
|
||||
<Private>True</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="$(FSharpSourcesRoot)\fsharp\FSharp.Data.TypeProviders\FSharp.Data.TypeProviders.fsproj">
|
||||
<Project>{cb7d20c4-6506-406d-9144-5342c3595f03}</Project>
|
||||
<Name>FSharp.Data.TypeProviders</Name>
|
||||
<Private>True</Private>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="$(FSharpSourcesRoot)\fsharp\FSharp.LanguageService.Compiler\FSharp.LanguageService.Compiler.fsproj">
|
||||
<Name>FSharp.LanguageService.Compiler</Name>
|
||||
<Project>{a437a6ec-5323-47c2-8f86-e2cac54ff152}</Project>
|
||||
|
|
Загрузка…
Ссылка в новой задаче