Пример #1
0
        public void OnExecute()
        {
            var pipeName = Guid.NewGuid().ToString();

            Console.WriteLine("Starting PipeGen Server...");
            //Process.Start("dotnet", $"tool run efx -- pipe-gen --pipe-name {pipeName}");
            Process.Start("dotnet", $"tool run efx -- pipe-gen --pipe-name {pipeName}");
            Console.WriteLine("STARTED");

            using var client = OutProcGenProtocol.CreateClient(pipeName);
            Console.WriteLine("Connecting to Pipe...");
            client.Connect();
            Console.WriteLine("CONNECTED");

            client.BeginSession();
            client.ReadProfiles((profile, path, content) =>
            {
                var name = path
                           .Replace("\\", "__")
                           .Replace("/", "__");

                Console.WriteLine($"Got file: {profile}, {name}:");
                Console.WriteLine($"  Length: {content.Length}");
                //Console.WriteLine("--8<---------------------------------------------------------------");
                //Console.WriteLine(content);
                //Console.WriteLine("--------------------------------------------------------------->8--");
            });


            // var content = reader.ReadToEnd();
            // Console.WriteLine("GOT:");
            // Console.WriteLine("--8<---------------------------------------------------------------");
            // Console.WriteLine(content);
            // Console.WriteLine("--------------------------------------------------------------->8--");
        }
Пример #2
0
        static void DoOPGClient()
        {
            using var client = OutProcGenProtocol.CreateClient("foo");
            Console.WriteLine("Client created");

            client.Connect();
            Console.WriteLine("Client connected");

            client.BeginSession();
            client.ReadProfiles((profile, path, content) =>
            {
                Console.WriteLine($"Got Profile [{profile}] path [{path}]:");
                Console.WriteLine($"  Body: [{content}]");
            });
        }
Пример #3
0
        public void Execute(GeneratorExecutionContext context)
        {
            var pipeName = Guid.NewGuid().ToString();

            context.ReportDiagnostic(Diagnostic.Create("EFX-0", "EFX",
                                                       $"Starting EFX Pipe Generator Server...",
                                                       DiagnosticSeverity.Warning, DiagnosticSeverity.Warning, true, 1));

            var proc = Process.Start("dotnet", $"tool run efx -- pipe-gen --pipe-name {pipeName}");

            context.ReportDiagnostic(Diagnostic.Create("EFX-0", "EFX",
                                                       $"...STARTED: {pipeName} - {proc.Id}",
                                                       DiagnosticSeverity.Warning, DiagnosticSeverity.Warning, true, 1));

            using var client = OutProcGenProtocol.CreateClient(pipeName);

            context.ReportDiagnostic(Diagnostic.Create("EFX-0", "EFX",
                                                       "Connecting to EFX Pipe Generator Server...",
                                                       DiagnosticSeverity.Warning, DiagnosticSeverity.Warning, true, 1));
            client.Connect();
            context.ReportDiagnostic(Diagnostic.Create("EFX-0", "EFX",
                                                       "...CONNECTED",
                                                       DiagnosticSeverity.Warning, DiagnosticSeverity.Warning, true, 1));

            int sources = 0;

            client.BeginSession();
            client.ReadProfiles((profile, path, content) =>
            {
                var name = path
                           .Replace("\\", "__")
                           .Replace("/", "__")
                           .Replace(":", "__");
                context.AddSource(name, content);
                sources++;
            });

            context.ReportDiagnostic(Diagnostic.Create("EFX-0", "EFX",
                                                       $"Added source files: [{sources}]",
                                                       DiagnosticSeverity.Warning, DiagnosticSeverity.Warning, true, 1));
        }