Open a764578566 opened 4 years ago
Would you mind submitting a fix and test for this via PR. Thanks for reporting this.
we want this Void. Ctor (System.Func '1[consoleapp5.person]) constructor ,Sort the constructor
private IEnumerable<ConstructorInfo> GetTypeConstructors(Type type)
{
//#if NETFX_CORE
// return type.GetTypeInfo().DeclaredConstructors.OrderByDescending(ctor => ctor.GetParameters().Count());
//#else
var candidateCtors = type.GetConstructors(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
.Where(x => !x.IsPrivate) // Includes internal constructors but not private constructors
.Where(x => !x.IsFamily) // Excludes protected constructors
.ToList();
var attributeCtors = candidateCtors.Where(x => x.GetCustomAttributes(typeof(TinyIoCConstructorAttribute), false).Any())
.ToList();
if (attributeCtors.Any())
candidateCtors = attributeCtors;
return candidateCtors.OrderByDescending(ctor => ctor.GetParameters().Count()).ThenByDescending(ctor => ctor.ToString());
//#endif
}
I wonder if this is ok?
I'm not sure without digging in, what happens if you try and do this with the Microsoft di? I'd think one would prefer the boolean parameter instead of the safety mode, but how would either of those get injected?
I use .net core 3.1 and .net 5 RC2
but The type.gettypeconStructors method gets six constructors in Framework 4.5
Causes the Resolve lazy object to be initialized