static IUnresolvedMethod CreateDummyConstructor() { var m = new DefaultUnresolvedMethod { SymbolKind = SymbolKind.Constructor, Name = ".ctor", Accessibility = Accessibility.Public, IsSynthetic = true, ReturnType = KnownTypeReference.Void }; m.Freeze(); return(m); }
MemberList GetMemberList() { var result = LazyInit.VolatileRead(ref this.memberList); if (result != null) { return(result); } List <IUnresolvedMember> unresolvedMembers = new List <IUnresolvedMember>(); List <ITypeResolveContext> contextPerMember = new List <ITypeResolveContext>(); List <PartialMethodInfo> partialMethodInfos = null; bool addDefaultConstructorIfRequired = false; foreach (IUnresolvedTypeDefinition part in parts) { ITypeResolveContext parentContextForPart = part.CreateResolveContext(parentContext); ITypeResolveContext contextForPart = parentContextForPart.WithCurrentTypeDefinition(this); foreach (var member in part.Members) { IUnresolvedMethod method = member as IUnresolvedMethod; if (method != null && method.IsPartial) { // Merge partial method declaration and implementation if (partialMethodInfos == null) { partialMethodInfos = new List <PartialMethodInfo>(); } PartialMethodInfo newInfo = new PartialMethodInfo(method, contextForPart); PartialMethodInfo existingInfo = null; foreach (var info in partialMethodInfos) { if (newInfo.IsSameSignature(info, Compilation.NameComparer)) { existingInfo = info; break; } } if (existingInfo != null) { // Add the unresolved method to the PartialMethodInfo: existingInfo.AddPart(method, contextForPart); } else { partialMethodInfos.Add(newInfo); } } else { unresolvedMembers.Add(member); contextPerMember.Add(contextForPart); } } addDefaultConstructorIfRequired |= part.AddDefaultConstructorIfRequired; } if (addDefaultConstructorIfRequired) { TypeKind kind = this.Kind; if (kind == TypeKind.Class && !this.IsStatic && !unresolvedMembers.Any(m => m.SymbolKind == SymbolKind.Constructor && !m.IsStatic) || kind == TypeKind.Enum || kind == TypeKind.Struct) { contextPerMember.Add(parts[0].CreateResolveContext(parentContext).WithCurrentTypeDefinition(this)); unresolvedMembers.Add(DefaultUnresolvedMethod.CreateDefaultConstructor(parts[0])); } } result = new MemberList(contextPerMember, unresolvedMembers, partialMethodInfos); return(LazyInit.GetOrSet(ref this.memberList, result)); }
public DefaultResolvedMethod(DefaultUnresolvedMethod unresolved, ITypeResolveContext parentContext) : this(unresolved, parentContext, unresolved.IsExtensionMethod) { }