Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ ccd9b352d4066839cbe2dff010df6ab464ea871e

# Normalize whitespace and JSON key order via pre-commit.
39b63732ecc81559303a7f1ab9d1283c37b279c9

# Apply dotnet format across the solution.
2fea688003a3947a656d91e0532cd2dff2a737c6
19 changes: 0 additions & 19 deletions .github/workflows/build.yml

This file was deleted.

95 changes: 94 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: Continuous Integration

# All jobs are inlined here rather than split into a reusable workflow. This repo
# publishes nothing and has no tests, so it can't consume the shared
# autofac/.github ci.yml, and nothing else consumes ours.

on:
push:
branches:
Expand All @@ -9,6 +13,95 @@ on:
branches:
- main

# If multiple pushes happen quickly in succession, cancel the running build
# and start a new one.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
# Deduplicate the PR-vs-feature-branch double build. A push to a feature
# branch that already has an open PR is skipped, because the pull_request
# event already covers it. Everything else proceeds. Combined with the
# cancel-in-progress concurrency above, this ensures exactly one build runs
# per change and superseded runs are cancelled.
gate:
runs-on: ubuntu-latest
outputs:
should-build: ${{ steps.decide.outputs.should-build }}
steps:
- name: Decide whether to build
id: decide
uses: actions/github-script@v9
with:
script: |
// Always build for pull_request events and for non-feature pushes.
if (context.eventName !== 'push') {
core.info(`Event is ${context.eventName}; building.`);
core.setOutput('should-build', 'true');
return;
}
const ref = context.ref; // e.g. refs/heads/feature/foo or refs/tags/v1.2.3
if (!ref.startsWith('refs/heads/feature/')) {
core.info(`Push to ${ref} is not a feature branch; building.`);
core.setOutput('should-build', 'true');
return;
}
const branch = ref.replace('refs/heads/', '');
const { data: prs } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
head: `${context.repo.owner}:${branch}`,
});
if (prs.length > 0) {
core.info(`Open PR #${prs[0].number} exists for ${branch}; skipping push build (PR build covers it).`);
core.setOutput('should-build', 'false');
} else {
core.info(`No open PR for ${branch}; building feature branch.`);
core.setOutput('should-build', 'true');
}

# Runs on Windows because the .NET Framework examples won't restore on Linux.
dotnet-format:
needs: gate
if: ${{ needs.gate.outputs.should-build == 'true' }}
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
- name: dotnet format
run: dotnet format Examples.slnx --verify-no-changes

