Skip to content

Commit 994a0fd

Browse files
committed
Merge branch 'develop'
2 parents 4ccfc93 + 2791a45 commit 994a0fd

19 files changed

+859
-610
lines changed

.editorconfig

Lines changed: 199 additions & 190 deletions
Large diffs are not rendered by default.

.vscode/settings.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"cSpell.words": [
3+
"autofac",
4+
"browsable",
5+
"cref",
6+
"inheritdoc",
7+
"langword",
8+
"owin",
9+
"paramref",
10+
"seealso",
11+
"typeparam",
12+
"unmanaged",
13+
"xunit"
14+
],
15+
"dotnet-test-explorer.runInParallel": true,
16+
"dotnet-test-explorer.testProjectPath": "test/**/*.Test.csproj"
17+
}

.vscode/tasks.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"tasks": [
3+
{
4+
"args": [
5+
"build",
6+
"${workspaceFolder}/Autofac.WebApi.Owin.sln",
7+
"/property:GenerateFullPaths=true",
8+
"/consoleloggerparameters:NoSummary"
9+
],
10+
"command": "dotnet",
11+
"group": {
12+
"isDefault": true,
13+
"kind": "build"
14+
},
15+
"label": "build",
16+
"problemMatcher": "$msCompile",
17+
"type": "process"
18+
}
19+
],
20+
"version": "2.0.0"
21+
}

NuGet.Config

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
<configuration>
33
<packageSources>
44
<clear />
5-
<add key="Autofac MyGet" value="https://www.myget.org/F/autofac/api/v2" />
6-
<add key="xUnit.net" value="https://www.myget.org/F/xunit/api/v2/" />
7-
<add key="NuGet v3" value="https://api.nuget.org/v3/index.json" />
5+
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
6+
<add key="Autofac MyGet" value="https://www.myget.org/F/autofac/api/v3/index.json" protocolVersion="3" />
87
</packageSources>
8+
<disabledPackageSources>
9+
<add key="Microsoft and .NET" value="true" />
10+
</disabledPackageSources>
911
</configuration>

