public async Task <string> GenerateAsync(string source) { var opts = new CSharpParseOptions(LanguageVersion.Latest, DocumentationMode.None, SourceCodeKind.Regular); var tree = CSharpSyntaxTree.ParseText(source, opts); var root = await tree.GetRootAsync(); var classes = root.ChildNodes() .OfType <ClassDeclarationSyntax>() .ToList(); if (classes.Count == 0) { throw new ArgumentException("No root class found", nameof(source)); } var sb = new StringBuilder(); var i = 0; foreach (var @class in classes) { var walker = new PropertyCollector(); walker.Visit(@class); var result = ProcessProperties(walker.Properties); var classStr = _languageService.GetContainerDeclaration(@class.Identifier.Text, result); sb.Append(classStr); if (++i != classes.Count) { sb.AppendLine(Environment.NewLine); } } return(sb.ToString()); }