Skip to content

Commit

Permalink
Merge pull request #1401 from autofac/feature/net8
Browse files Browse the repository at this point in the history
Update build/target frameworks for .NET 8; remove netcoreapp3.1.
  • Loading branch information
tillig committed Nov 15, 2023
2 parents 5af8326 + 7a25198 commit e61a651
Show file tree
Hide file tree
Showing 33 changed files with 92 additions and 147 deletions.
3 changes: 1 addition & 2 deletions .vscode/extensions.json
@@ -1,7 +1,6 @@
{
"recommendations": [
"formulahendry.dotnet-test-explorer",
"ms-dotnettools.csharp",
"ms-dotnettools.csdevkit",
"editorconfig.editorconfig",
"davidanson.vscode-markdownlint"
]
Expand Down
6 changes: 3 additions & 3 deletions .vscode/settings.json
Expand Up @@ -8,20 +8,20 @@
"diagnoser",
"inheritdoc",
"langword",
"netcoreapp",
"netstandard",
"notnull",
"paramref",
"startable",
"subclassing",
"typeparam",
"unconfigured",
"xunit"
],
"dotnet-test-explorer.testProjectPath": "test/**/*Test.csproj",
"dotnet.defaultSolution": "Autofac.sln",
"explorer.fileNesting.enabled": true,
"explorer.fileNesting.patterns": {
"*.resx": "$(capture).*.resx, $(capture).designer.cs, $(capture).designer.vb"
},
"omnisharp.enableEditorConfigSupport": true,
"omnisharp.enableRoslynAnalyzers": true
"omnisharp.enableEditorConfigSupport": true
}
4 changes: 2 additions & 2 deletions appveyor.yml
@@ -1,9 +1,9 @@
image: Ubuntu

version: "7.1.0.{build}"
version: "8.0.0.{build}"

dotnet_csproj:
version_prefix: "7.1.0"
version_prefix: "8.0.0"
patch: true
file: 'src\**\*.csproj'

Expand Down
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.5" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.10" />
</ItemGroup>

<ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions bench/Autofac.Benchmarks/Autofac.Benchmarks.csproj
Expand Up @@ -34,10 +34,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="BenchmarkDotNet" Version="0.13.10" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="xunit" Version="2.6.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion bench/Autofac.Benchmarks/ConcurrencyBenchmark.cs
Expand Up @@ -45,7 +45,7 @@ public async Task MultipleResolvesOnMultipleTasks()
}
catch (Exception ex)
{
Assert.True(false, ex.ToString());
Assert.Fail(ex.ToString());
}
});
tasks.Add(task);
Expand Down
Expand Up @@ -55,7 +55,7 @@ public async Task MultipleResolvesOnMultipleTasks()
}
catch (Exception ex)
{
Assert.True(false, ex.ToString());
Assert.Fail(ex.ToString());
}
});
tasks.Add(task);
Expand Down
8 changes: 8 additions & 0 deletions build/Analyzers.ruleset
Expand Up @@ -4,8 +4,16 @@
<Rules AnalyzerId="Microsoft.Usage" RuleNamespace="Microsoft.Usage">
<!-- Implement standard exception constructors - not all of the exception constructors (e.g., parameterless) are desired in our system. -->
<Rule Id="CA1032" Action="None" />
<!-- Use ArgumentNullException.ThrowIfNull - this isn't available until we stop targeting netstandard. -->
<Rule Id="CA1510" Action="None" />
<!-- Use ArgumentOutOfRangeException.ThrowIfNegative - this isn't available until we stop targeting anything below net8.0. -->
<Rule Id="CA1512" Action="None" />
<!-- Use ObjectDisposedException.ThrowIf - this isn't available until we stop targeting anything below net8.0. -->
<Rule Id="CA1513" Action="None" />
<!-- 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. -->
<Rule Id="CA1716" Action="None" />
<!-- Cache a CompositeFormat object for use in String.Format - this isn't available until we stop targeting netstandard, and we only String.Format when throwing exceptions so the work/complexity isn't justified to increase perf just for those situations. -->
<Rule Id="CA1863" Action="None" />
<!-- Implement serialization constructors - false positive when building .NET Core -->
<Rule Id="CA2229" Action="None" />
<!-- Mark ISerializable types with SerializableAttribute - false positive when building .NET Core -->
Expand Down
5 changes: 3 additions & 2 deletions codegen/Autofac.CodeGen/Autofac.CodeGen.csproj
Expand Up @@ -12,6 +12,7 @@
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
<ImplicitUsings>enable</ImplicitUsings>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
</PropertyGroup>

<ItemGroup>
Expand All @@ -23,8 +24,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.5.0" PrivateAssets="all" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.7.0" PrivateAssets="all" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.507" PrivateAssets="all" />
</ItemGroup>

