Skip to content

Commit b0d4b65

Browse files
authored
Merge pull request #1481 from autofac/feature/build-metadata-update
Feature/build metadata update
2 parents 045ba98 + 1b0a827 commit b0d4b65

257 files changed

Lines changed: 2885 additions & 1158 deletions

File tree

Some content is hidden

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

.editorconfig

Lines changed: 228 additions & 136 deletions
Large diffs are not rendered by default.

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ repos:
88
- id: end-of-file-fixer
99
- id: trailing-whitespace
1010
- repo: https://github.com/igorshubovych/markdownlint-cli
11-
rev: "76b3d32d3f4b965e1d6425253c59407420ae2c43" # frozen: v0.47.0
11+
rev: "e72a3ca1632f0b11a07d171449fe447a7ff6795e" # frozen: v0.48.0
1212
hooks:
1313
- id: markdownlint
1414
args:
1515
- --fix
1616
- repo: https://github.com/tillig/json-sort-cli
17-
rev: "009ab2ab49e1f2fa9d6b9dfc31009ceeca055204" # frozen: v3.0.0
17+
rev: "2b7e147e0933bd30b58133b6f287e5c695ff4f0e" # frozen: v3.0.1
1818
hooks:
1919
- id: json-sort
2020
args:

bench/Autofac.BenchmarkProfiling/Program.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ namespace Autofac.BenchmarkProfiling;
66
/// <summary>
77
/// Simple command-line tool to invoke a benchmark manually in a way that helps with profiling each of the benchmarks.
88
/// </summary>
9-
class Program
9+
internal class Program
1010
{
11-
static void Main(string[] args)
11+
private static void Main(string[] args)
1212
{
1313
// Pick a benchmark.
1414
var availableBenchmarks = Benchmarks.BenchmarkSet.All;
@@ -84,7 +84,7 @@ static void Main(string[] args)
8484

8585
// Workload method is generated differently when BenchmarkDotNet actually runs; we'll need to wrap it in the set of parameters.
8686
// It's way slower than they way they do it, but it should still give us good profiler results.
87-
void workloadAction(int repeat)
87+
void WorkloadAction(int repeat)
8888
{
8989
while (repeat > 0)
9090
{
@@ -96,13 +96,13 @@ void workloadAction(int repeat)
9696
setupAction.InvokeSingle();
9797

9898
// Warmup.
99-
workloadAction(100);
99+
WorkloadAction(100);
100100

101101
// Now start a new thread.
102102
var runThread = new Thread(new ThreadStart(() =>
103103
{
104104
// Do a lot.
105-
workloadAction(10000);
105+
WorkloadAction(10000);
106106
}))
107107
{
108108
Name = "Workload Thread"
@@ -124,7 +124,7 @@ private static void PrintBenchmarks(Type[] availableBenchmarks)
124124

125125
private static void PrintCases(BenchmarkRunInfo benchRunInfo)
126126
{
127-
for (int idx = 0; idx < benchRunInfo.BenchmarksCases.Length; idx++)
127+
for (var idx = 0; idx < benchRunInfo.BenchmarksCases.Length; idx++)
128128
{
129129
var benchCase = benchRunInfo.BenchmarksCases[idx];
130130
if (benchCase.HasParameters)

bench/Autofac.Benchmarks/ConcurrencyBenchmark.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,16 @@ public ConcurrencyBenchmark()
2424
}
2525

2626
[Params(100 /*, 100, 1_000 */)]
27-
public int ResolveTaskCount { get; set; }
27+
public int ResolveTaskCount
28+
{
29+
get; set;
30+
}
2831

2932
[Params(100 /*, 1_000, 10_000 */)]
30-
public int ResolvesPerTask { get; set; }
33+
public int ResolvesPerTask
34+
{
35+
get; set;
36+
}
3137

3238
[Benchmark]
3339
public async Task MultipleResolvesOnMultipleTasks()
@@ -40,11 +46,7 @@ public async Task MultipleResolvesOnMultipleTasks()
4046
{
4147
for (var j = 0; j < ResolvesPerTask; j++)
4248
{
43-
var instance = _container.Resolve<A>();
44-
if (instance is null)
45-
{
46-
throw new InvalidOperationException("Instance is null");
47-
}
49+
var instance = _container.Resolve<A>() ?? throw new InvalidOperationException("Instance is null");
4850
}
4951
});
5052
tasks.Add(task);

bench/Autofac.Benchmarks/ConcurrencyNestedScopeBenchmark.cs

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,16 @@ public ConcurrencyNestedScopeBenchmark()
2222
}
2323

2424
[Params(100 /*, 100, 1_000 */)]
25-
public int ConcurrentRequests { get; set; }
25+
public int ConcurrentRequests
26+
{
27+
get; set;
28+
}
2629

2730
[Params(10)]
28-
public int RepeatCount { get; set; }
31+
public int RepeatCount
32+
{
33+
get; set;
34+
}
2935

3036
[Benchmark]
3137
public async Task MultipleResolvesOnMultipleTasks()
@@ -41,25 +47,13 @@ public async Task MultipleResolvesOnMultipleTasks()
4147
// Start request
4248
using (var requestScope = _container.BeginLifetimeScope("request"))
4349
{
44-
var service1 = requestScope.Resolve<MockRequestScopeService1>();
45-
if (service1 == null)
46-
{
47-
throw new InvalidOperationException("Service1 is null");
48-
}
50+
var service1 = requestScope.Resolve<MockRequestScopeService1>() ?? throw new InvalidOperationException("Service1 is null");
4951

5052
using (var unitOfWorkScope = requestScope.BeginLifetimeScope())
5153
{
52-
var nestedRequestService2 = unitOfWorkScope.Resolve<MockRequestScopeService2>();
53-
if (nestedRequestService2 == null)
54-
{
55-
throw new InvalidOperationException("Nested request service is null");
56-
}
54+
var nestedRequestService2 = unitOfWorkScope.Resolve<MockRequestScopeService2>() ?? throw new InvalidOperationException("Nested request service is null");
5755

58-
var unitOfWork = unitOfWorkScope.Resolve<MockUnitOfWork>();
59-
if (unitOfWork == null)
60-
{
61-
throw new InvalidOperationException("Unit of work is null");
62-
}
56+
var unitOfWork = unitOfWorkScope.Resolve<MockUnitOfWork>() ?? throw new InvalidOperationException("Unit of work is null");
6357
}
6458
}
6559
}

bench/Autofac.Benchmarks/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ private static bool TryMatchBaselineArg(string arg, out string? valueFromAssignm
7878
{
7979
valueFromAssignment = null;
8080

81-
static bool Matches(string candidate) =>
82-
candidate.Equals("--baseline-version", StringComparison.OrdinalIgnoreCase) ||
81+
static bool Matches(string candidate)
82+
=> candidate.Equals("--baseline-version", StringComparison.OrdinalIgnoreCase) ||
8383
candidate.Equals("--baselineVersion", StringComparison.OrdinalIgnoreCase);
8484

8585
var equalsIndex = arg.AsSpan().IndexOf('=');

bench/Autofac.Benchmarks/PropertyInjectionBenchmark.cs

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,47 @@ public void Resolve()
3030

3131
internal class A
3232
{
33-
public B1? B1 { get; set; }
33+
public B1? B1
34+
{
35+
get; set;
36+
}
3437

35-
public B2? B2 { get; set; }
38+
public B2? B2
39+
{
40+
get; set;
41+
}
3642
}
3743

3844
internal class B1
3945
{
40-
public C1? C1 { get; set; }
46+
public C1? C1
47+
{
48+
get; set;
49+
}
4150
}
4251

4352
internal class B2
4453
{
45-
public C2? C2 { get; set; }
54+
public C2? C2
55+
{
56+
get; set;
57+
}
4658
}
4759

4860
internal class C1
4961
{
50-
public D1? D1 { get; set; }
62+
public D1? D1
63+
{
64+
get; set;
65+
}
5166
}
5267

5368
internal class C2
5469
{
55-
public D2? D2 { get; set; }
70+
public D2? D2
71+
{
72+
get; set;
73+
}
5674
}
5775

5876
internal class D1

bench/Autofac.Benchmarks/RequiredPropertyBenchmark.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,27 @@ public ConstructorComponent(ServiceA serviceA, ServiceB serviceB)
4848
ServiceB = serviceB;
4949
}
5050

51-
public ServiceA ServiceA { get; }
51+
public ServiceA ServiceA
52+
{
53+
get;
54+
}
5255

53-
public ServiceB ServiceB { get; }
56+
public ServiceB ServiceB
57+
{
58+
get;
59+
}
5460
}
5561

5662
private class RequiredPropertyComponent
5763
{
58-
public required ServiceA ServiceA { get; set; }
64+
public required ServiceA ServiceA
65+
{
66+
get; set;
67+
}
5968

60-
public required ServiceA ServiceB { get; set; }
69+
public required ServiceA ServiceB
70+
{
71+
get; set;
72+
}
6173
}
6274
}

build/stylecop.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
"licenseName": "MIT"
1010
},
1111
"xmlHeader": false
12+
},
13+
"orderingRules": {
14+
"usingDirectivesPlacement": "outsideNamespace"
1215
}
1316
}
1417
}

