public void Execute(GeneratorExecutionContext context) { if (GeneratorContext.LaunchDebugger(context)) { Debugger.Launch(); } if (!"C#".Equals(context.ParseOptions.Language, StringComparison.OrdinalIgnoreCase)) { return; } var outputContext = new GeneratorContext(context); var candidates = (context.SyntaxReceiver as SourceGeneratorSyntaxReceiver)?.Candidates; if (candidates == null || candidates.Count == 0) { outputContext.CleanUp(); return; } using (new AssemblyResolver()) { foreach (var entry in ExpandCandidates(context, candidates)) { context.CancellationToken.ThrowIfCancellationRequested(); var logger = new Logger(context, entry.Candidate, entry.Attribute); InvokeGenerator(outputContext, entry.Factory, entry.Candidate, logger); } } outputContext.CleanUp(); }
public void LaunchDebugger(string?value, bool expected) { _globalOptions .Setup(o => o.TryGetValue("build_property.servicemodelgrpcdesigntime_launchdebugger", out value)) .Returns(value != null); GeneratorContext.LaunchDebugger(_context).ShouldBe(expected); }