Example #1
0
        private string GetInternalMethodMetaInfo(IMethodSymbol symbol, MethodMetaType metaType)
        {
            Contract.Assert(symbol != null);
            if (symbol.DeclaredAccessibility != Accessibility.Public)
            {
                return(null);
            }

            string codeTemplate = null;

            if (!symbol.IsFromCode())
            {
                codeTemplate = GetTypeMetaInfo(symbol)?.GetMethodMetaInfo(symbol.Name)?.GetMetaInfo(symbol, metaType);
            }

            if (codeTemplate == null)
            {
                if (symbol.IsOverride)
                {
                    if (symbol.OverriddenMethod != null)
                    {
                        codeTemplate = GetInternalMethodMetaInfo(symbol.OverriddenMethod, metaType);
                    }
                }
                else
                {
                    var interfaceImplementations = symbol.InterfaceImplementations();
                    if (interfaceImplementations != null)
                    {
                        foreach (IMethodSymbol interfaceMethod in interfaceImplementations)
                        {
                            codeTemplate = GetInternalMethodMetaInfo(interfaceMethod, metaType);
                            if (codeTemplate != null)
                            {
                                break;
                            }
                        }
                    }
                }
            }
            return(codeTemplate);
        }
Example #2
0
        private string GetInternalMethodMetaInfo(IMethodSymbol symbol, MethodMetaType metaType)
        {
            Contract.Assert(symbol != null);
            if (!symbol.IsPublic())
            {
                return(null);
            }

            string metaInfo = null;

            if (symbol.IsFromAssembly())
            {
                metaInfo = GetTypeMetaInfo(symbol)?.GetMethodMetaInfo(symbol.Name)?.GetMetaInfo(symbol, metaType);
            }

            if (metaInfo == null)
            {
                if (symbol.IsOverride)
                {
                    if (symbol.OverriddenMethod != null)
                    {
                        metaInfo = GetInternalMethodMetaInfo(symbol.OverriddenMethod, metaType);
                    }
                }
                else
                {
                    var interfaceImplementations = symbol.InterfaceImplementations();
                    if (interfaceImplementations != null)
                    {
                        foreach (IMethodSymbol interfaceMethod in interfaceImplementations)
                        {
                            metaInfo = GetInternalMethodMetaInfo(interfaceMethod, metaType);
                            if (metaInfo != null)
                            {
                                break;
                            }
                        }
                    }
                }
            }
            return(metaInfo);
        }
Example #3
0
            public string GetMetaInfo(IMethodSymbol symbol, MethodMetaType type)
            {
                switch (type)
                {
                case MethodMetaType.Name: {
                    return(GetName(symbol));
                }

                case MethodMetaType.CodeTemplate: {
                    return(GetCodeTemplate(symbol));
                }

                case MethodMetaType.IgnoreGeneric: {
                    return(GetIgnoreGeneric(symbol));
                }

                default: {
                    throw new InvalidOperationException();
                }
                }
            }
Example #4
0
                internal string GetMetaInfo(MethodMetaType type)
                {
                    switch (type)
                    {
                    case MethodMetaType.Name: {
                        return(Name);
                    }

                    case MethodMetaType.CodeTemplate: {
                        return(Template);
                    }

                    case MethodMetaType.IgnoreGeneric: {
                        return(IgnoreGeneric ? bool.TrueString : bool.FalseString);
                    }

                    default: {
                        throw new InvalidOperationException();
                    }
                    }
                }
Example #5
0
 private string GetMethodMetaInfo(IMethodSymbol symbol, MethodMetaType metaType)
 {
     Utility.CheckMethodDefinition(ref symbol);
     return(GetInternalMethodMetaInfo(symbol, metaType));
 }
Example #6
0
 public string GetMetaInfo(IMethodSymbol symbol, MethodMetaType type)
 {
     return(GetMethodModel(symbol, type == MethodMetaType.CodeTemplate)?.GetMetaInfo(type));
 }