codegen/Autofac.CodeGen/DelegateRegisterGenerator.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
2626
{
2727
// Set up an incremental generator that regenerates when the 'RegistrationExtensions' class changes.
2828
// Capture the INamedTypeSymbol when it does.
29-
IncrementalValuesProvider<INamedTypeSymbol> classDeclarations = context.SyntaxProvider
29+
var classDeclarations = context.SyntaxProvider
3030
.CreateSyntaxProvider(
3131
predicate: static (s, _) => s is ClassDeclarationSyntax classSyn && classSyn.Modifiers.Any(static m => m.IsKind(SyntaxKind.PartialKeyword)),
3232
transform: static (context, cancelToken) =>
@@ -47,7 +47,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
4747
.Where(static m => m is not null)!;
4848

4949
// Just get our first one (will only be one instance anyway, we just need to convert to a single value provider).
50-
IncrementalValueProvider<INamedTypeSymbol?> firstSyntax
50+
var firstSyntax
5151
= classDeclarations.Collect().Select((all, _) => all.FirstOrDefault());
5252

5353
context.RegisterSourceOutput(
@@ -74,9 +74,9 @@ private static void Execute(SourceProductionContext spc, INamedTypeSymbol? regEx
7474
spc,
7575
"RegistrationExtensions",
7676
"Register",
77-
static (int argCount, bool hasComponentContext) => hasComponentContext ?
78-
$"DelegateInvokers.DelegateInvoker{argCount}WithComponentContext" :
79-
$"DelegateInvokers.DelegateInvoker{argCount}",
77+
static (int argCount, bool hasComponentContext) => hasComponentContext
78+
? $"DelegateInvokers.DelegateInvoker{argCount}WithComponentContext"
79+
: $"DelegateInvokers.DelegateInvoker{argCount}",
8080
NumberOfGenericArgs);
8181
}
8282

0 commit comments

Comments
 (0)