static void Main(string[] args)
        {
            NitroBolt.CommandLine.CommandLineManager.Process(args, typeof(Program).Assembly);

            return;

            if (true)
            {
                var xml = @"<!--x--><data><X><!--x-->12</X>s<!--c--><Z x='5'>tt</Z><S>v</S></data>";

                if (true)
                {
                    var data = Sample.XLoading.Load(System.Xml.XmlReader.Create(new StringReader(xml)));
                    Console.WriteLine($"x:{data.X}");
                    Console.WriteLine($"y:{data.Y}");
                    Console.WriteLine($"z:{data.Z}");
                }
                if (true)
                {
                    var data = Sample.XLoading.LoadByDictionary(System.Xml.XmlReader.Create(new StringReader(xml)));
                    Console.WriteLine($"x:{data.X}");
                    Console.WriteLine($"y:{data.Y}");
                    Console.WriteLine($"z:{data.Z}");
                }


                return;
            }
            if (true)
            {
                //foreach (var group in new[] { "A", "A", "B", "C", "C", "C", "A"}.SplitBy(x => x))
                //{
                //    Console.WriteLine($"{group.Key}: {group.Items.JoinToString(", ")}");
                //}
                //return;


                var @class = new DataImmutableGenerator.Class("Test",
                                                              new[]
                {
                    new DataImmutableGenerator.Member("X1", "string", true, "x1", "string", null, true, "x1", "string", false),
                    new DataImmutableGenerator.Member("X2", "string", true, "x2", "string", null, true, "x2", "Option<string>", true),
                    new DataImmutableGenerator.Member("Y1", "string", true, "y1", "string", "1.ToString()", true, "y1", "string", false),
                    new DataImmutableGenerator.Member("Y2", "string", true, "y2", "string", "null", true, "y2", "Option<string>", true),
                    new DataImmutableGenerator.Member("IsX1", "bool", true, "isX1", "bool?", "true", true, "isX1", "bool?", false),
                    new DataImmutableGenerator.Member("Public", "string", true, "@public", "string", "\"rr\"", true, "@public", "string", false)
                }.ToImmutableArray()
                                                              );
                var code = DataImmutableGenerator.Generate(new[] { @class, new DataImmutableGenerator.Class("X.Y." + @class.Name, @class.Members), new DataImmutableGenerator.Class("X.Y.R", @class.Members) });
                Console.WriteLine(code);
                File.WriteAllText("q.cs", code);

                var ts    = new[] { new T1("x", "X"), new T1("y", "Y") };
                var tcode = TransformationGenerator.Generate(ts);
                Console.WriteLine(tcode);
                File.WriteAllText("transformation.cs", code);
            }
            return;

            if (true)
            {
                var code = System.IO.File.ReadAllText(@"P:\Projects\NitroBolt.Projects\NitroBolt.DevConsole\CsGenerator.cs");

                var resultCode = InterfaceToClassGenerator.Generate(code);
            }
            //Console.WriteLine(resultCode);
        }
        //http://roslynquoter.azurewebsites.net/

        public static string Generate(string code)
        {
            try
            {
                var tree = CSharpSyntaxTree.ParseText(code);

                var compilation = CSharpCompilation.Create("data")
                                  .WithOptions(new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary))
                                  .AddReferences(MetadataReference.CreateFromFile(typeof(object).Assembly.Location))
                                  .AddReferences(MetadataReference.CreateFromFile(typeof(System.Collections.Immutable.ImmutableArray).Assembly.Location))
                                  .AddSyntaxTrees(tree);

                var model = compilation.GetSemanticModel(tree);


                var @namespace = tree.GetCompilationUnitRoot().Members.OfType <NamespaceDeclarationSyntax>().FirstOrDefault();


                var usings = tree.GetCompilationUnitRoot().Usings.ToArray();


                var r = s.CompilationUnit()
                        .AddUsings
                        (
                    new[] { "System" },
                    new[] { "System", "Linq" },
                    new[] { "System", "Collections", "Generic" },
                    new[] { "System", "Collections", "Immutable" },
                    new[] { "NitroBolt", "Functional" },
                    new[] { "NitroBolt", "Immutable" }
                        )
                        .AddUsings(usings);


                var isAdded = false;

                if (@namespace != null)
                {
                    var resultMembers = new List <MemberDeclarationSyntax>();
                    foreach (var @class in @namespace.Members.OfType <ClassDeclarationSyntax>())
                    {
                        var members = GetMembersForGeneration(@class, model);

                        if (!members.OrEmpty().Any())
                        {
                            continue;
                        }

                        resultMembers.Add(GenerateConstructorAndWithMethod(@class.Identifier.ValueText, members));

                        //var byHelper = GenerateByMethod(@class.Identifier.ValueText, members);
                        //if (byHelper != null)
                        //    resultMembers.Add(byHelper);
                    }

                    resultMembers.AddRange(InterfaceToClassGenerator.GenerateClasses(@namespace));

                    var resultNamespace = s.NamespaceDeclaration(@namespace.Name).AddMembers(resultMembers.ToArray());
                    r = r.AddMembers(resultNamespace);

                    isAdded = isAdded || resultMembers.Any();
                }
                if (!isAdded)
                {
                    return(null);
                }
                return(r.NormalizeWhitespace().ToString());
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc);
                return(null);
            }
        }