README.md

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,59 @@ OWIN support for the ASP.NET Web API integration for [Autofac](https://autofac.o
44

55
[![Build status](https://ci.appveyor.com/api/projects/status/sllnx8g95topf79l?svg=true)](https://ci.appveyor.com/project/Autofac/autofac-webapi-owin)
66

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

99
- [Documentation](https://autofac.readthedocs.io/en/latest/integration/webapi.html)
1010
- [NuGet](https://www.nuget.org/packages/Autofac.WebApi2.Owin/)
11-
- [Contributing](https://autofac.readthedocs.io/en/latest/contributors.html)
11+
- [Contributing](https://autofac.readthedocs.io/en/latest/contributors.html)
12+
- [Open in Visual Studio Code](https://open.vscode.dev/autofac/Autofac.WebApi.Owin)
13+
14+
## Quick Start
15+
16+
If you are using Web API [as part of an OWIN application](https://autofac.readthedocs.io/en/latest/integration/owin.html), you need to:
17+
18+
- Do all the stuff for [standard Web API integration](https://autofac.readthedocs.io/en/latest/integration/webapi.html) - register controllers, set the dependency resolver, etc.
19+
- Set up your app with the [base Autofac OWIN integration](https://autofac.readthedocs.io/en/latest/integration/owin.html).
20+
- Add a reference to the `Autofac.WebApi2.Owin` NuGet package.
21+
- In your application startup class, register the Autofac Web API middleware after registering the base Autofac middleware.
22+
23+
```c#
24+
public class Startup
25+
{
26+
public void Configuration(IAppBuilder app)
27+
{
28+
var builder = new ContainerBuilder();
29+
30+
// STANDARD WEB API SETUP:
31+
32+
// Get your HttpConfiguration. In OWIN, you'll create one
33+
// rather than using GlobalConfiguration.
34+
var config = new HttpConfiguration();
35+
36+
// Register your Web API controllers.
37+
builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
38+
39+
// Run other optional steps, like registering filters,
40+
// per-controller-type services, etc., then set the dependency resolver
41+
// to be Autofac.
42+
var container = builder.Build();
43+
config.DependencyResolver = new AutofacWebApiDependencyResolver(container);
44+
45+
// OWIN WEB API SETUP:
46+
47+
// Register the Autofac middleware FIRST, then the Autofac Web API middleware,
48+
// and finally the standard Web API middleware.
49+
app.UseAutofacMiddleware(container);
50+
app.UseAutofacWebApi(config);
51+
app.UseWebApi(config);
52+
}
53+
}
54+
```
55+
56+
A common error in OWIN integration is use of the `GlobalConfiguration.Configuration`. **In OWIN you create the configuration from scratch.** You should not reference `GlobalConfiguration.Configuration` anywhere when using the OWIN integration.
57+
58+
[Check out the documentation](https://autofac.readthedocs.io/en/latest/integration/webapi.html) for more usage details.
59+
60+
## Get Help
61+
62+
**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).

appveyor.yml

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
image: Visual Studio 2019
1+
image: Visual Studio 2022
22

3-
version: 6.0.0.{build}
3+
version: 6.1.0.{build}
44

55
dotnet_csproj:
6-
version_prefix: '6.0.0'
6+
version_prefix: '6.1.0'
77
patch: true
88
file: 'src\**\*.csproj'
99

@@ -20,19 +20,20 @@ nuget:
2020

2121
clone_depth: 1
2222

23-
test: off
23+
test: false
2424

2525
build_script:
26-
- ps: .\build.ps1
27-
26+
- pwsh: .\build.ps1
27+
2828
artifacts:
29-
- path: artifacts\packages\**\*.nupkg
29+
- path: artifacts\packages\**\*.*nupkg
3030
name: MyGet
31+
type: NuGetPackage
3132

3233
deploy:
33-
- provider: NuGet
34-
server: https://www.myget.org/F/autofac/api/v2/package
35-
api_key:
36-
secure: rCUEY75fXN0wxtMy6QL4jCrLdaYbxIBzIXWeN+wEu/XDpyqimzreOc5AH5jMd5ah
37-
skip_symbols: false
38-
symbol_server: https://www.myget.org/F/autofac/symbols/api/v2/package
34+
- provider: NuGet
35+
server: https://www.myget.org/F/autofac/api/v2/package
36+
symbol_server: https://www.myget.org/F/autofac/api/v2/package
37+
api_key:
38+
secure: xUXExgVAagrdEicCjSxsQVrwiLo2TtnfqMbYB9Cauq2cpbm/EVz957PBK0v/GEYq
39+
artifact: MyGet

build.ps1

Lines changed: 48 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,61 @@
33
########################
44

55
Push-Location $PSScriptRoot
6-
Import-Module $PSScriptRoot\Build\Autofac.Build.psd1 -Force
6+
try {
7+
Import-Module $PSScriptRoot/build/Autofac.Build.psd1 -Force
78

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

12-
# Clean up artifacts folder
13-
if (Test-Path $artifactsPath) {
14-
Write-Message "Cleaning $artifactsPath folder"
15-
Remove-Item $artifactsPath -Force -Recurse
16-
}
12+
$globalJson = (Get-Content "$PSScriptRoot/global.json" | ConvertFrom-Json -NoEnumerate);
13+
14+
$sdkVersion = $globalJson.sdk.version
15+
16+
# Clean up artifacts folder
17+
if (Test-Path $artifactsPath) {
18+
Write-Message "Cleaning $artifactsPath folder"
19+
Remove-Item $artifactsPath -Force -Recurse
20+
}
1721

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

22-
# Write out dotnet information
23-
& dotnet --info
35+
# Write out dotnet information
36+
& dotnet --info
2437

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

30-
Write-Message "Package version suffix is '$versionSuffix'"
43+
Write-Message "Package version suffix is '$versionSuffix'"
3144

32-
# Package restore
33-
Write-Message "Restoring packages"
34-
Get-DotNetProjectDirectory -RootPath $PSScriptRoot | Restore-DependencyPackages
45+
# Package restore
46+
Write-Message "Restoring packages"
47+
Get-DotNetProjectDirectory -RootPath $PSScriptRoot | Restore-DependencyPackages
3548

36-
# Build/package
37-
Write-Message "Building projects and packages"
38-
Get-DotNetProjectDirectory -RootPath $PSScriptRoot\src | Invoke-DotNetPack -PackagesPath $packagesPath -VersionSuffix $versionSuffix
49+
# Build/package
50+
Write-Message "Building projects and packages"
51+
Get-DotNetProjectDirectory -RootPath $PSScriptRoot\src | Invoke-DotNetPack -PackagesPath $packagesPath -VersionSuffix $versionSuffix
3952

40-
# Test
41-
Write-Message "Executing unit tests"
42-
Get-DotNetProjectDirectory -RootPath $PSScriptRoot\test | Invoke-Test
53+
# Test
54+
Write-Message "Executing unit tests"
55+
Get-DotNetProjectDirectory -RootPath $PSScriptRoot\test | Invoke-Test
4356

44-
# Finished
45-
Write-Message "Build finished"
46-
Pop-Location
57+
58+
# Finished
59+
Write-Message "Build finished"
60+
}
61+
finally {
62+
Pop-Location
63+
}

build/Analyzers.ruleset

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,31 @@
2020
<Rule Id="SA1122" Action="None" />
2121
<!-- Using statements must be inside a namespace -->
2222
<Rule Id="SA1200" Action="None" />
23+
<!-- Enforce order of class members by member type -->
24+
<Rule Id="SA1201" Action="None" />
25+
<!-- Enforce order of class members by member visibility -->
26+
<Rule Id="SA1202" Action="None" />
27+
<!-- Enforce order of constantand static members -->
28+
<Rule Id="SA1203" Action="None" />
29+
<!-- Enforce order of static vs. non-static members -->
30+
<Rule Id="SA1204" Action="None" />
31+
<!-- Enforce order of readonly vs. non-readonly members -->
32+
<Rule Id="SA1214" Action="None" />
2333
<!-- Fields can't start with underscore -->
2434
<Rule Id="SA1309" Action="None" />
25-
<!-- No single-line statements involving braces -->
26-
<Rule Id="SA1501" Action="None" />
35+
<!-- Suppressions must have a justification -->
36+
<Rule Id="SA1404" Action="None" />
37+
<!-- Parameter documentation must be in the right order -->
38+
<Rule Id="SA1612" Action="None" />
39+
<!-- Return value must be documented -->
40+
<Rule Id="SA1615" Action="None" />
41+
<!-- Generic type parameters must be documented -->
42+
<Rule Id="SA1618" Action="None" />
43+
<!-- Don't copy/paste documentation -->
44+
<Rule Id="SA1625" Action="None" />
45+
<!-- Exception documentation must not be empty -->
46+
<Rule Id="SA1627" Action="None" />
47+
<!-- Enable XML documentation output-->
48+
<Rule Id="SA1652" Action="None" />
2749
</Rules>
2850
</RuleSet>

build/Autofac.Build.psd1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@{
22
RootModule = '.\Autofac.Build.psm1'
3-
ModuleVersion = '0.2.0'
3+
ModuleVersion = '0.3.0'
44
GUID = '55d3f738-f48f-4497-9b2c-ecd90ec1f978'
55
Author = 'Autofac Contributors'
66
CompanyName = 'Autofac'
@@ -12,4 +12,4 @@
1212
ModuleList = @()
1313
FileList = @()
1414
PrivateData = ''
15-
}
15+
}

0 commit comments

Comments
 (0)