Skip to content

Commit

Permalink
Last renames and comments (for now)
Browse files Browse the repository at this point in the history
  • Loading branch information
alistairjevans committed May 20, 2020
1 parent 014445c commit e76a8d3
Show file tree
Hide file tree
Showing 67 changed files with 1,704 additions and 599 deletions.
39 changes: 29 additions & 10 deletions src/Autofac/Autofac.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<NoWarn>$(NoWarn);CS1591;IDE0008</NoWarn>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>Autofac</AssemblyName>
<AssemblyOriginatorKeyFile>../../Autofac.snk</AssemblyOriginatorKeyFile>
Expand Down Expand Up @@ -40,6 +40,11 @@
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'net461'">
<NoWarn>$(NoWarn);8600;8601;8602;8603;8604</NoWarn>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Core\Pipeline\**" />
<EmbeddedResource Remove="Core\Pipeline\**" />
<None Remove="Core\Pipeline\**" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\build\icon.png" Pack="true" PackagePath="\" />
Expand All @@ -49,7 +54,7 @@
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.0.0">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8">
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" Condition="Exists('$(MSBuildThisFileDirectory)../../.git')">
Expand Down Expand Up @@ -129,6 +134,11 @@
<AutoGen>True</AutoGen>
<DependentUpon>ContainerResources.resx</DependentUpon>
</Compile>
<Compile Update="Core\Diagnostics\TracerMessages.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>TracerMessages.resx</DependentUpon>
</Compile>
<Compile Update="Core\Lifetime\LifetimeScopeResources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
Expand All @@ -154,16 +164,21 @@
<AutoGen>True</AutoGen>
<DependentUpon>ServiceRegistrationInfoResources.resx</DependentUpon>
</Compile>
<Compile Update="Core\Resolving\CircularDependencyDetectorResources.Designer.cs">
<Compile Update="Core\Resolving\Middleware\CircularDependencyDetectorMessages.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>CircularDependencyDetectorResources.resx</DependentUpon>
<DependentUpon>CircularDependencyDetectorMessages.resx</DependentUpon>
</Compile>
<Compile Update="Core\Resolving\ComponentActivationResources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>ComponentActivationResources.resx</DependentUpon>
</Compile>
<Compile Update="Core\Resolving\Middleware\MiddlewareMessages.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>MiddlewareMessages.resx</DependentUpon>
</Compile>
<Compile Update="Core\Resolving\Pipeline\ResolvePipelineBuilderMessages.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
Expand Down Expand Up @@ -335,6 +350,10 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>ContainerResources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Update="Core\Diagnostics\TracerMessages.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>TracerMessages.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Update="Core\Lifetime\LifetimeScopeResources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>LifetimeScopeResources.Designer.cs</LastGenOutput>
Expand All @@ -355,14 +374,18 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>ServiceRegistrationInfoResources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Update="Core\Resolving\CircularDependencyDetectorResources.resx">
<EmbeddedResource Update="Core\Resolving\Middleware\CircularDependencyDetectorMessages.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>CircularDependencyDetectorResources.Designer.cs</LastGenOutput>
<LastGenOutput>CircularDependencyDetectorMessages.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Update="Core\Resolving\ComponentActivationResources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>ComponentActivationResources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Update="Core\Resolving\Middleware\MiddlewareMessages.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>MiddlewareMessages.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Update="Core\Resolving\Pipeline\ResolvePipelineBuilderMessages.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>ResolvePipelineBuilderMessages.Designer.cs</LastGenOutput>
Expand Down Expand Up @@ -460,8 +483,4 @@
<LastGenOutput>ReflectionExtensionsResources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
<Folder Include="Core\Pipeline\" />
</ItemGroup>
</Project>
13 changes: 5 additions & 8 deletions src/Autofac/Core/Activators/Delegate/DelegateActivator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,14 @@ public class DelegateActivator : InstanceActivator, IInstanceActivator
public DelegateActivator(Type limitType, Func<IComponentContext, IEnumerable<Parameter>, object> activationFunction)
: base(limitType)
{
if (activationFunction == null) throw new ArgumentNullException(nameof(activationFunction));

_activationFunction = activationFunction;
_activationFunction = activationFunction ?? throw new ArgumentNullException(nameof(activationFunction));
}

