Skip to content

Commit

Permalink
Converts FrameworkName to FrameworkIdentifier
Browse files Browse the repository at this point in the history
  • Loading branch information
mrinaldi committed Sep 19, 2015
1 parent 676a2e5 commit 2019f91
Showing 1 changed file with 87 additions and 1 deletion.
88 changes: 87 additions & 1 deletion src/Paket.Core/FrameworkHandling.fs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
namespace Paket
namespace Paket

open System.IO
open System
open System.Runtime.Versioning

[<RequireQualifiedAccess>]
/// The Framework version.
Expand Down Expand Up @@ -141,6 +142,91 @@ type FrameworkIdentifier =
| WindowsPhoneApp _ -> [ WindowsPhoneApp "v8.1" ]
| WindowsPhoneSilverlight _ -> [ WindowsPhoneSilverlight "v8.1" ]

module FrameworkConversion =
let version (input: FrameworkName) =
sprintf "v%O" input.Version

let (|DotNetFramework|_|) (input: FrameworkName) =
match input.Identifier with
| ".NETFramework" -> Some (version input,input.Profile)
| _ -> None
let (|DNX|_|) (input: FrameworkName) =
match input.Identifier with
| "DNX" -> Some (version input)
| _ -> None
let (|DNXCore|_|) (input: FrameworkName) =
match input.Identifier with
| "DNXCore" -> Some (version input)
| _ -> None
let (|Windows|_|) (input: FrameworkName) =
match input.Identifier with
| ".NETCore" -> Some (version input)
| _ -> None
let (|Silverlight|_|) (input: FrameworkName) =
match input.Identifier with
| "Silverlight" -> Some (version input)
| _ -> None
let (|WindowsPhoneApp|_|) (input: FrameworkName) =
match input.Identifier with
| "WindowsPhoneApp" -> Some (version input)
| _ -> None
let (|WindowsPhoneSilverlight|_|) (input: FrameworkName) =
match input.Identifier with
| "WindowsPhone" -> Some (version input)
| _ -> None
let (|MonoAndroid|_|) (input: FrameworkName) =
match input.Identifier with
| "MonoAndroid" -> Some ()
| _ -> None
let (|MonoTouch|_|) (input: FrameworkName) =
match input.Identifier with
| "MonoTouch" -> Some ()
| _ -> None
let (|MonoMac|_|) (input: FrameworkName) =
match input.Identifier with
| "MonoMac" -> Some ()
| _ -> None
let (|XamariniOS|_|) (input: FrameworkName) =
match input.Identifier with
| "Xamarin.iOS" -> Some ()
| _ -> None
let (|XamarinMac|_|) (input: FrameworkName) =
match input.Identifier with
| "Xamarin.Mac" -> Some ()
| _ -> None

let convertToFrameworkIdentifier frameworkName =
let version v =
match v with
| "v1.0","" -> Some(FrameworkVersion.V1)
| "v1.1","" -> Some(FrameworkVersion.V1_1)
| "v2.0","" -> Some(FrameworkVersion.V2)
| "v3.0","" -> Some(FrameworkVersion.V3)
| "v3.5","" -> Some(FrameworkVersion.V3_5)
| "v4.0","" -> Some(FrameworkVersion.V4)
| "v4.0","Client" -> Some(FrameworkVersion.V4_Client)
| "v4.5","" -> Some(FrameworkVersion.V4_5)
| "v4.5.1","" -> Some(FrameworkVersion.V4_5_1)
| "v4.5.2","" -> Some(FrameworkVersion.V4_5_2)
| "v4.5.3","" -> Some(FrameworkVersion.V4_5_3)
| "v4.6","" -> Some(FrameworkVersion.V4_6)
| "v5.0","" -> Some(FrameworkVersion.V5_0)
| _ -> None

match frameworkName with
| DotNetFramework v -> version v |> Option.map FrameworkIdentifier.DotNetFramework
| DNX v -> version (v,null) |> Option.map FrameworkIdentifier.DNX
| DNXCore v -> version (v,null) |> Option.map FrameworkIdentifier.DNXCore
| Windows v -> FrameworkIdentifier.Windows(v) |> Some
| Silverlight v -> FrameworkIdentifier.Silverlight(v) |> Some
| WindowsPhoneApp v -> FrameworkIdentifier.WindowsPhoneApp(v) |> Some
| WindowsPhoneSilverlight v -> FrameworkIdentifier.WindowsPhoneSilverlight(v) |> Some
| MonoAndroid _ -> Some FrameworkIdentifier.MonoAndroid
| MonoTouch _ -> Some FrameworkIdentifier.MonoTouch
| MonoMac _ -> Some FrameworkIdentifier.MonoMac
| XamariniOS _ -> Some FrameworkIdentifier.XamariniOS
| XamarinMac _ -> Some FrameworkIdentifier.XamarinMac
| _ -> None

module FrameworkDetection =
let private cache = System.Collections.Concurrent.ConcurrentDictionary<_,_>()
Expand Down

0 comments on commit 2019f91

Please sign in to comment.