Skip to content

Commit cc14ddf

Browse files
authored
Merge pull request #70 from autofac/feature/build-update
Update build and packaging
2 parents 03b7b7b + 386fe5d commit cc14ddf

File tree

97 files changed

+5896
-6147
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+5896
-6147
lines changed

.editorconfig

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

.vscode/settings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
{
22
"cSpell.words": [
33
"autofac",
4+
"cref",
5+
"inheritdoc",
6+
"langword",
7+
"notnull",
8+
"paramref",
9+
"seealso",
10+
"typeparam",
11+
"unmanaged",
412
"xunit"
513
],
614
"dotnet-test-explorer.runInParallel": true,

ISSUE_TEMPLATE.md

Lines changed: 0 additions & 11 deletions
This file was deleted.

NuGet.Config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<configuration>
33
<packageSources>
44
<clear />
5-
<add key="Autofac MyGet" value="https://www.myget.org/F/autofac/api/v2" />
6-
<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" />
77
</packageSources>
88
</configuration>

README.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,44 @@
22

33
ASP.NET Web API integration for [Autofac](https://autofac.org).
44

5-
[![Build status](https://ci.appveyor.com/api/projects/status/i7fjrapyswrvy73r?svg=true)](https://ci.appveyor.com/project/Autofac/autofac-webapi) [![Open in Visual Studio Code](https://open.vscode.dev/badges/open-in-vscode.svg)](https://open.vscode.dev/autofac/Autofac.WebApi)
5+
[![Build status](https://ci.appveyor.com/api/projects/status/i7fjrapyswrvy73r?svg=true)](https://ci.appveyor.com/project/Autofac/autofac-webapi)
66

77
Please file issues and pull requests for this package in this repository 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/)
1111
- [Contributing](https://autofac.readthedocs.io/en/latest/contributors.html)
12+
- [Open in Visual Studio Code](https://open.vscode.dev/autofac/Autofac.WebApi)
13+
14+
## Quick Start
15+
16+
To get Autofac integrated with Web API you need to reference the Web API integration NuGet package, register your controllers, and set the dependency resolver. You can optionally enable other features as well.
17+
18+
```c#
19+
protected void Application_Start()
20+
{
21+
var builder = new ContainerBuilder();
22+
23+
// Get your HttpConfiguration.
24+
var config = GlobalConfiguration.Configuration;
25+
26+
// Register your Web API controllers.
27+
builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
28+
29+
// OPTIONAL: Register the Autofac filter provider.
30+
builder.RegisterWebApiFilterProvider(config);
31+
32+
// OPTIONAL: Register the Autofac model binder provider.
33+
builder.RegisterWebApiModelBinderProvider();
34+
35+
// Set the dependency resolver to be Autofac.
36+
var container = builder.Build();
37+
config.DependencyResolver = new AutofacWebApiDependencyResolver(container);
38+
}
39+
```
40+
41+
[Check out the documentation](https://autofac.readthedocs.io/en/latest/integration/webapi.html) for more usage details.
42+
43+
## Get Help
44+
45+
**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: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
image: Visual Studio 2022
2+
13
version: 6.1.0.{build}
24

35
dotnet_csproj:
@@ -7,8 +9,6 @@ dotnet_csproj:
79

810
configuration: Release
911

10-
image: Visual Studio 2022
11-
1212
environment:
1313
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
1414
NUGET_XMLDOC_MODE: skip
@@ -23,15 +23,17 @@ clone_depth: 1
2323
test: false
2424

2525
build_script:
26-
- pwsh: .\build.ps1
26+
- pwsh: .\build.ps1
2727

2828
artifacts:
29-
- path: artifacts\packages\**\*.nupkg
30-
name: MyGet
29+
- path: artifacts\packages\**\*.*nupkg
30+
name: MyGet
31+
type: NuGetPackage
3132

3233
deploy:
33-
- provider: NuGet
34-
server: https://www.myget.org/F/autofac/
35-
api_key:
36-
secure: xUXExgVAagrdEicCjSxsQVrwiLo2TtnfqMbYB9Cauq2cpbm/EVz957PBK0v/GEYq
37-
symbol_server: https://nuget.symbolsource.org/MyGet/autofac
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: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,17 @@ try {
1919
Remove-Item $artifactsPath -Force -Recurse
2020
}
2121

22-
# Install dotnet CLI
23-
Install-DotNetCli -Version $sdkVersion
24-
25-
foreach ($additional in $globalJson.additionalSdks)
26-
{
27-
Install-DotNetCli -Version $additional;
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+
}
2833
}
2934

3035
# Write out dotnet information

build/Autofac.Build.psm1

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
# 4: dotnet / NuGet package restore failure
66

77
<#
8-
.SYNOPSIS
9-
Gets the set of directories in which projects are available for compile/processing.
8+
.SYNOPSIS
9+
Gets the set of directories in which projects are available for compile/processing.
1010
11-
.PARAMETER RootPath
12-
Path where searching for project directories should begin.
11+
.PARAMETER RootPath
12+
Path where searching for project directories should begin.
1313
#>
1414
function Get-DotNetProjectDirectory {
1515
[CmdletBinding()]
@@ -115,39 +115,39 @@ function Invoke-DotNetBuild {
115115
}
116116

117117
<#
118-
.SYNOPSIS
119-
Invokes the dotnet utility to package a project.
118+
.SYNOPSIS
119+
Invokes the dotnet utility to package a project.
120120
121-
.PARAMETER ProjectDirectory
122-
Path to the directory containing the project to package.
121+
.PARAMETER ProjectDirectory
122+
Path to the directory containing the project to package.
123123
124-
.PARAMETER PackagesPath
125-
Path to the "artifacts/packages" folder where packages should go.
124+
.PARAMETER PackagesPath
125+
Path to the "artifacts/packages" folder where packages should go.
126126
127-
.PARAMETER VersionSuffix
128-
The version suffix to use for the NuGet package version.
127+
.PARAMETER VersionSuffix
128+
The version suffix to use for the NuGet package version.
129129
#>
130130
function Invoke-DotNetPack {
131-
[CmdletBinding()]
132-
Param(
133-
[Parameter(Mandatory = $True, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)]
134-
[ValidateNotNull()]
135-
[System.IO.DirectoryInfo[]]
136-
$ProjectDirectory,
137-
138-
[Parameter(Mandatory = $True, ValueFromPipeline = $False)]
139-
[ValidateNotNull()]
140-
[System.IO.DirectoryInfo]
141-
$PackagesPath,
131+
[CmdletBinding()]
132+
Param(
133+
[Parameter(Mandatory = $True, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)]
134+
[ValidateNotNull()]
135+
[System.IO.DirectoryInfo[]]
136+
$ProjectDirectory,
142137

143138
[Parameter(Mandatory = $True, ValueFromPipeline = $False)]
144-
[AllowEmptyString()]
145-
[string]
146-
$VersionSuffix
147-
)
148-
Begin {
149-
New-Item -Path $PackagesPath -ItemType Directory -Force | Out-Null
150-
}
139+
[ValidateNotNull()]
140+
[System.IO.DirectoryInfo]
141+
$PackagesPath,
142+
143+
[Parameter(Mandatory = $True, ValueFromPipeline = $False)]
144+
[AllowEmptyString()]
145+
[string]
146+
$VersionSuffix
147+
)
148+
Begin {
149+
New-Item -Path $PackagesPath -ItemType Directory -Force | Out-Null
150+
}
151151
Process {
152152
foreach ($Project in $ProjectDirectory) {
153153
if ($VersionSuffix -eq "") {
@@ -212,11 +212,11 @@ function Invoke-Test {
212212
}
213213

214214
<#
215-
.SYNOPSIS
216-
Restores dependencies using the dotnet utility.
215+
.SYNOPSIS
216+
Restores dependencies using the dotnet utility.
217217
218-
.PARAMETER ProjectDirectory
219-
Path to the directory containing the project with dependencies to restore.
218+
.PARAMETER ProjectDirectory
219+
Path to the directory containing the project with dependencies to restore.
220220
#>
221221
function Restore-DependencyPackages {
222222
[CmdletBinding()]

build/CodeAnalysisDictionary.xml

Lines changed: 0 additions & 47 deletions
This file was deleted.

build/Test.ruleset

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<RuleSet Name="Autofac Analyzer Rules" Description="Analyzer rules for Autofac assemblies." ToolsVersion="16.0">
3+
<IncludeAll Action="Warning" />
4+
<Rules AnalyzerId="Microsoft.Usage" RuleNamespace="Microsoft.Usage">
5+
<!-- Implement standard exception constructors - not all of the exception constructors (e.g., parameterless) are desired in our system. -->
6+
<Rule Id="CA1032" Action="None" />
7+
<!-- Change names to avoid reserved word overlaps (e.g., Delegate, GetType, etc.) - too many of these in the public API, we'd break if we fixed it. -->
8+
<Rule Id="CA1716" Action="None" />
9+
<!-- Change Dispose() to call GC.SuppressFinalize - in tests we don't really care and it can impact readability. -->
10+
<Rule Id="CA1816" Action="None" />
11+
<!-- Mark members static - test methods may not access member data but also can't be static. -->
12+
<Rule Id="CA1822" Action="None" />
13+
<!-- Implement serialization constructors - false positive when building .NET Core -->
14+
<Rule Id="CA2229" Action="None" />
15+
<!-- Mark ISerializable types with SerializableAttribute - false positive when building .NET Core -->
16+
<Rule Id="CA2237" Action="None" />
17+
</Rules>
18+
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
19+
<!-- Prefix local calls with this -->
20+
<Rule Id="SA1101" Action="None" />
21+
<!-- Use built-in type alias -->
22+
<Rule Id="SA1121" Action="None" />
23+
<!-- Use String.Empty instead of "" -->
24+
<Rule Id="SA1122" Action="None" />
25+
<!-- Using statements must be inside a namespace -->
26+
<Rule Id="SA1200" Action="None" />
27+
<!-- Enforce order of class members by member type -->
28+
<Rule Id="SA1201" Action="None" />
29+
<!-- Enforce order of class members by member visibility -->
30+
<Rule Id="SA1202" Action="None" />
31+
<!-- Enforce order of constantand static members -->
32+
<Rule Id="SA1203" Action="None" />
33+
<!-- Enforce order of static vs. non-static members -->
34+
<Rule Id="SA1204" Action="None" />
35+
<!-- Enforce order of readonly vs. non-readonly members -->
36+
<Rule Id="SA1214" Action="None" />
37+
<!-- Fields can't start with underscore -->
38+
<Rule Id="SA1309" Action="None" />
39+
<!-- Suppressions must have a justification -->
40+
<Rule Id="SA1404" Action="None" />
41+
<!-- Elements should be documented -->
42+
<Rule Id="SA1600" Action="None" />
43+
<!-- Enuemration items should be documented -->
44+
<Rule Id="SA1602" Action="None" />
45+
<!-- Parameter documentation must be in the right order -->
46+
<Rule Id="SA1612" Action="None" />
47+
<!-- Return value must be documented -->
48+
<Rule Id="SA1615" Action="None" />
49+
<!-- Generic type parameters must be documented -->
50+
<Rule Id="SA1618" Action="None" />
51+
<!-- Don't copy/paste documentation -->
52+
<Rule Id="SA1625" Action="None" />
53+
<!-- Exception documentation must not be empty -->
54+
<Rule Id="SA1627" Action="None" />
55+
<!-- Enable XML documentation output-->
56+
<Rule Id="SA1652" Action="None" />
57+
<!-- Private member is unused - tests for reflection require members that may not get used. -->
58+
<Rule Id="IDE0051" Action="None" />
59+
<!-- Private member assigned value never read - tests for reflection require values that may not get used. -->
60+
<Rule Id="IDE0052" Action="None" />
61+
<!-- Remove unused parameter - tests for reflection require parameters that may not get used. -->
62+
<Rule Id="IDE0060" Action="None" />
63+
</Rules>
64+
</RuleSet>

0 commit comments

Comments
 (0)