From a108277ed869c483e84d2dc49620767d7655a282 Mon Sep 17 00:00:00 2001 From: Nikolay Pianikov Date: Wed, 13 Nov 2024 18:13:32 +0300 Subject: [PATCH] #73 Code generation errors when using Unity --- src/Pure.DI/SourceGenerator.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Pure.DI/SourceGenerator.cs b/src/Pure.DI/SourceGenerator.cs index 0362ea80e..ec1fd9623 100644 --- a/src/Pure.DI/SourceGenerator.cs +++ b/src/Pure.DI/SourceGenerator.cs @@ -2,6 +2,8 @@ namespace Pure.DI; +using Exception = System.Exception; + [Generator(LanguageNames.CSharp)] public class SourceGenerator : IIncrementalGenerator { @@ -17,7 +19,14 @@ public void Initialize(IncrementalGeneratorInitializationContext context) { foreach (var apiSource in _generator.Api) { - initializationContext.AddSource(apiSource.HintName, apiSource.SourceText); + try + { + initializationContext.AddSource(apiSource.HintName, apiSource.SourceText); + } + catch + { + // ignored + } } });