-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split TP into separate design time and runtime assemblies
- Loading branch information
Sam Hanes
committed
Oct 25, 2018
1 parent
4bf0a0a
commit 1421c08
Showing
46 changed files
with
642 additions
and
499 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Auto-Generated by FAKE; do not edit | ||
namespace System | ||
open System.Reflection | ||
open System.Runtime.CompilerServices | ||
|
||
[<assembly: AssemblyTitleAttribute("SqlClient")>] | ||
[<assembly: AssemblyProductAttribute("FSharp.Data.SqlClient")>] | ||
[<assembly: AssemblyDescriptionAttribute("SqlClient F# type providers")>] | ||
[<assembly: AssemblyVersionAttribute("1.8.6")>] | ||
[<assembly: AssemblyFileVersionAttribute("1.8.6")>] | ||
[<assembly: InternalsVisibleToAttribute("SqlClient.Tests")>] | ||
do () | ||
|
||
module internal AssemblyVersionInformation = | ||
let [<Literal>] AssemblyTitle = "SqlClient" | ||
let [<Literal>] AssemblyProduct = "FSharp.Data.SqlClient" | ||
let [<Literal>] AssemblyDescription = "SqlClient F# type providers" | ||
let [<Literal>] AssemblyVersion = "1.8.6" | ||
let [<Literal>] AssemblyFileVersion = "1.8.6" | ||
let [<Literal>] InternalsVisibleTo = "SqlClient.Tests" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
namespace FSharp.Data.SqlClient | ||
|
||
open System.Configuration | ||
open System.IO | ||
open System | ||
open System.Collections.Generic | ||
open System.Diagnostics | ||
|
||
[<CompilerMessageAttribute("This API supports the FSharp.Data.SqlClient infrastructure and is not intended to be used directly from your code.", 101, IsHidden = true)>] | ||
type internal DesignTimeConnectionString = | ||
| Literal of string | ||
| NameInConfig of name: string * value: string * provider: string | ||
|
||
static member Parse(s: string, resolutionFolder, fileName) = | ||
match s.Trim().Split([|'='|], 2, StringSplitOptions.RemoveEmptyEntries) with | ||
| [| "" |] -> invalidArg "ConnectionStringOrName" "Value is empty!" | ||
| [| prefix; tail |] when prefix.Trim().ToLower() = "name" -> | ||
let name = tail.Trim() | ||
let value, provider = DesignTimeConnectionString.ReadFromConfig( name, resolutionFolder, fileName) | ||
NameInConfig( name, value, provider) | ||
| _ -> | ||
Literal s | ||
|
||
static member ReadFromConfig(name, resolutionFolder, fileName) = | ||
let configFilename = | ||
if fileName <> "" | ||
then | ||
let path = Path.Combine(resolutionFolder, fileName) | ||
if not <| File.Exists path | ||
then raise <| FileNotFoundException( sprintf "Could not find config file '%s'." path) | ||
else path | ||
else | ||
let appConfig = Path.Combine(resolutionFolder, "app.config") | ||
let webConfig = Path.Combine(resolutionFolder, "web.config") | ||
|
||
if File.Exists appConfig then appConfig | ||
elif File.Exists webConfig then webConfig | ||
else failwithf "Cannot find either app.config or web.config." | ||
|
||
let map = ExeConfigurationFileMap() | ||
map.ExeConfigFilename <- configFilename | ||
let configSection = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None).ConnectionStrings.ConnectionStrings | ||
match configSection, lazy configSection.[name] with | ||
| null, _ | _, Lazy null -> raise <| KeyNotFoundException(message = sprintf "Cannot find name %s in <connectionStrings> section of %s file." name configFilename) | ||
| _, Lazy x -> | ||
let providerName = if String.IsNullOrEmpty x.ProviderName then "System.Data.SqlClient" else x.ProviderName | ||
x.ConnectionString, providerName | ||
|
||
member this.Value = | ||
match this with | ||
| Literal value -> value | ||
| NameInConfig(_, value, _) -> value | ||
|
||
member this.RunTimeValueExpr isHostedExecution = | ||
match this with | ||
| Literal value -> <@@ value @@> | ||
| NameInConfig(name, value, _) -> | ||
<@@ | ||
let hostProcess = Process.GetCurrentProcess().ProcessName.ToUpper() | ||
if isHostedExecution | ||
|| (Environment.Is64BitProcess && hostProcess = "FSIANYCPU") | ||
|| (not Environment.Is64BitProcess && hostProcess = "FSI") | ||
then | ||
value | ||
else | ||
let section = ConfigurationManager.ConnectionStrings.[name] | ||
if section = null | ||
then raise <| KeyNotFoundException(message = sprintf "Cannot find name %s in <connectionStrings> section of config file." name) | ||
else section.ConnectionString | ||
@@> | ||
|
||
member this.IsDefinedByLiteral = match this with | Literal _ -> true | _ -> false |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.