diff --git a/src/SafeRouting.Generator/IncrementalValueProviderExtensions.cs b/src/SafeRouting.Generator/IncrementalValueProviderExtensions.cs new file mode 100644 index 0000000..0af1b96 --- /dev/null +++ b/src/SafeRouting.Generator/IncrementalValueProviderExtensions.cs @@ -0,0 +1,9 @@ +using Microsoft.CodeAnalysis; + +namespace SafeRouting.Generator; + +public static class IncrementalValueProviderExtensions +{ + public static IncrementalValueProvider Not(this IncrementalValueProvider source) + => source.Select(static (x, _) => !x); +} diff --git a/src/SafeRouting.Generator/RouteGenerator.cs b/src/SafeRouting.Generator/RouteGenerator.cs index aa75527..68dae9e 100644 --- a/src/SafeRouting.Generator/RouteGenerator.cs +++ b/src/SafeRouting.Generator/RouteGenerator.cs @@ -28,10 +28,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) var isSupportedLanguageVersionProvider = languageVersionProvider .Select(static (x, _) => x >= LanguageVersion.CSharp8); - var isUnsupportedLanguageVersionProvider = isSupportedLanguageVersionProvider - .Select(static (x, _) => !x); - - context.RegisterConditionalOutput(isUnsupportedLanguageVersionProvider, static context => + context.RegisterConditionalOutput(isSupportedLanguageVersionProvider.Not(), static context => { context.ReportDiagnostic(Diagnostics.CreateUnsupportedLanguageVersionDiagnostic()); });