Skip to content
Permalink
Browse files

StyleCop warnings fixed.

  • Loading branch information...
dotnetjunkie committed Mar 22, 2019
1 parent 28fd0cb commit 61766fffcfa6835c185e4e6f74451254822ebc0d
@@ -39,7 +39,7 @@ public class SimpleInjectorPageModelActivatorProvider : IPageModelActivatorProvi
private readonly Container container;

/// <summary>
/// Creates a <see cref="SimpleInjectorPageModelActivatorProvider"/>.
/// Initializes a new instance of the <see cref="SimpleInjectorPageModelActivatorProvider"/> class.
/// </summary>
/// <param name="container">The container instance that will be used to create page model instances.</param>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="container"/> is null.</exception>
@@ -35,6 +35,7 @@ namespace SimpleInjector.Advanced
public sealed class KnownRelationship : IEquatable<KnownRelationship>
{
// This constructor is here for backwards compatibility: the library itself uses the internal ctor.

/// <summary>Initializes a new instance of the <see cref="KnownRelationship"/> class.</summary>
/// <param name="implementationType">The implementation type of the parent type.</param>
/// <param name="lifestyle">The lifestyle of the parent type.</param>
@@ -71,11 +71,11 @@ internal bool SatisfiesPredicate()
registration.ReplaceRelationships(this.e.InstanceProducer.GetRelationships());

var info = this.GetServiceTypeInfo(
e,
this.e,
originalExpression: expression,
originalRegistration: registration,
registeredServiceType: registeredServiceType);
registeredServiceType: this.registeredServiceType);

this.Context = this.CreatePredicateContext(this.registeredServiceType, expression, info);

return this.SatisfiesPredicate(this.Context);
@@ -121,14 +121,6 @@ public Lifestyle Lifestyle
// memory in a 32bit process).
internal Decorators.ServiceTypeDecoratorInfo DecoratorInfo { get; set; }

// Cache for storing items for the lifetime of an ExpressionBuiltEventArgs instance. A single
// ExpressionBuiltEventArgs instance is passed along to all ExpressionBuilt handlers of a single
// InstanceProducer on a single thread. This means that each InstanceProducer gets its own instance and
// the same producer on a different thread (which might get built in parallel) gets a different instance
// as well.
// Null is returned when the key is not found.
// This dictionary is NOT thread-safe.

[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode",
Justification = "This method is called by the debugger.")]
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
@@ -29,35 +29,24 @@ namespace SimpleInjector.Internals
using System.Linq.Expressions;
using SimpleInjector.Advanced;

internal class ServiceCreatedListenerArgs
{
public ServiceCreatedListenerArgs(InstanceProducer producer)
{
this.Producer = producer;
}

public bool Handled { get; set; }
public InstanceProducer Producer { get; }
}

// This class allows an ContainerControlledCollection<T> to notify about the creation of its wrapped items.
// This is solely used for diagnostic verification.
internal static class ControlledCollectionHelper
{
internal static bool ContainsServiceCreatedListeners;

private static readonly object ServiceCreatedListenersLocker = new object();

// The boolean flag is an optimization, to prevent slowing down resolving of items inside a collection
// too much.
private static List<Action<ServiceCreatedListenerArgs>> ServiceCreatedListeners;
private static List<Action<ServiceCreatedListenerArgs>> serviceCreatedListeners;

internal static bool ContainsServiceCreatedListeners { get; private set; }

internal static void AddServiceCreatedListener(Action<ServiceCreatedListenerArgs> serviceCreated)
{
lock (ServiceCreatedListenersLocker)
{
var listeners =
ServiceCreatedListeners ?? (ServiceCreatedListeners = new List<Action<ServiceCreatedListenerArgs>>());
serviceCreatedListeners ?? (serviceCreatedListeners = new List<Action<ServiceCreatedListenerArgs>>());

listeners.Add(serviceCreated);

@@ -69,11 +58,11 @@ internal static void RemoveServiceCreatedListener(Action<ServiceCreatedListenerA
{
lock (ServiceCreatedListenersLocker)
{
ServiceCreatedListeners.Remove(serviceCreated);
serviceCreatedListeners.Remove(serviceCreated);

if (ServiceCreatedListeners.Count == 0)
if (serviceCreatedListeners.Count == 0)
{
ServiceCreatedListeners = null;
serviceCreatedListeners = null;

ContainsServiceCreatedListeners = false;
}
@@ -84,13 +73,13 @@ internal static void NotifyServiceCreatedListeners(InstanceProducer producer)
{
lock (ServiceCreatedListenersLocker)
{
if (ServiceCreatedListeners != null)
if (serviceCreatedListeners != null)
{
var args = new ServiceCreatedListenerArgs(producer);

// Iterate the list in reverse order, as the inner most listener should
// be able to act first.
foreach (var listener in Enumerable.Reverse(ServiceCreatedListeners))
foreach (var listener in Enumerable.Reverse(serviceCreatedListeners))
{
listener(args);
}
@@ -0,0 +1,35 @@
#region Copyright Simple Injector Contributors
/* The Simple Injector is an easy-to-use Inversion of Control library for .NET
*
* Copyright (c) 2019 Simple Injector Contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
* associated documentation files (the "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
* following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
* EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#endregion

namespace SimpleInjector.Internals
{
internal class ServiceCreatedListenerArgs
{
public ServiceCreatedListenerArgs(InstanceProducer producer)
{
this.Producer = producer;
}

public bool Handled { get; set; }
public InstanceProducer Producer { get; }
}
}
@@ -230,7 +230,7 @@ private TImplementation CreateInstanceWithNullCheck()

Func<TImplementation> func = CompileExpression(expression);

TImplementation instance = CreateInstance(func);
TImplementation instance = this.CreateInstance(func);

EnsureInstanceIsNotNull(instance);

@@ -253,7 +253,7 @@ private TImplementation CreateInstance(Func<TImplementation> instanceCreator)
if (isCurrentThread.Value)
{
args.Handled = true;
var matchingRelationship = FindMatchingCollectionRelationship(args.Producer);
var matchingRelationship = this.FindMatchingCollectionRelationship(args.Producer);

var additionalInformation = StringResources.CollectionUsedDuringConstruction(
typeof(TImplementation),

0 comments on commit 61766ff

Please sign in to comment.
You can’t perform that action at this time.