Beispiel #1
0
        private void WalkType(INamedTypeSymbol typeSymbol)
        {
            var classAttribute = typeSymbol.GetPythonClassAttribute();

            if (classAttribute != null)
            {
                ClassAttributes.Add(typeSymbol, classAttribute);
            }

            foreach (var memberSymbol in typeSymbol.GetMembers())
            {
                switch (memberSymbol)
                {
                case IFieldSymbol fieldSymbol:
                    var fieldAttribute = fieldSymbol.GetPythonFieldAttribute();

                    if (fieldAttribute != null)
                    {
                        FieldAttributes.Add(fieldSymbol, fieldAttribute);
                    }

                    break;

                case IMethodSymbol methodSymbol:
                    var methodAttribute = methodSymbol.GetPythonMethodAttribute();

                    if (methodAttribute != null)
                    {
                        MethodAttributes.Add(methodSymbol, methodAttribute);
                    }

                    var operatorAttribute = methodSymbol.GetPythonOperatorAttribute();

                    if (operatorAttribute != null)
                    {
                        OperatorAttributes.Add(methodSymbol, operatorAttribute);
                    }

                    break;

                case IPropertySymbol propertySymbol:
                    var propertyAttribute = propertySymbol.GetPythonPropertyAttribute();

                    if (propertyAttribute != null)
                    {
                        PropertyAttributes.Add(propertySymbol, propertyAttribute);
                    }

                    break;
                }
            }
        }