</Project>
6 changes: 3 additions & 3 deletions global.json
@@ -1,11 +1,11 @@
{
"sdk": {
"version": "7.0.203",
"version": "8.0.100-rc.2.23502.2",
"rollForward": "latestFeature"
},

"additionalSdks": [
"3.1.426",
"6.0.408"
"6.0.416",
"7.0.403"
]
}
8 changes: 4 additions & 4 deletions src/Autofac/Autofac.csproj
Expand Up @@ -15,7 +15,7 @@
<SignAssembly>true</SignAssembly>
<NeutralLanguage>en-US</NeutralLanguage>
<!-- Frameworks and language features -->
<TargetFrameworks>net7.0;net6.0;netstandard2.1;netstandard2.0;</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0;netstandard2.1;netstandard2.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<NoWarn>$(NoWarn);CS1591</NoWarn>
Expand Down Expand Up @@ -75,14 +75,14 @@
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" Condition="Exists('$(MSBuildThisFileDirectory)../../.git')">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435">
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.507">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.7.1" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="7.0.2" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="1.1.0" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="7.0.0" />
</ItemGroup>

<ItemDefinitionGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Autofac/Builder/MetadataConfiguration.cs
Expand Up @@ -16,7 +16,7 @@ namespace Autofac.Builder;
/// <remarks>This feature was suggested by OJ Reeves (@TheColonial).</remarks>
public class MetadataConfiguration<TMetadata>
{
private readonly IDictionary<string, object?> _properties = new Dictionary<string, object?>();
private readonly Dictionary<string, object?> _properties = new Dictionary<string, object?>();

/// <summary>
/// Gets the set of properties that have been provided.
Expand Down
4 changes: 2 additions & 2 deletions src/Autofac/ContainerBuilder.cs
Expand Up @@ -39,7 +39,7 @@ public sealed class ContainerBuilder
private static int _builderAlreadyAllocated;

private readonly bool _clearRegistrationCaches;
private readonly IList<DeferredCallback> _configurationCallbacks = new List<DeferredCallback>();
private readonly List<DeferredCallback> _configurationCallbacks = new List<DeferredCallback>();
private BuildCallbackService? _buildCallbacks;
private bool _wasBuilt;

Expand Down Expand Up @@ -150,7 +150,7 @@ public ContainerBuilder RegisterBuildCallback(Action<ILifetimeScope> buildCallba
/// <summary>
/// Create a new container with the component registrations that have been made.
/// </summary>
/// <param name="options">Options that influence the way the container is initialised.</param>
/// <param name="options">Options that influence the way the container is initialized.</param>
/// <remarks>
/// Build can only be called once per <see cref="ContainerBuilder"/>
/// - this prevents ownership issues for provided instances.
Expand Down
13 changes: 0 additions & 13 deletions src/Autofac/Core/DependencyResolutionException.cs
@@ -1,8 +1,6 @@
// Copyright (c) Autofac Project. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

using System.Runtime.Serialization;

namespace Autofac.Core;

/// <summary>
Expand All @@ -11,19 +9,8 @@ namespace Autofac.Core;
/// been made during the operation. For example, 'on activated' handlers may have already been
/// fired, or 'single instance' components partially constructed.
/// </summary>
[Serializable]
public class DependencyResolutionException : Exception
{
/// <summary>
/// Initializes a new instance of the <see cref="DependencyResolutionException"/> class.
/// </summary>
/// <param name="info">The serialisation info.</param>
/// <param name="context">The serialisation streaming context.</param>
protected DependencyResolutionException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="DependencyResolutionException" /> class.
/// </summary>
Expand Down
6 changes: 3 additions & 3 deletions src/Autofac/Core/Lifetime/LifetimeScope.cs
Expand Up @@ -24,7 +24,7 @@ namespace Autofac.Core.Lifetime;
public class LifetimeScope : Disposable, ISharingLifetimeScope, IServiceProvider
{
/// <summary>
/// Protects shared instances from concurrent access. Other members and the base class are threadsafe.
/// Protects shared instances from concurrent access. Other members and the base class are thread-safe.
/// </summary>
private readonly object _synchRoot = new();
private readonly ConcurrentDictionary<Guid, object> _sharedInstances = new();
Expand Down Expand Up @@ -235,7 +235,7 @@ public ILifetimeScope BeginLoadContextLifetimeScope(object tag, AssemblyLoadCont
}
#endif

private ILifetimeScope InternalBeginLifetimeScope(object tag, Action<ContainerBuilder> configurationAction, bool isolatedScope)
private LifetimeScope InternalBeginLifetimeScope(object tag, Action<ContainerBuilder> configurationAction, bool isolatedScope)
{
if (configurationAction == null)
{
Expand Down Expand Up @@ -278,7 +278,7 @@ private ILifetimeScope InternalBeginLifetimeScope(object tag, Action<ContainerBu
/// <remarks>It is the responsibility of the caller to make sure that the registry is properly
/// disposed of. This is generally done by adding the registry to the <see cref="Disposer"/>
/// property of the child scope.</remarks>
private IComponentRegistryBuilder CreateScopeRestrictedRegistry(object tag, Action<ContainerBuilder> configurationAction, bool isolatedScope)
private ComponentRegistryBuilder CreateScopeRestrictedRegistry(object tag, Action<ContainerBuilder> configurationAction, bool isolatedScope)
{
var restrictedRootScopeLifetime = new MatchingScopeLifetime(tag);
var tracker = new ScopeRestrictedRegisteredServicesTracker(restrictedRootScopeLifetime);
Expand Down
Expand Up @@ -233,7 +233,7 @@ public IResolvePipeline Build()
return BuildPipeline(_last);
}

private static IResolvePipeline BuildPipeline(MiddlewareDeclaration? lastDecl)
private static ResolvePipeline BuildPipeline(MiddlewareDeclaration? lastDecl)
{
// When we build, we go through the set and construct a single call stack, starting from the end.
var current = lastDecl;
Expand Down
Expand Up @@ -190,7 +190,7 @@ private static Type GetElementType(Type type)
.FirstOrDefault();
}

private static IEnumerable<T> FilterAll<T>(IComponentContext context, string metadataKey, object metadataValue)
private static T[] FilterAll<T>(IComponentContext context, string metadataKey, object metadataValue)
{
// Using Lazy<T> to ensure components that aren't actually used won't get activated.
return context.Resolve<IEnumerable<Meta<Lazy<T>>>>()
Expand Down
Expand Up @@ -63,7 +63,7 @@ private static Service ServiceWithKey<TService>(object? key)
return new KeyedService(key, typeof(TService));
}

private static IRegistrationBuilder<TTo, LightweightAdapterActivatorData, DynamicRegistrationStyle>
private static RegistrationBuilder<TTo, LightweightAdapterActivatorData, DynamicRegistrationStyle>
RegisterAdapter<TFrom, TTo>(
ContainerBuilder builder,
Func<IComponentContext, IEnumerable<Parameter>, TFrom, TTo> adapter,
Expand Down
4 changes: 2 additions & 2 deletions src/Autofac/Util/Enforce.cs
Expand Up @@ -14,7 +14,7 @@ internal static class Enforce
/// <summary>
/// Enforce that sequence does not contain null. Returns the
/// value if valid so that it can be used inline in
/// base initialiser syntax.
/// base initializer syntax.
/// </summary>
/// <param name="value">The value.</param>
/// <param name="name">The parameter name.</param>
Expand Down Expand Up @@ -55,7 +55,7 @@ public static T NotNull<T>([ValidatedNotNull] T value)
/// <summary>
/// Enforce that an argument is not null or empty. Returns the
/// value if valid so that it can be used inline in
/// base initialiser syntax.
/// base initializer syntax.
/// </summary>
/// <param name="value">The value.</param>
/// <param name="description">The description.</param>
Expand Down
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0;net6.0;netcoreapp3.1;</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<CodeAnalysisRuleSet>../../build/Test.ruleset</CodeAnalysisRuleSet>
Expand All @@ -22,7 +22,7 @@
<ItemGroup>
<ProjectReference Include="..\..\src\Autofac\Autofac.csproj" />
<ProjectReference Include="..\Autofac.Test.Scenarios.ScannedAssembly\Autofac.Test.Scenarios.ScannedAssembly.csproj" />
<ProjectReference Include="..\Autofac.Test.Scenarios.LoadContext\Autofac.Test.Scenarios.LoadContext.csproj" Condition="'$(TargetFramework)' != 'netcoreapp3.1'">
<ProjectReference Include="..\Autofac.Test.Scenarios.LoadContext\Autofac.Test.Scenarios.LoadContext.csproj">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
Expand All @@ -34,20 +34,20 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.2.0">
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.msbuild" Version="3.2.0">
<PackageReference Include="coverlet.msbuild" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.507">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="xunit" Version="2.6.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
20 changes: 10 additions & 10 deletions test/Autofac.Test.CodeGen/Autofac.Test.CodeGen.csproj
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net8.0;net7.0;net6.0</TargetFrameworks>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyOriginatorKeyFile>../../Autofac.snk</AssemblyOriginatorKeyFile>
Expand Down Expand Up @@ -34,26 +34,26 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.2.0">
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.msbuild" Version="3.2.0">
<PackageReference Include="coverlet.msbuild" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.5.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435">
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.507">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="xunit" Version="2.6.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Verify.SourceGenerators" Version="2.1.0" />
<PackageReference Include="Verify.Xunit" Version="19.12.2" />
<PackageReference Include="Verify.SourceGenerators" Version="2.2.0" />
<PackageReference Include="Verify.Xunit" Version="22.1.4" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit e61a651

Please sign in to comment.