diff --git a/.gitignore b/.gitignore
index 0be0a878..bc064d5d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,29 +1,76 @@
-# Build Folders (you can keep bin if you'd like, to store dlls and pdbs)
-[Bb]in/
-[Oo]bj/
+# Files relevant to ScriptCS project
-# mstest test results
-TestResults
-
-## Ignore Visual Studio temporary files, build results, and
-## files generated by popular Visual Studio add-ons.
+artifacts
+/scriptcs_packages
# Diff files
*.orig
+# These are extra items from the original ignore file
+# keeping the items here until I submit PR to gitignore.io
+*.sln.ide
+*.bak
+*.ncrunch*
+*.Cache
+[Ss]tyle[Cc]op.*
+
+# -----------------------------------------------------------------------
+# Created by https://www.gitignore.io/api/visualstudio
+
+### VisualStudio ###
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+##
+## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
+
# User-specific files
*.suo
*.user
+*.userosscache
*.sln.docstates
-*.sln.ide
+
+# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
+[Dd]ebugPublic/
[Rr]elease/
+[Rr]eleases/
x64/
+x86/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+
+# Visual Studio 2015 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# 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
+
+# .NET Core
+project.lock.json
+project.fragment.lock.json
+artifacts/
+**/Properties/launchSettings.json
+
*_i.c
*_p.c
+*_i.h
*.ilk
*.meta
*.obj
@@ -37,36 +84,73 @@ x64/
*.tli
*.tlh
*.tmp
+*.tmp_proj
*.log
-*.bak
*.vspscc
*.vssscc
.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
+*.opendb
*.opensdf
*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
+*.sap
+
+# TFS 2012 Local Workspace
+$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
-_ReSharper*
+_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
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
# NCrunch
-*.ncrunch*
+_NCrunch_*
.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
-# Installshield output folder
-[Ee]xpress
+# Installshield output folder
+[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
@@ -79,38 +163,155 @@ DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
-publish
+publish/
# Publish Web Output
-*.Publish.xml
+*.[Pp]ublish.xml
+*.azurePubxml
+# TODO: Uncomment the next line to ignore your web deploy settings.
+# By default, sensitive information, such as encrypted password
+# should be stored in the .pubxml.user file.
+#*.pubxml
+*.pubxml.user
+*.publishproj
-# NuGet Packages Directory
-packages
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
-# Windows Azure Build Output
-csx
+# NuGet Packages
+*.nupkg
+# The packages folder can be ignored because of Package Restore
+**/packages/*
+# except build/, which is used as an MSBuild target.
+!**/packages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/packages/repositories.config
+# NuGet v3's project.json files produces more ignorable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
*.build.csdef
-# Windows Store app package directory
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!*.[Cc]ache/
# Others
-[Bb]in
-[Oo]bj
-sql
-TestResults
-[Tt]est[Rr]esult*
-*.Cache
-ClientBin
-[Ss]tyle[Cc]op.*
+ClientBin/
~$*
+*~
*.dbmdl
-Generated_Code #added for RIA/Silverlight projects
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+orleans.codegen.cs
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
-# Backup & report files from converting an old project file to a newer
-# Visual Studio version. Backup files are not needed, because we have git ;-)
+# 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
-artifacts
+# SQL Server files
+*.mdf
+*.ldf
+*.ndf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+node_modules/
+
+# Typescript v1 declaration files
+typings/
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+*.vbw
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# JetBrains Rider
+.idea/
+*.sln.iml
+
+# CodeRush
+.cr/
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+
+# Cake - Uncomment if you are using it
+# tools/**
+# !tools/packages.config
+
+# Telerik's JustMock configuration file
+*.jmconfig
+
+# BizTalk build output
+*.btp.cs
+*.btm.cs
+*.odx.cs
+*.xsd.cs
+
+### VisualStudio Patch ###
+# By default, sensitive information, such as encrypted password
+# should be stored in the .pubxml.user file.
+
+# End of https://www.gitignore.io/api/visualstudio
+*.DS_Store
diff --git a/.nuget/NuGet.exe b/.nuget/NuGet.exe
index c41a0d0d..a34c3675 100644
Binary files a/.nuget/NuGet.exe and b/.nuget/NuGet.exe differ
diff --git a/.nuget/packages.config b/.nuget/packages.config
index eb41749c..61ff56f9 100644
--- a/.nuget/packages.config
+++ b/.nuget/packages.config
@@ -1,4 +1,6 @@
-
+
-
-
\ No newline at end of file
+
+
+
+
diff --git a/.paket/Paket.Restore.targets b/.paket/Paket.Restore.targets
new file mode 100644
index 00000000..305e736c
--- /dev/null
+++ b/.paket/Paket.Restore.targets
@@ -0,0 +1,300 @@
+
+
+
+
+
+
+ $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
+
+ true
+ $(MSBuildThisFileDirectory)
+ $(MSBuildThisFileDirectory)..\
+ $(PaketRootPath)paket-files\paket.restore.cached
+ $(PaketRootPath)paket.lock
+ /Library/Frameworks/Mono.framework/Commands/mono
+ mono
+
+ $(PaketRootPath)paket.exe
+ $(PaketToolsPath)paket.exe
+ "$(PaketExePath)"
+ $(MonoPath) --runtime=v4.0.30319 "$(PaketExePath)"
+
+
+ <_PaketExeExtension>$([System.IO.Path]::GetExtension("$(PaketExePath)"))
+ dotnet "$(PaketExePath)"
+
+
+ "$(PaketExePath)"
+
+ $(PaketRootPath)paket.bootstrapper.exe
+ $(PaketToolsPath)paket.bootstrapper.exe
+ "$(PaketBootStrapperExePath)"
+ $(MonoPath) --runtime=v4.0.30319 "$(PaketBootStrapperExePath)"
+
+
+
+
+ true
+ true
+
+
+
+
+
+
+ true
+ $(NoWarn);NU1603;NU1604;NU1605;NU1608
+
+
+
+
+ /usr/bin/shasum "$(PaketRestoreCacheFile)" | /usr/bin/awk '{ print $1 }'
+ /usr/bin/shasum "$(PaketLockFilePath)" | /usr/bin/awk '{ print $1 }'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $([System.IO.File]::ReadAllText('$(PaketRestoreCacheFile)'))
+ $([System.IO.File]::ReadAllText('$(PaketLockFilePath)'))
+ true
+ false
+ true
+
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $(MSBuildProjectDirectory)\obj\$(MSBuildProjectFile).paket.references.cached
+
+ $(MSBuildProjectFullPath).paket.references
+
+ $(MSBuildProjectDirectory)\$(MSBuildProjectName).paket.references
+
+ $(MSBuildProjectDirectory)\paket.references
+
+ false
+ true
+ true
+ references-file-or-cache-not-found
+
+
+
+
+ $([System.IO.File]::ReadAllText('$(PaketReferencesCachedFilePath)'))
+ $([System.IO.File]::ReadAllText('$(PaketOriginalReferencesFilePath)'))
+ references-file
+ false
+
+
+
+
+ false
+
+
+
+
+ true
+ target-framework '$(TargetFramework)' or '$(TargetFrameworks)' files @(PaketResolvedFilePaths)
+
+
+
+
+
+
+
+
+
+ false
+ true
+
+
+
+
+
+
+
+
+
+
+ $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[0])
+ $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[1])
+ $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[4])
+ $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[5])
+
+
+ %(PaketReferencesFileLinesInfo.PackageVersion)
+ All
+ runtime
+ true
+
+
+
+
+ $(MSBuildProjectDirectory)/obj/$(MSBuildProjectFile).paket.clitools
+
+
+
+
+
+
+
+
+ $([System.String]::Copy('%(PaketCliToolFileLines.Identity)').Split(',')[0])
+ $([System.String]::Copy('%(PaketCliToolFileLines.Identity)').Split(',')[1])
+
+
+ %(PaketCliToolFileLinesInfo.PackageVersion)
+
+
+
+
+
+
+
+
+
+ false
+
+
+
+
+
+ <_NuspecFilesNewLocation Include="$(BaseIntermediateOutputPath)$(Configuration)\*.nuspec"/>
+
+
+
+ $(MSBuildProjectDirectory)/$(MSBuildProjectFile)
+ true
+ false
+ true
+ $(BaseIntermediateOutputPath)$(Configuration)
+ $(BaseIntermediateOutputPath)
+
+
+
+ <_NuspecFiles Include="$(AdjustedNuspecOutputPath)\*.nuspec"/>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.paket/paket.bootstrapper.exe b/.paket/paket.bootstrapper.exe
new file mode 100644
index 00000000..b98e000b
Binary files /dev/null and b/.paket/paket.bootstrapper.exe differ
diff --git a/.travis.yml b/.travis.yml
index db24c598..4f77655f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,10 +1,20 @@
-sudo: false
language: csharp
-
-install:
- - nuget restore ./ScriptCs.sln
+dotnet: 2.0.0
+sudo: required
+dist: trusty
+env:
+ global:
+ - secure: m2PtYwYOhaK0uFMZ19ZxApZwWZeAIq1dS//jx/5I3txpIWD+TfycQMAWYxycFJ/GJkeVF29P4Zz1uyS2XKKjPJpp2Pds98FNQyDv3OftpLAVa0drsjfhurVlBmSdrV7GH6ncKfvhd+h7KVK5vbZc+NeR4dH7eNvN/jraS//AMJg=
+ - DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true
+ - DOTNET_CLI_TELEMETRY_OPTOUT=true
+mono:
+ - 5.8.0
+
+os:
+ - linux
+ - osx
script:
- - mkdir artifacts --parents
- - xbuild ./ScriptCs.sln /property:Configuration=Release /nologo /verbosity:normal
- - mono ./packages/xunit.runners.1.9.2/tools/xunit.console.clr4.exe test/ScriptCs.Tests.Acceptance/bin/Release/ScriptCs.Tests.Acceptance.dll /xml artifacts/ScriptCs.Tests.Acceptance.dll.TestResult.xml /html artifacts/ScriptCs.Tests.Acceptance.dll.TestResult.html
+ - ulimit -n8192
+ - chmod +x build.sh
+ - ./build.sh
\ No newline at end of file
diff --git a/Directory.Build.props b/Directory.Build.props
new file mode 100644
index 00000000..fcb2be8d
--- /dev/null
+++ b/Directory.Build.props
@@ -0,0 +1,5 @@
+
+
+ latest
+
+
\ No newline at end of file
diff --git a/Directory.Build.targets b/Directory.Build.targets
new file mode 100644
index 00000000..eb7be3ec
--- /dev/null
+++ b/Directory.Build.targets
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/LICENSE.md b/LICENSE.md
index e59e1189..7261cf31 100644
--- a/LICENSE.md
+++ b/LICENSE.md
@@ -1,4 +1,4 @@
-Copyright 2013, 2014 Glenn Block, Justin Rusbatch, Filip Wojcieszyn
+Copyright 2013 Glenn Block, Justin Rusbatch, Filip Wojcieszyn
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/README.md b/README.md
index bcaffba7..01c0df77 100644
--- a/README.md
+++ b/README.md
@@ -30,11 +30,13 @@ If the above fails with the error indicating that proxy authentication is requir
@powershell -NoProfile -ExecutionPolicy Unrestricted -Command "[Net.WebRequest]::DefaultWebProxy.Credentials = [Net.CredentialCache]::DefaultCredentials; iex ((New-Object Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin
+**Note:** If you are using a version of Chocolatey > 0.9.9.0 you can pass the `-y` into the install and upgrade commands to prevent the confirmation that will appear.
+
### Installing scriptcs
Once Chocolatey has been installed, you can install the latest stable version of scriptcs from your command prompt:
- cinst scriptcs
+ choco install scriptcs
Chocolatey will install scriptcs to `%LOCALAPPDATA%\scriptcs\` and update your PATH accordingly.
@@ -44,35 +46,31 @@ Chocolatey will install scriptcs to `%LOCALAPPDATA%\scriptcs\` and update your P
With Chocolatey, keeping scriptcs updated is just as easy:
- cup scriptcs
+ choco upgrade scriptcs
+
+**Note:** If you are using a version of Chocolatey < 0.9.0.0 you will need to use `choco update scriptcs`, but also think about updating Chocolatey itself.
### Nightly builds
Nightly builds are hosted on [MyGet](https://www.myget.org/), and can also be installed through with Chocolatey:
- cinst scriptcs -pre -source https://www.myget.org/F/scriptcsnightly/
+ choco install scriptcs -pre -source https://www.myget.org/F/scriptcsnightly/
### Building from source
#### Windows
-1. Ensure you have .NET Framework 4.5 installed.
+1. Ensure you have .NET Framework 4.6.1 installed.
-1. Execute the build script.
+2. Execute the build script.
`build.cmd`
#### Linux
-1. Ensure you have Mono development tools 3.0 or later installed.
-
- `sudo apt-get install mono-devel`
-
-1. Ensure your mono instance has root SSL certificates
-
- `mozroots --import --sync`
+1. Ensure you have [Mono 5.12](https://www.mono-project.com/download/stable/) or later installed.
-1. Execute the build script
+2. Execute the build script
`./build.sh`
@@ -120,22 +118,12 @@ using Raven.Client.Indexes;
Console.WriteLine("Starting RavenDB server...");
-EmbeddableDocumentStore documentStore = null;
-try
+using (var documentStore = new EmbeddableDocumentStore { UseEmbeddedHttpServer = true })
{
- documentStore = new EmbeddableDocumentStore { UseEmbeddedHttpServer = true };
documentStore.Initialize();
-
- var url = string.Format("http://localhost:{0}", documentStore.Configuration.Port);
- Console.WriteLine("RavenDB started, listening on {0}.", url);
-
+ Console.WriteLine($"RavenDB started, listening on http://localhost:{documentStore.Configuration.Port}");
Console.ReadKey();
}
-finally
-{
- if (documentStore != null)
- documentStore.Dispose();
-}
```
* Install the [RavenDB.Embedded](https://nuget.org/packages/RavenDB.Embedded/) package from NuGet using the [install command](https://github.com/scriptcs/scriptcs/wiki/Package-installation).
@@ -161,7 +149,7 @@ RavenDB started, listening on http://localhost:8080.
Script Packs can be used to further reduce the amount of code you need to write when working with common frameworks.
-* In an empty directory, install the [ScriptCs.WebApi](https://nuget.org/packages/ScriptCs.WebApi/) script pack from NuGet. The script pack will automatically imports the Web API namespaces and provides a convenient factory method for initializing the Web API host. It also replaces the default `ControllerResolver` with a custom implementation that allows Web API to discover controllers declared in scripts.
+* In an empty directory, install the [ScriptCs.WebApi](https://nuget.org/packages/ScriptCs.WebApi/) script pack from NuGet. The script pack automatically imports the Web API namespaces and provides a convenient factory method for initializing the Web API host. It also replaces the default `ControllerResolver` with a custom implementation that allows Web API to discover controllers declared in scripts.
```batchfile
scriptcs -install ScriptCs.WebApi
@@ -241,11 +229,11 @@ Instructions for debugging scripts using Visual Studio can be found on the [wiki
### Package installation
-You can install any NuGet packages directly from the scriptcs CLI. This will pull the relevant packages from NuGet, and install them in the packages folder.
+You can install any NuGet packages directly from the scriptcs CLI. This will pull the relevant packages from NuGet, and install them in the scriptcs_packages folder.
Once the packages are installed, you can simply start using them in your script code directly (just import the namespaces - no additional bootstrapping or DLL referencing is needed).
-The `install` command will also create a `packages.config` file if you don't have one - so that you can easily redistribute your script (without having to copy the package binaries).
+The `install` command will also create a `scriptcs_packages.config` file if you don't have one - so that you can easily redistribute your script (without having to copy the package binaries).
- `scriptcs -install {package name}` will install the desired package from NuGet.
@@ -253,9 +241,9 @@ The `install` command will also create a `packages.config` file if you don't hav
scriptcs -install ServiceStack
- - `scriptcs -install` (without package name) will look for the `packages.config` file located in the current execution directory, and install all the packages specified there. You only need to specify **top level** packages.
+ - `scriptcs -install` (without package name) will look for the `scriptcs_packages.config` file located in the current execution directory, and install all the packages specified there. You only need to specify **top level** packages.
-For example, you might create the following `packages.config`:
+For example, you might create the following `scriptcs_packages.config`:
@@ -268,7 +256,7 @@ And then just call:
scriptcs -install
-As a result, all packages specified in the `packages.config`, including all dependencies, will be downloaded and installed in the `packages` folder.
+As a result, all packages specified in the `scriptcs_packages.config`, including all dependencies, will be downloaded and installed in the `scriptcs_packages` folder.
## Contributing
@@ -298,7 +286,7 @@ Want to chat? In addition to Twitter, you can find us on [Google Groups](https:/
* [Damian Schenkelman](http://github.com/dschenkelman) ([@dschenkelman](https://twitter.com/intent/user?screen_name=dschenkelman))
* [Kristian Hellang](http://github.com/khellang) ([@khellang](https://twitter.com/intent/user?screen_name=khellang))
* [Adam Ralph](http://github.com/adamralph) ([@adamralph](https://twitter.com/intent/user?screen_name=adamralph))
-* [Paul Bouwer](http://github.com/paulbouwer) [@pbouwer](https://twitter.com/intent/user?screen_name=pbouwer))
+* [Paul Bouwer](http://github.com/paulbouwer) ([@pbouwer](https://twitter.com/intent/user?screen_name=pbouwer))
## Credits
diff --git a/ScriptCs.Test.ruleset b/ScriptCs.Test.ruleset
deleted file mode 100644
index c99131d0..00000000
--- a/ScriptCs.Test.ruleset
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/ScriptCs.ruleset b/ScriptCs.ruleset
deleted file mode 100644
index 0abac465..00000000
--- a/ScriptCs.ruleset
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/ScriptCs.sln b/ScriptCs.sln
index ef4d90bc..756ee82f 100644
--- a/ScriptCs.sln
+++ b/ScriptCs.sln
@@ -1,49 +1,39 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2013
-VisualStudioVersion = 12.0.31101.0
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.29709.97
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptCs", "src\ScriptCs\ScriptCs.csproj", "{25080671-1A80-4041-B9C7-260578FF4849}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScriptCs", "src\ScriptCs\ScriptCs.csproj", "{25080671-1A80-4041-B9C7-260578FF4849}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptCs.Contracts", "src\ScriptCs.Contracts\ScriptCs.Contracts.csproj", "{6049E205-8B5F-4080-B023-70600E51FD64}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScriptCs.Contracts", "src\ScriptCs.Contracts\ScriptCs.Contracts.csproj", "{6049E205-8B5F-4080-B023-70600E51FD64}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptCs.Tests", "test\ScriptCs.Tests\ScriptCs.Tests.csproj", "{4D6A2A55-BB17-40CB-9567-EAFF80BEFDCE}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScriptCs.Tests", "test\ScriptCs.Tests\ScriptCs.Tests.csproj", "{4D6A2A55-BB17-40CB-9567-EAFF80BEFDCE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{A59C6538-62EA-4BF6-AA00-E0E9A2892D47}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptCs.Core", "src\ScriptCs.Core\ScriptCs.Core.csproj", "{E590E710-E159-48E6-A3E6-1A83D3FE732C}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScriptCs.Core", "src\ScriptCs.Core\ScriptCs.Core.csproj", "{E590E710-E159-48E6-A3E6-1A83D3FE732C}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptCs.Core.Tests", "test\ScriptCs.Core.Tests\ScriptCs.Core.Tests.csproj", "{AC228213-7356-4F0D-BA48-EBA5FB8A7506}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScriptCs.Core.Tests", "test\ScriptCs.Core.Tests\ScriptCs.Core.Tests.csproj", "{AC228213-7356-4F0D-BA48-EBA5FB8A7506}"
EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{9659F354-CF48-4FD6-8E0C-E9EB3C2BDA32}"
- ProjectSection(SolutionItems) = preProject
- build\Build.proj = build\Build.proj
- build\ScriptCs.Common.props = build\ScriptCs.Common.props
- ScriptCs.ruleset = ScriptCs.ruleset
- build\ScriptCs.Tasks.targets = build\ScriptCs.Tasks.targets
- build\ScriptCs.Version.props = build\ScriptCs.Version.props
- EndProjectSection
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptCs.Engine.Roslyn", "src\ScriptCs.Engine.Roslyn\ScriptCs.Engine.Roslyn.csproj", "{E79EC231-E27D-4057-91C9-2D001A3A8C3B}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScriptCs.Engine.Roslyn.Tests", "test\ScriptCs.Engine.Roslyn.Tests\ScriptCs.Engine.Roslyn.Tests.csproj", "{28D11DE5-9F98-4E0A-8CCC-9CDC19110451}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptCs.Engine.Roslyn.Tests", "test\ScriptCs.Engine.Roslyn.Tests\ScriptCs.Engine.Roslyn.Tests.csproj", "{28D11DE5-9F98-4E0A-8CCC-9CDC19110451}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScriptCs.Hosting", "src\ScriptCs.Hosting\ScriptCs.Hosting.csproj", "{9AEF2D95-87FB-4829-B384-34BFE076D531}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptCs.Hosting", "src\ScriptCs.Hosting\ScriptCs.Hosting.csproj", "{9AEF2D95-87FB-4829-B384-34BFE076D531}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScriptCs.Hosting.Tests", "test\ScriptCs.Hosting.Tests\ScriptCs.Hosting.Tests.csproj", "{EC03EAA0-94FD-4145-8F78-5F2E30E3FF9A}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptCs.Hosting.Tests", "test\ScriptCs.Hosting.Tests\ScriptCs.Hosting.Tests.csproj", "{EC03EAA0-94FD-4145-8F78-5F2E30E3FF9A}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptCs.Engine.Mono", "src\ScriptCs.Engine.Mono\ScriptCs.Engine.Mono.csproj", "{E4ADCFEE-FF3B-4EF5-8298-2B31F407F58B}"
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{B138045D-DC04-4A04-A2BA-F771173BCC32}"
+ ProjectSection(SolutionItems) = preProject
+ .nuget\packages.config = .nuget\packages.config
+ EndProjectSection
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptCs.Engine.Mono.Tests", "test\ScriptCs.Engine.Mono.Tests\ScriptCs.Engine.Mono.Tests.csproj", "{D0723C2D-D3B4-40B7-8E5A-84FB3A6E5092}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScriptCs.Engine.Roslyn", "src\ScriptCs.Engine.Roslyn\ScriptCs.Engine.Roslyn.csproj", "{E79EC231-E27D-4057-91C9-2D001A3A8C3B}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScriptCs.Tests.Acceptance", "test\ScriptCs.Tests.Acceptance\ScriptCs.Tests.Acceptance.csproj", "{10684649-2922-41F5-AB9B-20B127CBF92C}"
- ProjectSection(ProjectDependencies) = postProject
- {25080671-1A80-4041-B9C7-260578FF4849} = {25080671-1A80-4041-B9C7-260578FF4849}
- EndProjectSection
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScriptCs.Tests.Acceptance", "test\ScriptCs.Tests.Acceptance\ScriptCs.Tests.Acceptance.csproj", "{10684649-2922-41F5-AB9B-20B127CBF92C}"
EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{B138045D-DC04-4A04-A2BA-F771173BCC32}"
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8C5ABCEF-82F9-4850-B2B8-1D7B73D9C5C3}"
ProjectSection(SolutionItems) = preProject
- .nuget\packages.config = .nuget\packages.config
+ Directory.Build.props = Directory.Build.props
+ Directory.Build.targets = Directory.Build.targets
EndProjectSection
EndProject
Global
@@ -72,10 +62,6 @@ Global
{AC228213-7356-4F0D-BA48-EBA5FB8A7506}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AC228213-7356-4F0D-BA48-EBA5FB8A7506}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AC228213-7356-4F0D-BA48-EBA5FB8A7506}.Release|Any CPU.Build.0 = Release|Any CPU
- {E79EC231-E27D-4057-91C9-2D001A3A8C3B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {E79EC231-E27D-4057-91C9-2D001A3A8C3B}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {E79EC231-E27D-4057-91C9-2D001A3A8C3B}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {E79EC231-E27D-4057-91C9-2D001A3A8C3B}.Release|Any CPU.Build.0 = Release|Any CPU
{28D11DE5-9F98-4E0A-8CCC-9CDC19110451}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{28D11DE5-9F98-4E0A-8CCC-9CDC19110451}.Debug|Any CPU.Build.0 = Debug|Any CPU
{28D11DE5-9F98-4E0A-8CCC-9CDC19110451}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -88,14 +74,10 @@ Global
{EC03EAA0-94FD-4145-8F78-5F2E30E3FF9A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EC03EAA0-94FD-4145-8F78-5F2E30E3FF9A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EC03EAA0-94FD-4145-8F78-5F2E30E3FF9A}.Release|Any CPU.Build.0 = Release|Any CPU
- {E4ADCFEE-FF3B-4EF5-8298-2B31F407F58B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {E4ADCFEE-FF3B-4EF5-8298-2B31F407F58B}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {E4ADCFEE-FF3B-4EF5-8298-2B31F407F58B}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {E4ADCFEE-FF3B-4EF5-8298-2B31F407F58B}.Release|Any CPU.Build.0 = Release|Any CPU
- {D0723C2D-D3B4-40B7-8E5A-84FB3A6E5092}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {D0723C2D-D3B4-40B7-8E5A-84FB3A6E5092}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {D0723C2D-D3B4-40B7-8E5A-84FB3A6E5092}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {D0723C2D-D3B4-40B7-8E5A-84FB3A6E5092}.Release|Any CPU.Build.0 = Release|Any CPU
+ {E79EC231-E27D-4057-91C9-2D001A3A8C3B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E79EC231-E27D-4057-91C9-2D001A3A8C3B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E79EC231-E27D-4057-91C9-2D001A3A8C3B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E79EC231-E27D-4057-91C9-2D001A3A8C3B}.Release|Any CPU.Build.0 = Release|Any CPU
{10684649-2922-41F5-AB9B-20B127CBF92C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{10684649-2922-41F5-AB9B-20B127CBF92C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{10684649-2922-41F5-AB9B-20B127CBF92C}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -109,7 +91,9 @@ Global
{AC228213-7356-4F0D-BA48-EBA5FB8A7506} = {A59C6538-62EA-4BF6-AA00-E0E9A2892D47}
{28D11DE5-9F98-4E0A-8CCC-9CDC19110451} = {A59C6538-62EA-4BF6-AA00-E0E9A2892D47}
{EC03EAA0-94FD-4145-8F78-5F2E30E3FF9A} = {A59C6538-62EA-4BF6-AA00-E0E9A2892D47}
- {D0723C2D-D3B4-40B7-8E5A-84FB3A6E5092} = {A59C6538-62EA-4BF6-AA00-E0E9A2892D47}
{10684649-2922-41F5-AB9B-20B127CBF92C} = {A59C6538-62EA-4BF6-AA00-E0E9A2892D47}
EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {AD80B19D-7299-4CBD-B59F-6DB868FF6A9C}
+ EndGlobalSection
EndGlobal
diff --git a/Settings.StyleCop b/Settings.StyleCop
deleted file mode 100644
index 9416cb43..00000000
--- a/Settings.StyleCop
+++ /dev/null
@@ -1,283 +0,0 @@
-
-
- False
- False
-
- nullable
-
-
-
-
-
-
- TemporaryGeneratedFile_.*\.cs$|LibLog.cs
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- True
-
-
-
-
- True
-
-
-
-
- False
-
-
-
-
- True
- True
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- True
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644
index 00000000..55cad9e8
--- /dev/null
+++ b/appveyor.yml
@@ -0,0 +1,16 @@
+version: 1.0.{build}
+
+image: Visual Studio 2017
+
+environment:
+ DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
+ DOTNET_CLI_TELEMETRY_OPTOUT: true
+
+init:
+- git config --global core.autocrlf false
+
+build_script:
+- cmd:
+ build.cmd
+
+test: off
\ No newline at end of file
diff --git a/build.cmd b/build.cmd
index e290c2c2..752c9f63 100644
--- a/build.cmd
+++ b/build.cmd
@@ -1,25 +1,14 @@
-@echo Off
-setlocal
+@echo off
+cls
-if exist artifacts goto Build
-mkdir artifacts
+.paket\paket.bootstrapper.exe
+if errorlevel 1 (
+ exit /b %errorlevel%
+)
-:Build
-%WINDIR%\Microsoft.NET\Framework\v4.0.30319\msbuild Build\Build.proj /nologo /m /v:M %* /fl /flp:LogFile=artifacts\msbuild.log;Verbosity=Diagnostic;DetailedSummary /nr:false
+.paket\paket.exe restore
+if errorlevel 1 (
+ exit /b %errorlevel%
+)
-if %ERRORLEVEL% neq 0 goto BuildFail
-goto BuildSuccess
-
-:BuildFail
-echo.
-echo *** BUILD FAILED ***
-goto End
-
-:BuildSuccess
-echo.
-echo **** BUILD SUCCESSFUL ***
-goto end
-
-:End
-echo.
-exit /b %ERRORLEVEL%
\ No newline at end of file
+packages\FAKE\tools\FAKE.exe build.fsx %*
\ No newline at end of file
diff --git a/build.fsx b/build.fsx
new file mode 100644
index 00000000..51ba6692
--- /dev/null
+++ b/build.fsx
@@ -0,0 +1,70 @@
+#r "packages/FAKE/tools/FakeLib.dll"
+
+open Fake
+open Fake.DotNetCli
+open Fake.Testing
+open System.IO
+
+Target "Clean" (fun _ ->
+ !! "artifacts" ++ "src/*/bin" ++ "test/*/bin" ++ "src/*/obj" ++ "test/*/obj"
+ |> DeleteDirs
+)
+
+Target "Build" (fun _ ->
+ DotNetCli.Restore id
+
+ "ScriptCs.sln"
+ |> MSBuildHelper.build (fun p ->
+ { p with
+ RestorePackagesFlag = true
+ Verbosity = Some Minimal
+ Targets = [ "Build" ]
+ Properties =
+ [
+ "Optimize", "True"
+ "Configuration", "Release"
+ ]
+ } )
+)
+
+Target "Test" (fun _ ->
+#if MONO
+ !! "test/**/bin/**/*Tests.Acceptance.dll"
+ |> xUnit2 (fun c ->
+ {c with
+ MaxThreads = CollectionConcurrencyMode.MaxThreads 1
+ })
+#else
+ !! "test/**/*Tests*.csproj"
+ |> Seq.iter (fun p ->
+ DotNetCli.Test (fun c ->
+ {c with
+ WorkingDir = Path.GetDirectoryName p
+ AdditionalArgs = ["--no-build"]
+ })
+ )
+#endif
+)
+
+Target "Pack" (fun _ ->
+ "ScriptCs.sln"
+ |> MSBuildHelper.build (fun p ->
+ { p with
+ RestorePackagesFlag = true
+ Verbosity = Some Minimal
+ Targets = [ "Pack" ]
+ Properties =
+ [
+ "Optimize", "True"
+ "Configuration", "Release"
+ "PackageOutputPath", "../../artifacts"
+ ]
+ } )
+)
+
+"Clean"
+ ==> "Build"
+ ==> "Test"
+ ==> "Pack"
+
+RunTargetOrDefault "Pack"
\ No newline at end of file
diff --git a/build.sh b/build.sh
index 41b4f391..fa37cd79 100755
--- a/build.sh
+++ b/build.sh
@@ -1,15 +1,33 @@
-#!/usr/bin/env bash
-set -e
-set -o pipefail
-set -x
+#!/bin/bash
+if test "$OS" = "Windows_NT"
+then
+ # use .Net
-# install
-mozroots --import --sync --quiet
-mono ./.nuget/NuGet.exe restore ./ScriptCs.sln
+ .paket/paket.bootstrapper.exe prerelease
+ exit_code=$?
+ if [ $exit_code -ne 0 ]; then
+ exit $exit_code
+ fi
-# script
-mkdir -p artifacts/Release/bin
-xbuild ./ScriptCs.sln /property:Configuration=Release /nologo /verbosity:normal
-cp src/*/bin/Release/* artifacts/Release/bin/
-mono ./packages/xunit.runners.1.9.2/tools/xunit.console.clr4.exe test/ScriptCs.Tests.Acceptance/bin/Release/ScriptCs.Tests.Acceptance.dll /xml artifacts/ScriptCs.Tests.Acceptance.dll.TestResult.xml /html artifacts/ScriptCs.Tests.Acceptance.dll.TestResult.html
+ .paket/paket.exe restore
+ exit_code=$?
+ if [ $exit_code -ne 0 ]; then
+ exit $exit_code
+ fi
+ packages/FAKE/tools/FAKE.exe $@ --nocache --fsiargs build.fsx
+else
+ # use mono
+ mono .paket/paket.bootstrapper.exe prerelease
+ exit_code=$?
+ if [ $exit_code -ne 0 ]; then
+ exit $exit_code
+ fi
+
+ mono .paket/paket.exe restore
+ exit_code=$?
+ if [ $exit_code -ne 0 ]; then
+ exit $exit_code
+ fi
+ mono packages/FAKE/tools/FAKE.exe $@ --nocache --fsiargs -d:MONO build.fsx
+fi
\ No newline at end of file
diff --git a/build/Build.proj b/build/Build.proj
deleted file mode 100644
index 7138da9f..00000000
--- a/build/Build.proj
+++ /dev/null
@@ -1,116 +0,0 @@
-
-
-
-
-
-
-
-
- Release
-
- $(MSBuildThisFileDirectory)..\
- $(Root)artifacts\
- $(BaseArtifactsPath)$(Configuration)\
- $(BaseArtifactsPath)$(Configuration)
-
- $(Root).nuget\NuGet.exe
-
- $([System.IO.Path]::Combine( $(Root), 'common\CommonVersionInfo.cs' ))
-
-
-
-
-
- Configuration=$(Configuration);
- ArtifactsPath=$(ArtifactsPath);
- RunCodeAnalysis=false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -Version $(PackageVersion) -Symbols -Verbosity quiet -NoPackageAnalysis -OutputDirectory "$(PackageOutputPath)" -p Configuration=$(Configuration)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/build/ScriptCs.Common.props b/build/ScriptCs.Common.props
deleted file mode 100644
index 0a1bcee9..00000000
--- a/build/ScriptCs.Common.props
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
- bin\$(Configuration)\
- true
- prompt
- 4
- true
-
- true
-
-
-
- $(DefineConstants);MONO
- false
-
-
-
- false
-
-
-
- $(DefineConstants);DEBUG
- full
- false
-
-
-
- pdbonly
- true
-
-
\ No newline at end of file
diff --git a/build/ScriptCs.Tasks.targets b/build/ScriptCs.Tasks.targets
deleted file mode 100644
index 3c48de20..00000000
--- a/build/ScriptCs.Tasks.targets
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/build/ScriptCs.Version.props b/build/ScriptCs.Version.props
deleted file mode 100644
index 3e888860..00000000
--- a/build/ScriptCs.Version.props
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-
-
- 0
- 15
- 0
-
-
-
-
-
-
-
-
- $(MajorVersion).$(MinorVersion).0
- $(MajorVersion).$(MinorVersion).$(PatchVersion)
- $(AssemblyInformationalVersion)-$(BuildQuality)
- $(AssemblyInformationalVersion)-nightly-$([System.DateTime]::UtcNow.ToString("yyMMdd"))
-
- $(AssemblyInformationalVersion)
-
-
-
-
- <_Parameter1>$(AssemblyVersion)
-
-
- <_Parameter1>$(AssemblyInformationalVersion)
-
-
-
diff --git a/build_brew.sh b/build_brew.sh
new file mode 100755
index 00000000..b74b80e4
--- /dev/null
+++ b/build_brew.sh
@@ -0,0 +1,13 @@
+#!/usr/bin/env bash
+set -e
+set -o pipefail
+set -x
+
+# install
+mozroots --import --sync --quiet
+mono ./.nuget/NuGet.exe restore ./ScriptCs.sln
+
+# script
+mkdir -p artifacts/Release/bin
+msbuild ./ScriptCs.sln /property:Configuration=Release /nologo /verbosity:normal
+cp src/ScriptCs/bin/Release/net461/* artifacts/Release/bin/
diff --git a/common/CommonAssemblyInfo.cs b/common/CommonAssemblyInfo.cs
deleted file mode 100644
index 1bf26ab7..00000000
--- a/common/CommonAssemblyInfo.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using System;
-using System.Reflection;
-using System.Runtime.InteropServices;
-
-#if DEBUG
-[assembly: AssemblyConfiguration("Debug")]
-#else
-[assembly: AssemblyConfiguration("Release")]
-#endif
-
-[assembly: AssemblyProduct("scriptcs")]
-[assembly: AssemblyCompany("Glenn Block, Filip Wojcieszyn, Justin Rusbatch, Kristian Hellang, Damian Schenkelman, Adam Ralph")]
-[assembly: AssemblyCopyright("Copyright 2013 Glenn Block, Justin Rusbatch, Filip Wojcieszyn")]
-
-[assembly: ComVisible(false)]
-[assembly: CLSCompliant(false)]
\ No newline at end of file
diff --git a/common/CommonVersionInfo.cs b/common/CommonVersionInfo.cs
deleted file mode 100644
index 590a13eb..00000000
--- a/common/CommonVersionInfo.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using System.Reflection;
-
-/**
- * Do not manually edit this file. The build script will generate and insert the proper version numbers based on the
- * contents of 'build\ScriptCs.Version.props'.
- **/
-
-[assembly: AssemblyVersion("0.0.0")]
-[assembly: AssemblyInformationalVersion("0.0.0")]
\ No newline at end of file
diff --git a/common/Icon.ico b/common/Icon.ico
deleted file mode 100644
index d946fa05..00000000
Binary files a/common/Icon.ico and /dev/null differ
diff --git a/edit-stylecop-settings.cmd b/edit-stylecop-settings.cmd
deleted file mode 100644
index c45a2fe2..00000000
--- a/edit-stylecop-settings.cmd
+++ /dev/null
@@ -1,2 +0,0 @@
-@echo Off
-start packages\StyleCop.MSBuild.4.7.49.0\tools\StyleCopSettingsEditor.exe Settings.StyleCop
\ No newline at end of file
diff --git a/paket.dependencies b/paket.dependencies
new file mode 100644
index 00000000..a397754e
--- /dev/null
+++ b/paket.dependencies
@@ -0,0 +1,4 @@
+source https://nuget.org/api/v2
+
+nuget FAKE
+nuget xunit.runner.console
\ No newline at end of file
diff --git a/paket.lock b/paket.lock
new file mode 100644
index 00000000..a878f015
--- /dev/null
+++ b/paket.lock
@@ -0,0 +1,4 @@
+NUGET
+ remote: https://www.nuget.org/api/v2
+ FAKE (4.64.13)
+ xunit.runner.console (2.4.1)
diff --git a/src/ScriptCs.Contracts/AssemblyReferences.cs b/src/ScriptCs.Contracts/AssemblyReferences.cs
index e33d2cce..734bcea7 100644
--- a/src/ScriptCs.Contracts/AssemblyReferences.cs
+++ b/src/ScriptCs.Contracts/AssemblyReferences.cs
@@ -61,15 +61,9 @@ public AssemblyReferences(IEnumerable assemblies, IEnumerable
}
}
- public IEnumerable Assemblies
- {
- get { return _assemblies.Values.ToArray(); }
- }
+ public IEnumerable Assemblies => _assemblies.Values.ToArray();
- public IEnumerable Paths
- {
- get { return _paths.Values.ToArray(); }
- }
+ public IEnumerable Paths => _paths.Values.ToArray();
public AssemblyReferences Union(AssemblyReferences references)
{
diff --git a/src/ScriptCs.Contracts/DefaultLogProvider.cs b/src/ScriptCs.Contracts/DefaultLogProvider.cs
new file mode 100644
index 00000000..202dae56
--- /dev/null
+++ b/src/ScriptCs.Contracts/DefaultLogProvider.cs
@@ -0,0 +1,76 @@
+namespace ScriptCs.Contracts
+{
+ using System;
+
+ public class DefaultLogProvider : ILogProvider
+ {
+ private readonly ILogProvider _provider = ResolveLogProvider() ?? new NullLogProvider();
+
+ [Obsolete("Should not be called directly. Instead, call a method on LogProviderExtensions.")]
+ public Logger GetLogger(string name) => _provider.GetLogger(name);
+
+ ///
+ /// Opens a nested diagnostics context. Not supported in .
+ ///
+ /// The message to add to the diagnostics context.
+ /// A disposable that when disposed removes the message from the context.
+ public IDisposable OpenNestedContext(string message) => _provider.OpenNestedContext(message);
+
+ ///
+ /// Opens a mapped diagnostics context. Not supported in .
+ ///
+ /// A key.
+ /// A value.
+ /// A disposable that when disposed removes the map from the context.
+ public IDisposable OpenMappedContext(string key, string value) => _provider.OpenMappedContext(key, value);
+
+ private static ILogProvider ResolveLogProvider()
+ {
+ var libLogProvider = LibLog.LogProvider.ResolveLogProvider();
+ return libLogProvider == null ? null : new LibLogAdapter(libLogProvider);
+ }
+
+ private class NullLogProvider : ILogProvider
+ {
+ private static readonly Logger logger = (_, __, ___, ____) => false;
+ private static readonly Disposable disposable = new Disposable();
+
+ [Obsolete("Should not be called directly. Instead, call a method on LogProviderExtensions.")]
+ public Logger GetLogger(string name)
+ {
+ return logger;
+ }
+
+ public IDisposable OpenNestedContext(string message) => disposable;
+
+ public IDisposable OpenMappedContext(string key, string value) => disposable;
+
+ private sealed class Disposable : IDisposable
+ {
+ public void Dispose()
+ {
+ }
+ }
+ }
+
+ private class LibLogAdapter : ILogProvider
+ {
+ private readonly LibLog.ILogProvider _libLogProvider;
+
+ public LibLogAdapter(LibLog.ILogProvider libLogProvider)
+ {
+ _libLogProvider = libLogProvider;
+ }
+
+ public Logger GetLogger(string name)
+ {
+ return (logLevel, messageFunc, exception, formatParameters) =>
+ _libLogProvider.GetLogger(name)((LibLog.LogLevel)logLevel, messageFunc, exception, formatParameters);
+ }
+
+ public IDisposable OpenNestedContext(string message) => _libLogProvider.OpenNestedContext(message);
+
+ public IDisposable OpenMappedContext(string key, string value) => _libLogProvider.OpenMappedContext(key, value);
+ }
+ }
+}
diff --git a/src/ScriptCs.Contracts/DirectiveLineProcessor.cs b/src/ScriptCs.Contracts/DirectiveLineProcessor.cs
index d05be903..9494a54b 100644
--- a/src/ScriptCs.Contracts/DirectiveLineProcessor.cs
+++ b/src/ScriptCs.Contracts/DirectiveLineProcessor.cs
@@ -4,17 +4,11 @@ namespace ScriptCs.Contracts
{
public abstract class DirectiveLineProcessor : IDirectiveLineProcessor
{
- protected virtual BehaviorAfterCode BehaviorAfterCode
- {
- get { return BehaviorAfterCode.Ignore; }
- }
+ protected virtual BehaviorAfterCode BehaviorAfterCode => BehaviorAfterCode.Ignore;
protected abstract string DirectiveName { get; }
- private string DirectiveString
- {
- get { return string.Format("#{0}", DirectiveName); }
- }
+ private string DirectiveString => string.Format("#{0}", DirectiveName);
public bool ProcessLine(IFileParser parser, FileParserContext context, string line, bool isBeforeCode)
{
@@ -29,7 +23,7 @@ public bool ProcessLine(IFileParser parser, FileParserContext context, string li
{
throw new InvalidDirectiveUseException(string.Format("Encountered directive '{0}' after the start of code. Please move this directive to the beginning of the file.", DirectiveString));
}
- else if (BehaviorAfterCode == Contracts.BehaviorAfterCode.Ignore)
+ if (BehaviorAfterCode == Contracts.BehaviorAfterCode.Ignore)
{
return true;
}
diff --git a/src/ScriptCs.Contracts/FileParserContext.cs b/src/ScriptCs.Contracts/FileParserContext.cs
index 312a6f5f..adc754d8 100644
--- a/src/ScriptCs.Contracts/FileParserContext.cs
+++ b/src/ScriptCs.Contracts/FileParserContext.cs
@@ -19,5 +19,7 @@ public FileParserContext()
public List LoadedScripts { get; private set; }
public List BodyLines { get; private set; }
+
+ public string ScriptPath { get; set; }
}
}
\ No newline at end of file
diff --git a/src/ScriptCs.Contracts/FilePreProcessorResult.cs b/src/ScriptCs.Contracts/FilePreProcessorResult.cs
index 7406b3a3..2b664edc 100644
--- a/src/ScriptCs.Contracts/FilePreProcessorResult.cs
+++ b/src/ScriptCs.Contracts/FilePreProcessorResult.cs
@@ -17,6 +17,8 @@ public FilePreProcessorResult()
public List References { get; set; }
+ public string ScriptPath { get; set; }
+
public string Code { get; set; }
}
}
\ No newline at end of file
diff --git a/src/ScriptCs.Contracts/IConsole.cs b/src/ScriptCs.Contracts/IConsole.cs
index be06d0d9..2ff69cdc 100644
--- a/src/ScriptCs.Contracts/IConsole.cs
+++ b/src/ScriptCs.Contracts/IConsole.cs
@@ -10,7 +10,7 @@ public interface IConsole
void WriteLine(string value);
- string ReadLine();
+ string ReadLine(string prompt);
void Clear();
@@ -19,5 +19,7 @@ public interface IConsole
void ResetColor();
ConsoleColor ForegroundColor { get; set; }
+
+ int Width { get; }
}
}
\ No newline at end of file
diff --git a/src/ScriptCs.Contracts/IFileSystem.cs b/src/ScriptCs.Contracts/IFileSystem.cs
index 1c6921f1..0f0fb352 100644
--- a/src/ScriptCs.Contracts/IFileSystem.cs
+++ b/src/ScriptCs.Contracts/IFileSystem.cs
@@ -35,6 +35,8 @@ IEnumerable EnumerateFilesAndDirectories(
string GetFullPath(string path);
+ string TempPath { get; }
+
string CurrentDirectory { get; set; }
string NewLine { get; }
diff --git a/src/ScriptCs.Contracts/IFileSystemMigrator.cs b/src/ScriptCs.Contracts/IFileSystemMigrator.cs
deleted file mode 100644
index 3a8ca5c4..00000000
--- a/src/ScriptCs.Contracts/IFileSystemMigrator.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace ScriptCs.Contracts
-{
- public interface IFileSystemMigrator
- {
- void Migrate();
- }
-}
diff --git a/src/ScriptCs.Contracts/ILog.cs b/src/ScriptCs.Contracts/ILog.cs
new file mode 100644
index 00000000..795e61b2
--- /dev/null
+++ b/src/ScriptCs.Contracts/ILog.cs
@@ -0,0 +1,36 @@
+namespace ScriptCs.Contracts
+{
+ using System;
+
+ public interface ILog
+ {
+ ///
+ /// Logs a message for a specified log level, if the is enabled for that log level.
+ ///
+ /// The log level.
+ ///
+ /// Optional function which creates the message.
+ /// Specify null to simply check if the logger is enabled for the .
+ ///
+ /// An optional exception to include with the message.
+ ///
+ /// Optional arguments for formatting the message created by .
+ ///
+ ///
+ /// true if the is enabled for the .
+ /// Otherwise false.
+ ///
+ ///
+ /// Note to implementers for optimal performance:
+ /// When the is null, simply return a
+ /// indicating whether the is enabled for the specified .
+ /// When the is not null, it should only be invoked
+ /// if the is enabled for the specified .
+ ///
+ bool Log(
+ LogLevel logLevel,
+ Func createMessage = null,
+ Exception exception = null,
+ params object[] formatArgs);
+ }
+}
diff --git a/src/ScriptCs.Contracts/ILogProvider.cs b/src/ScriptCs.Contracts/ILogProvider.cs
new file mode 100644
index 00000000..17946070
--- /dev/null
+++ b/src/ScriptCs.Contracts/ILogProvider.cs
@@ -0,0 +1,21 @@
+namespace ScriptCs.Contracts
+{
+ using System;
+
+ public interface ILogProvider
+ {
+ ///
+ /// Gets the specified named logger.
+ ///
+ /// Name of the logger.
+ /// The logger reference.
+ ///
+ /// Do not call this method directly. Instead, call a method on .
+ ///
+ Logger GetLogger(string name);
+
+ IDisposable OpenNestedContext(string message);
+
+ IDisposable OpenMappedContext(string key, string value);
+ }
+}
diff --git a/src/ScriptCs.Contracts/IScriptEnvironment.cs b/src/ScriptCs.Contracts/IScriptEnvironment.cs
index 3ebcec7d..60a6c637 100644
--- a/src/ScriptCs.Contracts/IScriptEnvironment.cs
+++ b/src/ScriptCs.Contracts/IScriptEnvironment.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Reflection;
using System.Text;
using System.Threading.Tasks;
@@ -9,5 +10,12 @@ namespace ScriptCs.Contracts
public interface IScriptEnvironment
{
IReadOnlyList ScriptArgs { get; }
+ void AddCustomPrinter(Func printer);
+ void Print(T o);
+ void Print(object o);
+ string ScriptPath { get; }
+ string[] LoadedScripts { get; }
+ Assembly ScriptAssembly { get; }
+ void Initialize();
}
-}
+}
\ No newline at end of file
diff --git a/src/ScriptCs.Contracts/IScriptExecutor.cs b/src/ScriptCs.Contracts/IScriptExecutor.cs
index 0dba0d22..fe9b992d 100644
--- a/src/ScriptCs.Contracts/IScriptExecutor.cs
+++ b/src/ScriptCs.Contracts/IScriptExecutor.cs
@@ -7,7 +7,7 @@ public interface IScriptExecutor
{
AssemblyReferences References { get; }
- ICollection Namespaces { get; }
+ IReadOnlyCollection Namespaces { get; }
IScriptEngine ScriptEngine { get; }
diff --git a/src/ScriptCs.Contracts/IScriptInfo.cs b/src/ScriptCs.Contracts/IScriptInfo.cs
new file mode 100644
index 00000000..1686a1af
--- /dev/null
+++ b/src/ScriptCs.Contracts/IScriptInfo.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ScriptCs.Contracts
+{
+ public interface IScriptInfo
+ {
+ string ScriptPath { get; set; }
+ IList LoadedScripts { get; }
+ }
+}
diff --git a/src/ScriptCs.Core/App_Packages/LibLog.3.1/LibLog.cs b/src/ScriptCs.Contracts/Internal/LibLog.cs
similarity index 71%
rename from src/ScriptCs.Core/App_Packages/LibLog.3.1/LibLog.cs
rename to src/ScriptCs.Contracts/Internal/LibLog.cs
index cc0c7d40..f5f232ac 100644
--- a/src/ScriptCs.Core/App_Packages/LibLog.3.1/LibLog.cs
+++ b/src/ScriptCs.Contracts/Internal/LibLog.cs
@@ -3,7 +3,7 @@
//
// https://github.com/damianh/LibLog
//===============================================================================
-// Copyright © 2011-2015 Damian Hickey. All rights reserved.
+// Copyright © 2011-2015 Damian Hickey. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@@ -27,20 +27,62 @@
// ReSharper disable PossibleNullReferenceException
// Define LIBLOG_PORTABLE conditional compilation symbol for PCL compatibility
+//
+// Define LIBLOG_PUBLIC to enable ability to GET a logger (LogProvider.For<>() etc) from outside this library. NOTE:
+// this can have unintended consequences of consumers of your library using your library to resolve a logger. If the
+// reason is because you want to open this functionality to other projects within your solution,
+// consider [InternalsVisibleTo] instead.
+//
+// Define LIBLOG_PROVIDERS_ONLY if your library provides its own logging API and you just want to use the
+// LibLog providers internally to provide built in support for popular logging frameworks.
#pragma warning disable 1591
-namespace ScriptCs.Logging
+using System.Diagnostics.CodeAnalysis;
+
+[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "ScriptCs.Contracts.Logging")]
+[assembly: SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed", Scope = "member", Target = "ScriptCs.Contracts.Logging.Logger.#Invoke(ScriptCs.Contracts.Logging.LogLevel,System.Func`1,System.Exception,System.Object[])")]
+
+// If you copied this file manually, you need to change all "YourRootNameSpace" so not to clash with other libraries
+// that use LibLog
+#if LIBLOG_PROVIDERS_ONLY
+namespace ScriptCs.Contracts.LibLog
+#else
+namespace ScriptCs.Contracts.Logging
+#endif
{
using System.Collections.Generic;
- using ScriptCs.Logging.LogProviders;
+ using System.Diagnostics.CodeAnalysis;
+#if LIBLOG_PROVIDERS_ONLY
+ using ScriptCs.Contracts.LibLog.LogProviders;
+#else
+ using ScriptCs.Contracts.Logging.LogProviders;
+#endif
using System;
+#if !LIBLOG_PROVIDERS_ONLY
using System.Diagnostics;
+#if !LIBLOG_PORTABLE
+ using System.Runtime.CompilerServices;
+#endif
+#endif
+#if LIBLOG_PROVIDERS_ONLY
+ internal
+#else
+ public
+#endif
+ delegate bool Logger(LogLevel logLevel, Func messageFunc, Exception exception = null, params object[] formatParameters);
+
+#if !LIBLOG_PROVIDERS_ONLY
///
/// Simple interface that represent a logger.
///
- public interface ILog
+#if LIBLOG_PUBLIC
+ public
+#else
+ internal
+#endif
+ interface ILog
{
///
/// Log a message the specified log level.
@@ -58,11 +100,17 @@ public interface ILog
///
bool Log(LogLevel logLevel, Func messageFunc, Exception exception = null, params object[] formatParameters );
}
+#endif
///
/// The log level.
///
- public enum LogLevel
+#if LIBLOG_PROVIDERS_ONLY
+ internal
+#else
+ public
+#endif
+ enum LogLevel
{
Trace,
Debug,
@@ -72,7 +120,13 @@ public enum LogLevel
Fatal
}
- public static class LogExtensions
+#if !LIBLOG_PROVIDERS_ONLY
+#if LIBLOG_PUBLIC
+ public
+#else
+ internal
+#endif
+ static partial class LogExtensions
{
public static bool IsDebugEnabled(this ILog logger)
{
@@ -140,7 +194,6 @@ public static void DebugException(this ILog logger, string message, Exception ex
}
}
-
public static void DebugException(this ILog logger, string message, Exception exception, params object[] formatParams)
{
if (logger.IsDebugEnabled())
@@ -151,6 +204,7 @@ public static void DebugException(this ILog logger, string message, Exception ex
public static void Error(this ILog logger, Func messageFunc)
{
+ GuardAgainstNullLogger(logger);
logger.Log(LogLevel.Error, messageFunc);
}
@@ -297,6 +351,7 @@ public static void WarnException(this ILog logger, string message, Exception exc
}
}
+ // ReSharper disable once UnusedParameter.Local
private static void GuardAgainstNullLogger(ILog logger)
{
if (logger == null)
@@ -321,18 +376,24 @@ private static T Return(this T value)
return value;
}
}
+#endif
///
/// Represents a way to get a
///
- public interface ILogProvider
+#if LIBLOG_PROVIDERS_ONLY
+ internal
+#else
+ public
+#endif
+ interface ILogProvider
{
///
/// Gets the specified named logger.
///
/// Name of the logger.
/// The logger reference.
- ILog GetLogger(string name);
+ Logger GetLogger(string name);
///
/// Opens a nested diagnostics context. Not supported in EntLib logging.
@@ -353,18 +414,83 @@ public interface ILogProvider
///
/// Provides a mechanism to create instances of objects.
///
- public static class LogProvider
+#if LIBLOG_PROVIDERS_ONLY
+ internal
+#else
+ public
+#endif
+ static class LogProvider
{
- private static ILogProvider _currentLogProvider;
+#if !LIBLOG_PROVIDERS_ONLY
+ ///
+ /// The disable logging environment variable. If the environment variable is set to 'true', then logging
+ /// will be disabled.
+ ///
+ public const string DisableLoggingEnvironmentVariable = "ScriptCs.Contracts_LIBLOG_DISABLE";
private const string NullLogProvider = "Current Log Provider is not set. Call SetCurrentLogProvider " +
"with a non-null value first.";
+ private static dynamic s_currentLogProvider;
+ private static Action s_onCurrentLogProviderSet;
+
+ [SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline")]
+ static LogProvider()
+ {
+ IsDisabled = false;
+ }
+
+ ///
+ /// Sets the current log provider.
+ ///
+ /// The log provider.
+ public static void SetCurrentLogProvider(ILogProvider logProvider)
+ {
+ s_currentLogProvider = logProvider;
+
+ RaiseOnCurrentLogProviderSet();
+ }
+
+ ///
+ /// Gets or sets a value indicating whether this is logging is disabled.
+ ///
+ ///
+ /// true if logging is disabled; otherwise, false.
+ ///
+ public static bool IsDisabled { get; set; }
+
+ ///
+ /// Sets an action that is invoked when a consumer of your library has called SetCurrentLogProvider. It is
+ /// important that hook into this if you are using child libraries (especially ilmerged ones) that are using
+ /// LibLog (or other logging abstraction) so you adapt and delegate to them.
+ ///
+ ///
+ internal static Action OnCurrentLogProviderSet
+ {
+ set
+ {
+ s_onCurrentLogProviderSet = value;
+ RaiseOnCurrentLogProviderSet();
+ }
+ }
+
+ internal static ILogProvider CurrentLogProvider
+ {
+ get
+ {
+ return s_currentLogProvider;
+ }
+ }
///
/// Gets a logger for the specified type.
///
/// The type whose name will be used for the logger.
/// An instance of
- public static ILog For()
+#if LIBLOG_PUBLIC
+ public
+#else
+ internal
+#endif
+ static ILog For()
{
return GetLogger(typeof(T));
}
@@ -374,7 +500,13 @@ public static ILog For()
/// Gets a logger for the current class.
///
/// An instance of
- public static ILog GetCurrentClassLogger()
+ [MethodImpl(MethodImplOptions.NoInlining)]
+#if LIBLOG_PUBLIC
+ public
+#else
+ internal
+#endif
+ static ILog GetCurrentClassLogger()
{
var stackFrame = new StackFrame(1, false);
return GetLogger(stackFrame.GetMethod().DeclaringType);
@@ -386,7 +518,12 @@ public static ILog GetCurrentClassLogger()
///
/// The type whose name will be used for the logger.
/// An instance of
- public static ILog GetLogger(Type type)
+#if LIBLOG_PUBLIC
+ public
+#else
+ internal
+#endif
+ static ILog GetLogger(Type type)
{
return GetLogger(type.FullName);
}
@@ -396,44 +533,77 @@ public static ILog GetLogger(Type type)
///
/// The name.
/// An instance of
- public static ILog GetLogger(string name)
+#if LIBLOG_PUBLIC
+ public
+#else
+ internal
+#endif
+ static ILog GetLogger(string name)
{
- ILogProvider logProvider = _currentLogProvider ?? ResolveLogProvider();
- return logProvider == null ? new NoOpLogger() : (ILog)new LoggerExecutionWrapper(logProvider.GetLogger(name));
+ ILogProvider logProvider = CurrentLogProvider ?? ResolveLogProvider();
+ return logProvider == null
+ ? NoOpLogger.Instance
+ : (ILog)new LoggerExecutionWrapper(logProvider.GetLogger(name), () => IsDisabled);
}
///
- /// Sets the current log provider.
+ /// Opens a nested diagnostics context.
///
- /// The log provider.
- public static void SetCurrentLogProvider(ILogProvider logProvider)
+ /// A message.
+ /// An that closes context when disposed.
+ [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "SetCurrentLogProvider")]
+#if LIBLOG_PUBLIC
+ public
+#else
+ internal
+#endif
+ static IDisposable OpenNestedContext(string message)
{
- _currentLogProvider = logProvider;
+ return CurrentLogProvider == null
+ ? new DisposableAction(() => {})
+ : CurrentLogProvider.OpenNestedContext(message);
}
- public static IDisposable OpenNestedConext(string message)
- {
- if(_currentLogProvider == null)
- {
- throw new InvalidOperationException(NullLogProvider);
- }
- return _currentLogProvider.OpenNestedContext(message);
- }
-
- public static IDisposable OpenMappedContext(string key, string value)
+ ///
+ /// Opens a mapped diagnostics context.
+ ///
+ /// A key.
+ /// A value.
+ /// An that closes context when disposed.
+ [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "SetCurrentLogProvider")]
+#if LIBLOG_PUBLIC
+ public
+#else
+ internal
+#endif
+ static IDisposable OpenMappedContext(string key, string value)
{
- if (_currentLogProvider == null)
- {
- throw new InvalidOperationException(NullLogProvider);
- }
- return _currentLogProvider.OpenMappedContext(key, value);
+ return CurrentLogProvider == null
+ ? new DisposableAction(() => { })
+ : CurrentLogProvider.OpenMappedContext(key, value);
}
+#endif
- public delegate bool IsLoggerAvailable();
+#if LIBLOG_PROVIDERS_ONLY
+ private
+#else
+ internal
+#endif
+ delegate bool IsLoggerAvailable();
- public delegate ILogProvider CreateLogProvider();
+#if LIBLOG_PROVIDERS_ONLY
+ private
+#else
+ internal
+#endif
+ delegate ILogProvider CreateLogProvider();
- public static readonly List> LogProviderResolvers =
+#if LIBLOG_PROVIDERS_ONLY
+ private
+#else
+ internal
+#endif
+ static readonly List> LogProviderResolvers =
new List>
{
new Tuple(SerilogLogProvider.IsLoggerAvailable, () => new SerilogLogProvider()),
@@ -441,10 +611,21 @@ public static IDisposable OpenMappedContext(string key, string value)
new Tuple(Log4NetLogProvider.IsLoggerAvailable, () => new Log4NetLogProvider()),
new Tuple(EntLibLogProvider.IsLoggerAvailable, () => new EntLibLogProvider()),
new Tuple(LoupeLogProvider.IsLoggerAvailable, () => new LoupeLogProvider()),
- new Tuple(ColouredConsoleLogProvider.IsLoggerAvailable, () => new ColouredConsoleLogProvider()),
};
- private static ILogProvider ResolveLogProvider()
+#if !LIBLOG_PROVIDERS_ONLY
+ private static void RaiseOnCurrentLogProviderSet()
+ {
+ if (s_onCurrentLogProviderSet != null)
+ {
+ s_onCurrentLogProviderSet(s_currentLogProvider);
+ }
+ }
+#endif
+
+ [SuppressMessage("Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", MessageId = "System.Console.WriteLine(System.String,System.Object,System.Object)")]
+ [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
+ internal static ILogProvider ResolveLogProvider()
{
try
{
@@ -463,42 +644,63 @@ private static ILogProvider ResolveLogProvider()
#else
Console.WriteLine(
#endif
- "Exception occured resolving a log provider. Logging for this assembly {0} is disabled. {1}",
+ "Exception occurred resolving a log provider. Logging for this assembly {0} is disabled. {1}",
typeof(LogProvider).GetAssemblyPortable().FullName,
ex);
}
return null;
}
+#if !LIBLOG_PROVIDERS_ONLY
internal class NoOpLogger : ILog
{
+ internal static readonly NoOpLogger Instance = new NoOpLogger();
+
public bool Log(LogLevel logLevel, Func messageFunc, Exception exception, params object[] formatParameters)
{
return false;
}
}
+#endif
}
+#if !LIBLOG_PROVIDERS_ONLY
internal class LoggerExecutionWrapper : ILog
{
- private readonly ILog _logger;
+ private readonly Logger _logger;
+ private readonly Func _getIsDisabled;
internal const string FailedToGenerateLogMessage = "Failed to generate log message";
- internal LoggerExecutionWrapper(ILog logger)
+ internal LoggerExecutionWrapper(Logger logger, Func getIsDisabled = null)
{
_logger = logger;
+ _getIsDisabled = getIsDisabled ?? (() => false);
}
- public ILog WrappedLogger
+ internal Logger WrappedLogger
{
get { return _logger; }
}
+ [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
public bool Log(LogLevel logLevel, Func messageFunc, Exception exception = null, params object[] formatParameters)
{
+ if (_getIsDisabled())
+ {
+ return false;
+ }
+#if !LIBLOG_PORTABLE
+ var envVar = Environment.GetEnvironmentVariable(LogProvider.DisableLoggingEnvironmentVariable);
+
+ if (envVar != null && envVar.Equals("true", StringComparison.OrdinalIgnoreCase))
+ {
+ return false;
+ }
+#endif
+
if (messageFunc == null)
{
- return _logger.Log(logLevel, null);
+ return _logger(logLevel, null);
}
Func wrappedMessageFunc = () =>
@@ -513,19 +715,31 @@ public bool Log(LogLevel logLevel, Func messageFunc, Exception exception
}
return null;
};
- return _logger.Log(logLevel, wrappedMessageFunc, exception, formatParameters);
+ return _logger(logLevel, wrappedMessageFunc, exception, formatParameters);
}
}
+#endif
}
-namespace ScriptCs.Logging.LogProviders
+#if LIBLOG_PROVIDERS_ONLY
+namespace ScriptCs.Contracts.LibLog.LogProviders
+#else
+namespace ScriptCs.Contracts.Logging.LogProviders
+#endif
{
using System;
using System.Collections.Generic;
+ using System.Diagnostics.CodeAnalysis;
+#if !LIBLOG_PORTABLE
+ using System.Diagnostics;
+#endif
using System.Globalization;
+ using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
+#if !LIBLOG_PORTABLE
using System.Text;
+#endif
using System.Text.RegularExpressions;
internal abstract class LogProviderBase : ILogProvider
@@ -545,8 +759,8 @@ protected LogProviderBase()
= new Lazy(GetOpenMdcMethod);
}
- public abstract ILog GetLogger(string name);
-
+ public abstract Logger GetLogger(string name);
+
public IDisposable OpenNestedContext(string message)
{
return _lazyOpenNdcMethod.Value(message);
@@ -571,8 +785,10 @@ protected virtual OpenMdc GetOpenMdcMethod()
internal class NLogLogProvider : LogProviderBase
{
private readonly Func _getLoggerByNameDelegate;
- private static bool _providerIsAvailableOverride = true;
+ private static bool s_providerIsAvailableOverride = true;
+ [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "LogManager")]
+ [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "NLog")]
public NLogLogProvider()
{
if (!IsLoggerAvailable())
@@ -584,13 +800,13 @@ public NLogLogProvider()
public static bool ProviderIsAvailableOverride
{
- get { return _providerIsAvailableOverride; }
- set { _providerIsAvailableOverride = value; }
+ get { return s_providerIsAvailableOverride; }
+ set { s_providerIsAvailableOverride = value; }
}
- public override ILog GetLogger(string name)
+ public override Logger GetLogger(string name)
{
- return new NLogLogger(_getLoggerByNameDelegate(name));
+ return new NLogLogger(_getLoggerByNameDelegate(name)).Log;
}
public static bool IsLoggerAvailable()
@@ -601,7 +817,7 @@ public static bool IsLoggerAvailable()
protected override OpenNdc GetOpenNdcMethod()
{
Type ndcContextType = Type.GetType("NLog.NestedDiagnosticsContext, NLog");
- MethodInfo pushMethod = ndcContextType.GetMethodPortable("Push", new[] { typeof(string) });
+ MethodInfo pushMethod = ndcContextType.GetMethodPortable("Push", typeof(string));
ParameterExpression messageParam = Expression.Parameter(typeof(string), "message");
MethodCallExpression pushMethodCall = Expression.Call(null, pushMethod, messageParam);
return Expression.Lambda(pushMethodCall, messageParam).Compile();
@@ -611,8 +827,8 @@ protected override OpenMdc GetOpenMdcMethod()
{
Type mdcContextType = Type.GetType("NLog.MappedDiagnosticsContext, NLog");
- MethodInfo setMethod = mdcContextType.GetMethodPortable("Set", new[] { typeof(string), typeof(string) });
- MethodInfo removeMethod = mdcContextType.GetMethodPortable("Remove", new[] { typeof(string) });
+ MethodInfo setMethod = mdcContextType.GetMethodPortable("Set", typeof(string), typeof(string));
+ MethodInfo removeMethod = mdcContextType.GetMethodPortable("Remove", typeof(string));
ParameterExpression keyParam = Expression.Parameter(typeof(string), "key");
ParameterExpression valueParam = Expression.Parameter(typeof(string), "value");
@@ -641,13 +857,13 @@ private static Type GetLogManagerType()
private static Func GetGetLoggerMethodCall()
{
Type logManagerType = GetLogManagerType();
- MethodInfo method = logManagerType.GetMethodPortable("GetLogger", new[] { typeof(string) });
+ MethodInfo method = logManagerType.GetMethodPortable("GetLogger", typeof(string));
ParameterExpression nameParam = Expression.Parameter(typeof(string), "name");
MethodCallExpression methodCall = Expression.Call(null, method, nameParam);
return Expression.Lambda>(methodCall, nameParam).Compile();
}
- public class NLogLogger : ILog
+ internal class NLogLogger
{
private readonly dynamic _logger;
@@ -656,6 +872,7 @@ internal NLogLogger(dynamic logger)
_logger = logger;
}
+ [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
public bool Log(LogLevel logLevel, Func messageFunc, Exception exception, params object[] formatParameters)
{
if (messageFunc == null)
@@ -716,6 +933,7 @@ public bool Log(LogLevel logLevel, Func messageFunc, Exception exception
return false;
}
+ [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
private bool LogException(LogLevel logLevel, Func messageFunc, Exception exception)
{
switch (logLevel)
@@ -790,8 +1008,9 @@ private bool IsLogLevelEnable(LogLevel logLevel)
internal class Log4NetLogProvider : LogProviderBase
{
private readonly Func _getLoggerByNameDelegate;
- private static bool _providerIsAvailableOverride = true;
+ private static bool s_providerIsAvailableOverride = true;
+ [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "LogManager")]
public Log4NetLogProvider()
{
if (!IsLoggerAvailable())
@@ -803,13 +1022,13 @@ public Log4NetLogProvider()
public static bool ProviderIsAvailableOverride
{
- get { return _providerIsAvailableOverride; }
- set { _providerIsAvailableOverride = value; }
+ get { return s_providerIsAvailableOverride; }
+ set { s_providerIsAvailableOverride = value; }
}
- public override ILog GetLogger(string name)
+ public override Logger GetLogger(string name)
{
- return new Log4NetLogger(_getLoggerByNameDelegate(name));
+ return new Log4NetLogger(_getLoggerByNameDelegate(name)).Log;
}
internal static bool IsLoggerAvailable()
@@ -819,28 +1038,56 @@ internal static bool IsLoggerAvailable()
protected override OpenNdc GetOpenNdcMethod()
{
- Type ndcContextType = Type.GetType("log4net.NDC, log4net");
- MethodInfo pushMethod = ndcContextType.GetMethodPortable("Push", new[] { typeof(string) });
- ParameterExpression messageParam = Expression.Parameter(typeof(string), "message");
- MethodCallExpression pushMethodCall = Expression.Call(null, pushMethod, messageParam);
- return Expression.Lambda(pushMethodCall, messageParam).Compile();
+ Type logicalThreadContextType = Type.GetType("log4net.LogicalThreadContext, log4net");
+ PropertyInfo stacksProperty = logicalThreadContextType.GetPropertyPortable("Stacks");
+ Type logicalThreadContextStacksType = stacksProperty.PropertyType;
+ PropertyInfo stacksIndexerProperty = logicalThreadContextStacksType.GetPropertyPortable("Item");
+ Type stackType = stacksIndexerProperty.PropertyType;
+ MethodInfo pushMethod = stackType.GetMethodPortable("Push");
+
+ ParameterExpression messageParameter =
+ Expression.Parameter(typeof(string), "message");
+
+ // message => LogicalThreadContext.Stacks.Item["NDC"].Push(message);
+ MethodCallExpression callPushBody =
+ Expression.Call(
+ Expression.Property(Expression.Property(null, stacksProperty),
+ stacksIndexerProperty,
+ Expression.Constant("NDC")),
+ pushMethod,
+ messageParameter);
+
+ OpenNdc result =
+ Expression.Lambda(callPushBody, messageParameter)
+ .Compile();
+
+ return result;
}
protected override OpenMdc GetOpenMdcMethod()
{
- Type mdcContextType = Type.GetType("log4net.MDC, log4net");
+ Type logicalThreadContextType = Type.GetType("log4net.LogicalThreadContext, log4net");
+ PropertyInfo propertiesProperty = logicalThreadContextType.GetPropertyPortable("Properties");
+ Type logicalThreadContextPropertiesType = propertiesProperty.PropertyType;
+ PropertyInfo propertiesIndexerProperty = logicalThreadContextPropertiesType.GetPropertyPortable("Item");
+
+ MethodInfo removeMethod = logicalThreadContextPropertiesType.GetMethodPortable("Remove");
- MethodInfo setMethod = mdcContextType.GetMethodPortable("Set", new[] { typeof(string), typeof(string) });
- MethodInfo removeMethod = mdcContextType.GetMethodPortable("Remove", new[] { typeof(string) });
ParameterExpression keyParam = Expression.Parameter(typeof(string), "key");
ParameterExpression valueParam = Expression.Parameter(typeof(string), "value");
- MethodCallExpression setMethodCall = Expression.Call(null, setMethod, keyParam, valueParam);
- MethodCallExpression removeMethodCall = Expression.Call(null, removeMethod, keyParam);
+ MemberExpression propertiesExpression = Expression.Property(null, propertiesProperty);
+
+ // (key, value) => LogicalThreadContext.Properties.Item[key] = value;
+ BinaryExpression setProperties = Expression.Assign(Expression.Property(propertiesExpression, propertiesIndexerProperty, keyParam), valueParam);
+
+ // key => LogicalThreadContext.Properties.Remove(key);
+ MethodCallExpression removeMethodCall = Expression.Call(propertiesExpression, removeMethod, keyParam);
Action set = Expression
- .Lambda>(setMethodCall, keyParam, valueParam)
+ .Lambda>(setProperties, keyParam, valueParam)
.Compile();
+
Action remove = Expression
.Lambda>(removeMethodCall, keyParam)
.Compile();
@@ -860,19 +1107,82 @@ private static Type GetLogManagerType()
private static Func GetGetLoggerMethodCall()
{
Type logManagerType = GetLogManagerType();
- MethodInfo method = logManagerType.GetMethodPortable("GetLogger", new[] { typeof(string) });
+ MethodInfo method = logManagerType.GetMethodPortable("GetLogger", typeof(string));
ParameterExpression nameParam = Expression.Parameter(typeof(string), "name");
MethodCallExpression methodCall = Expression.Call(null, method, nameParam);
return Expression.Lambda>(methodCall, nameParam).Compile();
}
- public class Log4NetLogger : ILog
+ internal class Log4NetLogger
{
private readonly dynamic _logger;
-
+ private static Type s_callerStackBoundaryType;
+ private static readonly object CallerStackBoundaryTypeSync = new object();
+
+ private readonly object _levelDebug;
+ private readonly object _levelInfo;
+ private readonly object _levelWarn;
+ private readonly object _levelError;
+ private readonly object _levelFatal;
+ private readonly Func