Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
tillig committed Jul 18, 2022
2 parents 691de19 + bcc9f91 commit e8a229b
Show file tree
Hide file tree
Showing 39 changed files with 1,847 additions and 1,629 deletions.
397 changes: 199 additions & 198 deletions .editorconfig

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"cSpell.words": [
"autofac",
"cref",
"inheritdoc",
"langword",
"paramref",
"seealso",
"typeparam",
"unmanaged",
"xunit"
],
"dotnet-test-explorer.runInParallel": true,
"dotnet-test-explorer.testProjectPath": "test/**/*.Test.csproj"
}
21 changes: 21 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"tasks": [
{
"args": [
"build",
"${workspaceFolder}/Autofac.Wcf.sln",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"command": "dotnet",
"group": {
"isDefault": true,
"kind": "build"
},
"label": "build",
"problemMatcher": "$msCompile",
"type": "process"
}
],
"version": "2.0.0"
}
1 change: 0 additions & 1 deletion NuGet.Config
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<packageSources>
<clear />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="Xunit MyGet" value="https://myget.org/F/xunit/api/v3/index.json" protocolVersion="3" />
<add key="Autofac MyGet" value="https://www.myget.org/F/autofac/api/v3/index.json" protocolVersion="3" />
</packageSources>
<disabledPackageSources>
Expand Down
86 changes: 84 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,90 @@ Windows Communication Foundation (WCF) integration for [Autofac](https://autofac

[![Build status](https://ci.appveyor.com/api/projects/status/5hf5l1qqncrc15yu?svg=true)](https://ci.appveyor.com/project/Autofac/autofac-yirkj)

Please file issues and pull requests for this package in this repository rather than in the Autofac core repo.
Please file issues and pull requests for this package [in this repository](https://github.com/autofac/Autofac.Wcf/issues) rather than in the Autofac core repo.

- [Documentation](https://autofac.readthedocs.io/en/latest/integration/wcf.html)
- [NuGet](https://www.nuget.org/packages/Autofac.Wcf/)
- [Contributing](https://autofac.readthedocs.io/en/latest/contributors.html)
- [Contributing](https://autofac.readthedocs.io/en/latest/contributors.html)
- [Open in Visual Studio Code](https://open.vscode.dev/autofac/Autofac.Wcf)

## Quick Start: Clients

During application startup, for each service register a `ChannelFactory<T>` and a function that uses the factory to open channels:

```c#
var builder = new ContainerBuilder();

// Register the channel factory for the service. Make it
// SingleInstance since you don't need a new one each time.
builder
.Register(c => new ChannelFactory<ITrackListing>(
new BasicHttpBinding(),
new EndpointAddress("http://localhost/TrackListingService")))
.SingleInstance();

// Register the service interface using a lambda that creates
// a channel from the factory. Include the UseWcfSafeRelease()
// helper to handle proper disposal.
builder
.Register(c => c.Resolve<ChannelFactory<ITrackListing>>().CreateChannel())
.As<ITrackListing>()
.UseWcfSafeRelease();

// You can also register other dependencies.
builder.RegisterType<AlbumPrinter>();

var container = builder.Build();
```

When consuming the service, add a constructor dependency as normal. This example shows an application that prints a track listing to the console using the remote `ITrackListing` service. It does this via the `AlbumPrinter` class:

```c#
public class AlbumPrinter
{
readonly ITrackListing _trackListing;

public AlbumPrinter(ITrackListing trackListing)
{
_trackListing = trackListing;
}

public void PrintTracks(string artist, string album)
{
foreach (var track in _trackListing.GetTracks(artist, album))
Console.WriteLine("{0} - {1}", track.Position, track.Title);
}
}
```

## Quick Start: Services

To get Autofac integrated with WCF on the service side you need to reference the WCF integration NuGet package, register your services, and set the dependency resolver. You also need to update your .svc files to reference the Autofac service host factory.

Here’s a sample application startup block:

```c#
protected void Application_Start()
{
var builder = new ContainerBuilder();

// Register your service implementations.
builder.RegisterType<TestService.Service1>();

// Set the dependency resolver.
var container = builder.Build();
AutofacHostFactory.Container = container;
}
```

And here’s a sample .svc file.

```aspx
<%@ ServiceHost
Service="TestService.Service1, TestService"
Factory="Autofac.Integration.Wcf.AutofacServiceHostFactory, Autofac.Integration.Wcf" %>
```

## Get Help

**Need help with Autofac?** We have [a documentation site](https://autofac.readthedocs.io/) as well as [API documentation](https://autofac.org/apidoc/). We're ready to answer your questions on [Stack Overflow](https://stackoverflow.com/questions/tagged/autofac) or check out the [discussion forum](https://groups.google.com/forum/#forum/autofac).
30 changes: 15 additions & 15 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
version: 6.0.0.{build}
image: Visual Studio 2022

version: 6.1.0.{build}

dotnet_csproj:
version_prefix: '6.0.0'
version_prefix: '6.1.0'
patch: true
file: 'src\**\*.csproj'

configuration: Release

image: Visual Studio 2019

environment:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
NUGET_XMLDOC_MODE: skip
Expand All @@ -20,20 +20,20 @@ nuget:

clone_depth: 1

test: off
test: false

build_script:
- ps: .\build.ps1
- pwsh: .\build.ps1

artifacts:
- path: artifacts\packages\**\*.nupkg
name: MyGet
- path: artifacts\packages\**\*.*nupkg
name: MyGet
type: NuGetPackage

deploy:
- provider: NuGet
server: https://www.myget.org/F/autofac/api/v2/package
api_key:
secure: rCUEY75fXN0wxtMy6QL4jCrLdaYbxIBzIXWeN+wEu/XDpyqimzreOc5AH5jMd5ah
skip_symbols: true
symbol_server: https://www.myget.org/F/autofac/symbols/api/v2/package
artifact: MyGet
- provider: NuGet
server: https://www.myget.org/F/autofac/api/v2/package
symbol_server: https://www.myget.org/F/autofac/api/v2/package
api_key:
secure: xUXExgVAagrdEicCjSxsQVrwiLo2TtnfqMbYB9Cauq2cpbm/EVz957PBK0v/GEYq
artifact: MyGet
79 changes: 48 additions & 31 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,61 @@
########################

Push-Location $PSScriptRoot
Import-Module $PSScriptRoot\Build\Autofac.Build.psd1 -Force
try {
Import-Module $PSScriptRoot/build/Autofac.Build.psd1 -Force

$artifactsPath = "$PSScriptRoot\artifacts"
$packagesPath = "$artifactsPath\packages"
$sdkVersion = (Get-Content "$PSScriptRoot\global.json" | ConvertFrom-Json).sdk.version
$artifactsPath = "$PSScriptRoot/artifacts"
$packagesPath = "$artifactsPath/packages"

# Clean up artifacts folder
if (Test-Path $artifactsPath) {
Write-Message "Cleaning $artifactsPath folder"
Remove-Item $artifactsPath -Force -Recurse
}
$globalJson = (Get-Content "$PSScriptRoot/global.json" | ConvertFrom-Json -NoEnumerate);

$sdkVersion = $globalJson.sdk.version

# Clean up artifacts folder
if (Test-Path $artifactsPath) {
Write-Message "Cleaning $artifactsPath folder"
Remove-Item $artifactsPath -Force -Recurse
}

# Install dotnet CLI
Write-Message "Installing .NET Core SDK version $sdkVersion"
Install-DotNetCli -Version $sdkVersion
# Install dotnet SDK versions during CI. In a local build we assume you have
# everything installed; on CI we'll force the install. If you install _any_
# SDKs, you have to install _all_ of them because you can't install SDKs in
# two different locations. dotnet CLI locates SDKs relative to the
# executable.
if ($Null -ne $env:APPVEYOR_BUILD_NUMBER) {
Install-DotNetCli -Version $sdkVersion
foreach ($additional in $globalJson.additionalSdks)
{
Install-DotNetCli -Version $additional;
}
}

# Write out dotnet information
& dotnet --info
# Write out dotnet information
& dotnet --info

# Set version suffix
$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL];
$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
$versionSuffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "master" -and $revision -ne "local"]
# Set version suffix
$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$NULL -ne $env:APPVEYOR_REPO_BRANCH];
$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$NULL -ne $env:APPVEYOR_BUILD_NUMBER];
$versionSuffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)).Replace('/', '-'))-$revision" }[$branch -eq "master" -and $revision -ne "local"]

Write-Message "Package version suffix is '$versionSuffix'"
Write-Message "Package version suffix is '$versionSuffix'"

# Package restore
Write-Message "Restoring packages"
Get-DotNetProjectDirectory -RootPath $PSScriptRoot | Restore-DependencyPackages
# Package restore
Write-Message "Restoring packages"
Get-DotNetProjectDirectory -RootPath $PSScriptRoot | Restore-DependencyPackages

# Build/package
Write-Message "Building projects and packages"
Get-DotNetProjectDirectory -RootPath $PSScriptRoot\src | Invoke-DotNetPack -PackagesPath $packagesPath -VersionSuffix $versionSuffix
# Build/package
Write-Message "Building projects and packages"
Get-DotNetProjectDirectory -RootPath $PSScriptRoot\src | Invoke-DotNetPack -PackagesPath $packagesPath -VersionSuffix $versionSuffix

# Test
Write-Message "Executing unit tests"
Get-DotNetProjectDirectory -RootPath $PSScriptRoot\test | Invoke-Test
# Test
Write-Message "Executing unit tests"
Get-DotNetProjectDirectory -RootPath $PSScriptRoot\test | Invoke-Test

# Finished
Write-Message "Build finished"
Pop-Location

# Finished
Write-Message "Build finished"
}
finally {
Pop-Location
}
6 changes: 1 addition & 5 deletions build/Analyzers.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@
<Rule Id="SA1309" Action="None" />
<!-- Suppressions must have a justification -->
<Rule Id="SA1404" Action="None" />
<!-- Use trailing comma in initializers - lots of false positives for enums in StyleCop 1.1.0-beta004 -->
<Rule Id="SA1413" Action="None" />
<!-- Parameter documentation mus be in the right order -->
<!-- Parameter documentation must be in the right order -->
<Rule Id="SA1612" Action="None" />
<!-- Return value must be documented -->
<Rule Id="SA1615" Action="None" />
Expand All @@ -46,8 +44,6 @@
<Rule Id="SA1625" Action="None" />
<!-- Exception documentation must not be empty -->
<Rule Id="SA1627" Action="None" />
<!-- File must have header -->
<Rule Id="SA1633" Action="None" />
<!-- Enable XML documentation output-->
<Rule Id="SA1652" Action="None" />
</Rules>
Expand Down
44 changes: 32 additions & 12 deletions build/Autofac.Build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,7 @@ function Install-DotNetCli {
[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;
}
}
Write-Message "Installing .NET SDK version $Version"

$callerPath = Split-Path $MyInvocation.PSCommandPath
$installDir = Join-Path -Path $callerPath -ChildPath ".dotnet/cli"
Expand All @@ -56,15 +49,43 @@ function Install-DotNetCli {
}

& ./.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"
}

Add-Path "$installDir"
}

<#
.SYNOPSIS
Appends a given value to the path but only if the value does not yet exist within the path.
.PARAMETER Path
The path to append.
#>
function Add-Path {
[CmdletBinding()]
Param(
[ValidateNotNullOrEmpty()]
[string]
$Path
)

$pathSeparator = ":";

if ($IsWindows) {
$pathSeparator = ";";
}

$pathValues = $env:PATH.Split($pathSeparator);
if ($pathValues -Contains $Path) {
return;
}

$env:PATH = "${Path}${pathSeparator}$env:PATH"
}

<#
Expand Down Expand Up @@ -175,8 +196,7 @@ function Invoke-Test {
--configuration Release `
--logger:trx `
/p:CollectCoverage=true `
/p:CoverletOutput="..\..\" `
/p:MergeWith="..\..\coverage.json" `
/p:CoverletOutput="../../artifacts/coverage/$($Project.Name)/" `
/p:CoverletOutputFormat="json%2clcov" `
/p:ExcludeByAttribute=CompilerGeneratedAttribute `
/p:ExcludeByAttribute=GeneratedCodeAttribute
Expand Down
Loading

0 comments on commit e8a229b

Please sign in to comment.