Exemplo n.º 1
0
        public void SetProperties(ClassDeclarationSyntax classNode, AbstractionModel model)
        {
            try
            {
                var parser = new CodeParser()
                {
                    AccessLevel = "public"
                };

                var properties = parser
                                 .FilterByAccessLevel(parser.GetProperties(classNode), accessLevel: "public")
                                 .Select(p => (p as PropertyDeclarationSyntax));

                foreach (var property in properties)
                {
                    if (property == null)
                    {
                        continue;
                    }

                    var propertyName = property.Identifier.ValueText;

                    model.AddProperty(propertyName, property.Initializer?.Value.ToString() ?? "default", type: property.Type.ToString());

                    if (property.HasLeadingTrivia)
                    {
                        var parsedDocumentation = GetDocumentation(property);
                        model.AddDocumentation(propertyName, parsedDocumentation);
                    }
                }
            }
            catch (Exception e)
            {
                Logging.Log($"Failed to set properties in AbstractionModelManager.\nError: {e}");
            }
        }