protected bool ShouldExportConstructor(IMethod ctor) { var att = ctor.GetMetadata <JsMethodAttribute>(); if (att != null && !att.Export) { return(false); } if (ctor.IsGenerated(Compiler.Project) && Sk.OmitDefaultConstructor(ctor.GetDeclaringTypeDefinition())) { return(false); } return(true); }
public List <IMember> GetMembersToExport(ITypeDefinition ce) { var members = ce.Members.Where(t => ShouldExportMember(t)).ToList(); var fields = GeneratePropertyFields(ce, true).Concat(GeneratePropertyFields(ce, false)); members = members.Concat(fields).ToList(); var ctor = ce.Members.Where(t => t.SymbolKind == SymbolKind.Constructor && !t.IsStatic).FirstOrDefault(); if (ctor == null && !Sk.OmitDefaultConstructor(ce)) { ctor = GenerateDefaultConstructor(ce); if (ctor != null) { members.Add(ctor); } } if (ctor != null && members.Contains(ctor)) { var ctorIndex = 0; if (members.IndexOf(ctor) != ctorIndex) { members.Remove(ctor); members.Insert(ctorIndex, ctor); } } var inlineFields = Sk.InlineFields(ce); if (!inlineFields) { var vars = members.Where(t => t.SymbolKind == SymbolKind.Field).Cast <IField>(); if (vars.Where(t => t.IsStatic()).FirstOrDefault() != null) { var cctor = ce.GetConstructors(false, true).FirstOrDefault(); if (cctor == null) { cctor = CreateStaticCtor(ce); members.Insert(1, cctor); } } members.RemoveAll(t => t.SymbolKind == SymbolKind.Field); } return(members); }