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); }
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); }
public static void SetLogger(this GeneratorExecutionContext context, ISourceGeneratorLogger logger) { _logger.Add(context, logger); }