Пример #1
0
        public void LogAttributes(AttributeWalker projectAttributes)
        {
            Logger.LogHeading("Attributes - Class", LogLevel.Info);

            foreach (var entry in projectAttributes.ClassAttributes)
            {
                string target = entry.Key.ToString();
                PythonClassAttribute attribute = entry.Value;
                Logger.Log($"{target} -> {attribute.ModuleName}:{attribute.ClassName} ({attribute.File}) {(attribute.GenerateMethods ? "*" : "")}", LogLevel.Info);
            }

            Logger.LogHeading("Attributes - Fields", LogLevel.Info);

            foreach (var entry in projectAttributes.FieldAttributes)
            {
                string target = entry.Key.ToString();
                PythonFieldAttribute attribute = entry.Value;
                Logger.Log($"{target} -> {attribute.Name} ({attribute.File})", LogLevel.Info);
            }

            Logger.LogHeading("Attributes - Methods", LogLevel.Info);

            foreach (var entry in projectAttributes.MethodAttributes)
            {
                string target = entry.Key.ToString();
                PythonMethodAttribute attribute = entry.Value;
                Logger.Log($"{target} -> {attribute.Function} ({attribute.File}) {(attribute.Generate ? "*" : "")}", LogLevel.Info);
            }

            Logger.LogHeading("Attributes - Properties", LogLevel.Info);

            foreach (var entry in projectAttributes.PropertyAttributes)
            {
                string target = entry.Key.ToString();
                PythonPropertyAttribute attribute = entry.Value;

                Logger.Log($"{target} -> {attribute.Name} ({attribute.File})", LogLevel.Info);
            }

            Logger.LogHeading("Attributes - Operators", LogLevel.Info);

            foreach (var entry in projectAttributes.OperatorAttributes)
            {
                string target = entry.Key.ToString();
                PythonOperatorAttribute attribute = entry.Value;
                Logger.Log($"{target} -> {attribute.Operator}", LogLevel.Info);
            }
        }
Пример #2
0
        public static string GetPythonFile(this ISymbol symbol)
        {
            PythonMethodAttribute pythonMethodAttribute = symbol.GetPythonMethodAttribute();

            if (pythonMethodAttribute != null && pythonMethodAttribute.File != null)
            {
                return(pythonMethodAttribute.File);
            }

            while (symbol != null)
            {
                PythonClassAttribute pythonClassAttribute = symbol.GetPythonClassAttribute();

                if (pythonClassAttribute != null && pythonClassAttribute.File != null)
                {
                    return(pythonClassAttribute.File);
                }

                symbol = symbol.ContainingType;
            }

            return(null);
        }