public void DateTimeDefaultConstructor() { IClass c = mscorlib.GetClass("System.DateTime", 0); Assert.IsFalse(c.Methods.Any(p => p.IsConstructor && p.Parameters.Count == 0)); Assert.IsTrue(c.GetAddDefaultConstructorIfRequired()); }
public void NoEncodingInfoDefaultConstructor() { IClass c = mscorlib.GetClass("System.Text.EncodingInfo", 0); Assert.IsFalse(c.Methods.Any(p => p.IsConstructor)); // EncodingInfo only has an internal constructor Assert.IsFalse(c.GetAddDefaultConstructorIfRequired()); }
public override List <IMethod> GetMethods() { List <IMethod> l = new List <IMethod>(); using (var busyLock = busyManager.Enter(this)) { if (busyLock.Success) { l.AddRange(c.Methods); if (c.GetAddDefaultConstructorIfRequired() && !c.IsStatic) { // A constructor is added for classes that do not have a default constructor; // and for all structs. if (c.ClassType == ClassType.Class && !l.Exists(m => m.IsConstructor)) { l.Add(Constructor.CreateDefault(c)); } else if (c.ClassType == ClassType.Struct || c.ClassType == ClassType.Enum) { l.Add(Constructor.CreateDefault(c)); } } if (c.ClassType == ClassType.Interface) { if (c.BaseTypes.Count == 0) { AddMethodsFromBaseType(l, c.ProjectContent.SystemTypes.Object); } else { foreach (IReturnType baseType in c.BaseTypes) { AddMethodsFromBaseType(l, baseType); } } } else { AddMethodsFromBaseType(l, c.BaseType); } } } return(l); }