pre-commit:
needs: gate
if: ${{ needs.gate.outputs.should-build == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: 3.x
# Enable npm links to allow pre-commit to install hooks that generate
# symlinks.
- name: Enable npm links
run: npm config set install-links true
- uses: pre-commit/action@v3.0.1

build:
uses: ./.github/workflows/build.yml
needs: gate
if: ${{ needs.gate.outputs.should-build == 'true' }}
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
- name: Build
run: dotnet build Examples.slnx --configuration Release
2 changes: 1 addition & 1 deletion src/AspNetCoreChildLifetimeScope/ApplicationAStartup.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using AspNetCoreChildLifetimeScope.Services;
using AspNetCoreChildLifetimeScope.Services;
using Autofac;
using Autofac.Extensions.DependencyInjection;

Expand Down
2 changes: 1 addition & 1 deletion src/AspNetCoreChildLifetimeScope/ApplicationBStartup.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using AspNetCoreChildLifetimeScope.Services;
using AspNetCoreChildLifetimeScope.Services;
using Autofac;
using Autofac.Extensions.DependencyInjection;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using AspNetCoreChildLifetimeScope.Services;
using AspNetCoreChildLifetimeScope.Services;
using Autofac;
using Microsoft.AspNetCore.Mvc;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using AspNetCoreChildLifetimeScope.Services;
using AspNetCoreChildLifetimeScope.Services;
using Autofac;
using Microsoft.AspNetCore.Mvc;

Expand Down
2 changes: 1 addition & 1 deletion src/AspNetCoreChildLifetimeScope/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using AspNetCoreChildLifetimeScope.Services;
using AspNetCoreChildLifetimeScope.Services;
using Autofac;
using Autofac.Extensions.DependencyInjection;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
namespace AspNetCoreChildLifetimeScope.Services
namespace AspNetCoreChildLifetimeScope.Services;

public class ApplicationAScopedDependency
{
public class ApplicationAScopedDependency
public override string ToString()
{
public override string ToString()
{
return $"{GetType().Name} registered only for ApplicationA";
}
return $"{GetType().Name} registered only for ApplicationA";
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
namespace AspNetCoreChildLifetimeScope.Services
namespace AspNetCoreChildLifetimeScope.Services;

public class ApplicationBScopedDependency
{
public class ApplicationBScopedDependency
public override string ToString()
{
public override string ToString()
{
return $"{GetType().Name} registered only for ApplicationB";
}
return $"{GetType().Name} registered only for ApplicationB";
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
namespace AspNetCoreChildLifetimeScope.Services
namespace AspNetCoreChildLifetimeScope.Services;

public class SingletonRootDependency
{
public class SingletonRootDependency
public override string ToString()
{
public override string ToString()
{
return $"{GetType().Name} registered in the root and available to ApplicationA and ApplicationB";
}
return $"{GetType().Name} registered in the root and available to ApplicationA and ApplicationB";
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
namespace AspNetCoreChildLifetimeScope.Services
namespace AspNetCoreChildLifetimeScope.Services;

public class TransientChildScopeDependency
{
public class TransientChildScopeDependency
public override string ToString()
{
public override string ToString()
{
return $"{GetType().Name} registered in the specific scope for ApplicationA and ApplicationB";
}
return $"{GetType().Name} registered in the specific scope for ApplicationA and ApplicationB";
}
}
2 changes: 1 addition & 1 deletion src/AspNetCoreExample/AutofacModule.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using AspNetCoreExample.Services;
using Autofac;
using AspNetCoreExample.Services;

namespace AspNetCoreExample;

Expand Down
2 changes: 1 addition & 1 deletion src/AspNetCoreExample/Controllers/ValuesController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using AspNetCoreExample.Services;
using AspNetCoreExample.Services;
using Microsoft.AspNetCore.Mvc;

namespace AspNetCoreExample.Controllers;
Expand Down
2 changes: 1 addition & 1 deletion src/AspNetCoreExample/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Autofac.Extensions.DependencyInjection;
using Autofac.Extensions.DependencyInjection;

namespace AspNetCoreExample;

Expand Down
7 changes: 5 additions & 2 deletions src/AspNetCoreExample/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Autofac;
using Autofac;

namespace AspNetCoreExample;

Expand All @@ -11,7 +11,10 @@ public Startup(IConfiguration configuration)
Configuration = configuration;
}

public IConfiguration Configuration { get; }
public IConfiguration Configuration
{
get;
}

public void ConfigureServices(IServiceCollection services)
{
Expand Down
2 changes: 1 addition & 1 deletion src/AspNetCoreNoStartupExample/AutofacModule.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using AspNetCoreNoStartupExample.Services;
using AspNetCoreNoStartupExample.Services;
using Autofac;
using Microsoft.Extensions.Logging;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using AspNetCoreNoStartupExample.Services;
using AspNetCoreNoStartupExample.Services;
using Microsoft.AspNetCore.Mvc;

namespace AspNetCoreNoStartupExample.Controllers;
Expand Down
2 changes: 1 addition & 1 deletion src/AspNetCoreNoStartupExample/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using AspNetCoreNoStartupExample;
using Autofac;
using Autofac.Extensions.DependencyInjection;
using AspNetCoreNoStartupExample;

// This example shows how to use Autofac with the minimal hosting model
// (no Startup class). Everything is configured inline in Program.cs.
Expand Down
2 changes: 1 addition & 1 deletion src/AspNetCoreNoStartupExample/Services/IValuesService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace AspNetCoreNoStartupExample.Services;
namespace AspNetCoreNoStartupExample.Services;

public interface IValuesService
{
Expand Down
2 changes: 1 addition & 1 deletion src/AspNetCoreNoStartupExample/Services/ValuesService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging;

namespace AspNetCoreNoStartupExample.Services;

Expand Down
5 changes: 4 additions & 1 deletion src/AttributeMetadataExample/AppenderMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@

public class AppenderMetadata
{
public string AppenderName { get; set; }
public string AppenderName
{
get; set;
}
}
5 changes: 4 additions & 1 deletion src/AttributeMetadataExample/AppenderNameAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ public AppenderNameAttribute(string appenderName)
AppenderName = appenderName;
}

public string AppenderName { get; private set; }
public string AppenderName
{
get; private set;
}
}
5 changes: 4 additions & 1 deletion src/AttributeMetadataExample/IAppenderMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@

public interface IAppenderMetadata
{
string AppenderName { get; }
string AppenderName
{
get;
}
}
2 changes: 1 addition & 1 deletion src/AttributeMetadataExample/LogWithFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class LogWithFilter
{
private readonly ILogAppender _appender;

public LogWithFilter([MetadataFilter("AppenderName", "attributed")]ILogAppender appender)
public LogWithFilter([MetadataFilter("AppenderName", "attributed")] ILogAppender appender)
{
_appender = appender;
}
Expand Down
5 changes: 4 additions & 1 deletion src/ConfigurationExampleInterface/IPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ public interface IPlugin
/// <value>
/// A <see cref="string"/> with the plugin name. Likely just the type name for illustrative purposes.
/// </value>
string Name { get; }
string Name
{
get;
}
}
}
33 changes: 16 additions & 17 deletions src/GenericHostBuilderExample/HostedService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,25 @@
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;

namespace GenericHostBuilderExample
namespace GenericHostBuilderExample;

internal class HostedService : IHostedService
{
internal class HostedService : IHostedService
{
private readonly ILogger _logger;
private readonly ILogger _logger;

// ReSharper disable once UnusedMember.Global
public HostedService(ILogger logger)
{
_logger = logger;
}
// ReSharper disable once UnusedMember.Global
public HostedService(ILogger logger)
{
_logger = logger;
}

public async Task StartAsync(CancellationToken cancellationToken)
{
await _logger.Log("Starting hosted service");
}
public async Task StartAsync(CancellationToken cancellationToken)
{
await _logger.Log("Starting hosted service");
}

public async Task StopAsync(CancellationToken cancellationToken)
{
await _logger.Log("Stopping hosted service");
}
public async Task StopAsync(CancellationToken cancellationToken)
{
await _logger.Log("Stopping hosted service");
}
}
Loading
Loading