Example #1
0
        private string GetSymbolBaseName(ISymbol symbol)
        {
            switch (symbol.Kind)
            {
            case SymbolKind.Method: {
                IMethodSymbol method = (IMethodSymbol)symbol;
                string        name   = XmlMetaProvider.GetMethodMapName(method);
                if (name != null)
                {
                    return(name);
                }
                var implementation = method.ExplicitInterfaceImplementations.FirstOrDefault();
                if (implementation != null)
                {
                    return(implementation.Name);
                }
                break;
            }

            case SymbolKind.Property: {
                IPropertySymbol property = (IPropertySymbol)symbol;
                if (property.IsIndexer)
                {
                    return(string.Empty);
                }
                else
                {
                    var implementation = property.ExplicitInterfaceImplementations.FirstOrDefault();
                    if (implementation != null)
                    {
                        return(implementation.Name);
                    }
                }
                break;
            }

            case SymbolKind.Event: {
                IEventSymbol eventSymbol    = (IEventSymbol)symbol;
                var          implementation = eventSymbol.ExplicitInterfaceImplementations.FirstOrDefault();
                if (implementation != null)
                {
                    return(implementation.Name);
                }
                break;
            }
            }
            return(symbol.Name);
        }
Example #2
0
        private LuaIdentifierNameSyntax InternalGetMemberName(ISymbol symbol)
        {
            if (symbol.Kind == SymbolKind.Method)
            {
                string name = XmlMetaProvider.GetMethodMapName((IMethodSymbol)symbol);
                if (name != null)
                {
                    return(new LuaIdentifierNameSyntax(name));
                }
            }

            if (!symbol.IsFromCode() || symbol.ContainingType.TypeKind == TypeKind.Interface)
            {
                return(new LuaIdentifierNameSyntax(GetSymbolBaseName(symbol)));
            }

            if (symbol.IsStatic)
            {
                if (symbol.ContainingType.IsStatic)
                {
                    return(GetStaticClassMemberName(symbol));
                }
            }

            while (symbol.IsOverride)
            {
                var overriddenSymbol = symbol.OverriddenSymbol();
                if (!overriddenSymbol.IsFromCode())
                {
                    break;
                }
                symbol = overriddenSymbol;
            }

            return(GetAllTypeSameName(symbol));
        }