public void GetTypeContextModel() { var asm = Assembly.LoadFrom(@"..\..\..\Test\ContextTest1\Microsoft.VisualBasic.dll"); Type asmType = asm.GetType("Microsoft.VisualBasic.CompilerServices.IncompleteInitialization"); AssemblyModel.AddContext("ContextTest1", @"..\..\..\Test\ContextTest1"); var ns = AssemblyModel.FindNamespace("Microsoft.VisualBasic.CompilerServices"); var type = AssemblyModel.GetCtsType("ContextTest1", "Microsoft.VisualBasic.CompilerServices", "IncompleteInitialization"); Assert.IsNotNull(type); Assert.AreEqual("Microsoft.VisualBasic.CompilerServices", type.Namespace.Name); Assert.AreEqual("ContextTest1", type.Assembly.Context.Name); Assert.AreEqual(3, type.Contructors.Count); Assert.AreEqual(0, type.Events.Count); Assert.AreEqual(0, type.Fields.Count); Assert.AreEqual("Microsoft.VisualBasic.CompilerServices.IncompleteInitialization", type.FullName); Assert.AreEqual(16, type.Methods.Count); Assert.AreEqual(7, type.Properties.Count); foreach (var fieldInfo in asmType.GetFields()) { var info = fieldInfo; var ctor = type.Fields.Find(s => s.Name == info.Name); Assert.IsNotNull(ctor); Assert.AreEqual(info.Name, ctor.Name); Assert.AreEqual(info.FieldType.Name, ctor.Type.Name); } foreach (var propertyInfo in asmType.GetProperties()) { var info = propertyInfo; var ctor = type.Properties.Find(s => s.Name == info.Name); Assert.IsNotNull(ctor); Assert.AreEqual(info.Name, ctor.Name); Assert.AreEqual(info.PropertyType.Name, ctor.Type.Name); } foreach (var constructorInfo in asmType.GetConstructors()) { var info = constructorInfo; var ctor = type.Contructors.Find(s => s.Name == info.Name); Assert.IsNotNull(ctor); Assert.AreEqual(constructorInfo.Name, ctor.Name); } foreach (var methodInfo in asmType.GetMethods()) { var info = methodInfo; var lmtor = type.Methods.FindAll(s => (s.Name == info.Name) && (s.Parameters.Count == info.GetParameters().Count())); var info2 = methodInfo; var mtor = lmtor.Find(s => s.Parameters.TrueForAll( t => info2.GetParameters().ToList().Find(p => p.ParameterType.Name == t.Type.Name) != null)); Assert.IsNotNull(mtor); Assert.AreEqual(methodInfo.Name, mtor.Name); Assert.AreEqual(methodInfo.GetParameters().Count(), mtor.Parameters.Count); Assert.AreEqual(methodInfo.ReturnType.Name, mtor.Return.Name); foreach (var parameterInfo in methodInfo.GetParameters()) { var info1 = parameterInfo; var ptor = mtor.Parameters.Find(s => s.Name == info1.Name); Assert.IsNotNull(ptor); Assert.AreEqual(parameterInfo.Name, ptor.Name); Assert.AreEqual(parameterInfo.ParameterType.Name, ptor.Type.Name); } } }