diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..ecf851a --- /dev/null +++ b/.editorconfig @@ -0,0 +1,11 @@ +root = true + +[*.{cs, py, fsx}] +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.{json, xml}] +indent_style = space +indent_size = 2 diff --git a/.gitattributes b/.gitattributes index 1ff0c42..176a458 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,63 +1 @@ -############################################################################### -# Set default behavior to automatically normalize line endings. -############################################################################### * text=auto - -############################################################################### -# Set default behavior for command prompt diff. -# -# This is need for earlier builds of msysgit that does not have it on by -# default for csharp files. -# Note: This is only used by command line -############################################################################### -#*.cs diff=csharp - -############################################################################### -# Set the merge driver for project and solution files -# -# Merging from the command prompt will add diff markers to the files if there -# are conflicts (Merging from VS is not affected by the settings below, in VS -# the diff markers are never inserted). Diff markers may cause the following -# file extensions to fail to load in VS. An alternative would be to treat -# these files as binary and thus will always conflict and require user -# intervention with every merge. To do so, just uncomment the entries below -############################################################################### -#*.sln merge=binary -#*.csproj merge=binary -#*.vbproj merge=binary -#*.vcxproj merge=binary -#*.vcproj merge=binary -#*.dbproj merge=binary -#*.fsproj merge=binary -#*.lsproj merge=binary -#*.wixproj merge=binary -#*.modelproj merge=binary -#*.sqlproj merge=binary -#*.wwaproj merge=binary - -############################################################################### -# behavior for image files -# -# image files are treated as binary by default. -############################################################################### -#*.jpg binary -#*.png binary -#*.gif binary - -############################################################################### -# diff behavior for common document formats -# -# Convert binary document formats to text before diffing them. This feature -# is only available from the command line. Turn it on by uncommenting the -# entries below. -############################################################################### -#*.doc diff=astextplain -#*.DOC diff=astextplain -#*.docx diff=astextplain -#*.DOCX diff=astextplain -#*.dot diff=astextplain -#*.DOT diff=astextplain -#*.pdf diff=astextplain -#*.PDF diff=astextplain -#*.rtf diff=astextplain -#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore index 1f02c37..b0bfb06 100644 --- a/.gitignore +++ b/.gitignore @@ -1,15 +1,9 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. - # User-specific files *.suo *.user *.userosscache *.sln.docstates -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - # Build results [Dd]ebug/ [Dd]ebugPublic/ @@ -17,127 +11,28 @@ [Rr]eleases/ x64/ x86/ +build/ bld/ [Bb]in/ [Oo]bj/ +# Coverity output +cov-int/ + # Visual Studio 2015 cache/options directory .vs/ -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUNIT -*.VisualState.xml -TestResult.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - # DNX project.lock.json artifacts/ -*_i.c -*_p.c -*_i.h -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opensdf -*.sdf -*.cachefile - # Visual Studio profiler *.psess *.vsp *.vspx -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# JustCode is a .NET coding add-in -.JustCode - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# NCrunch -_NCrunch_* -.*crunch*.local.xml - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - # Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -## TODO: Comment the next line if you want to checkin your -## web deploy settings but do note that will include unencrypted -## passwords -#*.pubxml - -*.publishproj +[Pp]ublish/ # NuGet Packages *.nupkg @@ -161,52 +56,8 @@ AppPackages/ # but keep track of directories ending in .cache !*.[Cc]ache/ -# Others -ClientBin/ -[Ss]tyle[Cc]op.* -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.pfx -*.publishsettings -node_modules/ -orleans.codegen.cs +# Fake .fake/ -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -*.mdf -*.ldf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings - -# Microsoft Fakes -FakesAssemblies/ - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# LightSwitch generated files -GeneratedArtifacts/ -_Pvt_Extensions/ -ModelManifest.xml +# No APK +*.apk diff --git a/README.md b/README.md index 8630679..634eeca 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # NetLegacySupport +[![Build status](https://ci.appveyor.com/api/projects/status/0v2wraqkyyltgyg1?svg=true)](https://ci.appveyor.com/project/veblush/netlegacysupport) +[![Coverage Status](https://coveralls.io/repos/github/SaladLab/AsyncWorker/badge.svg?branch=master)](https://coveralls.io/github/SaladLab/NetLegacySupport?branch=master) + Library helps supporting old .NET frameworks like .NET 2.0 and 3.5. This is a backport from .NET Core. Following classes are provided: diff --git a/appveyor.yml b/appveyor.yml index ecfc717..3c64f41 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,14 +1,10 @@ version: 1.1.0.{build} os: Visual Studio 2015 -configuration: Debug -before_build: -- cmd: nuget restore -build: - project: NetLegacySupport.sln - verbosity: minimal -test: on environment: NUGETKEY: secure: z2fJQckgBQJ7IKfjOyrZYPM2+xDj4xYuqaUDBG7MrJs+b1bNc0vzYMTxpF6Sb1mA -deploy_script: -- cmd: build.cmd nuget nugetkey=%NUGETKEY% nugetpublishurl=https://www.myget.org/F/saladbowlcreative/api/v2/package nugetprerelease=%APPVEYOR_BUILD_NUMBER% + COVERALLSKEY: + secure: Zyppdxjp/FCADlmcIWWEz+hDqNLwdUYXoI0gOkqs2M9ZRXOeRDdEHp8ALb3Mr+CD +test: off +build_script: +- cmd: build.cmd ci nugetkey=%NUGETKEY% nugetpublishurl=https://www.myget.org/F/saladlab/api/v2/package nugetprerelease=%APPVEYOR_BUILD_NUMBER% coverallskey=%COVERALLSKEY% diff --git a/build.cmd b/build.cmd index 05cf1aa..a5c8b97 100644 --- a/build.cmd +++ b/build.cmd @@ -2,11 +2,21 @@ pushd %~dp0 -tools\nuget\NuGet.exe update -self -tools\nuget\NuGet.exe install FAKE -ConfigFile tools\nuget\Nuget.Config -OutputDirectory packages -ExcludeVersion -Version 4.10.3 -tools\nuget\NuGet.exe install nunit.runners -ConfigFile tools\nuget\Nuget.Config -OutputDirectory packages\FAKE -ExcludeVersion -Version 3.0.1 +SET PACKAGEPATH=.\packages\ +SET NUGET=.\tools\nuget\NuGet.exe +SET NUGETOPTIONS=-ConfigFile .\tools\nuget\NuGet.Config -OutputDirectory %PACKAGEPATH% -ExcludeVersion + +IF NOT EXIST %PACKAGEPATH%FAKE\Ver_4.23.0 ( + %NUGET% install FAKE -Version 4.23.0 %NUGETOPTIONS% + COPY NUL %PACKAGEPATH%FAKE\Ver_4.23.0 +) + +IF NOT EXIST %PACKAGEPATH%FAKE.BuildLib\Ver_0.1.5 ( + %NUGET% install FAKE.BuildLib -Version 0.1.5 %NUGETOPTIONS% + COPY NUL %PACKAGEPATH%FAKE.BuildLib\Ver_0.1.5 +) set encoding=utf-8 -packages\FAKE\tools\FAKE.exe build.fsx %* +"%PACKAGEPATH%FAKE\tools\FAKE.exe" build.fsx %* popd diff --git a/build.fsx b/build.fsx index b77ef4a..7d98704 100644 --- a/build.fsx +++ b/build.fsx @@ -1,220 +1,63 @@ #I @"packages/FAKE/tools" +#I @"packages/FAKE.BuildLib/lib/net451" #r "FakeLib.dll" +#r "BuildLib.dll" open Fake -open System.IO -open Fake.Testing.XUnit2 -open Fake.AssemblyInfoFile -open Fake.ReleaseNotesHelper - -// ------------------------------------------------------------------------------ Project - -let buildSolutionFile = "./NetLegacySupport.sln" -let buildConfiguration = "Release" - -type Project = { - Name: string; - Folder: string; - Template: bool; - AssemblyVersion: string; - PackageVersion: string; - Releases: ReleaseNotes list; - Dependencies: (string * string) list; -} - -let emptyProject = { Name=""; Folder=""; Template=false; AssemblyVersion=""; - PackageVersion=""; Releases=[]; Dependencies=[] } - -let decoratePrerelease v = - let couldParse, parsedInt = System.Int32.TryParse(v) - if couldParse then "build" + (sprintf "%04d" parsedInt) else v - -let decoratePackageVersion v = - if hasBuildParam "nugetprerelease" then - v + "-" + decoratePrerelease((getBuildParam "nugetprerelease")) - else - v - -let projects = ([ - { emptyProject with - Name="NetLegacySupport.Action"; - Folder="./core/Action"; - Dependencies=[]; - }; - { emptyProject with - Name="NetLegacySupport.ConcurrentDictionary"; - Folder="./core/ConcurrentDictionary"; - Dependencies=[("NetLegacySupport.Action", "")]; - }; - { emptyProject with - Name="NetLegacySupport.Tuple"; - Folder="./core/Tuple"; - Dependencies=[]; - }] - |> List.map (fun p -> - let parsedReleases = - File.ReadLines (p.Folder @@ (p.Name + ".Release.md")) - |> ReleaseNotesHelper.parseAllReleaseNotes - let latest = List.head parsedReleases - { p with AssemblyVersion = latest.AssemblyVersion; - PackageVersion = decoratePackageVersion(latest.AssemblyVersion); - Releases = parsedReleases } - )) - -let project name = - List.filter (fun p -> p.Name = name) projects |> List.head - -let dependencies p deps = - p.Dependencies |> - List.map (fun d -> match d with - | (id, "") -> (id, match List.tryFind (fun (x, ver) -> x = id) deps with - | Some (_, ver) -> ver - | None -> ((project id).PackageVersion)) - | (id, ver) -> (id, ver)) - -// ---------------------------------------------------------------------------- Variables - -let binDir = "bin" -let testDir = binDir @@ "test" -let nugetDir = binDir @@ "nuget" -let nugetWorkDir = nugetDir @@ "work" - -// ------------------------------------------------------------------------------ Targets - -Target "Clean" (fun _ -> - CleanDirs [binDir] -) - -Target "AssemblyInfo" (fun _ -> - projects - |> List.filter (fun p -> not p.Template) - |> List.iter (fun p -> - CreateCSharpAssemblyInfo (p.Folder @@ "Properties" @@ "AssemblyInfoGenerated.cs") - [ Attribute.Version ((SemVerHelper.parse p.AssemblyVersion).Major.ToString() + ".0.0") - Attribute.FileVersion p.AssemblyVersion - Attribute.InformationalVersion p.PackageVersion ] - ) -) - -Target "Build" (fun _ -> - !! buildSolutionFile - |> MSBuild "" "Rebuild" [ "Configuration", buildConfiguration ] - |> Log "Build-Output: " -) - -Target "Test" (fun _ -> - ensureDirectory testDir - !! ("./core/**/bin/" + buildConfiguration + "/*.Tests.dll") - |> NUnit (fun p -> - {p with - ToolName = "nunit3-console.exe"; - ToolPath = "./packages/FAKE/NUnit.Console/tools"; - DisableShadowCopy = true; - OutputFile = testDir @@ "TestResult.xml" }) -) - -let createNugetPackages _ = - projects - |> List.iter (fun project -> - let nugetFile = project.Folder @@ project.Name + ".nuspec"; - let workDir = nugetWorkDir @@ project.Name; - - let targets = [("", "net45"); (".Net20", "net20"); (".Net35", "net35"); (".Net40", "net40")]; - targets |> List.iter (fun (postfix, target) -> - let dllFileNameNet = (project.Folder + postfix) @@ "bin/Release" @@ project.Name; - let dllFilesNet = (!! (dllFileNameNet + ".dll") - ++ (dllFileNameNet + ".pdb") - ++ (dllFileNameNet + ".xml")) - if (Seq.length dllFilesNet > 0) then ( - dllFilesNet |> CopyFiles (workDir @@ "lib" @@ target)) - ) - - let isAssemblyInfo f = (filename f).Contains("AssemblyInfo") - let isSrc f = (hasExt ".cs" f) && not (isAssemblyInfo f) - CopyDir (workDir @@ "src") project.Folder isSrc - - let packageFile = project.Folder @@ "packages.config" - let packageDependencies = if (fileExists packageFile) then (getDependencies packageFile) else [] - - NuGet (fun p -> - {p with - Project = project.Name - OutputPath = nugetDir - WorkingDir = workDir - Dependencies = dependencies project packageDependencies - SymbolPackage = (if (project.Name.Contains("Templates")) then NugetSymbolPackage.None else NugetSymbolPackage.Nuspec) - Version = project.PackageVersion - ReleaseNotes = (List.head project.Releases).Notes |> String.concat "\n" - }) nugetFile - ) - -let publishNugetPackages _ = - projects - |> List.iter (fun project -> - try - NuGetPublish (fun p -> - {p with - Project = project.Name - OutputPath = nugetDir - WorkingDir = nugetDir - AccessKey = getBuildParamOrDefault "nugetkey" "" - PublishUrl = getBuildParamOrDefault "nugetpublishurl" "" - Version = project.PackageVersion }) - with e -> if getBuildParam "forcepublish" = "" then raise e; () - if not project.Template && hasBuildParam "nugetpublishurl" then ( - // current FAKE doesn't support publishing symbol package with NuGetPublish. - // To workaround thid limitation, let's tweak Version to cheat nuget read symbol package - try - NuGetPublish (fun p -> - {p with - Project = project.Name - OutputPath = nugetDir - WorkingDir = nugetDir - AccessKey = getBuildParamOrDefault "nugetkey" "" - PublishUrl = getBuildParamOrDefault "nugetpublishurl" "" - Version = project.PackageVersion + ".symbols" }) - with e -> if getBuildParam "forcepublish" = "" then raise e; () - ) - ) +open BuildLib + +let solution = + initSolution + "./NetLegacySupport.sln" "Release" + [ { emptyProject with Name="NetLegacySupport.Action"; + Folder="./core/Action"; + Dependencies=[] }; + { emptyProject with Name="NetLegacySupport.ConcurrentDictionary"; + Folder="./core/ConcurrentDictionary"; + Dependencies=[("NetLegacySupport.Action", "")] }; + { emptyProject with Name="NetLegacySupport.Tuple"; + Folder="./core/Tuple"; + Dependencies=[] } ] + +Target "Clean" <| fun _ -> cleanBin + +Target "AssemblyInfo" <| fun _ -> generateAssemblyInfo solution + +Target "Restore" <| fun _ -> restoreNugetPackages solution + +Target "Build" <| fun _ -> buildSolution solution + +Target "Test" <| fun _ -> testSolution solution + +Target "Cover" <| fun _ -> coverSolution solution Target "Nuget" <| fun _ -> - createNugetPackages() - publishNugetPackages() + createNugetPackages solution + publishNugetPackages solution Target "CreateNuget" <| fun _ -> - createNugetPackages() + createNugetPackages solution Target "PublishNuget" <| fun _ -> - publishNugetPackages() - -Target "Help" (fun _ -> - List.iter printfn [ - "usage:" - "build [target]" - "" - " Targets for building:" - " * Build Build" - " * Test Build and Test" - " * Nuget Create and publish nugets packages" - " * CreateNuget Create nuget packages" - " [nugetprerelease={VERSION_PRERELEASE}] " - " * PublishNuget Publish nugets packages" - " [nugetkey={API_KEY}] [nugetpublishurl={PUBLISH_URL}] [forcepublish=1]" - ""] -) - -// --------------------------------------------------------------------------- Dependency - -// Build order + publishNugetPackages solution + +Target "CI" <| fun _ -> () + +Target "Help" <| fun _ -> + showUsage solution (fun _ -> None) + "Clean" ==> "AssemblyInfo" + ==> "Restore" ==> "Build" ==> "Test" -"Build" - ==> "Nuget" +"Build" ==> "Nuget" +"Build" ==> "CreateNuget" +"Build" ==> "Cover" + +"Test" ==> "CI" +"Cover" ==> "CI" +"Nuget" ==> "CI" -"Build" - ==> "CreateNuget" - RunTargetOrDefault "Help" diff --git a/core/Action/Properties/AssemblyInfoGenerated.cs b/core/Action/Properties/AssemblyInfoGenerated.cs index 72ebee3..ddbc430 100644 --- a/core/Action/Properties/AssemblyInfoGenerated.cs +++ b/core/Action/Properties/AssemblyInfoGenerated.cs @@ -1,11 +1,12 @@ // using System.Reflection; -[assembly: AssemblyVersionAttribute("1.0.0")] +[assembly: AssemblyVersionAttribute("1.1.0")] [assembly: AssemblyFileVersionAttribute("1.1.0")] [assembly: AssemblyInformationalVersionAttribute("1.1.0")] namespace System { internal static class AssemblyVersionInformation { - internal const string Version = "1.0.0"; + internal const string Version = "1.1.0"; + internal const string InformationalVersion = "1.1.0"; } } diff --git a/core/ConcurrentDictionary/Properties/AssemblyInfoGenerated.cs b/core/ConcurrentDictionary/Properties/AssemblyInfoGenerated.cs index 72ebee3..ddbc430 100644 --- a/core/ConcurrentDictionary/Properties/AssemblyInfoGenerated.cs +++ b/core/ConcurrentDictionary/Properties/AssemblyInfoGenerated.cs @@ -1,11 +1,12 @@ // using System.Reflection; -[assembly: AssemblyVersionAttribute("1.0.0")] +[assembly: AssemblyVersionAttribute("1.1.0")] [assembly: AssemblyFileVersionAttribute("1.1.0")] [assembly: AssemblyInformationalVersionAttribute("1.1.0")] namespace System { internal static class AssemblyVersionInformation { - internal const string Version = "1.0.0"; + internal const string Version = "1.1.0"; + internal const string InformationalVersion = "1.1.0"; } } diff --git a/core/Tuple.Tests/TestTuple.cs b/core/Tuple.Tests/TestTuple.cs index 5323b80..682d2c2 100644 --- a/core/Tuple.Tests/TestTuple.cs +++ b/core/Tuple.Tests/TestTuple.cs @@ -1,8 +1,6 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -#if NET20 || NET35 - using System; using System.Collections; using NUnit; @@ -700,5 +698,3 @@ public int GetHashCode(object x) } } } - -#endif diff --git a/core/Tuple/Properties/AssemblyInfoGenerated.cs b/core/Tuple/Properties/AssemblyInfoGenerated.cs index 72ebee3..ddbc430 100644 --- a/core/Tuple/Properties/AssemblyInfoGenerated.cs +++ b/core/Tuple/Properties/AssemblyInfoGenerated.cs @@ -1,11 +1,12 @@ // using System.Reflection; -[assembly: AssemblyVersionAttribute("1.0.0")] +[assembly: AssemblyVersionAttribute("1.1.0")] [assembly: AssemblyFileVersionAttribute("1.1.0")] [assembly: AssemblyInformationalVersionAttribute("1.1.0")] namespace System { internal static class AssemblyVersionInformation { - internal const string Version = "1.0.0"; + internal const string Version = "1.1.0"; + internal const string InformationalVersion = "1.1.0"; } }