Skip to content
Permalink
Browse files

Merge branch 'master' of https://github.com/simpleinjector/SimpleInje…

…ctor into v4.5.x

# Conflicts:
#	src/SimpleInjector/Internals/CompilationHelpers.cs
#	src/SimpleInjector/Internals/TypeConstraintValidator.cs
  • Loading branch information...
dotnetjunkie committed Apr 1, 2019
2 parents d874da1 + a92d18e commit 7bf2063808e41e6e0e7c269e73d7745c62dc5dc0
Showing with 1,980 additions and 1,684 deletions.
  1. +2 −1 .github/ISSUE_TEMPLATE/bug_report.md
  2. +1 −0 .github/ISSUE_TEMPLATE/question-and-feature-request.md
  3. +7 −17 src/Settings.StyleCop
  4. +15 −0 src/SimpleInjector.CodeSamples.Tests.Unit/Settings.StyleCop
  5. +5 −2 src/SimpleInjector.CodeSamples/ContextualDecoratorExtensions.cs
  6. +15 −0 src/SimpleInjector.CodeSamples/Settings.StyleCop
  7. +4 −2 src/SimpleInjector.Integration.AspNetCore.Mvc/SimpleInjectorTagHelperActivator.cs
  8. +6 −4 src/SimpleInjector.Integration.Wcf/SimpleInjectorServiceBehavior.cs
  9. +4 −4 src/SimpleInjector.Integration.Wcf/SimpleInjectorServiceHost.cs
  10. +2 −2 src/SimpleInjector.Integration.Wcf/SimpleInjectorWcfExtensions.Obsolete.cs
  11. +10 −5 src/SimpleInjector.Integration.Wcf/SimpleInjectorWcfExtensions.cs
  12. +7 −2 src/SimpleInjector.Integration.Web.Mvc/SimpleInjectorMvcExtensions.cs
  13. +33 −3 src/SimpleInjector.Integration.Web.Tests.Unit/Settings.StyleCop
  14. +3 −3 src/SimpleInjector.Integration.Web/SimpleInjectorWebExtensions.cs
  15. +2 −2 src/SimpleInjector.Integration.WebApi/SimpleInjectorWebApiDependencyResolver.cs
  16. +2 −2 src/SimpleInjector.Integration.WebApi/SimpleInjectorWebApiExtensions.Obsolete.cs
  17. +15 −13 src/SimpleInjector.Integration.WebApi/SimpleInjectorWebApiExtensions.cs
  18. +11 −5 src/SimpleInjector.Packaging/PackageExtensions.cs
  19. +1 −1 src/SimpleInjector.Tests.Unit/AddRegistrationTests.cs
  20. +1 −1 src/SimpleInjector.Tests.Unit/Advanced/AdvancedExtensionsTests.cs
  21. +1 −1 src/SimpleInjector.Tests.Unit/ContainerCollectionAppendToTests.cs
  22. +1 −1 src/SimpleInjector.Tests.Unit/DecoratorCollectionTests.cs
  23. +2 −2 src/SimpleInjector.Tests.Unit/DecoratorTests.cs
  24. +2 −2 src/SimpleInjector.Tests.Unit/Diagnostics/LifestyleMismatchServicesTests.cs
  25. +2 −2 src/SimpleInjector.Tests.Unit/Diagnostics/ShortCircuitContainerAnalyzerTests.cs
  26. +2 −2 src/SimpleInjector.Tests.Unit/RegisterBatchTests.cs
  27. +10 −10 src/SimpleInjector.Tests.Unit/RegisterConditionalTests.cs
  28. +2 −2 src/SimpleInjector.Tests.Unit/RegisterOpenGenericTests.cs
  29. +15 −0 src/SimpleInjector.Tests.Unit/Settings.StyleCop
  30. +6 −5 src/SimpleInjector/Advanced/AdvancedExtensions.cs
  31. +5 −5 src/SimpleInjector/Advanced/BehaviorDeprecationExtensions.cs
  32. +1 −1 src/SimpleInjector/Advanced/DefaultConstructorResolutionBehavior.cs
  33. +3 −2 src/SimpleInjector/Advanced/DefaultDependencyInjectionBehavior.cs
  34. +1 −3 src/SimpleInjector/Advanced/DefaultLifestyleSelectionBehavior.cs
  35. +2 −2 src/SimpleInjector/Advanced/DefaultPropertySelectionBehavior.cs
  36. +3 −2 src/SimpleInjector/Advanced/InitializationContext.cs
  37. +1 −1 src/SimpleInjector/Advanced/InitializerContext.cs
  38. +7 −8 src/SimpleInjector/Advanced/InstanceInitializationData.cs
  39. +2 −1 src/SimpleInjector/Advanced/Internal/LazyScope.cs
  40. +4 −2 src/SimpleInjector/Advanced/Internal/LazyScopedRegistration.cs
  41. +9 −5 src/SimpleInjector/Advanced/KnownRelationship.cs
  42. +3 −1 src/SimpleInjector/Advanced/PropertyInjectionHelper.cs
  43. +58 −75 src/SimpleInjector/Container.Common.cs
  44. +72 −31 src/SimpleInjector/Container.Registration.Batch.cs
  45. +52 −51 src/SimpleInjector/Container.Registration.CollectionRegistrator.cs
  46. +19 −15 src/SimpleInjector/Container.Registration.Collections.cs
  47. +22 −12 src/SimpleInjector/Container.Registration.Conditional.cs
  48. +24 −11 src/SimpleInjector/Container.Registration.Decorators.cs
  49. +63 −37 src/SimpleInjector/Container.Registration.cs
  50. +56 −57 src/SimpleInjector/Container.Resolving.cs
  51. +2 −3 src/SimpleInjector/Container.Verification.cs
  52. +5 −5 src/SimpleInjector/ContainerOptions.cs
  53. +1 −1 src/SimpleInjector/DecoratorContext.cs
  54. +17 −10 src/SimpleInjector/DecoratorPredicateContext.cs
  55. +9 −8 src/SimpleInjector/Decorators/CompositeHelpers.cs
  56. +23 −19 src/SimpleInjector/Decorators/ContainerUncontrolledServicesDecoratorInterceptor.cs
  57. +31 −29 src/SimpleInjector/Decorators/DecoratorExpressionInterceptor.cs
  58. +6 −2 src/SimpleInjector/Decorators/DecoratorExpressionInterceptorData.cs
  59. +19 −16 src/SimpleInjector/Decorators/DecoratorHelpers.cs
  60. +12 −11 src/SimpleInjector/Decorators/DecoratorInterceptor.cs
  61. +8 −8 src/SimpleInjector/Decorators/ServiceDecoratorExpressionInterceptor.cs
  62. +13 −9 src/SimpleInjector/Decorators/ServiceTypeDecoratorInfo.cs
  63. +3 −8 src/SimpleInjector/DiagnosticVerificationException.cs
  64. +25 −16 src/SimpleInjector/Diagnostics/AmbiguousLifestylesDiagnosticResult.cs
  65. +22 −15 src/SimpleInjector/Diagnostics/Analyzers/AmbiguousLifestylesAnalyzer.cs
  66. +19 −33 src/SimpleInjector/Diagnostics/Analyzers/ContainerRegisteredServiceAnalyzer.cs
  67. +8 −17 src/SimpleInjector/Diagnostics/Analyzers/DisposableTransientComponentAnalyzer.cs
  68. +6 −12 src/SimpleInjector/Diagnostics/Analyzers/LifestyleMismatchAnalyzer.cs
  69. +19 −23 src/SimpleInjector/Diagnostics/Analyzers/ShortCircuitedDependencyAnalyzer.cs
  70. +3 −14 src/SimpleInjector/Diagnostics/Analyzers/SingleResponsibilityViolationsAnalyzer.cs
  71. +17 −13 src/SimpleInjector/Diagnostics/Analyzers/TornLifestyleContainerAnalyzer.cs
  72. +8 −8 src/SimpleInjector/Diagnostics/ContainerAnalyzerProvider.cs
  73. +9 −5 src/SimpleInjector/Diagnostics/ContainerRegisteredServiceDiagnosticResult.cs
  74. +14 −15 src/SimpleInjector/Diagnostics/Debugger/ContainerDebugView.cs
  75. +3 −3 src/SimpleInjector/Diagnostics/Debugger/DebuggerGeneralWarningsContainerAnalyzer.cs
  76. +3 −2 src/SimpleInjector/Diagnostics/Debugger/DebuggerViewItem.cs
  77. +8 −3 src/SimpleInjector/Diagnostics/DiagnosticGroup.cs
  78. +13 −9 src/SimpleInjector/Diagnostics/DiagnosticResult.cs
  79. +6 −7 src/SimpleInjector/Diagnostics/DiagnosticResultGrouper.cs
  80. +9 −5 src/SimpleInjector/Diagnostics/DisposableTransientComponentDiagnosticResult.cs
  81. +1 −1 src/SimpleInjector/Diagnostics/IContainerAnalyzer.cs
  82. +2 −2 src/SimpleInjector/Diagnostics/LifestyleMismatchChecker.cs
  83. +9 −6 src/SimpleInjector/Diagnostics/LifestyleMismatchDiagnosticResult.cs
  84. +20 −14 src/SimpleInjector/Diagnostics/ShortCircuitedDependencyDiagnosticResult.cs
  85. +12 −5 src/SimpleInjector/Diagnostics/SingleResponsibilityViolationDiagnosticResult.cs
  86. +23 −14 src/SimpleInjector/Diagnostics/TornLifestyleDiagnosticResult.cs
  87. +3 −3 src/SimpleInjector/Diagnostics/TypeGeneralizer.cs
  88. +4 −3 src/SimpleInjector/ExpressionBuildingEventArgs.cs
  89. +1 −1 src/SimpleInjector/ExpressionBuiltEventArgs.cs
  90. +28 −31 src/SimpleInjector/Helpers.cs
  91. +41 −33 src/SimpleInjector/InstanceProducer.cs
  92. +8 −8 src/SimpleInjector/Internals/ArgumentMapping.cs
  93. +7 −8 src/SimpleInjector/Internals/CollectionResolver.cs
  94. +61 −48 src/SimpleInjector/Internals/CompilationHelpers.cs
  95. +3 −7 src/SimpleInjector/Internals/ConditionalHashSet.cs
  96. +13 −15 src/SimpleInjector/Internals/ConstantArrayIndexizerVisitor.cs
  97. +0 −1 src/SimpleInjector/Internals/ConstantFinderVisitor.cs
  98. +21 −31 src/SimpleInjector/Internals/ContainerControlledCollection.cs
  99. +2 −2 src/SimpleInjector/Internals/ContainerControlledCollectionResolver.cs
  100. +3 −1 src/SimpleInjector/Internals/ContainerControlledItem.cs
  101. +4 −5 src/SimpleInjector/Internals/ContainerUncontrolledCollectionResolver.cs
  102. +3 −5 src/SimpleInjector/Internals/ControlledCollectionHelper.cs
  103. +5 −2 src/SimpleInjector/Internals/CyclicDependencyException.cs
  104. +1 −5 src/SimpleInjector/Internals/CyclicDependencyValidator.cs
  105. +5 −3 src/SimpleInjector/Internals/GenericArgumentFinder.cs
  106. +48 −42 src/SimpleInjector/Internals/GenericRegistrationEntry.cs
  107. +14 −12 src/SimpleInjector/Internals/GenericTypeBuilder.cs
  108. +9 −3 src/SimpleInjector/Internals/IRegistrationEntry.cs
  109. +26 −12 src/SimpleInjector/Internals/InstanceProducerVisualizer.cs
  110. +2 −2 src/SimpleInjector/Internals/InternalsFinderVisitor.cs
  111. +52 −25 src/SimpleInjector/Internals/NonGenericRegistrationEntry.cs
  112. +2 −2 src/SimpleInjector/Internals/{ObjectGraphBuilder.cs → ObjectGraphStringBuilder.cs}
  113. +1 −1 src/SimpleInjector/Internals/ParameterDictionary.cs
  114. +0 −1 src/SimpleInjector/Internals/RegistrationEntry.cs
  115. +2 −7 src/SimpleInjector/Internals/SubExpressionReplacer.cs
  116. +2 −2 src/SimpleInjector/Internals/TypeConstraintValidator.cs
  117. +30 −25 src/SimpleInjector/Lifestyle.cs
  118. +13 −13 src/SimpleInjector/Lifestyles/CustomLifestyle.cs
  119. +4 −2 src/SimpleInjector/Lifestyles/DefaultFallbackScopedHybridLifestyle.cs
  120. +12 −31 src/SimpleInjector/Lifestyles/ExpressionRegistration.cs
  121. +19 −14 src/SimpleInjector/Lifestyles/HybridLifestyle.cs
  122. +8 −4 src/SimpleInjector/Lifestyles/HybridRegistration.cs
  123. +8 −18 src/SimpleInjector/Lifestyles/LifestyleSelectionBehaviorProxyLifestyle.cs
  124. +3 −1 src/SimpleInjector/Lifestyles/LifestyleSelectorScopedHybridLifestyle.cs
  125. +1 −1 src/SimpleInjector/Lifestyles/ScopeManager.cs
  126. +7 −8 src/SimpleInjector/Lifestyles/ScopedProxyLifestyle.cs
  127. +12 −19 src/SimpleInjector/Lifestyles/ScopedRegistration.cs
  128. +8 −10 src/SimpleInjector/Lifestyles/ScopedScopeLifestyle.cs
  129. +25 −24 src/SimpleInjector/Lifestyles/SingletonLifestyle.cs
  130. +2 −2 src/SimpleInjector/Lifestyles/ThreadScopedLifestyle.cs
  131. +4 −4 src/SimpleInjector/Lifestyles/TransientLifestyle.cs
  132. +5 −11 src/SimpleInjector/Lifestyles/UnknownLifestyle.cs
  133. +23 −23 src/SimpleInjector/PredicateContext.cs
  134. +11 −7 src/SimpleInjector/Registration.cs
  135. +78 −68 src/SimpleInjector/Requires.cs
  136. +8 −13 src/SimpleInjector/Scope.cs
  137. +3 −6 src/SimpleInjector/ScopedLifestyle.cs
  138. +285 −241 src/SimpleInjector/StringResources.cs
  139. +7 −4 src/SimpleInjector/TypeFactoryContext.cs
  140. +17 −15 src/SimpleInjector/Types.cs
  141. +2 −2 src/SimpleInjector/TypesExtensions.cs
  142. +10 −8 src/SimpleInjector/UnregisteredTypeEventArgs.cs
