Skip to content

Commit 4fff3f5

Browse files
authored
Merge pull request #46 from autofac/feature/net8
Update to build with .NET 8, update dependencies
2 parents ecfb304 + 59dbc8c commit 4fff3f5

19 files changed

+227
-322
lines changed

.vscode/extensions.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"recommendations": [
3-
"formulahendry.dotnet-test-explorer",
4-
"ms-dotnettools.csharp",
3+
"ms-dotnettools.csdevkit",
54
"editorconfig.editorconfig",
65
"davidanson.vscode-markdownlint"
76
]

.vscode/launch.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"cwd": "${workspaceFolder}/test/Autofac.Configuration.Test",
88
"name": ".NET Core Launch (console)",
99
"preLaunchTask": "build",
10-
"program": "${workspaceFolder}/test/Autofac.Configuration.Test/bin/Debug/netcoreapp2.0/Autofac.Configuration.Test.dll",
10+
"program": "${workspaceFolder}/test/Autofac.Configuration.Test/bin/Debug/net8.0/Autofac.Configuration.Test.dll",
1111
"request": "launch",
1212
"stopAtEntry": false,
1313
"type": "coreclr"
@@ -20,4 +20,4 @@
2020
}
2121
],
2222
"version": "0.2.0"
23-
}
23+
}

.vscode/settings.json

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"cSpell.words": [
33
"autofac",
4+
"autowired",
45
"cref",
56
"cyclomatic",
67
"langword",
@@ -10,7 +11,24 @@
1011
"typeparam",
1112
"xunit"
1213
],
14+
"coverage-gutters.coverageBaseDir": "artifacts/coverage/**",
15+
"coverage-gutters.coverageFileNames": [
16+
"coverage.info"
17+
],
18+
"dotnet-test-explorer.runInParallel": true,
1319
"dotnet-test-explorer.testProjectPath": "test/**/*Test.csproj",
14-
"omnisharp.enableEditorConfigSupport": true,
15-
"omnisharp.enableRoslynAnalyzers": true
20+
"dotnet.unitTestDebuggingOptions": {
21+
"enableStepFiltering": false,
22+
"justMyCode": false,
23+
"requireExactSource": false,
24+
"sourceLinkOptions": {
25+
"*": {
26+
"enabled": true
27+
}
28+
},
29+
"suppressJITOptimizations": true,
30+
"symbolOptions": {
31+
"searchNuGetOrgSymbolServer": true
32+
}
33+
}
1634
}

appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
image: Ubuntu
22

3-
version: "6.0.0.{build}"
3+
version: 7.0.0.{build}
44

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

build/Test.ruleset

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
<Rule Id="CA1816" Action="None" />
1313
<!-- Mark members static - test methods may not access member data but also can't be static. -->
1414
<Rule Id="CA1822" Action="None" />
15-
<!-- Do not directly await a task - this is for libraries rather than test code. -->
15+
<!-- Seal internal types - tests use internal types for stubs and performance isn't a problem; this causes unnecessary ceremony. -->
16+
<Rule Id="CA1852" Action="None" />
17+
<!-- Call ConfigureAwait - conflicts with xUnit1030 and may cause test parallelization limits to be bypassed. -->
1618
<Rule Id="CA2007" Action="None" />
1719
<!-- Implement serialization constructors - false positive when building .NET Core. -->
1820
<Rule Id="CA2229" Action="None" />

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "6.0.300",
3+
"version": "8.0.204",
44
"rollForward": "latestFeature"
55
}
66
}

src/Autofac.Configuration/Autofac.Configuration.csproj

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
32
<PropertyGroup>
43
<!-- VersionPrefix patched by AppVeyor -->
54
<VersionPrefix>0.0.1</VersionPrefix>
@@ -20,6 +19,7 @@
2019
<Nullable>enable</Nullable>
2120
<GenerateDocumentationFile>true</GenerateDocumentationFile>
2221
<CodeAnalysisRuleSet>../../build/Analyzers.ruleset</CodeAnalysisRuleSet>
22+
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
2323
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
2424
<ImplicitUsings>enable</ImplicitUsings>
2525
<!-- Packaging -->
@@ -37,6 +37,8 @@
3737
<EmbedAllSources>true</EmbedAllSources>
3838
<IncludeSymbols>true</IncludeSymbols>
3939
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
40+
<!-- OmniSharp/VS Code resource generation -->
41+
<CoreCompileDependsOn>PrepareResources;$(CompileDependsOn)</CoreCompileDependsOn>
4042
</PropertyGroup>
4143

4244
<ItemGroup>
@@ -58,14 +60,29 @@
5860
</ItemGroup>
5961