/// <inheritdoc/>
public void ConfigurePipeline(IComponentRegistryServices componentRegistryServices, IResolvePipelineBuilder pipelineBuilder)
{
if (pipelineBuilder is null) throw new ArgumentNullException(nameof(pipelineBuilder));

pipelineBuilder.Use(this.DisplayName(), PipelinePhase.Activation, MiddlewareInsertionMode.EndOfPhase, (ctxt, next) =>
{
ctxt.Instance = ActivateInstance(ctxt, ctxt.Parameters);
Expand All @@ -64,15 +65,11 @@ public void ConfigurePipeline(IComponentRegistryServices componentRegistryServic
}

/// <summary>
/// Activate an instance in the provided context.
/// Invokes the delegate and returns the instance.
/// </summary>
/// <param name="context">Context in which to activate instances.</param>
/// <param name="parameters">Parameters to the instance.</param>
/// <returns>The activated instance.</returns>
/// <remarks>
/// The context parameter here should probably be ILifetimeScope in order to reveal Disposer,
/// but will wait until implementing a concrete use case to make the decision.
/// </remarks>
private object ActivateInstance(IComponentContext context, IEnumerable<Parameter> parameters)
{
if (context == null) throw new ArgumentNullException(nameof(context));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,19 @@ public ProvidedInstanceActivator(object instance)
_instance = instance;
}

/// <summary>
/// Activate an instance in the provided context.
/// </summary>
/// <param name="context">Context in which to activate instances.</param>
/// <param name="parameters">Parameters to the instance.</param>
/// <returns>The activated instance.</returns>
/// <remarks>
/// The context parameter here should probably be ILifetimeScope in order to reveal Disposer,
/// but will wait until implementing a concrete use case to make the decision.
/// </remarks>
/// <inheritdoc/>
public void ConfigurePipeline(IComponentRegistryServices componentRegistryServices, IResolvePipelineBuilder pipelineBuilder)
{
if (pipelineBuilder is null) throw new ArgumentNullException(nameof(pipelineBuilder));

pipelineBuilder.Use(this.DisplayName(), PipelinePhase.Activation, MiddlewareInsertionMode.EndOfPhase, (ctxt, next) =>
{
ctxt.Instance = GetInstance();
next(ctxt);
});
}

private object GetInstance()
{
CheckNotDisposed();
Expand All @@ -71,16 +74,6 @@ private object GetInstance()
return _instance;
}

public void ConfigurePipeline(IComponentRegistryServices componentRegistryServices, IResolvePipelineBuilder pipelineBuilder)
{
pipelineBuilder.Use(this.DisplayName(), PipelinePhase.Activation, MiddlewareInsertionMode.EndOfPhase, (ctxt, next) =>
{
ctxt.Instance = GetInstance();
next(ctxt);
});
}

/// <summary>
/// Gets or sets a value indicating whether the activator disposes the instance that it holds.
/// Necessary because otherwise instances that are never resolved will never be
Expand All @@ -97,8 +90,10 @@ protected override void Dispose(bool disposing)
// Only dispose of the instance here if it wasn't activated. If it was activated,
// then either the owning lifetime scope will dispose of it automatically
// (see InstanceLookup.Activate) or an OnRelease handler will take care of it.
if (disposing && DisposeInstance && _instance is IDisposable && !_activated)
((IDisposable)_instance).Dispose();
if (disposing && DisposeInstance && _instance is IDisposable disposable && !_activated)
{
disposable.Dispose();
}

base.Dispose(disposing);
}
Expand Down
16 changes: 8 additions & 8 deletions src/Autofac/Core/Activators/Reflection/ReflectionActivator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public class ReflectionActivator : InstanceActivator, IInstanceActivator
private readonly Parameter[] _configuredProperties;
private readonly Parameter[] _defaultParameters;
private ConstructorInfo[]? _availableConstructors;
private readonly object _availableConstructorsLock = new object();

/// <summary>
/// Initializes a new instance of the <see cref="ReflectionActivator"/> class.
Expand Down Expand Up @@ -85,18 +84,19 @@ public class ReflectionActivator : InstanceActivator, IInstanceActivator
/// </summary>
public IConstructorSelector ConstructorSelector { get; }

/// <inheritdoc/>
public void ConfigurePipeline(IComponentRegistryServices componentRegistryServices, IResolvePipelineBuilder pipelineBuilder)
{
// Lazy instantiate available constructor list so the constructor
// finder can be changed during AsSelf() registration. AsSelf() creates
// a temporary activator just long enough to get the LimitType.
if (_availableConstructors == null)
{
_availableConstructors = ConstructorFinder.FindConstructors(_implementationType);
}
if (componentRegistryServices is null) throw new ArgumentNullException(nameof(componentRegistryServices));
if (pipelineBuilder is null) throw new ArgumentNullException(nameof(pipelineBuilder));

// Locate the possible constructors at container build time.
_availableConstructors = ConstructorFinder.FindConstructors(_implementationType);

if (_availableConstructors.Length == 0)
{
throw new NoConstructorsFoundException(_implementationType, string.Format(CultureInfo.CurrentCulture, ReflectionActivatorResources.NoConstructorsAvailable, _implementationType, ConstructorFinder));
}

pipelineBuilder.Use(this.ToString(), PipelinePhase.Activation, MiddlewareInsertionMode.EndOfPhase, (ctxt, next) =>
{
Expand Down
10 changes: 5 additions & 5 deletions src/Autofac/Core/Container.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@
// OTHER DEALINGS IN THE SOFTWARE.

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading.Tasks;
using Autofac.Core.Diagnostics;
using Autofac.Core.Lifetime;
using Autofac.Core.Registration;
using Autofac.Core.Resolving;
using Autofac.Util;

Expand Down Expand Up @@ -101,9 +99,10 @@ public ILifetimeScope BeginLifetimeScope(object tag, Action<ContainerBuilder> co
return _rootLifetimeScope.BeginLifetimeScope(tag, configurationAction);
}

public void TraceWith(IResolvePipelineTracer tracer)
/// <inheritdoc/>
public void AttachTrace(IResolvePipelineTracer tracer)
{
_rootLifetimeScope.TraceWith(tracer);
_rootLifetimeScope.AttachTrace(tracer);
}

/// <summary>
Expand Down Expand Up @@ -172,11 +171,12 @@ protected override void Dispose(bool disposing)
base.Dispose(disposing);
}

/// <inheritdoc/>
protected override async ValueTask DisposeAsync(bool disposing)
{
if (disposing)
{
await _rootLifetimeScope.DisposeAsync();
await _rootLifetimeScope.DisposeAsync().ConfigureAwait(false);

// Registries are not likely to have async tasks to dispose of,
// so we will leave it as a straight dispose.
Expand Down
Loading

0 comments on commit e76a8d3

Please sign in to comment.