Open
Description
I use .net core 3.1 and .net 5 RC2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using TinyIoC;
namespace ConsoleApp4
{
class Program
{
static void Main(string[] args)
{
var personLazy = TinyIoCContainer.Current.Resolve<Lazy<Person>>();
//var person = personLazy.Value;
var candidateCtors = typeof(Lazy<Person>).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 ctors = candidateCtors.OrderByDescending(ctor => ctor.GetParameters().Count());
foreach (var ctor in ctors)
{
Console.WriteLine(ctor.ToString());
}
Console.ReadKey();
}
}
class Person
{
public Person()
{
Console.WriteLine("new Person");
}
}
}
but The type.gettypeconStructors method gets six constructors in Framework 4.5
Metadata
Metadata
Assignees
Labels
No labels