6062
<ItemGroup>
61-
<PackageReference Include="Autofac" Version="6.0.0" />
62-
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.2.0" />
63-
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="2.2.0" />
64-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" Condition="Exists('$(MSBuildThisFileDirectory)../../.git')">
63+
<PackageReference Include="Autofac" Version="8.0.0" />
64+
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
65+
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.2" />
66+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" Condition="Exists('$(MSBuildThisFileDirectory)../../.git')">
6567
<PrivateAssets>all</PrivateAssets>
6668
</PackageReference>
67-
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.406">
69+
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
6870
<PrivateAssets>all</PrivateAssets>
6971
</PackageReference>
7072
</ItemGroup>
73+
74+
<ItemDefinitionGroup>
75+
<EmbeddedResource>
76+
<Generator>MSBuild:Compile</Generator>
77+
<StronglyTypedLanguage>CSharp</StronglyTypedLanguage>
78+
<StronglyTypedFileName>$(IntermediateOutputPath)%(Filename).Designer.cs</StronglyTypedFileName>
79+
<StronglyTypedClassName>%(Filename)</StronglyTypedClassName>
80+
</EmbeddedResource>
81+
</ItemDefinitionGroup>
82+
83+
<ItemGroup>
84+
<EmbeddedResource Update="ConfigurationResources.resx">
85+
<StronglyTypedNamespace>Autofac.Configuration</StronglyTypedNamespace>
86+
</EmbeddedResource>
87+
</ItemGroup>
7188
</Project>

src/Autofac.Configuration/Properties/ConfigurationResources.resx renamed to src/Autofac.Configuration/ConfigurationResources.resx

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<root>
3-
<!--
4-
Microsoft ResX Schema
5-
3+
<!--
4+
Microsoft ResX Schema
5+
66
Version 2.0
7-
8-
The primary goals of this format is to allow a simple XML format
9-
that is mostly human readable. The generation and parsing of the
10-
various data types are done through the TypeConverter classes
7+
8+
The primary goals of this format is to allow a simple XML format
9+
that is mostly human readable. The generation and parsing of the
10+
various data types are done through the TypeConverter classes
1111
associated with the data types.
12-
12+
1313
Example:
14-
14+
1515
... ado.net/XML headers & schema ...
1616
<resheader name="resmimetype">text/microsoft-resx</resheader>
1717
<resheader name="version">2.0</resheader>
@@ -26,36 +26,36 @@
2626
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
2727
<comment>This is a comment</comment>
2828
</data>
29-
30-
There are any number of "resheader" rows that contain simple
29+
30+
There are any number of "resheader" rows that contain simple
3131
name/value pairs.
32-
33-
Each data row contains a name, and value. The row also contains a
34-
type or mimetype. Type corresponds to a .NET class that support
35-
text/value conversion through the TypeConverter architecture.
36-
Classes that don't support this are serialized and stored with the
32+
33+
Each data row contains a name, and value. The row also contains a
34+
type or mimetype. Type corresponds to a .NET class that support
35+
text/value conversion through the TypeConverter architecture.
36+
Classes that don't support this are serialized and stored with the
3737
mimetype set.
38-
39-
The mimetype is used for serialized objects, and tells the
40-
ResXResourceReader how to depersist the object. This is currently not
38+
39+
The mimetype is used for serialized objects, and tells the
40+
ResXResourceReader how to depersist the object. This is currently not
4141
extensible. For a given mimetype the value must be set accordingly:
42-
43-
Note - application/x-microsoft.net.object.binary.base64 is the format
44-
that the ResXResourceWriter will generate, however the reader can
42+
43+
Note - application/x-microsoft.net.object.binary.base64 is the format
44+
that the ResXResourceWriter will generate, however the reader can
4545
read any of the formats listed below.
46-
46+
4747
mimetype: application/x-microsoft.net.object.binary.base64
48-
value : The object must be serialized with
48+
value : The object must be serialized with
4949
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
5050
: and then encoded with base64 encoding.
51-
51+
5252
mimetype: application/x-microsoft.net.object.soap.base64
53-
value : The object must be serialized with
53+
value : The object must be serialized with
5454
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
5555
: and then encoded with base64 encoding.
5656
5757
mimetype: application/x-microsoft.net.object.bytearray.base64
58-
value : The object must be serialized into a byte array
58+
value : The object must be serialized into a byte array
5959
: using a System.ComponentModel.TypeConverter
6060
: and then encoded with base64 encoding.
6161
-->
@@ -126,6 +126,9 @@
126126
<data name="DictionaryKeyMayNotBeNullOrEmpty" xml:space="preserve">
127127
<value>Key cannot be null or empty in a dictionary parameter.</value>
128128
</data>
129+
<data name="NoConstructorsFound" xml:space="preserve">
130+
<value>No constructors on type '{0}' can be found. Make sure your type has at least one public constructor.</value>
131+
</data>
129132
<data name="ServiceTypeMustBeSpecified" xml:space="preserve">
130133
<value>If 'name' is specified, 'service' must also be specified (component name='{0}'.)</value>
131134
</data>
@@ -138,13 +141,13 @@
138141
<data name="TypeNotFound" xml:space="preserve">
139142
<value>The type '{0}' could not be found. It may require assembly qualification, e.g. "MyType, MyAssembly".</value>
140143
</data>
141-
<data name="UnrecognisedBoolean" xml:space="preserve">
144+
<data name="UnrecognizedBoolean" xml:space="preserve">
142145
<value>The value '{0}' is not valid for a Boolean setting. Valid values are 'true' and 'false'.</value>
143146
</data>
144-
<data name="UnrecognisedOwnership" xml:space="preserve">
147+
<data name="UnrecognizedOwnership" xml:space="preserve">
145148
<value>The value '{0}' is not valid for the ownership setting. Valid values are 'lifetime-scope' (the default) and 'external'.</value>
146149
</data>
147-
<data name="UnrecognisedScope" xml:space="preserve">
150+
<data name="UnrecognizedScope" xml:space="preserve">
148151
<value>The value '{0}' is not valid for the instance scope setting. Valid values are 'single-instance', 'per-dependency' (the default), 'per-lifetime-scope', and 'per-request'.</value>
149152
</data>
150-
</root>
153+
</root>

