diff --git a/Autofac.Extras.CommonServiceLocator.sln b/Autofac.Extras.CommonServiceLocator.sln index edf7098..82b0932 100644 --- a/Autofac.Extras.CommonServiceLocator.sln +++ b/Autofac.Extras.CommonServiceLocator.sln @@ -1,12 +1,19 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26430.16 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30503.244 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Autofac.Extras.CommonServiceLocator", "src\Autofac.Extras.CommonServiceLocator\Autofac.Extras.CommonServiceLocator.csproj", "{7A6DB23D-117E-4742-A9FA-8A6956DF6829}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Autofac.Extras.CommonServiceLocator.Test", "test\Autofac.Extras.CommonServiceLocator.Test\Autofac.Extras.CommonServiceLocator.Test.csproj", "{304C6D1B-7264-408E-BE9B-4F6E6462CF08}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{9A5D1456-F759-48AB-B365-A7BC33619739}" + ProjectSection(SolutionItems) = preProject + appveyor.yml = appveyor.yml + global.json = global.json + NuGet.Config = NuGet.Config + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -25,4 +32,7 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {5BF15888-EFB2-4BB2-B938-EAF74B956AB5} + EndGlobalSection EndGlobal diff --git a/NuGet.Config b/NuGet.Config index f1ed192..1c4ba76 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -3,6 +3,7 @@ + diff --git a/appveyor.yml b/appveyor.yml index 182b752..47677dd 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,9 @@ -version: 6.0.0.{build} +version: 6.0.1.{build} + +dotnet_csproj: + version_prefix: '6.0.1' + patch: true + file: 'src\**\*.csproj' configuration: Release diff --git a/build/Analyzers.ruleset b/build/Analyzers.ruleset index 3621770..badb0fe 100644 --- a/build/Analyzers.ruleset +++ b/build/Analyzers.ruleset @@ -1,10 +1,11 @@  - - + - - + + + + @@ -33,12 +34,12 @@ + + - - diff --git a/build/Autofac.Build.psd1 b/build/Autofac.Build.psd1 index 5d93715..8a5bfac 100644 --- a/build/Autofac.Build.psd1 +++ b/build/Autofac.Build.psd1 @@ -1,6 +1,6 @@ @{ RootModule = '.\Autofac.Build.psm1' - ModuleVersion = '0.2.0' + ModuleVersion = '0.3.0' GUID = '55d3f738-f48f-4497-9b2c-ecd90ec1f978' Author = 'Autofac Contributors' CompanyName = 'Autofac' @@ -12,4 +12,4 @@ ModuleList = @() FileList = @() PrivateData = '' -} \ No newline at end of file +} diff --git a/build/Autofac.Build.psm1 b/build/Autofac.Build.psm1 index a0144c0..ddf597a 100644 --- a/build/Autofac.Build.psm1 +++ b/build/Autofac.Build.psm1 @@ -5,86 +5,66 @@ # 4: dotnet / NuGet package restore failure <# - .SYNOPSIS - Writes a build progress message to the host. +.SYNOPSIS + Gets the set of directories in which projects are available for compile/processing. - .PARAMETER Message - The message to write. +.PARAMETER RootPath + Path where searching for project directories should begin. #> -function Write-Message -{ - [CmdletBinding()] - Param( - [Parameter(Mandatory=$True, ValueFromPipeline=$False, ValueFromPipelineByPropertyName=$False)] - [ValidateNotNullOrEmpty()] - [string] - $Message - ) - - Write-Host "[BUILD] $Message" -ForegroundColor Cyan +function Get-DotNetProjectDirectory { + [CmdletBinding()] + Param( + [Parameter(Mandatory = $True, ValueFromPipeline = $False, ValueFromPipelineByPropertyName = $False)] + [ValidateNotNullOrEmpty()] + [string] + $RootPath + ) + + Get-ChildItem -Path $RootPath -Recurse -Include "*.csproj" | Select-Object @{ Name = "ParentFolder"; Expression = { $_.Directory.FullName.TrimEnd("\") } } | Select-Object -ExpandProperty ParentFolder } <# - .SYNOPSIS - Gets the set of directories in which projects are available for compile/processing. - - .PARAMETER RootPath - Path where searching for project directories should begin. +.SYNOPSIS + Runs the dotnet CLI install script from GitHub to install a project-local + copy of the CLI. #> -function Get-DotNetProjectDirectory -{ - [CmdletBinding()] - Param( - [Parameter(Mandatory=$True, ValueFromPipeline=$False, ValueFromPipelineByPropertyName=$False)] - [ValidateNotNullOrEmpty()] - [string] - $RootPath - ) - - Get-ChildItem -Path $RootPath -Recurse -Include "*.csproj" | Select-Object @{ Name="ParentFolder"; Expression={ $_.Directory.FullName.TrimEnd("\") } } | Select-Object -ExpandProperty ParentFolder -} +function Install-DotNetCli { + [CmdletBinding()] + Param( + [string] + $Version = "Latest" + ) + + if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue)) { + $installedVersion = dotnet --version + if ($installedVersion -eq $Version) { + Write-Message ".NET Core SDK version $Version is already installed" + return; + } + } -<# - .SYNOPSIS - Runs the dotnet CLI install script from GitHub to install a project-local - copy of the CLI. -#> -function Install-DotNetCli -{ - [CmdletBinding()] - Param( - [string] - $Version = "Latest" - ) - - if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue)) - { - $installedVersion = dotnet --version - if ($installedVersion -eq $Version) - { - Write-Message ".NET Core SDK version $Version is already installed" - return; + $callerPath = Split-Path $MyInvocation.PSCommandPath + $installDir = Join-Path -Path $callerPath -ChildPath ".dotnet/cli" + if (!(Test-Path $installDir)) { + New-Item -ItemType Directory -Path "$installDir" | Out-Null + } + + # Download the dotnet CLI install script + if ($IsWindows) { + if (!(Test-Path ./.dotnet/dotnet-install.ps1)) { + Invoke-WebRequest "https://dot.net/v1/dotnet-install.ps1" -OutFile "./.dotnet/dotnet-install.ps1" + } + + & ./.dotnet/dotnet-install.ps1 -InstallDir "$installDir" -Version $Version + $env:PATH = "$installDir;$env:PATH" + } else { + if (!(Test-Path ./.dotnet/dotnet-install.sh)) { + Invoke-WebRequest "https://dot.net/v1/dotnet-install.sh" -OutFile "./.dotnet/dotnet-install.sh" + } + + & bash ./.dotnet/dotnet-install.sh --install-dir "$installDir" --version $Version + $env:PATH = "$installDir`:$env:PATH" } - } - - $callerPath = Split-Path $MyInvocation.PSCommandPath - $installDir = Join-Path -Path $callerPath -ChildPath ".dotnet\cli" - if (!(Test-Path $installDir)) - { - New-Item -ItemType Directory -Path "$installDir" | Out-Null - } - - # Download the dotnet CLI install script - if (!(Test-Path .\dotnet\install.ps1)) - { - Invoke-WebRequest "https://dot.net/v1/dotnet-install.ps1" -OutFile ".\.dotnet\dotnet-install.ps1" - } - - # Run the dotnet CLI install - & .\.dotnet\dotnet-install.ps1 -InstallDir "$installDir" -Version $Version - - # Add the dotnet folder path to the process. - $env:PATH = "$installDir;$env:PATH" } <# @@ -95,156 +75,153 @@ function Install-DotNetCli .PARAMETER DirectoryName The path to the directory containing the project to build. #> -function Invoke-DotNetBuild -{ - [CmdletBinding()] - Param( - [Parameter(Mandatory=$True, ValueFromPipeline=$True, ValueFromPipelineByPropertyName=$True)] - [ValidateNotNull()] - [System.IO.DirectoryInfo[]] - $ProjectDirectory - ) - Process - { - foreach($Project in $ProjectDirectory) - { - & dotnet build ("""" + $Project.FullName + """") --configuration Release - if ($LASTEXITCODE -ne 0) - { - exit 1 - } +function Invoke-DotNetBuild { + [CmdletBinding()] + Param( + [Parameter(Mandatory = $True, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)] + [ValidateNotNull()] + [System.IO.DirectoryInfo[]] + $ProjectDirectory + ) + Process { + foreach ($Project in $ProjectDirectory) { + & dotnet build ("""" + $Project.FullName + """") --configuration Release + if ($LASTEXITCODE -ne 0) { + exit 1 + } + } } - } } <# - .SYNOPSIS - Invokes the dotnet utility to package a project. +.SYNOPSIS + Invokes the dotnet utility to package a project. - .PARAMETER ProjectDirectory - Path to the directory containing the project to package. +.PARAMETER ProjectDirectory + Path to the directory containing the project to package. - .PARAMETER PackagesPath - Path to the "artifacts\packages" folder where packages should go. +.PARAMETER PackagesPath + Path to the "artifacts/packages" folder where packages should go. - .PARAMETER VersionSuffix - The version suffix to use for the NuGet package version. +.PARAMETER VersionSuffix + The version suffix to use for the NuGet package version. #> -function Invoke-DotNetPack -{ - [CmdletBinding()] - Param( - [Parameter(Mandatory=$True, ValueFromPipeline=$True, ValueFromPipelineByPropertyName=$True)] - [ValidateNotNull()] - [System.IO.DirectoryInfo[]] - $ProjectDirectory, - - [Parameter(Mandatory=$True, ValueFromPipeline=$False)] - [ValidateNotNull()] - [System.IO.DirectoryInfo] - $PackagesPath, - - [Parameter(Mandatory=$True, ValueFromPipeline=$False)] - [AllowEmptyString()] - [string] - $VersionSuffix - ) - Begin - { - New-Item -Path $PackagesPath -ItemType Directory -Force | Out-Null - } - Process - { - foreach($Project in $ProjectDirectory) - { - if ($VersionSuffix -eq "") - { - & dotnet build ("""" + $Project.FullName + """") --configuration Release - } - else - { - & dotnet build ("""" + $Project.FullName + """") --configuration Release --version-suffix $VersionSuffix - } - if ($LASTEXITCODE -ne 0) - { - exit 1 - } - - if ($VersionSuffix -eq "") - { - & dotnet pack ("""" + $Project.FullName + """") --configuration Release --output $PackagesPath - } - else - { - & dotnet pack ("""" + $Project.FullName + """") --configuration Release --version-suffix $VersionSuffix --output $PackagesPath - } - if ($LASTEXITCODE -ne 0) - { - exit 1 - } +function Invoke-DotNetPack { + [CmdletBinding()] + Param( + [Parameter(Mandatory = $True, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)] + [ValidateNotNull()] + [System.IO.DirectoryInfo[]] + $ProjectDirectory, + + [Parameter(Mandatory = $True, ValueFromPipeline = $False)] + [ValidateNotNull()] + [System.IO.DirectoryInfo] + $PackagesPath, + + [Parameter(Mandatory = $True, ValueFromPipeline = $False)] + [AllowEmptyString()] + [string] + $VersionSuffix + ) + Begin { + New-Item -Path $PackagesPath -ItemType Directory -Force | Out-Null + } + Process { + foreach ($Project in $ProjectDirectory) { + if ($VersionSuffix -eq "") { + & dotnet build ("""" + $Project.FullName + """") --configuration Release + } + else { + & dotnet build ("""" + $Project.FullName + """") --configuration Release --version-suffix $VersionSuffix + } + if ($LASTEXITCODE -ne 0) { + exit 1 + } + + if ($VersionSuffix -eq "") { + & dotnet pack ("""" + $Project.FullName + """") --configuration Release --output $PackagesPath + } + else { + & dotnet pack ("""" + $Project.FullName + """") --configuration Release --version-suffix $VersionSuffix --output $PackagesPath + } + if ($LASTEXITCODE -ne 0) { + exit 1 + } + } } - } } <# - .Synopsis - Invokes dotnet test command. +.SYNOPSIS + Invokes dotnet test command. - .Parameter ProjectDirectory - Path to the directory containing the project to package. +.PARAMETER ProjectDirectory + Path to the directory containing the project to package. #> -function Invoke-Test -{ - [CmdletBinding()] - Param( - [Parameter(Mandatory=$True, ValueFromPipeline=$True, ValueFromPipelineByPropertyName=$True)] - [ValidateNotNull()] - [System.IO.DirectoryInfo[]] - $ProjectDirectory - ) - Process - { - foreach($Project in $ProjectDirectory) - { - Push-Location $Project - - & dotnet test --configuration Release --logger:trx - if ($LASTEXITCODE -ne 0) - { - Pop-Location - exit 3 - } - - Pop-Location +function Invoke-Test { + [CmdletBinding()] + Param( + [Parameter(Mandatory = $True, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)] + [ValidateNotNull()] + [System.IO.DirectoryInfo[]] + $ProjectDirectory + ) + Process { + foreach ($Project in $ProjectDirectory) { + Push-Location $Project + + & dotnet test --configuration Release --logger:trx + if ($LASTEXITCODE -ne 0) { + Pop-Location + exit 3 + } + + Pop-Location + } } - } } <# - .SYNOPSIS - Restores dependencies using the dotnet utility. +.SYNOPSIS + Restores dependencies using the dotnet utility. - .PARAMETER ProjectDirectory - Path to the directory containing the project with dependencies to restore. +.PARAMETER ProjectDirectory + Path to the directory containing the project with dependencies to restore. #> -function Restore-DependencyPackages -{ - [CmdletBinding()] - Param( - [Parameter(Mandatory=$True, ValueFromPipeline=$True, ValueFromPipelineByPropertyName=$True)] - [ValidateNotNull()] - [System.IO.DirectoryInfo[]] - $ProjectDirectory - ) - Process - { - foreach($Project in $ProjectDirectory) - { - & dotnet restore ("""" + $Project.FullName + """") --no-cache - if($LASTEXITCODE -ne 0) - { - exit 4 - } +function Restore-DependencyPackages { + [CmdletBinding()] + Param( + [Parameter(Mandatory = $True, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)] + [ValidateNotNull()] + [System.IO.DirectoryInfo[]] + $ProjectDirectory + ) + Process { + foreach ($Project in $ProjectDirectory) { + & dotnet restore ("""" + $Project.FullName + """") --no-cache + if ($LASTEXITCODE -ne 0) { + exit 4 + } + } } - } +} + +<# +.SYNOPSIS + Writes a build progress message to the host. + +.PARAMETER Message + The message to write. +#> +function Write-Message { + [CmdletBinding()] + Param( + [Parameter(Mandatory = $True, ValueFromPipeline = $False, ValueFromPipelineByPropertyName = $False)] + [ValidateNotNullOrEmpty()] + [string] + $Message + ) + + Write-Host "[BUILD] $Message" -ForegroundColor Cyan } diff --git a/global.json b/global.json index d9ca44a..83c3bc7 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,6 @@ { "sdk": { - "version": "3.1.100" + "version": "3.1.302", + "rollForward": "latestFeature" } } diff --git a/src/Autofac.Extras.CommonServiceLocator/Autofac.Extras.CommonServiceLocator.csproj b/src/Autofac.Extras.CommonServiceLocator/Autofac.Extras.CommonServiceLocator.csproj index a7b7076..5d9292a 100644 --- a/src/Autofac.Extras.CommonServiceLocator/Autofac.Extras.CommonServiceLocator.csproj +++ b/src/Autofac.Extras.CommonServiceLocator/Autofac.Extras.CommonServiceLocator.csproj @@ -2,7 +2,8 @@ Autofac extension for using the Microsoft Enterprise Library Common Service Locator with Autofac. - 6.0.0 + + 0.0.1 netstandard2.0 true true @@ -33,12 +34,12 @@ - - + + All - + All diff --git a/src/Autofac.Extras.CommonServiceLocator/AutofacServiceLocator.cs b/src/Autofac.Extras.CommonServiceLocator/AutofacServiceLocator.cs index b805106..1471ffe 100644 --- a/src/Autofac.Extras.CommonServiceLocator/AutofacServiceLocator.cs +++ b/src/Autofac.Extras.CommonServiceLocator/AutofacServiceLocator.cs @@ -1,4 +1,7 @@ -using System; +// Copyright (c) Autofac Project. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +using System; using System.Collections; using System.Collections.Generic; using System.Linq; @@ -12,19 +15,19 @@ namespace Autofac.Extras.CommonServiceLocator public class AutofacServiceLocator : ServiceLocatorImplBase { /// - /// The from which services + /// The from which services /// should be located. /// private readonly IComponentContext _container; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// - /// The from which services + /// The from which services /// should be located. /// - /// + /// /// Thrown if is . /// public AutofacServiceLocator(IComponentContext container) @@ -38,7 +41,7 @@ public AutofacServiceLocator(IComponentContext container) /// Type of instance requested. /// Name of registered service you want. May be . /// The requested service instance. - /// + /// /// Thrown if is . /// protected override object DoGetInstance(Type serviceType, string key) @@ -56,7 +59,7 @@ protected override object DoGetInstance(Type serviceType, string key) /// /// Type of instance requested. /// Sequence of service instance objects. - /// + /// /// Thrown if is . /// protected override IEnumerable DoGetAllInstances(Type serviceType) diff --git a/test/Autofac.Extras.CommonServiceLocator.Test/Autofac.Extras.CommonServiceLocator.Test.csproj b/test/Autofac.Extras.CommonServiceLocator.Test/Autofac.Extras.CommonServiceLocator.Test.csproj index d42e84d..70cc480 100644 --- a/test/Autofac.Extras.CommonServiceLocator.Test/Autofac.Extras.CommonServiceLocator.Test.csproj +++ b/test/Autofac.Extras.CommonServiceLocator.Test/Autofac.Extras.CommonServiceLocator.Test.csproj @@ -1,8 +1,8 @@  - netcoreapp2.1 - $(NoWarn);CS1591 + netcoreapp3.1 + $(NoWarn);CS1591;SA1600 true ../../Autofac.snk true @@ -18,13 +18,16 @@ - - + + All - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/test/Autofac.Extras.CommonServiceLocator.Test/AutofacServiceLocatorTests.cs b/test/Autofac.Extras.CommonServiceLocator.Test/AutofacServiceLocatorTests.cs index d053369..3d7876f 100644 --- a/test/Autofac.Extras.CommonServiceLocator.Test/AutofacServiceLocatorTests.cs +++ b/test/Autofac.Extras.CommonServiceLocator.Test/AutofacServiceLocatorTests.cs @@ -1,3 +1,6 @@ +// Copyright (c) Autofac Project. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System; using System.Collections; using System.Collections.Generic; @@ -56,16 +59,16 @@ public void GenericOverload_GetAllInstances() public void GenericOverload_GetInstance() { Assert.Equal( -_locator.GetInstance().GetType(), -_locator.GetInstance(typeof(ILogger), null).GetType()); + _locator.GetInstance().GetType(), + _locator.GetInstance(typeof(ILogger), null).GetType()); } [Fact] public void GenericOverload_GetInstance_WithName() { Assert.Equal( -_locator.GetInstance(typeof(AdvancedLogger).FullName).GetType(), -_locator.GetInstance(typeof(ILogger), typeof(AdvancedLogger).FullName).GetType()); + _locator.GetInstance(typeof(AdvancedLogger).FullName).GetType(), + _locator.GetInstance(typeof(ILogger), typeof(AdvancedLogger).FullName).GetType()); } [Fact] diff --git a/test/Autofac.Extras.CommonServiceLocator.Test/Components/AdvancedLogger.cs b/test/Autofac.Extras.CommonServiceLocator.Test/Components/AdvancedLogger.cs index 9b00822..519f3d4 100644 --- a/test/Autofac.Extras.CommonServiceLocator.Test/Components/AdvancedLogger.cs +++ b/test/Autofac.Extras.CommonServiceLocator.Test/Components/AdvancedLogger.cs @@ -1,3 +1,6 @@ +// Copyright (c) Autofac Project. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System; namespace Autofac.Extras.CommonServiceLocator.Test.Components diff --git a/test/Autofac.Extras.CommonServiceLocator.Test/Components/ILogger.cs b/test/Autofac.Extras.CommonServiceLocator.Test/Components/ILogger.cs index e77eaa7..546f632 100644 --- a/test/Autofac.Extras.CommonServiceLocator.Test/Components/ILogger.cs +++ b/test/Autofac.Extras.CommonServiceLocator.Test/Components/ILogger.cs @@ -1,3 +1,6 @@ +// Copyright (c) Autofac Project. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + namespace Autofac.Extras.CommonServiceLocator.Test.Components { public interface ILogger diff --git a/test/Autofac.Extras.CommonServiceLocator.Test/Components/SimpleLogger.cs b/test/Autofac.Extras.CommonServiceLocator.Test/Components/SimpleLogger.cs index 53524f4..50d2369 100644 --- a/test/Autofac.Extras.CommonServiceLocator.Test/Components/SimpleLogger.cs +++ b/test/Autofac.Extras.CommonServiceLocator.Test/Components/SimpleLogger.cs @@ -1,3 +1,6 @@ +// Copyright (c) Autofac Project. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + using System; namespace Autofac.Extras.CommonServiceLocator.Test.Components