From 1ef6e8788b5671b5a197e2c5ae5126a798b13e9f Mon Sep 17 00:00:00 2001 From: Stuart Turner Date: Fri, 10 Jul 2026 19:19:14 -0500 Subject: [PATCH 1/2] Upgrade `.net10.0` generator to net10 tfm --- .editorconfig | 2 + .gitattributes | 1 + .github/workflows/build.yml | 14 +--- .github/workflows/release.yml | 2 +- Directory.Build.props | 3 + Directory.Packages.props | 67 ++++++++++++++----- coverage-settings.xml | 33 +++++---- src/Common/SyntaxExtensions.cs | 4 +- .../Immediate.Injections.Analyzers.csproj | 3 +- .../RegisterServicesMethodAnalyzer.cs | 3 +- .../RegisterTypeAnalyzer.cs | 3 +- .../Immediate.Injections.Generators.csproj | 20 ++++-- .../ImmediateInjectionsGenerator.Render.cs | 3 + .../ImmediateInjectionsGenerator.cs | 4 +- .../Immediate.Injections.csproj | 41 +++++++++--- .../GeneratorTests/GeneratorTestHelper.cs | 14 +--- .../ImmediateAssemblyIdentifierTests.cs | 4 +- .../GeneratorTests/RegisterServicesTests.cs | 38 ++--------- ....ServiceCollectionExtensions.g.verified.cs | 62 ----------------- ....ServiceCollectionExtensions.g.verified.cs | 62 ----------------- ....ServiceCollectionExtensions.g.verified.cs | 62 ----------------- ...2#II.RegisterServicesMethods.g.verified.cs | 13 ---- ....ServiceCollectionExtensions.g.verified.cs | 62 ----------------- .../Immediate.Injections.Tests.csproj | 6 +- 24 files changed, 144 insertions(+), 382 deletions(-) delete mode 100644 tests/Immediate.Injections.Tests/GeneratorTests/Snapshots/ImmediateAssemblyIdentifierTests.ImmediateAssemblyIdentifierOverridesAssemblyName#II.ServiceCollectionExtensions.g.verified.cs delete mode 100644 tests/Immediate.Injections.Tests/GeneratorTests/Snapshots/RegisterServicesTests.ValidRegisterServicesMethodIsCalled1#II.ServiceCollectionExtensions.g.verified.cs delete mode 100644 tests/Immediate.Injections.Tests/GeneratorTests/Snapshots/RegisterServicesTests.ValidRegisterServicesMethodIsCalled2#II.ServiceCollectionExtensions.g.verified.cs delete mode 100644 tests/Immediate.Injections.Tests/GeneratorTests/Snapshots/RegisterServicesTests.ValidRegisterServicesMethodWhenLangVersionIs12#II.RegisterServicesMethods.g.verified.cs delete mode 100644 tests/Immediate.Injections.Tests/GeneratorTests/Snapshots/RegisterServicesTests.ValidRegisterServicesMethodWhenLangVersionIs12#II.ServiceCollectionExtensions.g.verified.cs diff --git a/.editorconfig b/.editorconfig index 06ab9f5..e4f8511 100644 --- a/.editorconfig +++ b/.editorconfig @@ -303,6 +303,8 @@ dotnet_diagnostic.MA0048.severity = none dotnet_diagnostic.MA0051.severity = none dotnet_diagnostic.MA0053.severity = warning +dotnet_diagnostic.RS1041.severity = none # RS1041: Compiler extensions should be implemented in assemblies targeting netstandard2.0 + [src/Immediate.Injections.Shared/**.cs] # XML Documentation diff --git a/.gitattributes b/.gitattributes index 176a458..0522160 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,2 @@ +*.verified.cs text eol=lf working-tree-encoding=UTF-8 * text=auto diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 61fc824..4999de6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 - name: Setup .NET uses: actions/setup-dotnet@v5 @@ -41,7 +41,7 @@ jobs: - name: Build run: dotnet build -c Release --no-restore - name: Test - run: dotnet test -c Release --no-build -- --coverage --coverage-output-format cobertura --coverage-output coverage.cobertura.xml --coverage-settings ./coverage-settings.xml + run: dotnet test -c Release --no-build -- --coverage --coverage-output-format cobertura --coverage-settings ./coverage-settings.xml - name: Package run: dotnet pack -c Release --no-build --property:PackageOutputPath=../../nupkgs @@ -51,12 +51,4 @@ jobs: - name: Coveralls uses: coverallsapp/github-action@v2 with: - files: > - tests/Immediate.Injections.FunctionalTests/bin/Release/net8.0/TestResults/coverage.cobertura.xml - tests/Immediate.Injections.FunctionalTests/bin/Release/net9.0/TestResults/coverage.cobertura.xml - tests/Immediate.Injections.FunctionalTests/bin/Release/net10.0/TestResults/coverage.cobertura.xml - tests/Immediate.Injections.FunctionalTests/bin/Release/net11.0/TestResults/coverage.cobertura.xml - tests/Immediate.Injections.Tests/bin/Release/net8.0/TestResults/coverage.cobertura.xml - tests/Immediate.Injections.Tests/bin/Release/net9.0/TestResults/coverage.cobertura.xml - tests/Immediate.Injections.Tests/bin/Release/net10.0/TestResults/coverage.cobertura.xml - tests/Immediate.Injections.Tests/bin/Release/net11.0/TestResults/coverage.cobertura.xml + files: 'TestResults/*.cobertura.xml' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c2ffb1e..9f8f59f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 - name: Setup .NET uses: actions/setup-dotnet@v5 diff --git a/Directory.Build.props b/Directory.Build.props index 0b1ad00..4a8879d 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -23,6 +23,7 @@ $(Polyfill)|T:System.Index + $(Polyfill)|T:System.HashCode $(Polyfill)|T:System.Range $(Polyfill)|T:System.Runtime.CompilerServices.CallerArgumentExpressionAttribute $(Polyfill)|T:System.Runtime.CompilerServices.CompilerFeatureRequiredAttribute @@ -30,6 +31,8 @@ $(Polyfill)|T:System.Runtime.CompilerServices.RequiredMemberAttribute $(Polyfill)|T:System.Runtime.CompilerServices.SkipLocalsInitAttribute $(Polyfill)|T:System.Diagnostics.CodeAnalysis + $(Polyfill)|M:System.ArgumentNullException.ThrowIfNull + $(Polyfill)|M:System.String.Replace(System.String,System.String,System.StringComparison) $(Polyfill) diff --git a/Directory.Packages.props b/Directory.Packages.props index 5d93f57..c48c9bd 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -5,56 +5,87 @@ - - - - - + + - - - - - + + - + + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + diff --git a/coverage-settings.xml b/coverage-settings.xml index 63eea14..88537ed 100644 --- a/coverage-settings.xml +++ b/coverage-settings.xml @@ -1,27 +1,26 @@ - + - - + + - .*Immediate.Handlers.Generators.dll$ + + ^System\.Diagnostics\.DebuggerHiddenAttribute$ + ^System\.Diagnostics\.DebuggerNonUserCodeAttribute$ + ^System\.CodeDom\.Compiler\.GeneratedCodeAttribute$ + ^System\.Diagnostics\.CodeAnalysis\.ExcludeFromCodeCoverageAttribute$ - + - - - - - ^System\.Diagnostics\.DebuggerHiddenAttribute$ - ^System\.Diagnostics\.DebuggerNonUserCodeAttribute$ - ^System\.CodeDom\.Compiler\.GeneratedCodeAttribute$ - ^System\.Diagnostics\.CodeAnalysis\.ExcludeFromCodeCoverageAttribute$ - - + + + .*/scriban/.* + + True - True + True - + diff --git a/src/Common/SyntaxExtensions.cs b/src/Common/SyntaxExtensions.cs index 607ffcc..a66fcf7 100644 --- a/src/Common/SyntaxExtensions.cs +++ b/src/Common/SyntaxExtensions.cs @@ -1,5 +1,3 @@ namespace Immediate.Injections; -internal static class SyntaxExtensions -{ -} +internal static class SyntaxExtensions; diff --git a/src/Immediate.Injections.Analyzers/Immediate.Injections.Analyzers.csproj b/src/Immediate.Injections.Analyzers/Immediate.Injections.Analyzers.csproj index 773ff9d..b36bf1d 100644 --- a/src/Immediate.Injections.Analyzers/Immediate.Injections.Analyzers.csproj +++ b/src/Immediate.Injections.Analyzers/Immediate.Injections.Analyzers.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + netstandard2.0;net10.0 true true @@ -11,7 +11,6 @@ - diff --git a/src/Immediate.Injections.Analyzers/RegisterServicesMethodAnalyzer.cs b/src/Immediate.Injections.Analyzers/RegisterServicesMethodAnalyzer.cs index 1caef5d..d0706ea 100644 --- a/src/Immediate.Injections.Analyzers/RegisterServicesMethodAnalyzer.cs +++ b/src/Immediate.Injections.Analyzers/RegisterServicesMethodAnalyzer.cs @@ -25,8 +25,7 @@ public sealed class RegisterServicesMethodAnalyzer : DiagnosticAnalyzer public override void Initialize(AnalysisContext context) { - if (context == null) - throw new ArgumentNullException(nameof(context)); + ArgumentNullException.ThrowIfNull(context); context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.EnableConcurrentExecution(); diff --git a/src/Immediate.Injections.Analyzers/RegisterTypeAnalyzer.cs b/src/Immediate.Injections.Analyzers/RegisterTypeAnalyzer.cs index 053ebca..08d1ee0 100644 --- a/src/Immediate.Injections.Analyzers/RegisterTypeAnalyzer.cs +++ b/src/Immediate.Injections.Analyzers/RegisterTypeAnalyzer.cs @@ -166,8 +166,7 @@ public sealed class RegisterTypeAnalyzer : DiagnosticAnalyzer public override void Initialize(AnalysisContext context) { - if (context == null) - throw new ArgumentNullException(nameof(context)); + ArgumentNullException.ThrowIfNull(context); context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.None); context.EnableConcurrentExecution(); diff --git a/src/Immediate.Injections.Generators/Immediate.Injections.Generators.csproj b/src/Immediate.Injections.Generators/Immediate.Injections.Generators.csproj index 15bc7f5..c94091d 100644 --- a/src/Immediate.Injections.Generators/Immediate.Injections.Generators.csproj +++ b/src/Immediate.Injections.Generators/Immediate.Injections.Generators.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + netstandard2.0;net10.0 true true $(NoWarn);CA1716 @@ -18,17 +18,29 @@ - + + + + + + + + + true + $(DefineConstants);SCRIBAN_NO_ASYNC + + + - + $(GetTargetPathDependsOn);GetDependencyTargetPaths - + diff --git a/src/Immediate.Injections.Generators/ImmediateInjectionsGenerator.Render.cs b/src/Immediate.Injections.Generators/ImmediateInjectionsGenerator.Render.cs index 10b68c1..453b120 100644 --- a/src/Immediate.Injections.Generators/ImmediateInjectionsGenerator.Render.cs +++ b/src/Immediate.Injections.Generators/ImmediateInjectionsGenerator.Render.cs @@ -1,4 +1,5 @@ using System.Collections.Immutable; +using System.Diagnostics; using System.Reflection; using Microsoft.CodeAnalysis; using Scriban; @@ -139,6 +140,8 @@ private static Template GetTemplate(string name) $"Immediate.Injections.Generators.Templates.{name}.sbntxt" ); + Debug.Assert(stream is { }); + using var reader = new StreamReader(stream); return Template.Parse(reader.ReadToEnd()); } diff --git a/src/Immediate.Injections.Generators/ImmediateInjectionsGenerator.cs b/src/Immediate.Injections.Generators/ImmediateInjectionsGenerator.cs index b729b80..27aaf9c 100644 --- a/src/Immediate.Injections.Generators/ImmediateInjectionsGenerator.cs +++ b/src/Immediate.Injections.Generators/ImmediateInjectionsGenerator.cs @@ -160,8 +160,8 @@ public static string GetAssemblyIdentifier(this Compilation compilation) } return (compilation.AssemblyName ?? string.Empty) - .Replace(".", string.Empty) - .Replace(" ", string.Empty) + .Replace(".", string.Empty, StringComparison.Ordinal) + .Replace(" ", string.Empty, StringComparison.Ordinal) .Trim(); } } diff --git a/src/Immediate.Injections/Immediate.Injections.csproj b/src/Immediate.Injections/Immediate.Injections.csproj index b1109cb..32a7277 100644 --- a/src/Immediate.Injections/Immediate.Injections.csproj +++ b/src/Immediate.Injections/Immediate.Injections.csproj @@ -20,20 +20,14 @@ https://github.com/ImmediatePlatform/Immediate.Injections + - - - - + + + + + + + + + + + + + + + + + diff --git a/tests/Immediate.Injections.Tests/GeneratorTests/GeneratorTestHelper.cs b/tests/Immediate.Injections.Tests/GeneratorTests/GeneratorTestHelper.cs index f67402b..0f95506 100644 --- a/tests/Immediate.Injections.Tests/GeneratorTests/GeneratorTestHelper.cs +++ b/tests/Immediate.Injections.Tests/GeneratorTests/GeneratorTestHelper.cs @@ -12,19 +12,10 @@ public static class GeneratorTestHelper public static GeneratorDriverRunResult RunGenerator( [StringSyntax("c#-test")] string source, params ReadOnlySpan skippedSteps - ) => RunGenerator(source, LanguageVersion.CSharp13, skippedSteps); - - public static GeneratorDriverRunResult RunGenerator( - [StringSyntax("c#-test")] string source, - LanguageVersion languageVersion, - params ReadOnlySpan skippedSteps ) { - var parseOptions = new CSharpParseOptions(languageVersion); - var syntaxTree = CSharpSyntaxTree.ParseText( source, - parseOptions, cancellationToken: TestContext.Current.CancellationToken ); @@ -43,14 +34,13 @@ params ReadOnlySpan skippedSteps GeneratorDriver driver = CSharpGeneratorDriver.Create( generators: [new ImmediateInjectionsGenerator().AsSourceGenerator(), new ImmediateHandlersGenerator().AsSourceGenerator()], - parseOptions: parseOptions, driverOptions: new GeneratorDriverOptions(default, trackIncrementalGeneratorSteps: true) ); driver = RunGenerator(driver, compilation); var result = driver.GetRunResult(); - VerifyIncrementality(driver, compilation, parseOptions, skippedSteps); + VerifyIncrementality(driver, compilation, skippedSteps); return result; } @@ -81,14 +71,12 @@ Compilation compilation private static void VerifyIncrementality( GeneratorDriver driver, Compilation compilation, - CSharpParseOptions parseOptions, ReadOnlySpan skippedSteps ) { var clone = compilation.Clone().AddSyntaxTrees( CSharpSyntaxTree.ParseText( "// dummy", - parseOptions, cancellationToken: TestContext.Current.CancellationToken ) ); diff --git a/tests/Immediate.Injections.Tests/GeneratorTests/ImmediateAssemblyIdentifierTests.cs b/tests/Immediate.Injections.Tests/GeneratorTests/ImmediateAssemblyIdentifierTests.cs index 6b09286..c7ddabe 100644 --- a/tests/Immediate.Injections.Tests/GeneratorTests/ImmediateAssemblyIdentifierTests.cs +++ b/tests/Immediate.Injections.Tests/GeneratorTests/ImmediateAssemblyIdentifierTests.cs @@ -1,3 +1,5 @@ +using static Immediate.Injections.Tests.Utility; + namespace Immediate.Injections.Tests.GeneratorTests; public sealed class ImmediateAssemblyIdentifierTests @@ -35,6 +37,6 @@ public static void CallMe(IServiceCollection services) result.GeneratedTrees.Select(t => t.FilePath.Replace('\\', '/')) ); - _ = await Verify(result); + _ = await VerifyIgnoreCommonFile(result); } } diff --git a/tests/Immediate.Injections.Tests/GeneratorTests/RegisterServicesTests.cs b/tests/Immediate.Injections.Tests/GeneratorTests/RegisterServicesTests.cs index b27bc0f..a671dec 100644 --- a/tests/Immediate.Injections.Tests/GeneratorTests/RegisterServicesTests.cs +++ b/tests/Immediate.Injections.Tests/GeneratorTests/RegisterServicesTests.cs @@ -1,39 +1,9 @@ +using static Immediate.Injections.Tests.Utility; + namespace Immediate.Injections.Tests.GeneratorTests; public sealed class RegisterServicesTests { -#if NET8_0 - [Fact] - public async Task ValidRegisterServicesMethodWhenLangVersionIs12() - { - var result = GeneratorTestHelper.RunGenerator( - """ - using Immediate.Injections.Shared; - using Microsoft.Extensions.DependencyInjection; - - public class Class - { - [RegisterServices] - public static void CallMe(IServiceCollection services) - { - } - } - """, - languageVersion: Microsoft.CodeAnalysis.CSharp.LanguageVersion.CSharp12 - ); - - Assert.Equal( - [ - "Immediate.Injections.Generators/Immediate.Injections.Generators.ImmediateInjectionsGenerator/II.ServiceCollectionExtensions.g.cs", - "Immediate.Injections.Generators/Immediate.Injections.Generators.ImmediateInjectionsGenerator/II.RegisterServicesMethods.g.cs", - ], - result.GeneratedTrees.Select(t => t.FilePath.Replace('\\', '/')) - ); - - _ = await Verify(result); - } -#endif - [Fact] public async Task ValidRegisterServicesMethodIsCalled1() { @@ -60,7 +30,7 @@ public static void CallMe(IServiceCollection services) result.GeneratedTrees.Select(t => t.FilePath.Replace('\\', '/')) ); - _ = await Verify(result); + _ = await VerifyIgnoreCommonFile(result); } [Fact] @@ -91,6 +61,6 @@ public static void CallMe(IServiceCollection services, ReadOnlySpan tags result.GeneratedTrees.Select(t => t.FilePath.Replace('\\', '/')) ); - _ = await Verify(result); + _ = await VerifyIgnoreCommonFile(result); } } diff --git a/tests/Immediate.Injections.Tests/GeneratorTests/Snapshots/ImmediateAssemblyIdentifierTests.ImmediateAssemblyIdentifierOverridesAssemblyName#II.ServiceCollectionExtensions.g.verified.cs b/tests/Immediate.Injections.Tests/GeneratorTests/Snapshots/ImmediateAssemblyIdentifierTests.ImmediateAssemblyIdentifierOverridesAssemblyName#II.ServiceCollectionExtensions.g.verified.cs deleted file mode 100644 index d1a2090..0000000 --- a/tests/Immediate.Injections.Tests/GeneratorTests/Snapshots/ImmediateAssemblyIdentifierTests.ImmediateAssemblyIdentifierOverridesAssemblyName#II.ServiceCollectionExtensions.g.verified.cs +++ /dev/null @@ -1,62 +0,0 @@ -//HintName: II.ServiceCollectionExtensions.g.cs -// -#nullable enable - -#pragma warning disable CS1591 - -public static partial class RegistrationServiceCollectionExtensions -{ - public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddCustomServices( - this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, - params global::System.ReadOnlySpan tags - ) - { - services.RegisterScoped(tags); - services.RegisterScoped1(tags); - services.RegisterScoped2(tags); - - services.RegisterSingleton(tags); - services.RegisterSingleton1(tags); - services.RegisterSingleton2(tags); - - services.RegisterTransient(tags); - services.RegisterTransient1(tags); - services.RegisterTransient2(tags); - - services.RegisterServices(tags); - - return services; - } - - static partial void RegisterScoped(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - static partial void RegisterScoped1(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - static partial void RegisterScoped2(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - - static partial void RegisterSingleton(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - static partial void RegisterSingleton1(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - static partial void RegisterSingleton2(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - - static partial void RegisterTransient(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - static partial void RegisterTransient1(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - static partial void RegisterTransient2(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - - static partial void RegisterServices(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - - // old-fashioned inner-loop; should be fine since neither tags list will ever be large - private static bool Intersects( - global::System.ReadOnlySpan first, - global::System.ReadOnlySpan second - ) - { - foreach (var f in first) - { - foreach (var s in second) - { - if (string.Equals(f, s, global::System.StringComparison.Ordinal)) - return true; - } - } - - return false; - } -} diff --git a/tests/Immediate.Injections.Tests/GeneratorTests/Snapshots/RegisterServicesTests.ValidRegisterServicesMethodIsCalled1#II.ServiceCollectionExtensions.g.verified.cs b/tests/Immediate.Injections.Tests/GeneratorTests/Snapshots/RegisterServicesTests.ValidRegisterServicesMethodIsCalled1#II.ServiceCollectionExtensions.g.verified.cs deleted file mode 100644 index 6bd7dc9..0000000 --- a/tests/Immediate.Injections.Tests/GeneratorTests/Snapshots/RegisterServicesTests.ValidRegisterServicesMethodIsCalled1#II.ServiceCollectionExtensions.g.verified.cs +++ /dev/null @@ -1,62 +0,0 @@ -//HintName: II.ServiceCollectionExtensions.g.cs -// -#nullable enable - -#pragma warning disable CS1591 - -public static partial class RegistrationServiceCollectionExtensions -{ - public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddTestsServices( - this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, - params global::System.ReadOnlySpan tags - ) - { - services.RegisterScoped(tags); - services.RegisterScoped1(tags); - services.RegisterScoped2(tags); - - services.RegisterSingleton(tags); - services.RegisterSingleton1(tags); - services.RegisterSingleton2(tags); - - services.RegisterTransient(tags); - services.RegisterTransient1(tags); - services.RegisterTransient2(tags); - - services.RegisterServices(tags); - - return services; - } - - static partial void RegisterScoped(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - static partial void RegisterScoped1(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - static partial void RegisterScoped2(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - - static partial void RegisterSingleton(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - static partial void RegisterSingleton1(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - static partial void RegisterSingleton2(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - - static partial void RegisterTransient(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - static partial void RegisterTransient1(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - static partial void RegisterTransient2(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - - static partial void RegisterServices(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - - // old-fashioned inner-loop; should be fine since neither tags list will ever be large - private static bool Intersects( - global::System.ReadOnlySpan first, - global::System.ReadOnlySpan second - ) - { - foreach (var f in first) - { - foreach (var s in second) - { - if (string.Equals(f, s, global::System.StringComparison.Ordinal)) - return true; - } - } - - return false; - } -} diff --git a/tests/Immediate.Injections.Tests/GeneratorTests/Snapshots/RegisterServicesTests.ValidRegisterServicesMethodIsCalled2#II.ServiceCollectionExtensions.g.verified.cs b/tests/Immediate.Injections.Tests/GeneratorTests/Snapshots/RegisterServicesTests.ValidRegisterServicesMethodIsCalled2#II.ServiceCollectionExtensions.g.verified.cs deleted file mode 100644 index 6bd7dc9..0000000 --- a/tests/Immediate.Injections.Tests/GeneratorTests/Snapshots/RegisterServicesTests.ValidRegisterServicesMethodIsCalled2#II.ServiceCollectionExtensions.g.verified.cs +++ /dev/null @@ -1,62 +0,0 @@ -//HintName: II.ServiceCollectionExtensions.g.cs -// -#nullable enable - -#pragma warning disable CS1591 - -public static partial class RegistrationServiceCollectionExtensions -{ - public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddTestsServices( - this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, - params global::System.ReadOnlySpan tags - ) - { - services.RegisterScoped(tags); - services.RegisterScoped1(tags); - services.RegisterScoped2(tags); - - services.RegisterSingleton(tags); - services.RegisterSingleton1(tags); - services.RegisterSingleton2(tags); - - services.RegisterTransient(tags); - services.RegisterTransient1(tags); - services.RegisterTransient2(tags); - - services.RegisterServices(tags); - - return services; - } - - static partial void RegisterScoped(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - static partial void RegisterScoped1(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - static partial void RegisterScoped2(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - - static partial void RegisterSingleton(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - static partial void RegisterSingleton1(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - static partial void RegisterSingleton2(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - - static partial void RegisterTransient(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - static partial void RegisterTransient1(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - static partial void RegisterTransient2(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - - static partial void RegisterServices(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - - // old-fashioned inner-loop; should be fine since neither tags list will ever be large - private static bool Intersects( - global::System.ReadOnlySpan first, - global::System.ReadOnlySpan second - ) - { - foreach (var f in first) - { - foreach (var s in second) - { - if (string.Equals(f, s, global::System.StringComparison.Ordinal)) - return true; - } - } - - return false; - } -} diff --git a/tests/Immediate.Injections.Tests/GeneratorTests/Snapshots/RegisterServicesTests.ValidRegisterServicesMethodWhenLangVersionIs12#II.RegisterServicesMethods.g.verified.cs b/tests/Immediate.Injections.Tests/GeneratorTests/Snapshots/RegisterServicesTests.ValidRegisterServicesMethodWhenLangVersionIs12#II.RegisterServicesMethods.g.verified.cs deleted file mode 100644 index 9c93111..0000000 --- a/tests/Immediate.Injections.Tests/GeneratorTests/Snapshots/RegisterServicesTests.ValidRegisterServicesMethodWhenLangVersionIs12#II.RegisterServicesMethods.g.verified.cs +++ /dev/null @@ -1,13 +0,0 @@ -//HintName: II.RegisterServicesMethods.g.cs -// -#nullable enable - -#pragma warning disable CS1591 - -public static partial class RegistrationServiceCollectionExtensions -{ - static partial void RegisterServices(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags) - { - global::Class.CallMe(services); - } -} diff --git a/tests/Immediate.Injections.Tests/GeneratorTests/Snapshots/RegisterServicesTests.ValidRegisterServicesMethodWhenLangVersionIs12#II.ServiceCollectionExtensions.g.verified.cs b/tests/Immediate.Injections.Tests/GeneratorTests/Snapshots/RegisterServicesTests.ValidRegisterServicesMethodWhenLangVersionIs12#II.ServiceCollectionExtensions.g.verified.cs deleted file mode 100644 index a07a5b4..0000000 --- a/tests/Immediate.Injections.Tests/GeneratorTests/Snapshots/RegisterServicesTests.ValidRegisterServicesMethodWhenLangVersionIs12#II.ServiceCollectionExtensions.g.verified.cs +++ /dev/null @@ -1,62 +0,0 @@ -//HintName: II.ServiceCollectionExtensions.g.cs -// -#nullable enable - -#pragma warning disable CS1591 - -public static partial class RegistrationServiceCollectionExtensions -{ - public static global::Microsoft.Extensions.DependencyInjection.IServiceCollection AddTestsServices( - this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, - params string[] tags - ) - { - services.RegisterScoped(tags); - services.RegisterScoped1(tags); - services.RegisterScoped2(tags); - - services.RegisterSingleton(tags); - services.RegisterSingleton1(tags); - services.RegisterSingleton2(tags); - - services.RegisterTransient(tags); - services.RegisterTransient1(tags); - services.RegisterTransient2(tags); - - services.RegisterServices(tags); - - return services; - } - - static partial void RegisterScoped(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - static partial void RegisterScoped1(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - static partial void RegisterScoped2(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - - static partial void RegisterSingleton(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - static partial void RegisterSingleton1(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - static partial void RegisterSingleton2(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - - static partial void RegisterTransient(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - static partial void RegisterTransient1(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - static partial void RegisterTransient2(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - - static partial void RegisterServices(this global::Microsoft.Extensions.DependencyInjection.IServiceCollection services, global::System.ReadOnlySpan tags); - - // old-fashioned inner-loop; should be fine since neither tags list will ever be large - private static bool Intersects( - global::System.ReadOnlySpan first, - global::System.ReadOnlySpan second - ) - { - foreach (var f in first) - { - foreach (var s in second) - { - if (string.Equals(f, s, global::System.StringComparison.Ordinal)) - return true; - } - } - - return false; - } -} diff --git a/tests/Immediate.Injections.Tests/Immediate.Injections.Tests.csproj b/tests/Immediate.Injections.Tests/Immediate.Injections.Tests.csproj index c76f4fe..8462b2c 100644 --- a/tests/Immediate.Injections.Tests/Immediate.Injections.Tests.csproj +++ b/tests/Immediate.Injections.Tests/Immediate.Injections.Tests.csproj @@ -15,10 +15,10 @@ - - + + - + From 75eea9c404e109f4088e22d6c15f56a92622d7b8 Mon Sep 17 00:00:00 2001 From: Stuart Turner Date: Fri, 10 Jul 2026 19:27:02 -0500 Subject: [PATCH 2/2] ... --- coverage-settings.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/coverage-settings.xml b/coverage-settings.xml index 88537ed..526e3a6 100644 --- a/coverage-settings.xml +++ b/coverage-settings.xml @@ -2,6 +2,13 @@ + + + + .*Immediate.Handlers.Generators.dll$ + + +