@@ -25,6 +25,7 @@ Add any other context about the problem here. e.g.:
* .NET version
*Used libraries or frameworks (with version) that are required
**Tip**
**Important**
* Do *not* include screen shots of [code](https://idownvotedbecau.se/imageofcode) or [exceptions](https://idownvotedbecau.se/imageofanexception/).
* Do ensure that code listing don't have a line width that exceeds 100 characters, as that would cause horizontal scrollbars, which make it harder to view the code.
* Follow the guidelines given by Stack Overflow and [IDownvotedBecau.se](https://idownvotedbecau.se/).
@@ -14,6 +14,7 @@ Describe your problem, question, or feature in a clear and concise way. Please m
* Show a **simplified, but realistic, representation of your application**. We are not interested to see a large amount of source code, but DI-related questions are typically design questions and it is impossible to feedback on your design when you reduce your interfaces and classes to e.g. `IFoo`, `Flux` and `Baz`.
* Include **complete stack trace including all exception details** of the exception and all inner exceptions in case an exception is thrown.
* Do **not include screen shots** of [code](https://idownvotedbecau.se/imageofcode), but provide actual code
* Do ensure that code listing don't have a **line width that exceeds 100 characters**, as that would cause horizontal scrollbars, which make it harder to view the code.
* Do not include screen shots of [exceptions](https://idownvotedbecau.se/imageofanexception/), but paste the actual exception details
* Make sure that code and exception details are [formatted correctly](https://help.github.com/en/articles/creating-and-highlighting-code-blocks) and ideally include the programming language (typically `c#`). This way GitHub will highlight the code automatically.
* Follow the guidelines given by Stack Overflow and [IDownvotedBecau.se](https://idownvotedbecau.se/) about asking good questions.
@@ -1,4 +1,4 @@
<StyleCopSettings Version="4.3">
<StyleCopSettings Version="105">
<GlobalSettings>
<StringProperty Name="MergeSettingsFiles">NoMerge</StringProperty>
</GlobalSettings>
@@ -17,15 +17,15 @@
</Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
<Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.NamingRules">
</Analyzer>
<Analyzer AnalyzerId="StyleCop.CSharp.NamingRules">
<AnalyzerSettings>
<CollectionProperty Name="Hungarian">
<Value>is</Value>
</CollectionProperty>
</AnalyzerSettings>
</Analyzer>
<Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.DocumentationRules">
</Analyzer>
<Analyzer AnalyzerId="StyleCop.CSharp.DocumentationRules">
<Rules>
<Rule Name="ElementDocumentationMustBeSpelledCorrectly">
<RuleSettings>
@@ -73,23 +73,13 @@
<BooleanProperty Name="IgnoreInternals">True</BooleanProperty>
</AnalyzerSettings>
</Analyzer>
<Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.ReadabilityRules">
<Analyzer AnalyzerId="StyleCop.CSharp.ReadabilityRules">
<Rules>
<Rule Name="ParameterMustFollowComma">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="SplitParametersMustStartOnLineAfterDeclaration">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ParametersMustBeOnSameLineOrSeparateLines">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ParameterMustNotSpanMultipleLines">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
@@ -98,7 +88,7 @@
</Rules>
<AnalyzerSettings />
</Analyzer>
<Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.OrderingRules">
<Analyzer AnalyzerId="StyleCop.CSharp.OrderingRules">
<Rules>
<Rule Name="StaticElementsMustAppearBeforeInstanceElements">
<RuleSettings>
@@ -35,5 +35,20 @@
</Rules>
<AnalyzerSettings />
</Analyzer>
<Analyzer AnalyzerId="StyleCop.CSharp.ReadabilityRules">
<Rules>
<Rule Name="ParameterMustFollowComma">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ParametersMustBeOnSameLineOrSeparateLines">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
</Analyzers>
</StyleCopSettings>
@@ -23,8 +23,11 @@ public static void EnableContextualDecoratorSupport(this ContainerOptions option
}
}

public static void RegisterContextualDecorator(this Container container, Type serviceType,
Type decoratorType, Predicate<InjectionTargetInfo> contextualPredicate)
public static void RegisterContextualDecorator(
this Container container,
Type serviceType,
Type decoratorType,
Predicate<InjectionTargetInfo> contextualPredicate)
{
var predicates = GetContextualPredicates(container);

@@ -200,5 +200,20 @@
</Rules>
<AnalyzerSettings />
</Analyzer>
<Analyzer AnalyzerId="StyleCop.CSharp.ReadabilityRules">
<Rules>
<Rule Name="ParameterMustFollowComma">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ParametersMustBeOnSameLineOrSeparateLines">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
</Analyzers>
</StyleCopSettings>
@@ -40,7 +40,7 @@ public class SimpleInjectorTagHelperActivator : ITagHelperActivator
/// <param name="container">The container instance.</param>
[Obsolete("This constructor is deprecated. Please use the other constructor overload or use the " +
"SimpleInjectorAspNetCoreMvcIntegrationExtensions.AddSimpleInjectorTagHelperActivation " +
"extension method instead.",
"extension method instead.",
error: false)]
public SimpleInjectorTagHelperActivator(Container container)
{
@@ -60,7 +60,9 @@ public SimpleInjectorTagHelperActivator(Container container)
/// by the supplied <paramref name="container"/> (when the predicate returns true) or using the
/// supplied <paramref name="frameworkTagHelperActivator"/> (when the predicate returns false).</param>
/// <param name="frameworkTagHelperActivator">The framework's tag helper activator.</param>
public SimpleInjectorTagHelperActivator(Container container, Predicate<Type> tagHelperSelector,
public SimpleInjectorTagHelperActivator(
Container container,
Predicate<Type> tagHelperSelector,
ITagHelperActivator frameworkTagHelperActivator)
{
if (container == null)
@@ -36,7 +36,7 @@ namespace SimpleInjector.Integration.Wcf
/// </summary>
public class SimpleInjectorServiceBehavior : IServiceBehavior
{
private readonly Container container;
private readonly Container container;

/// <summary>Initializes a new instance of the <see cref="SimpleInjectorServiceBehavior"/> class.</summary>
/// <param name="container">The container instance.</param>
@@ -58,8 +58,10 @@ public SimpleInjectorServiceBehavior(Container container)
/// <param name="serviceHostBase">The host of the service.</param>
/// <param name="endpoints">The service endpoints.</param>
/// <param name="bindingParameters">Custom objects to which binding elements have access.</param>
public void AddBindingParameters(ServiceDescription serviceDescription,
ServiceHostBase serviceHostBase, Collection<ServiceEndpoint> endpoints,
public void AddBindingParameters(
ServiceDescription serviceDescription,
ServiceHostBase serviceHostBase,
Collection<ServiceEndpoint> endpoints,
BindingParameterCollection bindingParameters)
{
}
@@ -77,7 +79,7 @@ public SimpleInjectorServiceBehavior(Container container)
Requires.IsNotNull(serviceDescription, nameof(serviceDescription));
Requires.IsNotNull(serviceHostBase, nameof(serviceHostBase));

var instanceProvider = new SimpleInjectorInstanceProvider(this.container,
var instanceProvider = new SimpleInjectorInstanceProvider(this.container,
this.ServiceType ?? serviceDescription.ServiceType);

var endpointDispatchers =
@@ -61,8 +61,8 @@ public SimpleInjectorServiceHost(Container container, Type serviceType, params U
/// <param name="baseAddresses">The base addresses.</param>
/// <exception cref="ArgumentNullException">Thrown when <paramref name="container"/> is a null
/// reference or <paramref name="singletonInstance"/> is a null reference.</exception>
public SimpleInjectorServiceHost(Container container, object singletonInstance,
params Uri[] baseAddresses)
public SimpleInjectorServiceHost(
Container container, object singletonInstance, params Uri[] baseAddresses)
: base(singletonInstance, baseAddresses)
{
Requires.IsNotNull(container, nameof(container));
@@ -71,8 +71,8 @@ public SimpleInjectorServiceHost(Container container, Type serviceType, params U
this.container = container;
}

internal SimpleInjectorServiceHost(Container container, Type serviceAbstraction, Type implementationType,
params Uri[] baseAddresses)
internal SimpleInjectorServiceHost(
Container container, Type serviceAbstraction, Type implementationType, params Uri[] baseAddresses)
: base(implementationType, baseAddresses)
{
Requires.IsNotNull(container, nameof(container));
@@ -142,8 +142,8 @@ public static void RegisterPerWcfOperation<TConcrete>(this Container container)
/// <typeparamref name="TService"/> has already been registered.</exception>
[Obsolete("RegisterPerWcfOperation has been deprecated. ", error: true)]
[EditorBrowsable(EditorBrowsableState.Never)]
public static void RegisterPerWcfOperation<TService>(this Container container,
Func<TService> instanceCreator, bool disposeWhenRequestEnds)
public static void RegisterPerWcfOperation<TService>(
this Container container, Func<TService> instanceCreator, bool disposeWhenRequestEnds)
where TService : class
{
throw new NotSupportedException("RegisterPerWcfOperation has been deprecated.");
@@ -70,14 +70,14 @@ where IsWcfServiceType(type)

foreach (Type serviceType in serviceTypes)
{
Lifestyle lifestyle =
Lifestyle lifestyle =
GetAppropriateLifestyle(serviceType, container.Options.LifestyleSelectionBehavior);

container.Register(serviceType, serviceType, lifestyle);
}
}

internal static ServiceBehaviorAttribute GetServiceBehaviorAttribute(this Type type) =>
internal static ServiceBehaviorAttribute GetServiceBehaviorAttribute(this Type type) =>
type.GetCustomAttributes(typeof(ServiceBehaviorAttribute), true)
.OfType<ServiceBehaviorAttribute>()
.FirstOrDefault();
@@ -122,7 +122,7 @@ private static bool HasInvalidConcurrencyMode(Type wcfServiceType)
return attribute != null && attribute.ConcurrencyMode == ConcurrencyMode.Multiple;
}

private static Lifestyle GetAppropriateLifestyle(Type wcfServiceType,
private static Lifestyle GetAppropriateLifestyle(Type wcfServiceType,
ILifestyleSelectionBehavior behavior)
{
var attribute = GetServiceBehaviorAttribute(wcfServiceType);
@@ -152,8 +152,13 @@ private static IEnumerable<Type> GetExportedTypes(Assembly assembly)
catch (Exception ex)
{
// Throw a more descriptive message containing the name of the assembly.
throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture,
"Unable to load types from assembly {0}. {1}", assembly.FullName, ex.Message), ex);
throw new InvalidOperationException(
string.Format(
CultureInfo.InvariantCulture,
"Unable to load types from assembly {0}. {1}",
assembly.FullName,
ex.Message),
ex);
}
}
}
@@ -182,8 +182,13 @@ private static IEnumerable<Type> GetExportedTypes(Assembly assembly)
catch (Exception ex)
{
// Throw a more descriptive message containing the name of the assembly.
throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture,
"Unable to load types from assembly {0}. {1}", assembly.FullName, ex.Message), ex);
throw new InvalidOperationException(
string.Format(
CultureInfo.InvariantCulture,
"Unable to load types from assembly {0}. {1}",
assembly.FullName,
ex.Message),
ex);
}
}
}
@@ -1,6 +1,6 @@
<StyleCopSettings Version="4.3">
<StyleCopSettings Version="105">
<Analyzers>
<Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.DocumentationRules">
<Analyzer AnalyzerId="StyleCop.CSharp.DocumentationRules">
<Rules>
<Rule Name="ElementsMustBeDocumented">
<RuleSettings>
@@ -10,13 +10,43 @@
</Rules>
<AnalyzerSettings />
</Analyzer>
<Analyzer AnalyzerId="Microsoft.StyleCop.CSharp.MaintainabilityRules">
<Analyzer AnalyzerId="StyleCop.CSharp.MaintainabilityRules">
<Rules>
<Rule Name="FileMayOnlyContainASingleClass">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="FieldsMustBePrivate">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
<Analyzer AnalyzerId="StyleCop.CSharp.OrderingRules">
<Rules>
<Rule Name="ElementsMustAppearInTheCorrectOrder">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
<Analyzer AnalyzerId="StyleCop.CSharp.ReadabilityRules">
<Rules>
<Rule Name="ParameterMustFollowComma">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ParametersMustBeOnSameLineOrSeparateLines">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
@@ -26,7 +26,6 @@ namespace SimpleInjector
{
using System;
using System.ComponentModel;
using SimpleInjector.Integration.Web;

/// <summary>
/// Extension methods for integrating Simple Injector with ASP.NET web applications.
@@ -150,8 +149,9 @@ public static void RegisterPerWebRequest<TConcrete>(this Container container)
"Please use Register<TService>(new WebRequestLifestyle(false)) instead to suppress disposal.",
error: true)]
[EditorBrowsable(EditorBrowsableState.Never)]
public static void RegisterPerWebRequest<TService>(this Container container,
Func<TService> instanceCreator, bool disposeInstanceWhenWebRequestEnds) where TService : class
public static void RegisterPerWebRequest<TService>(
this Container container, Func<TService> instanceCreator, bool disposeInstanceWhenWebRequestEnds)
where TService : class
{
throw new NotSupportedException(
"RegisterPerWebRequest has been deprecated. " +
@@ -129,8 +129,8 @@ public SimpleInjectorWebApiDependencyResolver(Container container)
if (scopeOption < DependencyResolverScopeOption.UseAmbientScope ||
scopeOption > DependencyResolverScopeOption.RequiresNew)
{
throw new System.ComponentModel.InvalidEnumArgumentException("scopeOption", (int)scopeOption,
typeof(DependencyResolverScopeOption));
throw new System.ComponentModel.InvalidEnumArgumentException(
"scopeOption", (int)scopeOption, typeof(DependencyResolverScopeOption));
}

this.scopeOption = scopeOption;
@@ -212,8 +212,8 @@ public static void RegisterWebApiRequest<TConcrete>(this Container container)
"to suppress disposal.",
error: true)]
[EditorBrowsable(EditorBrowsableState.Never)]
public static void RegisterWebApiRequest<TService>(this Container container,
Func<TService> instanceCreator, bool disposeWhenScopeEnds)
public static void RegisterWebApiRequest<TService>(
this Container container, Func<TService> instanceCreator, bool disposeWhenScopeEnds)
where TService : class
{
throw new NotSupportedException(
Oops, something went wrong.

0 comments on commit 7bf2063

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