Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
tillig committed Aug 2, 2022
2 parents 4ccfc93 + 2791a45 commit 994a0fd
Show file tree
Hide file tree
Showing 19 changed files with 859 additions and 610 deletions.
389 changes: 199 additions & 190 deletions .editorconfig

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"cSpell.words": [
"autofac",
"browsable",
"cref",
"inheritdoc",
"langword",
"owin",
"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.WebApi.Owin.sln",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"command": "dotnet",
"group": {
"isDefault": true,
"kind": "build"
},
"label": "build",
"problemMatcher": "$msCompile",
"type": "process"
}
],
"version": "2.0.0"
}
8 changes: 5 additions & 3 deletions NuGet.Config
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
<configuration>
<packageSources>
<clear />
<add key="Autofac MyGet" value="https://www.myget.org/F/autofac/api/v2" />
<add key="xUnit.net" value="https://www.myget.org/F/xunit/api/v2/" />
<add key="NuGet v3" value="https://api.nuget.org/v3/index.json" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="Autofac MyGet" value="https://www.myget.org/F/autofac/api/v3/index.json" protocolVersion="3" />
</packageSources>
<disabledPackageSources>
<add key="Microsoft and .NET" value="true" />
</disabledPackageSources>
</configuration>
55 changes: 53 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,59 @@ OWIN support for the ASP.NET Web API integration for [Autofac](https://autofac.o

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

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.WebApi.Owin/issues) rather than in the Autofac core repo.

- [Documentation](https://autofac.readthedocs.io/en/latest/integration/webapi.html)
- [NuGet](https://www.nuget.org/packages/Autofac.WebApi2.Owin/)
- [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.WebApi.Owin)

## Quick Start

If you are using Web API [as part of an OWIN application](https://autofac.readthedocs.io/en/latest/integration/owin.html), you need to:

- 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.
- Set up your app with the [base Autofac OWIN integration](https://autofac.readthedocs.io/en/latest/integration/owin.html).
- Add a reference to the `Autofac.WebApi2.Owin` NuGet package.
- In your application startup class, register the Autofac Web API middleware after registering the base Autofac middleware.

```c#
public class Startup
{
public void Configuration(IAppBuilder app)
{
var builder = new ContainerBuilder();

// STANDARD WEB API SETUP:
// Get your HttpConfiguration. In OWIN, you'll create one
// rather than using GlobalConfiguration.
var config = new HttpConfiguration();

// Register your Web API controllers.
builder.RegisterApiControllers(Assembly.GetExecutingAssembly());

// Run other optional steps, like registering filters,
// per-controller-type services, etc., then set the dependency resolver
// to be Autofac.
var container = builder.Build();
config.DependencyResolver = new AutofacWebApiDependencyResolver(container);

// OWIN WEB API SETUP:
// Register the Autofac middleware FIRST, then the Autofac Web API middleware,
// and finally the standard Web API middleware.
app.UseAutofacMiddleware(container);
app.UseAutofacWebApi(config);
app.UseWebApi(config);
}
}
```

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.

[Check out the documentation](https://autofac.readthedocs.io/en/latest/integration/webapi.html) for more usage details.

## 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).
27 changes: 14 additions & 13 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
image: Visual Studio 2019
image: Visual Studio 2022

version: 6.0.0.{build}
version: 6.1.0.{build}

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

Expand All @@ -20,19 +20,20 @@ nuget:

clone_depth: 1

test: off
test: false

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

artifacts:
- path: artifacts\packages\**\*.nupkg
- 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: false
symbol_server: https://www.myget.org/F/autofac/symbols/api/v2/package
- 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
}
26 changes: 24 additions & 2 deletions build/Analyzers.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,31 @@
<Rule Id="SA1122" Action="None" />
<!-- Using statements must be inside a namespace -->
<Rule Id="SA1200" Action="None" />
<!-- Enforce order of class members by member type -->
<Rule Id="SA1201" Action="None" />
<!-- Enforce order of class members by member visibility -->
<Rule Id="SA1202" Action="None" />
<!-- Enforce order of constantand static members -->
<Rule Id="SA1203" Action="None" />
<!-- Enforce order of static vs. non-static members -->
<Rule Id="SA1204" Action="None" />
<!-- Enforce order of readonly vs. non-readonly members -->
<Rule Id="SA1214" Action="None" />
<!-- Fields can't start with underscore -->
<Rule Id="SA1309" Action="None" />
<!-- No single-line statements involving braces -->
<Rule Id="SA1501" Action="None" />
<!-- Suppressions must have a justification -->
<Rule Id="SA1404" Action="None" />
<!-- Parameter documentation must be in the right order -->
<Rule Id="SA1612" Action="None" />
<!-- Return value must be documented -->
<Rule Id="SA1615" Action="None" />
<!-- Generic type parameters must be documented -->
<Rule Id="SA1618" Action="None" />
<!-- Don't copy/paste documentation -->
<Rule Id="SA1625" Action="None" />
<!-- Exception documentation must not be empty -->
<Rule Id="SA1627" Action="None" />
<!-- Enable XML documentation output-->
<Rule Id="SA1652" Action="None" />
</Rules>
</RuleSet>
4 changes: 2 additions & 2 deletions build/Autofac.Build.psd1
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -12,4 +12,4 @@
ModuleList = @()
FileList = @()
PrivateData = ''
}
}
Loading

0 comments on commit 994a0fd

Please sign in to comment.