Ejemplo n.º 1
0
        public override void Execute(SourceGeneratorContext context)
        {
#if DEBUG
            Debugger.Launch();
#endif

            _logger = context.GetLogger();

            DirectoryInfo projDir = new DirectoryInfo(Path.GetDirectoryName(context.Project.FilePath) ?? throw new InvalidOperationException("Context's project's file path is null"));

            string solutionFullName = null;

            while (projDir.Parent != null)
            {
                string filePath = Path.Combine(projDir.FullName, "BitConfigV1.json");

                if (File.Exists(filePath))
                {
                    solutionFullName = Directory.EnumerateFiles(projDir.FullName, "*.sln").FirstOrDefault();
                    break;
                }

                projDir = projDir.Parent;
            }

            CallGenerateCodes((MSBuildWorkspace)context.Project.Solution.Workspace, context.Project, solutionFullName).GetAwaiter().GetResult();
        }
        public override void Execute(SourceGeneratorContext context)
        {
#if DEBUG
            Debugger.Launch();
#endif

            _logger = context.GetLogger();

            DirectoryInfo projDir = new DirectoryInfo(Path.GetDirectoryName(context.Project.FilePath));

            string solutionFullName = null;

            while (projDir.Parent != null)
            {
                string filePath = Path.Combine(projDir.FullName, "BitConfigV1.json");

                if (File.Exists(filePath))
                {
                    solutionFullName = Directory.EnumerateFiles(projDir.FullName, "*.sln").FirstOrDefault();
                    break;
                }

                projDir = projDir.Parent;
            }

            CallGenerateCodes(context.Project.Solution.Workspace, solutionFullName);
        }
Ejemplo n.º 3
0
        public override void Execute(SourceGeneratorContext context)
        {
            //_ = Debugger.Launch(); // uncomment to debug code generator

            logger = context.GetLogger();
            logger.Info("Executing Hyperlinq generator!");

            var compilation = context.Compilation;

            hyperlinqNamespace = compilation.SourceModule.GlobalNamespace.GetNamespace("NetFabric", "Hyperlinq");

            CollectExtensionMethods(context);
            GenerateSource(context);
        }
Ejemplo n.º 4
0
 public static void SetLogger(this GeneratorExecutionContext context, ISourceGeneratorLogger logger)
 {
     _logger.Add(context, logger);
 }