diff --git a/src/Registration/ImplicitRegistration.cs b/src/Registration/ImplicitRegistration.cs index aade1547..39b994b1 100644 --- a/src/Registration/ImplicitRegistration.cs +++ b/src/Registration/ImplicitRegistration.cs @@ -20,7 +20,6 @@ namespace Unity.Registration #region Fields private int _refCount; - private ResolveDelegate? _pipeline; #endregion @@ -132,8 +131,6 @@ namespace Unity.Registration public bool BuildRequired => _registration.BuildRequired; - public Converter? Map => _registration.BuildType; - public LifetimeManager? LifetimeManager => null; public int RefCount => _registration._refCount; diff --git a/src/UnityContainer.Implementation.cs b/src/UnityContainer.Implementation.cs index b983c5c0..ce777830 100644 --- a/src/UnityContainer.Implementation.cs +++ b/src/UnityContainer.Implementation.cs @@ -141,14 +141,14 @@ namespace Unity throw new ArgumentException($"The type {typeTo} cannot be assigned to variables of type {typeFrom}."); #if NETSTANDARD1_0 || NETCOREAPP1_0 - if (null == typeFrom && null != typeTo && infoTo.IsInterface) + if (null == typeFrom && null != infoTo && infoTo.IsInterface) #else if (null == typeFrom && null != typeTo && typeTo.IsInterface) #endif throw new ArgumentException($"The type {typeTo} is an interface and can not be constructed."); #if NETSTANDARD1_0 || NETCOREAPP1_0 - if (null != typeFrom && null != typeTo && infoFrom.IsGenericType && infoTo.IsArray && infoFrom.GetGenericTypeDefinition() == typeof(IEnumerable<>)) + if (null != infoFrom && null != infoTo && infoFrom.IsGenericType && infoTo.IsArray && infoFrom.GetGenericTypeDefinition() == typeof(IEnumerable<>)) #else if (null != typeFrom && null != typeTo && typeFrom.IsGenericType && typeTo.IsArray && typeFrom.GetGenericTypeDefinition() == typeof(IEnumerable<>)) #endif diff --git a/src/UnityContainer.Resolution.cs b/src/UnityContainer.Resolution.cs index 94f6f5f0..f86a6b2a 100644 --- a/src/UnityContainer.Resolution.cs +++ b/src/UnityContainer.Resolution.cs @@ -111,7 +111,9 @@ namespace Unity continue; } +#pragma warning disable CS8601 // Possible null reference assignment. yield return (TElement)value; +#pragma warning restore CS8601 // Possible null reference assignment. } } } @@ -129,7 +131,9 @@ namespace Unity yield break; } +#pragma warning disable CS8601 // Possible null reference assignment. yield return (TElement)value; +#pragma warning restore CS8601 // Possible null reference assignment. } } @@ -171,7 +175,9 @@ namespace Unity continue; } +#pragma warning disable CS8601 // Possible null reference assignment. yield return (TElement)value; +#pragma warning restore CS8601 // Possible null reference assignment. } } @@ -195,7 +201,9 @@ namespace Unity catch (MakeGenericTypeFailedException) { continue; } catch (InvalidRegistrationException) { continue; } +#pragma warning disable CS8601 // Possible null reference assignment. yield return (TElement)value; +#pragma warning restore CS8601 // Possible null reference assignment. } } } @@ -214,7 +222,9 @@ namespace Unity yield break; } +#pragma warning disable CS8601 // Possible null reference assignment. yield return (TElement)value; +#pragma warning restore CS8601 // Possible null reference assignment. } } @@ -289,7 +299,9 @@ namespace Unity continue; } +#pragma warning disable CS8601 // Possible null reference assignment. yield return (TElement)value; +#pragma warning restore CS8601 // Possible null reference assignment. } } } @@ -335,7 +347,9 @@ namespace Unity continue; } +#pragma warning disable CS8601 // Possible null reference assignment. yield return (TElement)value; +#pragma warning restore CS8601 // Possible null reference assignment. } } } @@ -360,7 +374,9 @@ namespace Unity catch (MakeGenericTypeFailedException) { continue; } catch (InvalidRegistrationException) { continue; } +#pragma warning disable CS8601 // Possible null reference assignment. yield return (TElement)value; +#pragma warning restore CS8601 // Possible null reference assignment. } } } @@ -406,7 +422,9 @@ namespace Unity continue; } +#pragma warning disable CS8601 // Possible null reference assignment. yield return (TElement)value; +#pragma warning restore CS8601 // Possible null reference assignment. } } } @@ -453,7 +471,9 @@ namespace Unity continue; } +#pragma warning disable CS8601 // Possible null reference assignment. yield return (TElement)value; +#pragma warning restore CS8601 // Possible null reference assignment. } } } @@ -473,12 +493,16 @@ namespace Unity { var itemKey = new HashKey(typeof(TElement), registration.Name); var item = container.GetOrAdd(ref itemKey, typeof(TElement), registration.Name); +#pragma warning disable CS8601 // Possible null reference assignment. value = (TElement)resolve(typeof(TElement), item); +#pragma warning restore CS8601 // Possible null reference assignment. } catch (MakeGenericTypeFailedException) { continue; } catch (InvalidRegistrationException) { continue; } +#pragma warning disable CS8601 // Possible null reference assignment. yield return (TElement)value; +#pragma warning restore CS8601 // Possible null reference assignment. } } } diff --git a/src/Utility/ExtensionExtensions.cs b/src/Utility/ExtensionExtensions.cs index 99c7f203..42b1310d 100644 --- a/src/Utility/ExtensionExtensions.cs +++ b/src/Utility/ExtensionExtensions.cs @@ -63,7 +63,9 @@ namespace Unity public static TConfigurator Configure(this IUnityContainer container) where TConfigurator : IUnityContainerExtensionConfigurator { +#pragma warning disable CS8601 // Possible null reference assignment. return (TConfigurator)(container ?? throw new ArgumentNullException(nameof(container))).Configure(typeof(TConfigurator)); +#pragma warning restore CS8601 // Possible null reference assignment. } #endregion