diff --git a/.gitignore b/.gitignore
index 9399ea25..9e575617 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,9 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
+# dotnet cli
+project.lock.json
+
# User-specific files
*.suo
*.user
diff --git a/.travis.yml b/.travis.yml
index 9b785a16..3d049946 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,37 @@
language: csharp
-sudo: false # use the new container-based Travis infrastructure
+addons:
+ apt:
+ packages:
+ - gettext
+ - libcurl4-openssl-dev
+ - libicu-dev
+ - libssl-dev
+ - libunwind8
+ - zlib1g
-script:
- - ./build.sh
\ No newline at end of file
+matrix:
+ include:
+ - os: linux # Ubuntu 14.04
+ dist: trusty
+ sudo: required
+ env: DOTNET_SDK_URL=https://dotnetcli.blob.core.windows.net/dotnet/preview/Binaries/1.0.0-preview2-003121/dotnet-dev-ubuntu-x64.1.0.0-preview2-003121.tar.gz
+ - os: osx # OSX 10.11
+ osx_image: xcode7.2
+ env: DOTNET_SDK_URL=https://dotnetcli.blob.core.windows.net/dotnet/preview/Binaries/1.0.0-preview2-003121/dotnet-dev-osx-x64.1.0.0-preview2-003121.tar.gz
+
+before install:
+ - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi
+ - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install openssl ; fi
+ - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew link --force openssl ; fi
+
+install:
+ # Download .NET Core SDK and add to PATH
+ - export DOTNET_INSTALL_DIR="$PWD/.dotnetsdk"
+ - mkdir -p "$DOTNET_INSTALL_DIR"
+ - curl -L "$DOTNET_SDK_URL" | tar -xzv -C "$DOTNET_INSTALL_DIR"
+ - export PATH="$DOTNET_INSTALL_DIR:$PATH"
+
+script:
+ - dotnet --info
+ - ./build.sh
diff --git a/appveyor.yml b/appveyor.yml
index 8bc748b5..6bbd0408 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -1,3 +1,5 @@
+os: Visual Studio 2015
+
configuration: Release
test:
assemblies:
diff --git a/build.fsx b/build.fsx
index 1b951f50..825cc443 100644
--- a/build.fsx
+++ b/build.fsx
@@ -4,6 +4,7 @@
#I "packages/build/FAKE/tools"
#r "packages/build/FAKE/tools/FakeLib.dll"
+#r @"packages/build/FAKE/tools/Newtonsoft.Json.dll"
open System
open System.IO
@@ -171,6 +172,39 @@ Target "ReleaseGitHub" (fun _ ->
|> Async.RunSynchronously
)
+// .NET Core SDK and .NET Core
+
+let assertExitCodeZero x = if x = 0 then () else failwithf "Command failed with exit code %i" x
+
+Target "SetVersionInProjectJSON" (fun _ ->
+ !! "./**/project.json"
+ |> Seq.iter (DotNet.SetVersionInProjectJson release.NugetVersion)
+)
+
+Target "Build.NetCore" (fun _ ->
+ DotNet.Restore id
+
+ !! "src/**/project.json"
+ |> DotNet.Build id
+)
+
+Target "RunTests.NetCore" (fun _ ->
+ !! "tests/**/project.json"
+ |> DotNet.Test id
+)
+
+let isDotnetSDKInstalled = DotNet.isInstalled()
+
+Target "Nuget.AddNetCore" (fun _ ->
+ !! "src/**/project.json"
+ |> DotNet.Pack id
+
+ let nupkg = sprintf "../../bin/Argu.%s.nupkg" (release.NugetVersion)
+ let netcoreNupkg = sprintf "bin/Release/Argu.%s.nupkg" (release.NugetVersion)
+
+ Shell.Exec("dotnet", sprintf """mergenupkg --source "%s" --other "%s" --framework netstandard1.6 """ nupkg netcoreNupkg, "src/Argu/") |> assertExitCodeZero
+)
+
Target "Release" DoNothing
@@ -183,6 +217,7 @@ Target "Default" DoNothing
"Clean"
==> "AssemblyInfo"
+ ==> "SetVersionInProjectJSON"
==> "Prepare"
==> "Build.Net40"
==> "RunTests"
@@ -191,7 +226,10 @@ Target "Default" DoNothing
"Default"
==> "PrepareRelease"
==> "Build.Net35"
+ =?> ("Build.NetCore", isDotnetSDKInstalled)
+ =?> ("RunTests.NetCore", isDotnetSDKInstalled)
==> "NuGet"
+ =?> ("Nuget.AddNetCore", isDotnetSDKInstalled)
==> "GenerateDocs"
==> "ReleaseDocs"
==> "NuGetPush"
diff --git a/global.json b/global.json
new file mode 100644
index 00000000..3decd33e
--- /dev/null
+++ b/global.json
@@ -0,0 +1,3 @@
+{
+ "projects":[ "src", "tests" ]
+}
diff --git a/paket.lock b/paket.lock
index 2a3f0210..5f60c792 100644
--- a/paket.lock
+++ b/paket.lock
@@ -27,27 +27,27 @@ NUGET
System.Text.Encoding (>= 4.0.11) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard15
System.Threading.Tasks (>= 4.0.11) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard15
System.Linq (4.1) - framework: dnxcore50
- System.Collections (>= 4.0.11) - framework: dnxcore50, netstandard10, >= netstandard15
- System.Diagnostics.Debug (>= 4.0.11) - framework: dnxcore50, >= netstandard15
- System.Resources.ResourceManager (>= 4.0.1) - framework: dnxcore50, >= netstandard15
- System.Runtime (>= 4.1) - framework: dnxcore50, netstandard10, >= netstandard15
- System.Runtime.Extensions (>= 4.1) - framework: dnxcore50, >= netstandard15
+ System.Collections (>= 4.0.11) - framework: dnxcore50, netstandard10, >= netstandard16
+ System.Diagnostics.Debug (>= 4.0.11) - framework: dnxcore50, >= netstandard16
+ System.Resources.ResourceManager (>= 4.0.1) - framework: dnxcore50, >= netstandard16
+ System.Runtime (>= 4.1) - framework: dnxcore50, netstandard10, >= netstandard16
+ System.Runtime.Extensions (>= 4.1) - framework: dnxcore50, >= netstandard16
System.Linq.Expressions (4.1) - framework: dnxcore50
- System.Collections (>= 4.0.11) - framework: dnxcore50, >= netstandard15
- System.Diagnostics.Debug (>= 4.0.11) - framework: dnxcore50, >= netstandard15
- System.Globalization (>= 4.0.11) - framework: dnxcore50, >= netstandard15
- System.IO (>= 4.1) - framework: dnxcore50, >= netstandard15
- System.Linq (>= 4.1) - framework: dnxcore50, >= netstandard15
- System.Reflection (>= 4.1) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard15
- System.Reflection.Emit.ILGeneration (>= 4.0.1) - framework: dnxcore50, >= netstandard15
- System.Reflection.Emit.Lightweight (>= 4.0.1) - framework: dnxcore50, >= netstandard15
- System.Reflection.Extensions (>= 4.0.1) - framework: dnxcore50, >= netstandard15
- System.Reflection.Primitives (>= 4.0.1) - framework: dnxcore50, >= netstandard15
- System.Reflection.TypeExtensions (>= 4.1) - framework: dnxcore50, >= netstandard15
- System.Resources.ResourceManager (>= 4.0.1) - framework: dnxcore50, >= netstandard15
- System.Runtime (>= 4.1) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard15
- System.Runtime.Extensions (>= 4.1) - framework: dnxcore50, >= netstandard15
- System.Threading (>= 4.0.11) - framework: dnxcore50, >= netstandard15
+ System.Collections (>= 4.0.11) - framework: dnxcore50, >= netstandard16
+ System.Diagnostics.Debug (>= 4.0.11) - framework: dnxcore50, >= netstandard16
+ System.Globalization (>= 4.0.11) - framework: dnxcore50, >= netstandard16
+ System.IO (>= 4.1) - framework: dnxcore50, >= netstandard16
+ System.Linq (>= 4.1) - framework: dnxcore50, >= netstandard16
+ System.Reflection (>= 4.1) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard16
+ System.Reflection.Emit.ILGeneration (>= 4.0.1) - framework: dnxcore50, >= netstandard16
+ System.Reflection.Emit.Lightweight (>= 4.0.1) - framework: dnxcore50, >= netstandard16
+ System.Reflection.Extensions (>= 4.0.1) - framework: dnxcore50, >= netstandard16
+ System.Reflection.Primitives (>= 4.0.1) - framework: dnxcore50, >= netstandard16
+ System.Reflection.TypeExtensions (>= 4.1) - framework: dnxcore50, >= netstandard16
+ System.Resources.ResourceManager (>= 4.0.1) - framework: dnxcore50, >= netstandard16
+ System.Runtime (>= 4.1) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard16
+ System.Runtime.Extensions (>= 4.1) - framework: dnxcore50, >= netstandard16
+ System.Threading (>= 4.0.11) - framework: dnxcore50, >= netstandard16
System.ObjectModel (4.0.12) - framework: dnxcore50
System.Collections (>= 4.0.11) - framework: dnxcore50, >= netstandard13
System.Diagnostics.Debug (>= 4.0.11) - framework: dnxcore50, >= netstandard13
@@ -75,7 +75,7 @@ NUGET
System.Diagnostics.Contracts (>= 4.0.1) - framework: dnxcore50
System.Diagnostics.Debug (>= 4.0.11) - framework: dnxcore50
System.Linq (>= 4.1) - framework: dnxcore50
- System.Reflection (>= 4.1) - framework: dnxcore50, netstandard13, >= netstandard15
+ System.Reflection (>= 4.1) - framework: >= net462, dnxcore50, netstandard13, >= netstandard15
System.Reflection.Primitives (>= 4.0.1) - framework: dnxcore50
System.Resources.ResourceManager (>= 4.0.1) - framework: dnxcore50
System.Runtime (>= 4.1) - framework: dnxcore50, netstandard13, >= netstandard15
@@ -98,12 +98,12 @@ NUGET
Microsoft.NETCore.Targets (>= 1.0.1) - framework: dnxcore50, netstandard10, >= netstandard13
System.Runtime (>= 4.1) - framework: dnxcore50, netstandard10, >= netstandard13
System.Text.RegularExpressions (4.1) - framework: dnxcore50
- System.Collections (>= 4.0.11) - framework: dnxcore50, >= netstandard15
- System.Globalization (>= 4.0.11) - framework: dnxcore50, >= netstandard15
- System.Resources.ResourceManager (>= 4.0.1) - framework: dnxcore50, >= netstandard15
- System.Runtime (>= 4.1) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard15
- System.Runtime.Extensions (>= 4.1) - framework: dnxcore50, >= netstandard15
- System.Threading (>= 4.0.11) - framework: dnxcore50, >= netstandard15
+ System.Collections (>= 4.0.11) - framework: dnxcore50, >= netstandard16
+ System.Globalization (>= 4.0.11) - framework: dnxcore50, >= netstandard16
+ System.Resources.ResourceManager (>= 4.0.1) - framework: dnxcore50, >= netstandard16
+ System.Runtime (>= 4.1) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard16
+ System.Runtime.Extensions (>= 4.1) - framework: dnxcore50, >= netstandard16
+ System.Threading (>= 4.0.11) - framework: dnxcore50, >= netstandard16
System.Threading (4.0.11) - framework: dnxcore50
System.Runtime (>= 4.1) - framework: dnxcore50, netstandard10, >= netstandard13
System.Threading.Tasks (>= 4.0.11) - framework: dnxcore50, netstandard10, >= netstandard13
@@ -167,7 +167,7 @@ NUGET
GROUP Build
NUGET
remote: https://www.nuget.org/api/v2
- FAKE (4.29.2)
+ FAKE (4.34.5)
FSharp.Compiler.Service (2.0.0.6)
FSharp.Formatting (2.14.4)
FSharp.Compiler.Service (2.0.0.6)
@@ -185,5 +185,5 @@ NUGET
Microsoft.Net.Http - framework: net10, net11, net20, net30, net35, net40, net40-full
GITHUB
remote: fsharp/FAKE
- modules/Octokit/Octokit.fsx (c56456abac6b744c3bb95b217687db19fd19b367)
+ modules/Octokit/Octokit.fsx (573a4dc3d2be229d55a4935136f393d1f1d683c1)
Octokit (>= 0.20)
\ No newline at end of file
diff --git a/src/Argu/Argu.fsproj b/src/Argu/Argu.fsproj
index 152013e6..23114243 100644
--- a/src/Argu/Argu.fsproj
+++ b/src/Argu/Argu.fsproj
@@ -11,6 +11,7 @@
Argu
v4.0
Argu
+ false
4.3.0.0
diff --git a/src/Argu/ArgumentParser.fs b/src/Argu/ArgumentParser.fs
index b2f88a4b..d195aa99 100644
--- a/src/Argu/ArgumentParser.fs
+++ b/src/Argu/ArgumentParser.fs
@@ -153,7 +153,7 @@ and []
let ignoreUnrecognized = defaultArg ignoreUnrecognized false
let raiseOnUsage = defaultArg raiseOnUsage true
let inputs = match inputs with None -> getEnvironmentCommandLineArgs () | Some args -> args
- let configurationReader = match configurationReader with Some c -> c | None -> ConfigurationReader.FromAppSettings()
+ let configurationReader = match configurationReader with Some c -> c | None -> ConfigurationReader.DefaultReader()
try
let appSettingsResults = parseKeyValueConfig configurationReader argInfo
@@ -171,8 +171,13 @@ and []
member __.ParseAppSettings (?xmlConfigurationFile : string, ?ignoreMissing : bool) : ParseResults<'Template> =
let configurationReader =
match xmlConfigurationFile with
- | None -> ConfigurationReader.FromAppSettings()
- | Some f -> ConfigurationReader.FromAppSettingsFile(f)
+ | None -> ConfigurationReader.DefaultReader()
+ | Some f ->
+#if CORE_CLR
+ raise <| NotImplementedException "App.Config is not supported."
+#else
+ ConfigurationReader.FromAppSettingsFile(f)
+#endif
__.ParseConfiguration(configurationReader, ?ignoreMissing = ignoreMissing)
@@ -181,8 +186,12 @@ and []
/// Ignore errors caused by the Mandatory attribute. Defaults to false.
[]
member __.ParseAppSettings(assembly : Assembly, ?ignoreMissing : bool) =
+#if CORE_CLR
+ raise <| NotImplementedException "App.Config is not supported."
+#else
let configurationReader = ConfigurationReader.FromAppSettings(assembly)
__.ParseConfiguration(configurationReader, ?ignoreMissing = ignoreMissing)
+#endif
///
/// Converts a sequence of template argument inputs into a ParseResults instance
diff --git a/src/Argu/ConfigReaders.fs b/src/Argu/ConfigReaders.fs
index c9b56f0b..76c850f9 100644
--- a/src/Argu/ConfigReaders.fs
+++ b/src/Argu/ConfigReaders.fs
@@ -3,6 +3,8 @@
open System
open System.IO
open System.Collections.Generic
+
+#if !CORE_CLR
open System.Configuration
open System.Reflection
@@ -68,4 +70,14 @@ type ConfigurationReader =
/// Create a configuration reader instance using an F# function
static member FromFunction(reader : string -> string option, ?name : string) =
- new FunctionConfigurationReader(reader, ?name = name) :> IConfigurationReader
\ No newline at end of file
+ new FunctionConfigurationReader(reader, ?name = name) :> IConfigurationReader
+
+ static member DefaultReader () = ConfigurationReader.FromAppSettings()
+#else
+/// Configuration reader implementations
+type ConfigurationReader =
+ static member DefaultReader () =
+ { new IConfigurationReader with
+ member x.Name = "Default - Empty Configuration Reader"
+ member x.GetValue k = null }
+#endif
\ No newline at end of file
diff --git a/src/Argu/PreCompute.fs b/src/Argu/PreCompute.fs
index d4b7acce..93560115 100644
--- a/src/Argu/PreCompute.fs
+++ b/src/Argu/PreCompute.fs
@@ -48,7 +48,11 @@ let tryExtractUnionParameterLabel (p : PropertyInfo) =
else Some(p.Name.Replace('_',' '))
let (|NestedParseResults|Optional|List|Other|) (t : Type) =
+#if CORE_CLR
+ if t.GetTypeInfo().IsGenericType then
+#else
if t.IsGenericType then
+#endif
let gt = t.GetGenericTypeDefinition()
if typeof.IsAssignableFrom t then NestedParseResults(t.GetGenericArguments().[0])
elif gt = typedefof<_ option> then Optional(t.GetGenericArguments().[0])
@@ -95,7 +99,11 @@ let primitiveParsers =
/// Creates a primitive parser from an enumeration
let tryGetEnumerationParser label (t : Type) =
+#if CORE_CLR
+ if not (t.GetTypeInfo().IsEnum) then None else
+#else
if not t.IsEnum then None else
+#endif
let names = Enum.GetNames(t) |> Seq.map generateEnumName
let values = Enum.GetValues(t) |> Seq.cast
let index = Seq.zip names values |> Seq.toArray
@@ -211,7 +219,7 @@ let rec private preComputeUnionCaseArgInfo (stack : Type list) (helpParam : Help
let fields = uci.GetFields()
let types = fields |> Array.map (fun f -> f.PropertyType)
- let caseCtor = FSharpValue.PreComputeUnionConstructor(uci, bindingFlags = allBindings)
+ let caseCtor = FSharpValue.PreComputeUnionConstructor(uci, allBindings)
// create a dummy instance for given union case
let dummyFields = types |> Array.map Unchecked.UntypedDefaultOf
@@ -386,7 +394,7 @@ let rec private preComputeUnionCaseArgInfo (stack : Type list) (helpParam : Help
let tupleType = FSharpType.MakeTupleType types
FSharpValue.PreComputeTupleConstructor tupleType)
- let fieldReader = lazy(FSharpValue.PreComputeUnionReader(uci, bindingFlags = allBindings))
+ let fieldReader = lazy(FSharpValue.PreComputeUnionReader(uci, allBindings))
let assignParser = lazy(
match customAssignmentSeparator with
@@ -439,11 +447,15 @@ let rec private preComputeUnionCaseArgInfo (stack : Type list) (helpParam : Help
uai
and private preComputeUnionArgInfoInner (stack : Type list) (helpParam : HelpParam option) (tryGetParent : unit -> UnionCaseArgInfo option) (t : Type) : UnionArgInfo =
- if not <| FSharpType.IsUnion(t, bindingFlags = allBindings) then
+ if not <| FSharpType.IsUnion(t, allBindings) then
arguExn "template type '%O' is not an F# union." t
elif stack |> List.exists ((=) t) then
arguExn "template type '%O' implements unsupported recursive pattern." t
+#if CORE_CLR
+ elif t.GetTypeInfo().IsGenericType then
+#else
elif t.IsGenericType then
+#endif
arguExn "template type '%O' is generic; this is not supported." t
let helpParam =
@@ -469,7 +481,7 @@ and private preComputeUnionArgInfoInner (stack : Type list) (helpParam : HelpPar
let getCurrent = fun () -> !current
let caseInfo =
- FSharpType.GetUnionCases(t, bindingFlags = allBindings)
+ FSharpType.GetUnionCases(t, allBindings)
|> Seq.map (preComputeUnionCaseArgInfo (t :: stack) (Some helpParam) getCurrent)
|> Seq.sortBy (fun a -> a.Tag)
|> Seq.toArray
@@ -511,7 +523,7 @@ and private preComputeUnionArgInfoInner (stack : Type list) (helpParam : HelpPar
if not <| regex.IsMatch arg then [||]
else Array.init (arg.Length - 1) (fun i -> sprintf "-%c" arg.[i + 1]))
- let tagReader = lazy(FSharpValue.PreComputeUnionTagReader(t, bindingFlags = allBindings))
+ let tagReader = lazy(FSharpValue.PreComputeUnionTagReader(t, allBindings))
let cliIndex = lazy(
caseInfo
diff --git a/src/Argu/UnionArgInfo.fs b/src/Argu/UnionArgInfo.fs
index 467ceee6..efe3ac71 100644
--- a/src/Argu/UnionArgInfo.fs
+++ b/src/Argu/UnionArgInfo.fs
@@ -3,7 +3,9 @@ module internal Argu.UnionArgInfo
open System
open System.IO
+#if !CORE_CLR
open System.Configuration
+#endif
open System.Collections.Generic
open System.Reflection
diff --git a/src/Argu/Utils.fs b/src/Argu/Utils.fs
index 4f11d158..7f25138e 100644
--- a/src/Argu/Utils.fs
+++ b/src/Argu/Utils.fs
@@ -12,7 +12,11 @@ open FSharp.Reflection
open FSharp.Quotations
open FSharp.Quotations.Patterns
+#if NETSTANDARD1_6
+let allBindings = true
+#else
let allBindings = BindingFlags.NonPublic ||| BindingFlags.Public ||| BindingFlags.Static ||| BindingFlags.Instance
+#endif
let inline arguExn fmt = Printf.ksprintf(fun msg -> raise <| new ArguException(msg)) fmt
@@ -115,14 +119,24 @@ type Unchecked =
}
type MemberInfo with
- member m.ContainsAttribute<'T when 'T :> Attribute> () =
- m.GetCustomAttributes(typeof<'T>, true) |> Array.isEmpty |> not
+ member m.ContainsAttribute<'T when 'T :> Attribute> () : bool=
+ m.GetCustomAttributes(typeof<'T>, true) |> Seq.isEmpty |> not
- member m.TryGetAttribute<'T when 'T :> Attribute> () =
- match m.GetCustomAttributes(typeof<'T>, true) with
+ member m.TryGetAttribute<'T when 'T :> Attribute> () : 'T option =
+ match m.GetCustomAttributes(typeof<'T>, true) |> Seq.toArray with
| [||] -> None
- | attrs -> attrs |> Array.last |> unbox<'T> |> Some
+ | attrs -> attrs |> Array.last :?> 'T |> Some
+
+#if CORE_CLR
+type Type with
+ member x.GetCustomAttributes(t, b : bool) = x.GetTypeInfo().GetCustomAttributes(t, b)
+
+ member m.ContainsAttribute<'T when 'T :> Attribute> () : bool=
+ m.GetTypeInfo().ContainsAttribute<'T>()
+ member m.TryGetAttribute<'T when 'T :> Attribute> () : 'T option =
+ m.GetTypeInfo().TryGetAttribute<'T>()
+#endif
type IDictionary<'K,'V> with
member d.TryFind k =
@@ -131,19 +145,25 @@ type IDictionary<'K,'V> with
else None
+#if !CORE_CLR
let currentProgramName = lazy(System.Diagnostics.Process.GetCurrentProcess().MainModule.ModuleName)
+#else
+// error FS0039: The value, constructor, namespace or type 'Process' is not defined
+let currentProgramName = lazy("wtf")
+#endif
type UnionCaseInfo with
member uci.GetAttributes<'T when 'T :> Attribute> (?includeDeclaringTypeAttrs : bool) =
let includeDeclaringTypeAttrs = defaultArg includeDeclaringTypeAttrs false
- let caseAttrs = uci.GetCustomAttributes typeof<'T>
+ let caseAttrs = uci.GetCustomAttributes typeof<'T> |> Seq.cast
let attrs =
if includeDeclaringTypeAttrs then
uci.DeclaringType.GetCustomAttributes(typeof<'T>, false)
+ |> Seq.cast
|> Seq.append caseAttrs
else
- caseAttrs :> _
+ caseAttrs
attrs |> Seq.map (fun o -> o :?> 'T)
@@ -152,7 +172,7 @@ type UnionCaseInfo with
match uci.GetCustomAttributes typeof<'T> with
| [||] when includeDeclaringTypeAttrs ->
- match uci.DeclaringType.GetCustomAttributes(typeof<'T>, false) with
+ match uci.DeclaringType.GetCustomAttributes(typeof<'T>, false) |> Seq.toArray with
| [||] -> None
| attrs -> Some (attrs.[0] :?> 'T)
| [||] -> None
@@ -162,7 +182,7 @@ type UnionCaseInfo with
let includeDeclaringTypeAttrs = defaultArg includeDeclaringTypeAttrs false
if uci.GetCustomAttributes typeof<'T> |> Array.isEmpty |> not then true
elif includeDeclaringTypeAttrs then
- uci.DeclaringType.GetCustomAttributes(typeof<'T>, false) |> Array.isEmpty |> not
+ uci.DeclaringType.GetCustomAttributes(typeof<'T>, false) |> Seq.isEmpty |> not
else
false
diff --git a/src/Argu/project.json b/src/Argu/project.json
new file mode 100644
index 00000000..76c4002d
--- /dev/null
+++ b/src/Argu/project.json
@@ -0,0 +1,49 @@
+{
+ "version": "3.1.0",
+ "buildOptions": {
+ "debugType": "portable",
+ "compilerName": "fsc",
+ "define": [
+ "CORE_CLR"
+ ],
+ "compile": {
+ "includeFiles": [
+ "AssemblyInfo.fs",
+ "Types.fs",
+ "Attributes.fs",
+ "Utils.fs",
+ "ConfigReaders.fs",
+ "UnionArgInfo.fs",
+ "PreCompute.fs",
+ "UnParsers.fs",
+ "ParseResults.fs",
+ "Parsers/Common.fs",
+ "Parsers/Cli.fs",
+ "Parsers/KeyValue.fs",
+ "ArgumentParser.fs"
+ ]
+ }
+ },
+ "tools": {
+ "dotnet-mergenupkg": "1.0.*",
+ "dotnet-compile-fsc": {
+ "version": "1.0.0-preview2-*",
+ "imports": "dnxcore50"
+ }
+ },
+ "frameworks": {
+ "netstandard1.6": {
+ "buildOptions": {
+ "define": [
+ "NETSTANDARD1_5",
+ "NETSTANDARD1_6"
+ ]
+ },
+ "dependencies": {
+ "System.Xml.XDocument": "4.0.11",
+ "FSharp.Core": "4.0.1.7-alpha",
+ "NETStandard.Library": "1.6.0"
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/tests/Argu.NetCore.Tests/Program.fs b/tests/Argu.NetCore.Tests/Program.fs
new file mode 100644
index 00000000..52275b19
--- /dev/null
+++ b/tests/Argu.NetCore.Tests/Program.fs
@@ -0,0 +1,59 @@
+// Learn more about F# at http://fsharp.org
+
+open System
+open Argu
+
+type CLIArguments =
+ | Working_Directory of string
+ | Listener of host:string * port:int
+ | Data of byte []
+ | Port of int
+ | Log_Level of int
+ | Detach
+with
+ interface IArgParserTemplate with
+ member s.Usage =
+ match s with
+ | Working_Directory _ -> "specify a working directory."
+ | Listener _ -> "specify a listener (hostname : port)."
+ | Data _ -> "binary data in base64 encoding."
+ | Port _ -> "specify a primary port."
+ | Log_Level _ -> "set the log level."
+ | Detach _ -> "detach daemon from console."
+
+[]
+let main argv =
+ printfn "Hello World!"
+ printfn "%A" argv
+
+ // build the argument parser
+ let parser = ArgumentParser.Create()
+
+ // get usage text
+ let usage = parser.PrintUsage()
+ // output:
+ // --working-directory : specify a working directory.
+ // --listener : specify a listener (hostname : port).
+ // --log-level : set the log level.
+ // --detach: detach daemon from console.
+ // --help [-h|/h|/help|/?]: display this list of options.
+
+ printfn "Usage:"
+ printfn "%s" usage
+ printfn ""
+
+ // parse given input
+ let results = parser.Parse([| "--detach" ; "--listener" ; "localhost" ; "8080" |])
+
+ printfn "Results:"
+ printfn "%A" results
+ printfn ""
+
+ // get all parsed results
+ let all = results.GetAllResults() // [ Detach ; Listener ("localhost", 8080) ]
+
+ printfn "All results:"
+ printfn "%A" all
+ printfn ""
+
+ 0 // return an integer exit code
diff --git a/tests/Argu.NetCore.Tests/project.json b/tests/Argu.NetCore.Tests/project.json
new file mode 100644
index 00000000..d61ccfee
--- /dev/null
+++ b/tests/Argu.NetCore.Tests/project.json
@@ -0,0 +1,41 @@
+{
+ "version": "3.1.0",
+ "buildOptions": {
+ "debugType": "portable",
+ "emitEntryPoint": true,
+ "compilerName": "fsc",
+ "define": [
+ "CORE_CLR"
+ ],
+ "compile": {
+ "includeFiles": [
+ "Program.fs"
+ ]
+ }
+ },
+ "tools": {
+ "dotnet-compile-fsc": {
+ "version": "1.0.0-preview2-*",
+ "imports": "dnxcore50"
+ }
+ },
+ "dependencies": {
+ "Argu": {
+ "version": "*",
+ "target": "project"
+ }
+ },
+ "frameworks": {
+ "netcoreapp1.0": {
+ "dependencies": {
+ "Microsoft.NETCore.App": {
+ "type": "platform",
+ "version": "1.0.0"
+ }
+ },
+ "imports": [
+ "dnxcore50"
+ ]
+ }
+ }
+}
\ No newline at end of file
diff --git a/tests/Argu.Tests/Argu.Tests.fsproj b/tests/Argu.Tests/Argu.Tests.fsproj
index 349f4dbc..8fe3f9d1 100644
--- a/tests/Argu.Tests/Argu.Tests.fsproj
+++ b/tests/Argu.Tests/Argu.Tests.fsproj
@@ -52,34 +52,39 @@
-
+
-
+
- <__paket__xunit_runner_visualstudio_props>win81\xunit.runner.visualstudio
- <__paket__xunit_runner_visualstudio_targets>win81\xunit.runner.visualstudio
+ <__paket__xunit_runner_visualstudio_props>net20\xunit.runner.visualstudio
-
+
- <__paket__xunit_runner_visualstudio_props>wpa81\xunit.runner.visualstudio
- <__paket__xunit_runner_visualstudio_targets>wpa81\xunit.runner.visualstudio
+ <__paket__xunit_runner_visualstudio_props>portable-net45+win8+wp8+wpa81\xunit.runner.visualstudio
-
+
- <__paket__xunit_runner_visualstudio_props>net20\xunit.runner.visualstudio
+ <__paket__xunit_runner_visualstudio_props>win81\xunit.runner.visualstudio
+ <__paket__xunit_runner_visualstudio_targets>win81\xunit.runner.visualstudio
-
+
- <__paket__xunit_runner_visualstudio_props>portable-net45+win8+wp8+wpa81\xunit.runner.visualstudio
+ <__paket__xunit_runner_visualstudio_props>wpa81\xunit.runner.visualstudio
+ <__paket__xunit_runner_visualstudio_targets>wpa81\xunit.runner.visualstudio
+
+
+ <__paket__xunit_core_props>portable-net45+win8+wp8+wpa81\xunit.core
+
+
<__paket__xunit_core_props>win81\xunit.core
@@ -90,11 +95,6 @@
<__paket__xunit_core_props>wpa81\xunit.core
-
-
- <__paket__xunit_core_props>portable-net45+win8+wp8+wpa81\xunit.core
-
-