private static string AddInterfacePrefix(IMember property, IEmitter emitter, bool ignoreInterface, string attrName, bool isSetter) { IMember interfaceMember = null; if (property.IsExplicitInterfaceImplementation) { interfaceMember = property.ImplementedInterfaceMembers.First(); } else if (property.DeclaringTypeDefinition != null && property.DeclaringTypeDefinition.Kind == TypeKind.Interface) { interfaceMember = property; } if (interfaceMember != null && !ignoreInterface) { return(OverloadsCollection.GetInterfaceMemberName(emitter, interfaceMember, attrName, null, false, isSetter)); } return(attrName); }
protected virtual string GetOverloadName(IMember definition, bool skipInterfaceName = false, string prefix = null, bool withoutTypeParams = false) { IMember interfaceMember = null; if (definition.IsExplicitInterfaceImplementation) { interfaceMember = definition.ImplementedInterfaceMembers.First(); } else if (definition.DeclaringTypeDefinition != null && definition.DeclaringTypeDefinition.Kind == TypeKind.Interface) { interfaceMember = definition; } if (interfaceMember != null && !skipInterfaceName && !this.Emitter.Validator.IsObjectLiteral(interfaceMember.DeclaringTypeDefinition)) { return(OverloadsCollection.GetInterfaceMemberName(this.Emitter, interfaceMember, null, prefix, withoutTypeParams, this.IsSetter)); } string name = this.Emitter.GetEntityName(definition, this.CancelChangeCase); if (name.StartsWith("." + JS.Funcs.CONSTRUCTOR)) { name = JS.Funcs.CONSTRUCTOR; } var attr = Helpers.GetInheritedAttribute(definition, "Bridge.NameAttribute"); var iProperty = definition as IProperty; if (attr == null && iProperty != null && !IsField) { var acceessor = this.IsSetter ? iProperty.Setter : iProperty.Getter; if (acceessor != null) { attr = Helpers.GetInheritedAttribute(acceessor, "Bridge.NameAttribute"); } } if (attr != null) { var value = attr.PositionalArguments.First().ConstantValue; if (value is string) { name = value.ToString(); } if (!(iProperty != null || definition is IEvent)) { prefix = null; } } if (attr != null && definition.ImplementedInterfaceMembers.Count > 0) { if (this.Members.Where(member => member.ImplementedInterfaceMembers.Count > 0) .Any(member => definition.ImplementedInterfaceMembers.Any(implementedInterfaceMember => member.ImplementedInterfaceMembers.Any(m => m.DeclaringTypeDefinition == implementedInterfaceMember.DeclaringTypeDefinition)))) { attr = null; } } bool skipSuffix = false; if (definition.DeclaringTypeDefinition != null && this.Emitter.Validator.IsExternalType(definition.DeclaringTypeDefinition)) { if (definition.DeclaringTypeDefinition.Kind == TypeKind.Interface) { skipSuffix = definition.DeclaringTypeDefinition.ParentAssembly.AssemblyName != CS.NS.ROOT; } else { skipSuffix = true; } } if (attr != null || skipSuffix) { return(prefix != null ? prefix + name : name); } var iDefinition = definition as IMethod; var isCtor = iDefinition != null && iDefinition.IsConstructor; if (isCtor) { name = JS.Funcs.CONSTRUCTOR; } var index = this.GetIndex(definition); if (index > 0) { if (isCtor) { name = JS.Vars.D + name + index; } else { name += Helpers.PrefixDollar(index); name = Helpers.ReplaceFirstDollar(name); } } return(prefix != null ? prefix + name : name); }
protected virtual string GetOverloadName(IMember definition, bool skipInterfaceName = false, string prefix = null, bool withoutTypeParams = false) { IMember interfaceMember = null; if (definition.IsExplicitInterfaceImplementation) { interfaceMember = definition.ImplementedInterfaceMembers.First(); } else if (definition.DeclaringTypeDefinition != null && definition.DeclaringTypeDefinition.Kind == TypeKind.Interface) { interfaceMember = definition; } if (interfaceMember != null && !skipInterfaceName) { return(OverloadsCollection.GetInterfaceMemberName(this.Emitter, interfaceMember, null, prefix, withoutTypeParams, this.IsSetter)); } string name = this.Emitter.GetEntityName(definition, this.CancelChangeCase); if (name.StartsWith(".ctor")) { name = JS.Funcs.CONSTRUCTOR; } var attr = Helpers.GetInheritedAttribute(definition, "Bridge.NameAttribute"); if (attr == null && definition is IProperty) { var prop = (IProperty)definition; var acceessor = this.IsSetter ? prop.Setter : prop.Getter; if (acceessor != null) { attr = Helpers.GetInheritedAttribute(acceessor, "Bridge.NameAttribute"); } } if (attr != null) { var value = attr.PositionalArguments.First().ConstantValue; if (value is string) { name = value.ToString(); } prefix = null; } if (attr != null && definition.ImplementedInterfaceMembers.Count > 0) { if (this.Members.Where(member => member.ImplementedInterfaceMembers.Count > 0) .Any(member => definition.ImplementedInterfaceMembers.Any(implementedInterfaceMember => member.ImplementedInterfaceMembers.Any(m => m.DeclaringTypeDefinition == implementedInterfaceMember.DeclaringTypeDefinition)))) { attr = null; } } if (attr != null || (definition.DeclaringTypeDefinition != null && definition.DeclaringTypeDefinition.Kind != TypeKind.Interface && this.Emitter.Validator.IsIgnoreType(definition.DeclaringTypeDefinition))) { return(prefix != null ? prefix + name : name); } var isCtor = definition is IMethod && ((IMethod)definition).IsConstructor; if (isCtor) { name = JS.Funcs.CONSTRUCTOR; } var index = this.GetIndex(definition); if (index > 0) { if (isCtor) { name = JS.Vars.D + name + index; } else { name += Helpers.PrefixDollar(index); name = Helpers.ReplaceFirstDollar(name); } } return(prefix != null ? prefix + name : name); }