From d52f0a9d587691bd96412b9f33cd6176ba3aaaf0 Mon Sep 17 00:00:00 2001 From: Andrew Davey Date: Fri, 4 May 2012 16:52:49 +0100 Subject: [PATCH 1/7] Fix parameter name in doc comment. --- src/TinyIoC/TinyIoC.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/TinyIoC/TinyIoC.cs b/src/TinyIoC/TinyIoC.cs index 3903ded..b1e0723 100644 --- a/src/TinyIoC/TinyIoC.cs +++ b/src/TinyIoC/TinyIoC.cs @@ -1668,7 +1668,7 @@ public bool CanResolve(string name, NamedParameterOverloads paramet /// /// Attemps to resolve a type using the default options /// - /// Type to resolve + /// Type to resolve /// Resolved type or default if resolve fails /// True if resolved sucessfully, false otherwise public bool TryResolve(Type resolveType, out object resolvedType) @@ -1688,7 +1688,7 @@ public bool TryResolve(Type resolveType, out object resolvedType) /// /// Attemps to resolve a type using the given options /// - /// Type to resolve + /// Type to resolve /// Resolution options /// Resolved type or default if resolve fails /// True if resolved sucessfully, false otherwise @@ -1709,7 +1709,7 @@ public bool TryResolve(Type resolveType, ResolveOptions options, out object reso /// /// Attemps to resolve a type using the default options and given name /// - /// Type to resolve + /// Type to resolve /// Name of registration /// Resolved type or default if resolve fails /// True if resolved sucessfully, false otherwise @@ -1730,7 +1730,7 @@ public bool TryResolve(Type resolveType, string name, out object resolvedType) /// /// Attemps to resolve a type using the given options and name /// - /// Type to resolve + /// Type to resolve /// Name of registration /// Resolution options /// Resolved type or default if resolve fails @@ -1752,7 +1752,7 @@ public bool TryResolve(Type resolveType, string name, ResolveOptions options, ou /// /// Attemps to resolve a type using the default options and supplied constructor parameters /// - /// Type to resolve + /// Type to resolve /// User specified constructor parameters /// Resolved type or default if resolve fails /// True if resolved sucessfully, false otherwise @@ -1773,7 +1773,7 @@ public bool TryResolve(Type resolveType, NamedParameterOverloads parameters, out /// /// Attemps to resolve a type using the default options and supplied name and constructor parameters /// - /// Type to resolve + /// Type to resolve /// Name of registration /// User specified constructor parameters /// Resolved type or default if resolve fails @@ -1795,7 +1795,7 @@ public bool TryResolve(Type resolveType, string name, NamedParameterOverloads pa /// /// Attemps to resolve a type using the supplied options and constructor parameters /// - /// Type to resolve + /// Type to resolve /// Name of registration /// User specified constructor parameters /// Resolution options @@ -1818,7 +1818,7 @@ public bool TryResolve(Type resolveType, NamedParameterOverloads parameters, Res /// /// Attemps to resolve a type using the supplied name, options and constructor parameters /// - /// Type to resolve + /// Type to resolve /// Name of registration /// User specified constructor parameters /// Resolution options @@ -2022,7 +2022,7 @@ public bool TryResolve(string name, NamedParameterOverloads paramet /// /// Returns all registrations of a type /// - /// Type to resolveAll + /// Type to resolveAll /// Whether to include un-named (default) registrations /// IEnumerable public IEnumerable ResolveAll(Type resolveType, bool includeUnnamed) @@ -2033,7 +2033,7 @@ public IEnumerable ResolveAll(Type resolveType, bool includeUnnamed) /// /// Returns all registrations of a type, both named and unnamed /// - /// Type to resolveAll + /// Type to resolveAll /// IEnumerable public IEnumerable ResolveAll(Type resolveType) { From 5d2970dd8f3690307e9eabefb1f07882de09f25d Mon Sep 17 00:00:00 2001 From: Andrew Davey Date: Fri, 4 May 2012 16:59:43 +0100 Subject: [PATCH 2/7] Fix doc comments --- src/TinyIoC/TinyIoC.cs | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/TinyIoC/TinyIoC.cs b/src/TinyIoC/TinyIoC.cs index b1e0723..1ae212e 100644 --- a/src/TinyIoC/TinyIoC.cs +++ b/src/TinyIoC/TinyIoC.cs @@ -589,7 +589,7 @@ public RegisterOptions(TinyIoCContainer container, TypeRegistration registration /// Make registration a singleton (single instance) if possible /// /// RegisterOptions - /// + /// public RegisterOptions AsSingleton() { var currentFactory = _Container.GetCurrentFactory(_Registration); @@ -604,7 +604,7 @@ public RegisterOptions AsSingleton() /// Make registration multi-instance if possible /// /// RegisterOptions - /// + /// public RegisterOptions AsMultiInstance() { var currentFactory = _Container.GetCurrentFactory(_Registration); @@ -619,7 +619,7 @@ public RegisterOptions AsMultiInstance() /// Make registration hold a weak reference if possible /// /// RegisterOptions - /// + /// public RegisterOptions WithWeakReference() { var currentFactory = _Container.GetCurrentFactory(_Registration); @@ -634,7 +634,7 @@ public RegisterOptions WithWeakReference() /// Make registration hold a strong reference if possible /// /// RegisterOptions - /// + /// public RegisterOptions WithStrongReference() { var currentFactory = _Container.GetCurrentFactory(_Registration); @@ -718,7 +718,7 @@ public MultiRegisterOptions(IEnumerable registerOptions) /// Make registration a singleton (single instance) if possible /// /// RegisterOptions - /// + /// public MultiRegisterOptions AsSingleton() { _RegisterOptions = ExecuteOnAllRegisterOptions(ro => ro.AsSingleton()); @@ -729,7 +729,7 @@ public MultiRegisterOptions AsSingleton() /// Make registration multi-instance if possible /// /// MultiRegisterOptions - /// + /// public MultiRegisterOptions AsMultiInstance() { _RegisterOptions = ExecuteOnAllRegisterOptions(ro => ro.AsMultiInstance()); @@ -990,7 +990,7 @@ public RegisterOptions Register(Type registerType, Func /// Creates/replaces a container class registration with default options. /// - /// Type to register + /// Type to register /// RegisterOptions for fluent API public RegisterOptions Register() where RegisterType : class @@ -1001,7 +1001,7 @@ public RegisterOptions Register() /// /// Creates/replaces a named container class registration with default options. /// - /// Type to register + /// Type to register /// Name of registration /// RegisterOptions for fluent API public RegisterOptions Register(string name) @@ -1421,7 +1421,6 @@ public ResolveType Resolve(string name, NamedParameterOverloads par /// Note: Resolution may still fail if user defined factory registations fail to construct objects when called. /// /// Type to resolve - /// Name of registration /// Bool indicating whether the type can be resolved public bool CanResolve(Type resolveType) { @@ -1434,6 +1433,7 @@ public bool CanResolve(Type resolveType) /// Note: Resolution may still fail if user defined factory registations fail to construct objects when called. /// /// Type to resolve + /// Name of registration /// Bool indicating whether the type can be resolved private bool CanResolve(Type resolveType, string name) { @@ -1446,7 +1446,6 @@ private bool CanResolve(Type resolveType, string name) /// Note: Resolution may still fail if user defined factory registations fail to construct objects when called. /// /// Type to resolve - /// Name of registration /// Resolution options /// Bool indicating whether the type can be resolved public bool CanResolve(Type resolveType, ResolveOptions options) @@ -1542,7 +1541,6 @@ public bool CanResolve(Type resolveType, string name, NamedParameterOverloads pa /// Note: Resolution may still fail if user defined factory registations fail to construct objects when called. /// /// Type to resolve - /// Name of registration /// Bool indicating whether the type can be resolved public bool CanResolve() where ResolveType : class @@ -1569,7 +1567,6 @@ public bool CanResolve(string name) /// Note: Resolution may still fail if user defined factory registations fail to construct objects when called. /// /// Type to resolve - /// Name of registration /// Resolution options /// Bool indicating whether the type can be resolved public bool CanResolve(ResolveOptions options) @@ -1796,7 +1793,6 @@ public bool TryResolve(Type resolveType, string name, NamedParameterOverloads pa /// Attemps to resolve a type using the supplied options and constructor parameters /// /// Type to resolve - /// Name of registration /// User specified constructor parameters /// Resolution options /// Resolved type or default if resolve fails @@ -1975,7 +1971,6 @@ public bool TryResolve(string name, NamedParameterOverloads paramet /// Attemps to resolve a type using the supplied options and constructor parameters /// /// Type to resolve - /// Name of registration /// User specified constructor parameters /// Resolution options /// Resolved type or default if resolve fails @@ -2056,7 +2051,6 @@ public IEnumerable ResolveAll(bool includeUnnamed) /// Returns all registrations of a type, both named and unnamed /// /// Type to resolveAll - /// Whether to include un-named (default) registrations /// IEnumerable public IEnumerable ResolveAll() where ResolveType : class From c8116148dced8850f8ac3a02c856232f18760323 Mon Sep 17 00:00:00 2001 From: Andrew Davey Date: Fri, 4 May 2012 17:00:36 +0100 Subject: [PATCH 3/7] Remove redundant namespace qualifier --- src/TinyIoC/TinyIoC.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TinyIoC/TinyIoC.cs b/src/TinyIoC/TinyIoC.cs index 1ae212e..9e6855c 100644 --- a/src/TinyIoC/TinyIoC.cs +++ b/src/TinyIoC/TinyIoC.cs @@ -186,7 +186,7 @@ static TypeExtensions() /// MethodInfo or null if no matches found /// /// - public static MethodInfo GetGenericMethod(this Type sourceType, System.Reflection.BindingFlags bindingFlags, string methodName, Type[] genericTypes, Type[] parameterTypes) + public static MethodInfo GetGenericMethod(this Type sourceType, BindingFlags bindingFlags, string methodName, Type[] genericTypes, Type[] parameterTypes) { MethodInfo method; var cacheKey = new GenericMethodCacheKey(sourceType, methodName, genericTypes, parameterTypes); From fa99ad1b4a235d340e0580df847158f49494e006 Mon Sep 17 00:00:00 2001 From: Andrew Davey Date: Fri, 4 May 2012 17:04:02 +0100 Subject: [PATCH 4/7] Report correct parameter name in exception. --- src/TinyIoC/TinyIoC.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TinyIoC/TinyIoC.cs b/src/TinyIoC/TinyIoC.cs index 9e6855c..99b7491 100644 --- a/src/TinyIoC/TinyIoC.cs +++ b/src/TinyIoC/TinyIoC.cs @@ -1150,7 +1150,7 @@ public MultiRegisterOptions RegisterMultiple(IEnumerable imp public MultiRegisterOptions RegisterMultiple(Type registrationType, IEnumerable implementationTypes) { if (implementationTypes == null) - throw new ArgumentNullException("types", "types is null."); + throw new ArgumentNullException("implementationTypes", "implementationTypes is null."); foreach (var type in implementationTypes) if (!registrationType.IsAssignableFrom(type)) From 503aba7aa4245fabbe775aade732d461041f366f Mon Sep 17 00:00:00 2001 From: Andrew Davey Date: Fri, 4 May 2012 17:05:08 +0100 Subject: [PATCH 5/7] Remove private method that is never called. --- src/TinyIoC/TinyIoC.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/TinyIoC/TinyIoC.cs b/src/TinyIoC/TinyIoC.cs index 99b7491..515580a 100644 --- a/src/TinyIoC/TinyIoC.cs +++ b/src/TinyIoC/TinyIoC.cs @@ -3231,11 +3231,6 @@ private IEnumerable GetTypeConstructors(Type type) return type.GetConstructors().OrderByDescending(ctor => ctor.GetParameters().Count()); } - private object ConstructType(Type requestedType, Type implementationType, ResolveOptions options) - { - return ConstructType(requestedType, implementationType, null, NamedParameterOverloads.Default, options); - } - private object ConstructType(Type requestedType, Type implementationType, ConstructorInfo constructor, ResolveOptions options) { return ConstructType(requestedType, implementationType, constructor, NamedParameterOverloads.Default, options); From edc04eaa9d6d3a9238b1fe1c6b6d9c3c64eb53db Mon Sep 17 00:00:00 2001 From: Andrew Davey Date: Fri, 4 May 2012 17:06:58 +0100 Subject: [PATCH 6/7] Fields used in GetHashCode should be readonly. --- src/TinyIoC/TinyIoC.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TinyIoC/TinyIoC.cs b/src/TinyIoC/TinyIoC.cs index 515580a..b681b2c 100644 --- a/src/TinyIoC/TinyIoC.cs +++ b/src/TinyIoC/TinyIoC.cs @@ -2697,7 +2697,7 @@ public static TinyIoCContainer Current #region Type Registrations public sealed class TypeRegistration { - private int _hashCode; + private readonly int _hashCode; public Type Type { get; private set; } public string Name { get; private set; } From 6b682acb02a4ded027eb085067929d0c190a8a77 Mon Sep 17 00:00:00 2001 From: Andrew Davey Date: Fri, 4 May 2012 17:08:29 +0100 Subject: [PATCH 7/7] Remove unused private method. --- src/TinyIoC/TinyIoC.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/TinyIoC/TinyIoC.cs b/src/TinyIoC/TinyIoC.cs index b681b2c..69bb4a7 100644 --- a/src/TinyIoC/TinyIoC.cs +++ b/src/TinyIoC/TinyIoC.cs @@ -2895,11 +2895,6 @@ private RegisterOptions AddUpdateRegistration(TypeRegistration typeRegistration, return new RegisterOptions(this, typeRegistration); } - private void RemoveRegistration(TypeRegistration typeRegistration) - { - _RegisteredTypes.Remove(typeRegistration); - } - private ObjectFactoryBase GetDefaultObjectFactory(Type registerType, Type registerImplementation) { if (registerType.IsInterface || registerType.IsAbstract)