From 979cee9fb4803d81dc54b5e087be2ca9e45354d8 Mon Sep 17 00:00:00 2001 From: Bilal Fazlani Date: Wed, 10 Jan 2018 16:16:44 +0530 Subject: [PATCH] Bug fix in dependency detection --- CommandDotNet/AppInstanceCreator.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CommandDotNet/AppInstanceCreator.cs b/CommandDotNet/AppInstanceCreator.cs index 393510c2d..6305f2b8e 100644 --- a/CommandDotNet/AppInstanceCreator.cs +++ b/CommandDotNet/AppInstanceCreator.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; +using CommandDotNet.Attributes; using CommandDotNet.Models; namespace CommandDotNet @@ -17,7 +18,11 @@ public static object CreateInstance(Type type, IEnumerable constru object instance = Activator.CreateInstance(type, values); //detect properties - var properties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly); + var properties = type + .GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly) + .Where(p=> p.GetCustomAttribute() == null) + .ToList(); + if (properties.Any()) { if (dependencyResolver != null)