src/Autofac.Configuration/Core/ComponentRegistrar.cs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ protected virtual IEnumerable<Service> EnumerateComponentServices(IConfiguration
102102
// sources, we can't use "name" as the keyed service identifier;
103103
// instead, it must be "key."
104104
var serviceType = serviceDefinition.GetType("type", defaultAssembly);
105-
string serviceKey = serviceDefinition["key"];
105+
var serviceKey = serviceDefinition["key"];
106106
yield return !string.IsNullOrEmpty(serviceKey) ? new KeyedService(serviceKey, serviceType) : new TypedService(serviceType);
107107
}
108108
}
@@ -144,7 +144,11 @@ protected virtual void RegisterComponentMetadata<TReflectionActivatorData, TSing
144144

145145
foreach (var ep in component.GetOrderedSubsections("metadata"))
146146
{
147-
registrar.WithMetadata(ep["key"], TypeManipulation.ChangeToCompatibleType(ep["value"], ep.GetType("type", defaultAssembly)));
147+
var key = ep["key"];
148+
if (key is not null)
149+
{
150+
registrar.WithMetadata(key, TypeManipulation.ChangeToCompatibleType(ep["value"], ep.GetType("type", defaultAssembly)));
151+
}
148152
}
149153
}
150154

@@ -382,7 +386,7 @@ protected virtual void SetComponentOwnership<TReflectionActivatorData, TSingleRe
382386
throw new ArgumentNullException(nameof(registrar));
383387
}
384388

385-
string ownership = component["ownership"];
389+
var ownership = component["ownership"];
386390
if (string.IsNullOrWhiteSpace(ownership))
387391
{
388392
return;
@@ -402,7 +406,7 @@ protected virtual void SetComponentOwnership<TReflectionActivatorData, TSingleRe
402406
return;
403407
}
404408

405-
throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, ConfigurationResources.UnrecognisedOwnership, ownership));
409+
throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, ConfigurationResources.UnrecognizedOwnership, ownership));
406410
}
407411

408412
/// <summary>
@@ -527,7 +531,7 @@ protected virtual void SetLifetimeScope<TReflectionActivatorData, TSingleRegistr
527531
throw new ArgumentNullException(nameof(registrar));
528532
}
529533

530-
string lifetimeScope = component["instanceScope"];
534+
var lifetimeScope = component["instanceScope"];
531535
if (string.IsNullOrWhiteSpace(lifetimeScope))
532536
{
533537
return;
@@ -561,6 +565,6 @@ protected virtual void SetLifetimeScope<TReflectionActivatorData, TSingleRegistr
561565
return;
562566
}
563567

564-
throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, ConfigurationResources.UnrecognisedScope, lifetimeScope));
568+
throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, ConfigurationResources.UnrecognizedScope, lifetimeScope));
565569
}
566570
}

0 commit comments

Comments
 (0)