public bool Execute() { var files = InputFiles .Select(x => x.ItemSpec) .Where(Generator.IsMetaSharpFile) .ToImmutableArray(); var buildConstants = new BuildConstants( intermediateOutputPath: IntermediateOutputPath, targetPath: OutDir, generatorMode: GeneratorMode.MsBuild ); var code = RealEnvironmentGenerator.Generate( files, buildConstants, error => BuildEngine.LogErrorEvent(ToBuildError(error)), output => OutputFiles = output.Select(x => new TaskItem(x)).ToArray() ); return(code == GeneratorResultCode.Success); //var type = compilation.GlobalNamespace.GetNamespaceMembers().ElementAt(0).GetNamespaceMembers().ElementAt(0).GetTypeMembers().Single(); //var tree = type.Locations.Single().SourceTree; //if(tree == compilation.SyntaxTrees.Single()) { //} //var node = compilation.SyntaxTrees.Single().GetRoot().DescendantNodes().OfType<ClassDeclarationSyntax>().First(); //var model = compilation.GetSemanticModel(compilation.SyntaxTrees.Single()); //var symbol = model.GetDeclaredSymbol(node); //if(symbol == type) { //} }
static int Process(string[] args) { var parser = GetParser(); var result = parser.Parse(args); //Debugger.Launch(); if (result.HasErrors) { System.Console.WriteLine(result.ErrorText); return((int)GeneratorResultCode.Error); } Directory.SetCurrentDirectory(parser.Object.ProjectPath); var files = Directory.GetFiles(Directory.GetCurrentDirectory(), "*." + Generator.DefaultInputFileEnd, SearchOption.AllDirectories) .ToImmutableArray(); var buildConstants = new BuildConstants( intermediateOutputPath: null, targetPath: parser.Object.TargetPath, generatorMode: GeneratorMode.ConsoleApp ); var code = RealEnvironmentGenerator.Generate( files, buildConstants, error => System.Console.WriteLine(error.ToString()), output => { } ); return((int)code); }