diff --git a/.travis.yml b/.travis.yml index 7bab1a4e..1607c5d7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,21 +1,25 @@ language: csharp mono: - - beta - - latest - - 4.8.1 - - 4.2.2 - - 4.0.5 + - weekly + - nightly + +# beta doesn't work because of whacky msbuild package install problems +# beta + +# 5.4.0 doesn't work because of missing SDK build things for F# new styleprojects + msbuild +# - latest + +# 5.2.0 doesn't work because of missing SDK build things for F# new styleprojects + msbuild +# - 5.2.0 + +dotnet: 2.0.0 os: - linux - osx -matrix: - allow_failures: - - mono: beta - -sudo: false # use the new container-based Travis infrastructure +sudo: true # use the new container-based Travis infrastructure script: - ./build.sh RunTests diff --git a/build.fsx b/build.fsx index e9681ef4..de9fab5d 100644 --- a/build.fsx +++ b/build.fsx @@ -3,17 +3,13 @@ // -------------------------------------------------------------------------------------- #I "packages/FAKE/tools" -#r "FakeLib.dll" + +#r "packages/FAKE/tools/FakeLib.dll" open System open System.IO -open Fake.AssemblyInfoFile -open Fake.Git -open Fake.Testing -open Fake.FscHelper open Fake - // -------------------------------------------------------------------------------------- // Information about the project to be used at NuGet // -------------------------------------------------------------------------------------- @@ -28,12 +24,19 @@ let tags = "F# fsharp typeprovider" let gitHome = "https://github.com/fsprojects" let gitName = "FSharp.TypeProviders.SDK" +let config = "Release" + // Read release notes & version info from RELEASE_NOTES.md Environment.CurrentDirectory <- __SOURCE_DIRECTORY__ let release = File.ReadLines "RELEASE_NOTES.md" |> ReleaseNotesHelper.parseReleaseNotes + +let exec p args = + printfn "Executing %s %s" p args + Shell.Exec(p, args) |> function 0 -> () | d -> failwithf "%s %s exited with error %d" p args d + let pullRequest = match getBuildParamOrDefault "APPVEYOR_PULL_REQUEST_NUMBER" "" with | "" -> @@ -44,21 +47,16 @@ let pullRequest = Some <| int a let buildNumber = - int (getBuildParamOrDefault "APPVEYOR_BUILD_VERSION" "0") + getBuildParamOrDefault "APPVEYOR_BUILD_VERSION" "0" let version = match pullRequest with | None -> - sprintf "%s.%d" release.AssemblyVersion buildNumber + sprintf "%s.%s" release.AssemblyVersion buildNumber | Some num -> - sprintf "%s-pull-%d-%05d" release.AssemblyVersion num buildNumber + sprintf "%s-pull-%d-%s" release.AssemblyVersion num buildNumber let releaseNotes = release.Notes |> String.concat "\n" -let outputPath = "./output/" -let workingDir = "./temp/" let srcDir = "src" -let exampleDir = "examples" -let testDir = "test" -let nunitDir = "packages/NUnit/lib/net45" let sources = [srcDir @@ "ProvidedTypes.fsi" @@ -68,124 +66,57 @@ let sources = srcDir @@ "ProvidedTypesContext.fs" srcDir @@ "ProvidedTypesTesting.fs" ] - -// -------------------------------------------------------------------------------------- -// Clean build results - Target "Clean" (fun _ -> - CleanDirs [outputPath; workingDir] + CleanDirs [] ) -// -------------------------------------------------------------------------------------- -// Compile ProvidedTypes as a smoke test +Target "Restore" (fun _ -> + exec "dotnet" "restore" +) Target "Compile" (fun _ -> - // sources - // |> Compile [ - // FscHelper.Target TargetType.Library - // Platform PlatformType.AnyCpu - // Reference "System.Reflection.Metadata.dll" - // ] - - !! "FSharp.TypeProviders.SDK.sln" - |> MSBuildRelease "" "Build" - |> ignore +#if MONO + // We don't use dotnet build because of https://github.com/dotnet/sdk/issues/335 + exec "msbuild" ("src/FSharp.TypeProviders.SDK.fsproj /p:Configuration=" + config) + exec "msbuild" ("tests/FSharp.TypeProviders.SDK.Tests.fsproj /p:Configuration=" + config) +#else + exec "dotnet" "build" +#endif ) -type ExampleWithTests = - { Name : string - ProviderSourceFiles : string list - TestSourceFiles : string list } - - -// -------------------------------------------------------------------------------------- -// Compile example providers and accompanying test dlls -#if EXAMPLES -Target "Examples" (fun _ -> - let examples = - [ - { Name = "StaticProperty"; ProviderSourceFiles = ["StaticProperty.fsx"]; TestSourceFiles = ["StaticProperty.Tests.fsx"]} - { Name = "ErasedWithConstructor"; ProviderSourceFiles = ["ErasedWithConstructor.fsx"]; TestSourceFiles = ["ErasedWithConstructor.Tests.fsx"]} - ] - - if not (Directory.Exists testDir) then - Directory.CreateDirectory testDir |> ignore - - let testNunitDll = testDir @@ "nunit.framework.dll" - - if File.Exists testNunitDll then - File.Delete testNunitDll - - File.Copy (nunitDir @@ "nunit.framework.dll", testNunitDll) - - let fromExampleDir filenames = - filenames - |> List.map (fun filename -> exampleDir @@ filename) - - examples - |> List.iter (fun example -> - // Compile type provider - let output = testDir @@ example.Name + ".dll" - (List.concat [sources;fromExampleDir example.ProviderSourceFiles]) - |> Compile [ - Out output - FscHelper.Target TargetType.Library - ] - - // Compile test dll - (fromExampleDir example.TestSourceFiles) - |> Compile [ - Out (testDir @@ example.Name + ".Tests.dll") - FscHelper.Target TargetType.Library - References [output;nunitDir @@ "nunit.framework.dll"] - ] - ) -) -#endif +//#if EXAMPLES +// { Name = "StaticProperty"; ProviderSourceFiles = ["StaticProperty.fsx"]; TestSourceFiles = ["StaticProperty.Tests.fsx"]} +// { Name = "ErasedWithConstructor"; ProviderSourceFiles = ["ErasedWithConstructor.fsx"]; TestSourceFiles = ["ErasedWithConstructor.Tests.fsx"]} +//#endif Target "RunTests" (fun _ -> - !! ("tests/bin/Release/FSharp.TypeProviders.SDK.Tests.dll") - |> NUnit3 id - -#if EXAMPLES - !! (testDir @@ "*.Tests.dll") - |> NUnit3 id +#if MONO + // We don't use dotnet test because of https://github.com/dotnet/sdk/issues/335 + //exec "packages/xunit.runner.console/tools/net452/xunit.console.exe" ("/p:Configuration=" + config + " tests/bin/" + config + "/net461/FSharp.TypeProviders.SDK.Tests.dll -parallel none") + () +#else + exec "dotnet" ("test tests/FSharp.TypeProviders.SDK.Tests.fsproj -c " + config) + // This also gives console output: + //exec "packages/xunit.runner.console/tools/net452/xunit.console.exe" ("/p:Configuration=" + config + " tests/bin/" + config + "/net461/FSharp.TypeProviders.SDK.Tests.dll -parallel none") #endif + () ) -// -------------------------------------------------------------------------------------- -// Build a NuGet package - Target "NuGet" (fun _ -> - sources |> CopyTo (workingDir @@ "content") - - NuGet (fun p -> - { p with - Authors = authors - Project = project - Summary = summary - Description = description - Version = version - ReleaseNotes = releaseNotes - Tags = tags - OutputPath = outputPath - WorkingDir = workingDir - AccessKey = getBuildParamOrDefault "nugetkey" "" - Publish = hasBuildParam "nugetkey" - Files = [(workingDir, None, None)] - Dependencies = [] }) - "nuget/FSharp.TypeProviders.SDK.nuspec" +#if !MONO + // We don't do this on Linux/OSX because of https://github.com/dotnet/sdk/issues/335 + exec "dotnet" ("pack src/FSharp.TypeProviders.SDK.fsproj -c " + config) +#endif + () ) -// -------------------------------------------------------------------------------------- -// Help - "Clean" ==> "NuGet" -"Compile" -#if EXAMPLES - ==> "Examples" -#endif +"Restore" + ==> "Compile" +//#if EXAMPLES +// ==> "Examples" +//#endif ==> "RunTests" ==> "NuGet" diff --git a/build.sh b/build.sh index 1148060a..a0e43d42 100755 --- a/build.sh +++ b/build.sh @@ -12,8 +12,11 @@ then else # use mono + sudo apt-get -y install msbuild mono-complete mono-devel fsharp + which mono - find /usr/lib/mono + which dotnet + which msbuild mono .paket/paket.exe restore exit_code=$? diff --git a/examples/ErasedWithConstructor.Tests.fsx b/examples/ErasedWithConstructor.Tests.fsx index e3378b4f..c849e661 100644 --- a/examples/ErasedWithConstructor.Tests.fsx +++ b/examples/ErasedWithConstructor.Tests.fsx @@ -1,16 +1,15 @@ #if INTERACTIVE -#r @"../packages/NUnit/lib/net45/nunit.framework.dll" #r @"../test/ErasedWithConstructor.dll" #endif -open NUnit.Framework open ErasedWithConstructor.Provided +open Xunit -[] +[] let ``Default constructor should create instance`` () = - Assert.AreEqual("My internal state", MyType().InnerState) + Assert.Equal("My internal state", MyType().InnerState) -[] +[] let ``Constructor with parameter should create instance`` () = - Assert.AreEqual("override", MyType("override").InnerState) + Assert.Equal("override", MyType("override").InnerState) \ No newline at end of file diff --git a/examples/StaticProperty.Tests.fsx b/examples/StaticProperty.Tests.fsx index 7476ff34..63cfce5c 100644 --- a/examples/StaticProperty.Tests.fsx +++ b/examples/StaticProperty.Tests.fsx @@ -1,12 +1,10 @@ #if INTERACTIVE -#r @"../packages/NUnit/lib/net45/nunit.framework.dll" #r @"../test/StaticProperty.dll" #endif -open NUnit.Framework open StaticProperty.Provided -[] +[] let ``Static property should have been created`` () = - Assert.AreEqual("Hello world", MyType.MyProperty) + Assert.Equal("Hello world", MyType.MyProperty) \ No newline at end of file diff --git a/paket.dependencies b/paket.dependencies index ba155dd9..e79ec25d 100644 --- a/paket.dependencies +++ b/paket.dependencies @@ -3,9 +3,7 @@ source https://api.nuget.org/v3/index.json nuget Nuget.CommandLine nuget FAKE - -nuget NUnit -nuget NUnit.ConsoleRunner +nuget xunit.runner.console group fs31 source https://api.nuget.org/v3/index.json diff --git a/paket.lock b/paket.lock index 2c60d66a..5d7df708 100644 --- a/paket.lock +++ b/paket.lock @@ -1,10 +1,9 @@ RESTRICTION: >= net45 NUGET remote: https://api.nuget.org/v3/index.json - FAKE (4.63) + FAKE (4.63.2) Nuget.CommandLine (4.3) - NUnit (3.7.1) - NUnit.ConsoleRunner (3.7) + xunit.runner.console (2.3) GROUP fs31 NUGET diff --git a/src/FSharp.TypeProviders.SDK.fsproj b/src/FSharp.TypeProviders.SDK.fsproj index c955b37b..f4fb17c1 100644 --- a/src/FSharp.TypeProviders.SDK.fsproj +++ b/src/FSharp.TypeProviders.SDK.fsproj @@ -1,61 +1,9 @@ - - - + - ..\ - Debug - AnyCPU - 2.0 - 6ebfde55-9687-40a9-8c1a-6e204ecb117f + net45; netstandard2.0 Library - FSharp.TypeProviders.SDK - FSharp.TypeProviders.SDK - v4.5 - FSharp.TypeProviders.SDK - - 4.3.1.0 + NO_GENERATIVE; $(DefineConstants) - - true - full - false - false - ..\bin - DEBUG;TRACE - 3 - ..\bin\FSharp.TypeProviders.SDK.xml - Project - - - - - --warnon:1182 - - - pdbonly - true - true - ..\bin - TRACE - 3 - bin\FSharp.TypeProviders.SDK.xml - - - 11 - - - - - $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets - - - - - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets - - - - @@ -64,12 +12,4 @@ - - - - True - - - - \ No newline at end of file diff --git a/src/ProvidedTypes.fs b/src/ProvidedTypes.fs index 8e89f0c6..0e50d88c 100644 --- a/src/ProvidedTypes.fs +++ b/src/ProvidedTypes.fs @@ -15,7 +15,9 @@ open System.Text open System.IO open System.Reflection open System.Linq.Expressions +open System.Collections open System.Collections.Generic +open System.Diagnostics open Microsoft.FSharp.Quotations open Microsoft.FSharp.Quotations.Patterns open Microsoft.FSharp.Quotations.DerivedPatterns @@ -430,7 +432,7 @@ type QuotationSimplifier(isGenerated: bool) = if a.Name = "Empty" then a,b else b,a - fun v -> transValueList (v :?> System.Collections.IEnumerable, ty, nil, cons) + fun v -> transValueList (v :?> IEnumerable, ty, nil, cons) else fun v -> Expr.Value(v, ty) @@ -620,7 +622,7 @@ type CodeGenerator(assemblyMainModule: ModuleBuilder, uniqueLambdaTypeName, // have to use alternative means for various Method/Field/Constructor lookups on this kind of type. // Also, on Mono 3.x and 4.x this type had a different name. let TypeBuilderInstantiationType = - let runningOnMono = try System.Type.GetType("Mono.Runtime") <> null with e-> false + let runningOnMono = try not (isNull (Type.GetType("Mono.Runtime"))) with e-> false let ty = if runningOnMono then let ty = Type.GetType("System.Reflection.MonoGenericClass") @@ -670,7 +672,7 @@ type CodeGenerator(assemblyMainModule: ModuleBuilder, uniqueLambdaTypeName, ilg.Emit(OpCodes.Stloc, l) lambdaLocals.[v] <- l - let expectedState = if (invoke.ReturnType = typeof) then ExpectedStackState.Empty else ExpectedStackState.Value + let expectedState = if (invoke.ReturnType = typeof) then ExpectedStackState.Empty else ExpectedStackState.Value let lambadParamVars = [| Quotations.Var("this", lambda); v|] let codeGen = CodeGenerator(assemblyMainModule, uniqueLambdaTypeName, implicitCtorArgsAsFields, transType, transField, transMethod, transCtor, isLiteralEnumField, ilg, lambdaLocals, lambadParamVars) codeGen.EmitExpr (expectedState, body) @@ -952,7 +954,7 @@ type CodeGenerator(assemblyMainModule: ModuleBuilder, uniqueLambdaTypeName, | _ -> ilg.Emit(OpCodes.Call, mappedMeth) - let returnTypeIsVoid = mappedMeth.ReturnType = typeof + let returnTypeIsVoid = mappedMeth.ReturnType = typeof match returnTypeIsVoid, (isEmpty expectedState) with | false, true -> // method produced something, but we don't need it @@ -987,13 +989,13 @@ type CodeGenerator(assemblyMainModule: ModuleBuilder, uniqueLambdaTypeName, | :? float32 as x -> ilg.Emit(OpCodes.Ldc_R4, x) | :? float as x -> ilg.Emit(OpCodes.Ldc_R8, x) #if !FX_NO_GET_ENUM_UNDERLYING_TYPE - | :? System.Enum as x when x.GetType().GetEnumUnderlyingType() = typeof -> ilg.Emit(OpCodes.Ldc_I4, unbox v) + | :? Enum as x when x.GetType().GetEnumUnderlyingType() = typeof -> ilg.Emit(OpCodes.Ldc_I4, unbox v) #endif | :? Type as ty -> ilg.Emit(OpCodes.Ldtoken, transType ty) ilg.Emit(OpCodes.Call, GetTypeFromHandleMethod()) | :? decimal as x -> - let bits = System.Decimal.GetBits x + let bits = Decimal.GetBits x ilg.Emit(OpCodes.Ldc_I4, bits.[0]) ilg.Emit(OpCodes.Ldc_I4, bits.[1]) ilg.Emit(OpCodes.Ldc_I4, bits.[2]) @@ -1097,8 +1099,8 @@ module internal Misc = let notRequired opname item = let msg = sprintf "The operation '%s' on item '%s' should not be called on provided type, member or parameter" opname item - System.Diagnostics.Debug.Assert (false, msg) - raise (System.NotSupportedException msg) + Debug.Assert (false, msg) + raise (NotSupportedException msg) let mkParamArrayCustomAttributeData() = #if FX_NO_CUSTOMATTRIBUTEDATA @@ -1177,7 +1179,7 @@ module internal Misc = #else { new CustomAttributeData() with #endif - member __.Constructor = typeof.GetConstructors() |> Array.find (fun x -> x.GetParameters().Length = 2) + member __.Constructor = typeof.GetConstructors() |> Array.find (fun x -> x.GetParameters().Length = 2) member __.ConstructorArguments = upcast [|CustomAttributeTypedArgument(typeof, message) ; CustomAttributeTypedArgument(typeof, isError) |] member __.NamedArguments = upcast [| |] } @@ -1252,7 +1254,7 @@ module internal Misc = type ProvidedStaticParameter(parameterName:string,parameterType:Type,?parameterDefaultValue:obj) = - inherit System.Reflection.ParameterInfo() + inherit ParameterInfo() let customAttributesImpl = CustomAttributesImpl() @@ -1270,7 +1272,7 @@ type ProvidedStaticParameter(parameterName:string,parameterType:Type,?parameterD override __.GetCustomAttributes(_attributeType, _inherit) = notRequired "GetCustomAttributes" parameterName type ProvidedParameter(parameterName:string,parameterType:Type,?isOut:bool,?optionalValue:obj) = - inherit System.Reflection.ParameterInfo() + inherit ParameterInfo() let customAttributesImpl = CustomAttributesImpl() let isOut = defaultArg isOut false member __.IsParamArray with get() = customAttributesImpl.HasParamArray and set(v) = customAttributesImpl.HasParamArray <- v @@ -1291,11 +1293,11 @@ type ProvidedConstructor(parameters : ProvidedParameter list) = let parameters = parameters |> List.map (fun p -> p :> ParameterInfo) let mutable baseCall = None - let mutable declaringType = null : System.Type + let mutable declaringType = null : Type let mutable invokeCode = None : option Expr> let mutable isImplicitCtor = false let mutable ctorAttributes = MethodAttributes.Public ||| MethodAttributes.RTSpecialName - let nameText () = sprintf "constructor for %s" (if declaringType=null then "" else declaringType.FullName) + let nameText () = sprintf "constructor for %s" (if isNull declaringType then "" else declaringType.FullName) let isStatic() = ctorAttributes.HasFlag(MethodAttributes.Static) let customAttributesImpl = CustomAttributesImpl() @@ -1317,7 +1319,7 @@ type ProvidedConstructor(parameters : ProvidedParameter list) = member __.DeclaringTypeImpl with set x = - if declaringType<>null then failwith (sprintf "ProvidedConstructor: declaringType already set on '%s'" (nameText())); + if not (isNull declaringType) then failwith (sprintf "ProvidedConstructor: declaringType already set on '%s'" (nameText())); declaringType <- x member __.InvokeCode @@ -1367,7 +1369,7 @@ type ProvidedConstructor(parameters : ProvidedParameter list) = override __.GetCustomAttributes(_attributeType, _inherit) = notRequired "GetCustomAttributes" (nameText()) type ProvidedMethod(methodName: string, parameters: ProvidedParameter list, returnType: Type) = - inherit System.Reflection.MethodInfo() + inherit MethodInfo() let argParams = parameters |> List.map (fun p -> p :> ParameterInfo) // State @@ -1467,8 +1469,7 @@ type ProvidedMethod(methodName: string, parameters: ProvidedParameter list, retu type ProvidedProperty(propertyName: string, propertyType: Type, ?parameters: ProvidedParameter list) = - inherit System.Reflection.PropertyInfo() - // State + inherit PropertyInfo() let parameters = defaultArg parameters [] let mutable declaringType = null @@ -1482,7 +1483,7 @@ type ProvidedProperty(propertyName: string, propertyType: Type, ?parameters: Pro // Delay construction - to pick up the latest isStatic let markSpecialName (m:ProvidedMethod) = m.AddMethodAttrs(MethodAttributes.SpecialName); m let getter = lazy (ProvidedMethod("get_" + propertyName,parameters,propertyType,IsStaticMethod=isStatic,DeclaringTypeImpl=declaringType,InvokeCode=getterCode.Value) |> markSpecialName) - let setter = lazy (ProvidedMethod("set_" + propertyName,parameters @ [ProvidedParameter("value",propertyType)],typeof,IsStaticMethod=isStatic,DeclaringTypeImpl=declaringType,InvokeCode=setterCode.Value) |> markSpecialName) + let setter = lazy (ProvidedMethod("set_" + propertyName,parameters @ [ProvidedParameter("value",propertyType)],typeof,IsStaticMethod=isStatic,DeclaringTypeImpl=declaringType,InvokeCode=setterCode.Value) |> markSpecialName) let customAttributesImpl = CustomAttributesImpl() member __.AddXmlDocComputed xmlDocFunction = customAttributesImpl.AddXmlDocComputed xmlDocFunction @@ -1531,8 +1532,7 @@ type ProvidedProperty(propertyName: string, propertyType: Type, ?parameters: Pro override __.IsDefined(_attributeType, _inherit) = notRequired "IsDefined" propertyName type ProvidedEvent(propertyName:string,eventHandlerType:Type) = - inherit System.Reflection.EventInfo() - // State + inherit EventInfo() let mutable declaringType = null let mutable isStatic = false @@ -1541,8 +1541,8 @@ type ProvidedEvent(propertyName:string,eventHandlerType:Type) = // Delay construction - to pick up the latest isStatic let markSpecialName (m:ProvidedMethod) = m.AddMethodAttrs(MethodAttributes.SpecialName); m - let adder = lazy (ProvidedMethod("add_" + propertyName, [ProvidedParameter("handler", eventHandlerType)],typeof,IsStaticMethod=isStatic,DeclaringTypeImpl=declaringType,InvokeCode=adderCode.Value) |> markSpecialName) - let remover = lazy (ProvidedMethod("remove_" + propertyName, [ProvidedParameter("handler", eventHandlerType)],typeof,IsStaticMethod=isStatic,DeclaringTypeImpl=declaringType,InvokeCode=removerCode.Value) |> markSpecialName) + let adder = lazy (ProvidedMethod("add_" + propertyName, [ProvidedParameter("handler", eventHandlerType)],typeof,IsStaticMethod=isStatic,DeclaringTypeImpl=declaringType,InvokeCode=adderCode.Value) |> markSpecialName) + let remover = lazy (ProvidedMethod("remove_" + propertyName, [ProvidedParameter("handler", eventHandlerType)],typeof,IsStaticMethod=isStatic,DeclaringTypeImpl=declaringType,InvokeCode=removerCode.Value) |> markSpecialName) let customAttributesImpl = CustomAttributesImpl() member __.AddXmlDocComputed xmlDocFunction = customAttributesImpl.AddXmlDocComputed xmlDocFunction @@ -1585,8 +1585,7 @@ type ProvidedEvent(propertyName:string,eventHandlerType:Type) = override __.IsDefined(_attributeType, _inherit) = notRequired "IsDefined" propertyName type ProvidedLiteralField(fieldName:string,fieldType:Type,literalValue:obj) = - inherit System.Reflection.FieldInfo() - // State + inherit FieldInfo() let mutable declaringType = null @@ -1622,8 +1621,7 @@ type ProvidedLiteralField(fieldName:string,fieldType:Type,literalValue:obj) = override __.FieldHandle = notRequired "FieldHandle" fieldName type ProvidedField(fieldName:string,fieldType:Type) = - inherit System.Reflection.FieldInfo() - // State + inherit FieldInfo() let mutable declaringType = null @@ -1666,8 +1664,8 @@ type ProvidedSymbolKind = | Array of int | Pointer | ByRef - | Generic of System.Type - | FSharpTypeAbbreviation of (System.Reflection.Assembly * string * string[]) + | Generic of Type + | FSharpTypeAbbreviation of (Assembly * string * string[]) /// Represents an array or other symbolic type involving a provided type as the argument. @@ -1758,10 +1756,10 @@ type ProvidedSymbolType(kind: ProvidedSymbolKind, args: Type list, convToTgt: Ty override __.BaseType = match kind with - | ProvidedSymbolKind.SDArray -> convToTgt typeof - | ProvidedSymbolKind.Array _ -> convToTgt typeof - | ProvidedSymbolKind.Pointer -> convToTgt typeof - | ProvidedSymbolKind.ByRef -> convToTgt typeof + | ProvidedSymbolKind.SDArray -> convToTgt typeof + | ProvidedSymbolKind.Array _ -> convToTgt typeof + | ProvidedSymbolKind.Pointer -> convToTgt typeof + | ProvidedSymbolKind.ByRef -> convToTgt typeof | ProvidedSymbolKind.Generic gty -> if gty.BaseType = null then null else ProvidedSymbolType.convType args gty.BaseType @@ -1860,10 +1858,10 @@ type ProvidedSymbolType(kind: ProvidedSymbolKind, args: Type list, convToTgt: Ty override this.MakeArrayType arg = ProvidedSymbolType(ProvidedSymbolKind.Array arg, [this], convToTgt) :> Type type ProvidedSymbolMethod(genericMethodDefinition: MethodInfo, parameters: Type list) = - inherit System.Reflection.MethodInfo() + inherit MethodInfo() let convParam (p:ParameterInfo) = - { new System.Reflection.ParameterInfo() with + { new ParameterInfo() with override __.Name = p.Name override __.ParameterType = ProvidedSymbolType.convType parameters p.ParameterType override __.Attributes = p.Attributes @@ -1961,7 +1959,7 @@ type ProvidedMeasureBuilder() = [] type TypeContainer = | Namespace of Assembly * string // namespace - | Type of System.Type + | Type of Type | TypeToBeDecided #if !NO_GENERATIVE @@ -2073,6 +2071,9 @@ type ProvidedTypeDefinition(container:TypeContainer, className : string, baseTyp let customAttributesImpl = CustomAttributesImpl() + //interface IReflectableType with + // member __. GetTypeInfo() = failwith "IReflectableType.GetTypeInfo" + member __.AddXmlDocComputed xmlDocFunction = customAttributesImpl.AddXmlDocComputed xmlDocFunction member __.AddXmlDocDelayed xmlDocFunction = customAttributesImpl.AddXmlDocDelayed xmlDocFunction member __.AddXmlDoc xmlDoc = customAttributesImpl.AddXmlDoc xmlDoc @@ -2088,11 +2089,11 @@ type ProvidedTypeDefinition(container:TypeContainer, className : string, baseTyp member __.ResetEnclosingType (enclosingType) = container <- TypeContainer.Type enclosingType - new (assembly:Assembly,namespaceName,className,baseType) = new ProvidedTypeDefinition(TypeContainer.Namespace (assembly,namespaceName), className, baseType, id) - new (className:string,baseType) = new ProvidedTypeDefinition(TypeContainer.TypeToBeDecided, className, baseType, id) + new (assembly:Assembly,namespaceName,className,baseType) = ProvidedTypeDefinition(TypeContainer.Namespace (assembly,namespaceName), className, baseType, id) + new (className:string,baseType) = ProvidedTypeDefinition(TypeContainer.TypeToBeDecided, className, baseType, id) - new (assembly:Assembly,namespaceName,className,baseType,convToTgt) = new ProvidedTypeDefinition(TypeContainer.Namespace (assembly,namespaceName), className, baseType, convToTgt) - new (className,baseType, convToTgt) = new ProvidedTypeDefinition(TypeContainer.TypeToBeDecided, className, baseType, convToTgt) + new (assembly:Assembly,namespaceName,className,baseType,convToTgt) = ProvidedTypeDefinition(TypeContainer.Namespace (assembly,namespaceName), className, baseType, convToTgt) + new (className,baseType, convToTgt) = ProvidedTypeDefinition(TypeContainer.TypeToBeDecided, className, baseType, convToTgt) // state ops override __.UnderlyingSystemType = typeof @@ -2127,7 +2128,7 @@ type ProvidedTypeDefinition(container:TypeContainer, className : string, baseTyp this.AddMembersDelayed(fun () -> [memberFunction()]) #if !NO_GENERATIVE - member __.AddAssemblyTypesAsNestedTypesDelayed (assemblyFunction : unit -> System.Reflection.Assembly) = + member __.AddAssemblyTypesAsNestedTypesDelayed (assemblyFunction : unit -> Assembly) = let bucketByPath nodef tipf (items: (string list * 'Value) list) = // Find all the items with an empty key list and call 'tipf' let tips = @@ -2170,7 +2171,7 @@ type ProvidedTypeDefinition(container:TypeContainer, className : string, baseTyp staticParams <- parameters staticParamsApply <- Some instantiationFunction - /// Get ParameterInfo[] for the parametric type parameters (//s GetGenericParameters) + /// Get ParameterInfo[] for the parametric type parameters member __.GetStaticParameters() = [| for p in staticParams -> p :> ParameterInfo |] /// Instantiate parametrics type @@ -2373,7 +2374,7 @@ type ProvidedTypeDefinition(container:TypeContainer, className : string, baseTyp override __.Equals(that:obj) = match that with | null -> false - | :? ProvidedTypeDefinition as ti -> System.Object.ReferenceEquals(this,ti) + | :? ProvidedTypeDefinition as ti -> Object.ReferenceEquals(this,ti) | _ -> false override __.GetGenericArguments() = [||] @@ -2412,12 +2413,12 @@ type AssemblyGenerator(assemblyFileName) = let assemblyName = AssemblyName assemblyShortName #if FX_NO_LOCAL_FILESYSTEM let assembly = - System.AppDomain.CurrentDomain.DefineDynamicAssembly(name=assemblyName,access=AssemblyBuilderAccess.Run) + AppDomain.CurrentDomain.DefineDynamicAssembly(name=assemblyName,access=AssemblyBuilderAccess.Run) let assemblyMainModule = assembly.DefineDynamicModule("MainModule") #else let assembly = - System.AppDomain.CurrentDomain.DefineDynamicAssembly(name=assemblyName,access=(AssemblyBuilderAccess.Save ||| AssemblyBuilderAccess.Run),dir=Path.GetDirectoryName assemblyFileName) + AppDomain.CurrentDomain.DefineDynamicAssembly(name=assemblyName,access=(AssemblyBuilderAccess.Save ||| AssemblyBuilderAccess.Run),dir=Path.GetDirectoryName assemblyFileName) let assemblyMainModule = assembly.DefineDynamicModule("MainModule", Path.GetFileName assemblyFileName) #endif @@ -2606,11 +2607,11 @@ type AssemblyGenerator(assemblyFileName) = if p.HasDefaultParameterValue then do let ctor = typeof.GetConstructor([|typeof|]) - let builder = new CustomAttributeBuilder(ctor, [|p.RawDefaultValue|]) + let builder = CustomAttributeBuilder(ctor, [|p.RawDefaultValue|]) pb.SetCustomAttribute builder do let ctor = typeof.GetConstructor([||]) - let builder = new CustomAttributeBuilder(ctor, [||]) + let builder = CustomAttributeBuilder(ctor, [||]) pb.SetCustomAttribute builder pb.SetConstant p.RawDefaultValue methMap.[pminfo] <- mb @@ -2716,7 +2717,7 @@ type AssemblyGenerator(assemblyFileName) = //printfn "Emitting linqCode for %s::%s, code = %s" pminfo.DeclaringType.FullName pminfo.Name (try linqCode.ToString() with _ -> "") - let expectedState = if (minfo.ReturnType = typeof) then ExpectedStackState.Empty else ExpectedStackState.Value + let expectedState = if (minfo.ReturnType = typeof) then ExpectedStackState.Empty else ExpectedStackState.Value let codeGen = CodeGenerator(assemblyMainModule, uniqueLambdaTypeName, implicitCtorArgsAsFields, transType, transField, transMeth, transCtor, isLiteralEnumField, ilg, locals, parameterVars) codeGen.EmitExpr (expectedState, expr) ilg.Emit OpCodes.Ret @@ -2771,11 +2772,10 @@ type AssemblyGenerator(assemblyFileName) = | None -> () | Some ptd -> ptd.SetAssembly assemblyLoadedInMemory) -#if FX_NO_LOCAL_FILESYSTEM -#else +#if !FX_NO_LOCAL_FILESYSTEM member __.GetFinalBytes() = let assemblyBytes = File.ReadAllBytes assemblyFileName - let _assemblyLoadedInMemory = System.Reflection.Assembly.Load(assemblyBytes,null,System.Security.SecurityContextSource.CurrentAppDomain) + let _assemblyLoadedInMemory = Assembly.Load(assemblyBytes,null,System.Security.SecurityContextSource.CurrentAppDomain) //printfn "final bytes in '%s'" assemblyFileName File.Delete assemblyFileName assemblyBytes @@ -2809,7 +2809,7 @@ type ProvidedAssembly(assemblyFileName: string) = #if !FX_NO_LOCAL_FILESYSTEM static member RegisterGenerated (fileName:string) = //printfn "registered assembly in '%s'" fileName - let assemblyBytes = System.IO.File.ReadAllBytes fileName + let assemblyBytes = File.ReadAllBytes fileName let assembly = Assembly.Load(assemblyBytes,null,System.Security.SecurityContextSource.CurrentAppDomain) GlobalProvidedAssemblyElementsTable.theTable.Add(assembly, Lazy<_>.CreateFromValue assemblyBytes) assembly @@ -2825,7 +2825,7 @@ module Local = member __.GetNestedNamespaces() = [| |] member __.NamespaceName = namespaceName member __.GetTypes() = types |> Array.copy - member __.ResolveTypeName typeName : System.Type = + member __.ResolveTypeName typeName : Type = match types |> Array.tryFind (fun ty -> ty.Name = typeName) with | Some ty -> ty | None -> null @@ -2862,11 +2862,11 @@ type TypeProviderForNamespaces(namespacesAndTypes : list<(string * list Assembly + abstract member ResolveAssembly : args : ResolveEventArgs -> Assembly default __.ResolveAssembly(args) = let expectedName = (AssemblyName(args.Name)).Name + ".dll" @@ -2888,7 +2888,7 @@ type TypeProviderForNamespaces(namespacesAndTypes : list<(string * list IO.Path.GetDirectoryName |> this.RegisterProbingFolder - interface System.IDisposable with + interface IDisposable with member x.Dispose() = disposing.Trigger(x, EventArgs.Empty) AppDomain.CurrentDomain.remove_AssemblyResolve handler @@ -2932,7 +2932,7 @@ type TypeProviderForNamespaces(namespacesAndTypes : list<(string * list Expr.NewObjectUnchecked(cinfo, Array.toList parameters) - | :? System.Reflection.MethodInfo as minfo -> + | :? MethodInfo as minfo -> if minfo.IsStatic then Expr.CallUnchecked(minfo, Array.toList parameters) else @@ -2996,7 +2996,7 @@ type TypeProviderForNamespaces(namespacesAndTypes : list<(string * list failwith "FSharp.Core.dll not found as Manifest Resource, we're just trying to read some random .NET assembly, ok?" | resStream -> use stream = resStream.Stream @@ -3015,7 +3015,7 @@ type TypeProviderForNamespaces(namespacesAndTypes : list<(string * list bytes.Force() | _ -> - let bytes = System.IO.File.ReadAllBytes assembly.ManifestModule.FullyQualifiedName + let bytes = File.ReadAllBytes assembly.ManifestModule.FullyQualifiedName GlobalProvidedAssemblyElementsTable.theTable.[assembly] <- Lazy<_>.CreateFromValue bytes bytes #endif diff --git a/tests/AssemblyReaderTests.fs b/tests/AssemblyReaderTests.fs index 326fd2a1..5e32407c 100644 --- a/tests/AssemblyReaderTests.fs +++ b/tests/AssemblyReaderTests.fs @@ -1,21 +1,19 @@ #if INTERACTIVE -#r "../packages/NUnit/lib/net45/nunit.framework.dll" #load "../src/AssemblyReader.fs" //#load "../src/AssemblyReaderReflection.fs" (strangely fails to bind) -#load "FsUnit.fs" + #else module FSharp.TypeProviders.SDK.Tests.AssemblyReaderTests #endif open System open System.IO -open NUnit.Framework -open FsUnit +open Xunit -[] +[] let ``AssemblyReader reads assemblies containing Reflected Definitions``() : unit = - let file = Path.Combine [| __SOURCE_DIRECTORY__; ".."; "test"; "ConsoleApplication4.exe" |] + let file = Path.Combine [| __SOURCE_DIRECTORY__; "test"; "ConsoleApplication4.exe" |] let assemblyReader = ProviderImplementation.AssemblyReader.ILModuleReaderAfterReadingAllBytes(file, ProviderImplementation.AssemblyReader.mkILGlobals ProviderImplementation.AssemblyReader.EcmaMscorlibScopeRef) let someExtractedValue = [for inp in assemblyReader.ILModuleDef.ManifestOfAssembly.CustomAttrs.Elements do diff --git a/tests/BasicErasedProvisionTests.fs b/tests/BasicErasedProvisionTests.fs index 8a0a02a7..9f90b1db 100644 --- a/tests/BasicErasedProvisionTests.fs +++ b/tests/BasicErasedProvisionTests.fs @@ -1,9 +1,9 @@ #if INTERACTIVE -#r "../packages/NUnit/lib/net45/nunit.framework.dll" #load "../src/ProvidedTypes.fsi" "../src/ProvidedTypes.fs" "../src/AssemblyReader.fs" "../src/AssemblyReaderReflection.fs" "../src/ProvidedTypesContext.fs" #load "../src/ProvidedTypesTesting.fs" -#load "FsUnit.fs" + #else + module FSharp.TypeProviders.SDK.Tests.StaticProperty #endif @@ -14,8 +14,7 @@ open ProviderImplementation open ProviderImplementation.ProvidedTypes open ProviderImplementation.ProvidedTypesTesting open Microsoft.FSharp.Core.CompilerServices -open NUnit.Framework -open FsUnit +open Xunit #nowarn "760" // IDisposable needs new @@ -98,14 +97,14 @@ let testCrossTargeting (refs: string list) provider args = |> fun s -> s.Trim() |> fun s -> s.Replace("\r\n","\n") -[] +[] let ``ErasingProvider generates for .NET 4.5 F# 3.1 correctly``() : unit = let res = testCrossTargeting Targets.DotNet45FSharp31Refs (fun args -> new ErasingProvider(args)) [| |] Assert.False(res.Contains "[FSharp.Core, Version=3.259.3.1") Assert.True(res.Contains "[FSharp.Core, Version=4.3.1.0") Assert.False(res.Contains "[FSharp.Core, Version=4.4.0.0") -[] +[] let ``ErasingProvider generates for .NET 4.5 F# 4.0 correctly``() : unit = if (try File.Exists Targets.FSharpCore40Ref with _ -> false) then let res = testCrossTargeting Targets.DotNet45FSharp40Refs (fun args -> new ErasingProvider(args)) [| |] @@ -115,7 +114,7 @@ let ``ErasingProvider generates for .NET 4.5 F# 4.0 correctly``() : unit = -[] +[] let ``ErasingProvider generates for Portable Profile 259 F# 3.1 correctly``() : unit = // disabled on Linux for now because the standard packages don't come with F# PCL FSharp.Core.dll for this profile if Targets.hasPortableFSharpCoreDLLs then @@ -124,7 +123,7 @@ let ``ErasingProvider generates for Portable Profile 259 F# 3.1 correctly``() : Assert.False(res.Contains "[FSharp.Core, Version=4.3.1.0") Assert.False(res.Contains "[FSharp.Core, Version=4.4.4.0") -[] +[] let ``ErasingProvider generates for Portable Profile 259 F# 4.0 correctly``() : unit = // disabled on Linux for now because the standard packages don't come with F# PCL FSharp.Core.dll for this profile if Targets.supportsFSharp40 && Targets.hasPortableFSharpCoreDLLs then @@ -134,7 +133,7 @@ let ``ErasingProvider generates for Portable Profile 259 F# 4.0 correctly``() : Assert.False(res.Contains "[FSharp.Core, Version=4.4.4.0") -[] +[] let ``ErasingProvider generates for Portable Profile 7 F# 4.0 correctly``() : unit = // disabled on Linux for now because the standard packages don't come with F# PCL FSharp.Core.dll for this profile if Targets.supportsFSharp40 && Targets.hasPortableFSharpCoreDLLs then @@ -143,7 +142,7 @@ let ``ErasingProvider generates for Portable Profile 7 F# 4.0 correctly``() : un Assert.False(res.Contains "[FSharp.Core, Version=4.3.1.0") Assert.False(res.Contains "[FSharp.Core, Version=4.4.4.0") -[] +[] let ``ErasingProviderWithStaticParams generates for Portable Profile 7 F# 4.0 correctly``() : unit = // disabled on Linux for now because the standard packages don't come with F# PCL FSharp.Core.dll for this profile if Targets.supportsFSharp40 && Targets.hasPortableFSharpCoreDLLs then @@ -152,14 +151,14 @@ let ``ErasingProviderWithStaticParams generates for Portable Profile 7 F# 4.0 co Assert.False(res.Contains "[FSharp.Core, Version=4.3.1.0") Assert.False(res.Contains "[FSharp.Core, Version=4.4.4.0") -[] +[] let ``ErasingConstructorProvider generates for .NET 4.5 F# 3.1 correctly``() : unit = let res = testCrossTargeting Targets.DotNet45FSharp31Refs (fun args -> new ErasingConstructorProvider(args)) [| |] Assert.False(res.Contains "[FSharp.Core, Version=3.259.3.1") Assert.True(res.Contains "[FSharp.Core, Version=4.3.1.0") Assert.False(res.Contains "[FSharp.Core, Version=4.4.0.0") -[] +[] let ``ErasingConstructorProvider generates for .NET 4.5 F# 4.0 correctly``() : unit = if Targets.supportsFSharp40 then let res = testCrossTargeting Targets.DotNet45FSharp40Refs (fun args -> new ErasingConstructorProvider(args)) [| |] @@ -169,7 +168,7 @@ let ``ErasingConstructorProvider generates for .NET 4.5 F# 4.0 correctly``() : u -[] +[] let ``ErasingConstructorProvider generates for Portable Profile 259 F# 3.1 correctly``() : unit = // disabled on Linux for now because the standard packages don't come with F# PCL FSharp.Core.dll for this profile if Targets.hasPortableFSharpCoreDLLs then @@ -178,7 +177,7 @@ let ``ErasingConstructorProvider generates for Portable Profile 259 F# 3.1 corre Assert.False(res.Contains "[FSharp.Core, Version=4.3.1.0") Assert.False(res.Contains "[FSharp.Core, Version=4.4.4.0") -[] +[] let ``ErasingConstructorProvider generates for Portable Profile 259 F# 4.0 correctly``() : unit = // disabled on Linux for now because the standard packages don't come with F# PCL FSharp.Core.dll for this profile if Targets.supportsFSharp40 && Targets.hasPortableFSharpCoreDLLs then @@ -188,7 +187,7 @@ let ``ErasingConstructorProvider generates for Portable Profile 259 F# 4.0 corre Assert.False(res.Contains "[FSharp.Core, Version=4.4.4.0") -[] +[] let ``ErasingConstructorProvider generates for Portable Profile 7 F# 4.0 correctly``() : unit = // disabled on Linux for now because the standard packages don't come with F# PCL FSharp.Core.dll for this profile if Targets.supportsFSharp40 && Targets.hasPortableFSharpCoreDLLs then diff --git a/tests/BasicGenerativeProvisionTests.fs b/tests/BasicGenerativeProvisionTests.fs index 606444d3..a5272d32 100644 --- a/tests/BasicGenerativeProvisionTests.fs +++ b/tests/BasicGenerativeProvisionTests.fs @@ -1,8 +1,7 @@ #if INTERACTIVE -#r "../packages/NUnit/lib/net45/nunit.framework.dll" #load "../src/ProvidedTypes.fsi" "../src/ProvidedTypes.fs" "../src/AssemblyReader.fs" "../src/AssemblyReaderReflection.fs" "../src/ProvidedTypesContext.fs" #load "../src/ProvidedTypesTesting.fs" -#load "FsUnit.fs" + #else module FSharp.TypeProviders.SDK.Tests.BasicGenerativeTests #endif @@ -13,8 +12,7 @@ open ProviderImplementation open ProviderImplementation.ProvidedTypes open ProviderImplementation.ProvidedTypesTesting open Microsoft.FSharp.Core.CompilerServices -open NUnit.Framework -open FsUnit +open Xunit #nowarn "760" // IDisposable needs new @@ -47,7 +45,7 @@ type GenerativePropertyProviderWithStaticParams (config : TypeProviderConfig) as -[] +[] let ``GenerativePropertyProviderWithStaticParams generates for .NET 4.5 F# 4.0 correctly``() : unit = if Targets.supportsFSharp40 then let args = [| box 3; box 4 |] @@ -61,6 +59,6 @@ let ``GenerativePropertyProviderWithStaticParams generates for .NET 4.5 F# 4.0 c let t = providedTypeDefinition.MakeParametricType(typeName, args) Assert.True(t.Assembly.FullName.Contains("tmp")) let assemContents = (typeProviderForNamespaces :> ITypeProvider).GetGeneratedAssemblyContents(t.Assembly) - Assert.AreNotEqual(assemContents.Length, 0) + Assert.NotEqual(assemContents.Length, 0) #endif diff --git a/tests/FSharp.TypeProviders.SDK.Tests.fsproj b/tests/FSharp.TypeProviders.SDK.Tests.fsproj index b8b8d3b4..4ce8c0b9 100644 --- a/tests/FSharp.TypeProviders.SDK.Tests.fsproj +++ b/tests/FSharp.TypeProviders.SDK.Tests.fsproj @@ -1,59 +1,15 @@ - - - + - Debug - AnyCPU - 2.0 - 5ef9ff95-1c75-458a-983a-168e43945913 - Library - FSharp.TypeProviders.SDK.Tests - FSharp.TypeProviders.SDK.Tests - v4.5 - FSharp.TypeProviders.SDK.Tests - - ..\..\ - true - 4.3.1.0 - - - true - full - false - false - bin\Debug\ - DEBUG;TRACE - 3 - bin\Debug\FSharp.TypeProviders.SDK.Tests.XML - - - pdbonly - true - true - bin\Release\ - TRACE - 3 - bin\Release\FSharp.TypeProviders.SDK.Tests.XML - - - 11 - - - - - $(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets - - - - - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets - - - - + net461 + + + NO_GENERATIVE; $(DefineConstants) + false + - - + + PreserveNewest + ProvidedTypes.fsi @@ -76,28 +32,8 @@ - - - - - True - - - - - - - + + + - - - - - ..\packages\NUnit\lib\net45\nunit.framework.dll - True - True - - - - \ No newline at end of file diff --git a/tests/FsUnit.fs b/tests/FsUnit.fs deleted file mode 100644 index 8a1be068..00000000 --- a/tests/FsUnit.fs +++ /dev/null @@ -1,43 +0,0 @@ -module FsUnit - -open System.Diagnostics -open NUnit.Framework -open NUnit.Framework.Constraints - -[] -let should (f : 'a -> #Constraint) x (y : obj) = - let c = f x - let y = - match y with - | :? (unit -> unit) -> box (new TestDelegate(y :?> unit -> unit)) - | _ -> y - Assert.That(y, c) - -let equal x = new EqualConstraint(x) - -// like "should equal", but validates same-type -let shouldEqual (expected: 'a) (actual: 'a) = Assert.AreEqual(expected, actual, sprintf "Expected: %A\nActual: %A" expected actual) - -let notEqual x = new NotConstraint(new EqualConstraint(x)) - -let contain x = new ContainsConstraint(x) - -let haveLength n = Has.Length.EqualTo(n) - -let haveCount n = Has.Count.EqualTo(n) - -let be = id - -let Null = new NullConstraint() - -let Empty = new EmptyConstraint() - -let EmptyString = new EmptyStringConstraint() - -let True = new TrueConstraint() - -let False = new FalseConstraint() - -let sameAs x = new SameAsConstraint(x) - -let throw = Throws.TypeOf \ No newline at end of file diff --git a/tests/GenerativeEnumsProvisionTests.fs b/tests/GenerativeEnumsProvisionTests.fs index 82c7bfdd..8674d2db 100644 --- a/tests/GenerativeEnumsProvisionTests.fs +++ b/tests/GenerativeEnumsProvisionTests.fs @@ -1,9 +1,9 @@ #if INTERACTIVE -#r "../packages/NUnit/lib/net45/nunit.framework.dll" #load "../src/ProvidedTypes.fsi" "../src/ProvidedTypes.fs" "../src/AssemblyReader.fs" "../src/AssemblyReaderReflection.fs" "../src/ProvidedTypesContext.fs" #load "../src/ProvidedTypesTesting.fs" -#load "FsUnit.fs" + #else + module FSharp.TypeProviders.SDK.Tests.GenerativeEnumsProvisionTests #endif @@ -15,10 +15,10 @@ open System open System.Reflection open System.IO open Microsoft.FSharp.Core.CompilerServices +open Xunit open ProviderImplementation open ProviderImplementation.ProvidedTypes open ProviderImplementation.ProvidedTypesTesting -open NUnit.Framework let createEnum name (values: list) = let enumType = ProvidedTypeDefinition(name, Some typeof, IsErased = false) @@ -61,7 +61,7 @@ let testProvidedAssembly test = let cfg = Testing.MakeSimulatedTypeProviderConfig (__SOURCE_DIRECTORY__, runtimeAssembly, runtimeAssemblyRefs) let tp = GenerativeEnumsProvider(cfg) :> TypeProviderForNamespaces let providedTypeDefinition = tp.Namespaces |> Seq.last |> snd |> Seq.last - Assert.AreEqual("Container", providedTypeDefinition.Name) + Assert.Equal("Container", providedTypeDefinition.Name) let assemContents = (tp :> ITypeProvider).GetGeneratedAssemblyContents(providedTypeDefinition.Assembly) let assembly = Assembly.Load assemContents @@ -69,29 +69,29 @@ let testProvidedAssembly test = let runningOnMono = try System.Type.GetType("Mono.Runtime") <> null with e -> false -[] +[] let ``Enums are generated correctly``() = // See tracking bug https://github.com/fsprojects/FSharp.TypeProviders.SDK/issues/123 if not runningOnMono then testProvidedAssembly <| fun container -> let enumContainer = container.GetNestedType "EnumContainer" - Assert.IsNotNull enumContainer + Assert.NotNull enumContainer let nestedEnum = enumContainer.GetNestedType "NestedEnum" - Assert.IsNotNull nestedEnum + Assert.NotNull nestedEnum let nestedEnumField = enumContainer.GetField("nestedEnumField", BindingFlags.Instance ||| BindingFlags.NonPublic) - Assert.IsNotNull nestedEnumField - Assert.AreEqual(nestedEnum, nestedEnumField.FieldType) + Assert.NotNull nestedEnumField + Assert.Equal(nestedEnum, nestedEnumField.FieldType) - let enumValues = Enum.GetValues(nestedEnum) |> Seq.cast |> Seq.zip (Enum.GetNames(nestedEnum)) - CollectionAssert.AreEquivalent(["Foo", 1; "Bar", 2], enumValues) + let enumValues = Enum.GetValues(nestedEnum) |> Seq.cast |> Seq.zip (Enum.GetNames(nestedEnum)) |> Seq.toList + Assert.True(["Foo", 1; "Bar", 2] = enumValues) let topLevelEnum = container.GetNestedType "TopLevelEnum" - Assert.IsNotNull topLevelEnum + Assert.NotNull topLevelEnum let topLevelEnumField = enumContainer.GetField("topLevelEnumField", BindingFlags.Instance ||| BindingFlags.NonPublic) - Assert.IsNotNull topLevelEnumField - Assert.AreEqual(topLevelEnum, topLevelEnumField.FieldType) + Assert.NotNull topLevelEnumField + Assert.Equal(topLevelEnum, topLevelEnumField.FieldType) #endif \ No newline at end of file diff --git a/tests/app.config b/tests/app.config deleted file mode 100644 index 026b30b0..00000000 --- a/tests/app.config +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/tests/paket.references b/tests/paket.references deleted file mode 100644 index b6eae6ee..00000000 --- a/tests/paket.references +++ /dev/null @@ -1,2 +0,0 @@ -NUnit -NUnit.ConsoleRunner diff --git a/test/ConsoleApplication4.exe b/tests/test/ConsoleApplication4.exe similarity index 100% rename from test/ConsoleApplication4.exe rename to tests/test/ConsoleApplication4.exe diff --git a/tests/xunit.runner.json b/tests/xunit.runner.json new file mode 100644 index 00000000..c6fd41b7 --- /dev/null +++ b/tests/xunit.runner.json @@ -0,0 +1,3 @@ +{ + "parallelizeTestCollections": false + } \ No newline at end of file