diff --git a/.editorconfig b/.editorconfig
index 183d94f4..007f2e3d 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -309,3 +309,11 @@ dotnet_diagnostic.CA2000.severity = error # CA2000: Dispose object
dotnet_diagnostic.CA1515.severity = none # CA1515: Consider making public types internal
dotnet_diagnostic.CA1708.severity = none # CA1708: Identifiers should differ by more than case
dotnet_diagnostic.CA1716.severity = none # CA1716: Identifiers should not match keywords
+
+MA0053.public_class_should_be_sealed = true
+MA0053.exceptions_should_be_sealed = true
+
+dotnet_diagnostic.MA0004.severity = none
+dotnet_diagnostic.MA0048.severity = none
+dotnet_diagnostic.MA0051.severity = none
+dotnet_diagnostic.MA0053.severity = warning
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 0d4b6eb2..a5954b9d 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -35,4 +35,8 @@
+
+
+
+
diff --git a/benchmarks/Benchmark.Behaviors/Benchmark.cs b/benchmarks/Benchmark.Behaviors/Benchmark.cs
index e0b17f5f..01a432d2 100644
--- a/benchmarks/Benchmark.Behaviors/Benchmark.cs
+++ b/benchmarks/Benchmark.Behaviors/Benchmark.cs
@@ -77,7 +77,7 @@ public sealed record SomeRequest(Guid Id)
public sealed record SomeResponse(Guid Id);
-public class SomeService
+public sealed class SomeService
{
private static readonly SomeResponse s_response = new(Guid.NewGuid());
diff --git a/benchmarks/Benchmark.Large/Types.cs b/benchmarks/Benchmark.Large/Types.cs
index 1d3a731b..25a338e9 100644
--- a/benchmarks/Benchmark.Large/Types.cs
+++ b/benchmarks/Benchmark.Large/Types.cs
@@ -1,6 +1,7 @@
using Immediate.Handlers.Shared;
#pragma warning disable IDE0060
+#pragma warning disable MA0022
namespace Immediate.Handlers.Benchmarks;
diff --git a/samples/Normal/Behaviors.cs b/samples/Normal/Behaviors.cs
index 88eda20a..3ebca615 100644
--- a/samples/Normal/Behaviors.cs
+++ b/samples/Normal/Behaviors.cs
@@ -7,7 +7,7 @@
namespace Normal;
-public class LoggingBehavior(ILogger> logger)
+public sealed class LoggingBehavior(ILogger> logger)
: Behavior
{
public override async ValueTask HandleAsync(TRequest request, CancellationToken cancellationToken)
diff --git a/samples/Normal/GetWeatherForecast.cs b/samples/Normal/GetWeatherForecast.cs
index 9a0789a5..117eb528 100644
--- a/samples/Normal/GetWeatherForecast.cs
+++ b/samples/Normal/GetWeatherForecast.cs
@@ -19,9 +19,9 @@ public static partial class GetWeatherForecast
"Scorching",
];
- public record Query;
+ public sealed record Query;
- public record Response(DateOnly Date, int TemperatureC, string? Summary)
+ public sealed record Response(DateOnly Date, int TemperatureC, string? Summary)
{
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
}
diff --git a/src/Common/ITypeSymbolExtensions.cs b/src/Common/ITypeSymbolExtensions.cs
index ac56cb59..38cb625f 100644
--- a/src/Common/ITypeSymbolExtensions.cs
+++ b/src/Common/ITypeSymbolExtensions.cs
@@ -5,6 +5,25 @@ namespace Immediate.Handlers;
internal static class ITypeSymbolExtensions
{
+ public static bool IsHandlerAttribute(this ITypeSymbol? typeSymbol) =>
+ typeSymbol is
+ {
+ Name: "HandlerAttribute",
+ ContainingNamespace:
+ {
+ Name: "Shared",
+ ContainingNamespace:
+ {
+ Name: "Handlers",
+ ContainingNamespace:
+ {
+ Name: "Immediate",
+ ContainingNamespace.IsGlobalNamespace: true,
+ },
+ },
+ },
+ };
+
public static bool IsBehavior2(this ITypeSymbol typeSymbol) =>
typeSymbol is
{
diff --git a/src/Immediate.Handlers.Analyzers/HandlerClassAnalyzer.cs b/src/Immediate.Handlers.Analyzers/HandlerClassAnalyzer.cs
index 48d65a7c..6602000e 100644
--- a/src/Immediate.Handlers.Analyzers/HandlerClassAnalyzer.cs
+++ b/src/Immediate.Handlers.Analyzers/HandlerClassAnalyzer.cs
@@ -117,7 +117,7 @@ private static void AnalyzeSymbol(SymbolAnalysisContext context)
if (!namedTypeSymbol
.GetAttributes()
- .Any(x => x.AttributeClass?.ToString() == "Immediate.Handlers.Shared.HandlerAttribute")
+ .Any(x => x.AttributeClass.IsHandlerAttribute())
)
{
return;
@@ -178,10 +178,8 @@ private static void AnalyzeSymbol(SymbolAnalysisContext context)
case [var methodSymbol]:
{
token.ThrowIfCancellationRequested();
- if (methodSymbol.ReturnType is INamedTypeSymbol returnTypeSymbol
- && returnTypeSymbol.ConstructedFrom.ToString() is not (
- "System.Threading.Tasks.ValueTask"
- or "System.Threading.Tasks.ValueTask")
+ if (methodSymbol.ReturnType is INamedTypeSymbol { ConstructedFrom: { } from }
+ && !from.IsValueTask() && !from.IsValueTask1()
)
{
context.ReportDiagnostic(
diff --git a/src/Immediate.Handlers.CodeFixes/HandlerMethodMustExistCodeFixProvider.cs b/src/Immediate.Handlers.CodeFixes/HandlerMethodMustExistCodeFixProvider.cs
index fb04416d..09f697f9 100644
--- a/src/Immediate.Handlers.CodeFixes/HandlerMethodMustExistCodeFixProvider.cs
+++ b/src/Immediate.Handlers.CodeFixes/HandlerMethodMustExistCodeFixProvider.cs
@@ -11,7 +11,7 @@
namespace Immediate.Handlers.CodeFixes;
[ExportCodeFixProvider(LanguageNames.CSharp)]
-public class HandlerMethodMustExistCodeFixProvider : CodeFixProvider
+public sealed class HandlerMethodMustExistCodeFixProvider : CodeFixProvider
{
public override ImmutableArray FixableDiagnosticIds { get; } =
ImmutableArray.Create([DiagnosticIds.IHR0001HandlerMethodMustExist]);
diff --git a/src/Immediate.Handlers.Generators/ImmediateHandlersGenerator.Models.cs b/src/Immediate.Handlers.Generators/ImmediateHandlersGenerator.Models.cs
index fd23146e..216070ff 100644
--- a/src/Immediate.Handlers.Generators/ImmediateHandlersGenerator.Models.cs
+++ b/src/Immediate.Handlers.Generators/ImmediateHandlersGenerator.Models.cs
@@ -4,7 +4,7 @@
namespace Immediate.Handlers.Generators.ImmediateHandlers;
-public partial class ImmediateHandlersGenerator
+public sealed partial class ImmediateHandlersGenerator
{
[ExcludeFromCodeCoverage]
private sealed record Behavior
diff --git a/src/Immediate.Handlers.Generators/ImmediateHandlersGenerator.TransformBehaviors.cs b/src/Immediate.Handlers.Generators/ImmediateHandlersGenerator.TransformBehaviors.cs
index dc1d0985..4adcd15e 100644
--- a/src/Immediate.Handlers.Generators/ImmediateHandlersGenerator.TransformBehaviors.cs
+++ b/src/Immediate.Handlers.Generators/ImmediateHandlersGenerator.TransformBehaviors.cs
@@ -2,7 +2,7 @@
namespace Immediate.Handlers.Generators.ImmediateHandlers;
-public partial class ImmediateHandlersGenerator
+public sealed partial class ImmediateHandlersGenerator
{
private static EquatableReadOnlyList TransformBehaviors(
GeneratorAttributeSyntaxContext context,
@@ -132,7 +132,7 @@ private static (bool Valid, string? Constraint) GetConstraintType(ITypeParameter
ITypeParameterSymbol s,
]
}
- && s.Name == parameter.Name
+ && s.Name.Equals(parameter.Name, StringComparison.OrdinalIgnoreCase)
)
{
displayString = displayString.Replace(parameter.Name, "_TRequest_");
diff --git a/src/Immediate.Handlers.Generators/ImmediateHandlersGenerator.TransformHandler.cs b/src/Immediate.Handlers.Generators/ImmediateHandlersGenerator.TransformHandler.cs
index c346725a..2e185eb1 100644
--- a/src/Immediate.Handlers.Generators/ImmediateHandlersGenerator.TransformHandler.cs
+++ b/src/Immediate.Handlers.Generators/ImmediateHandlersGenerator.TransformHandler.cs
@@ -4,7 +4,7 @@
namespace Immediate.Handlers.Generators.ImmediateHandlers;
-public partial class ImmediateHandlersGenerator
+public sealed partial class ImmediateHandlersGenerator
{
private static Handler? TransformHandler(
GeneratorAttributeSyntaxContext context,
@@ -111,7 +111,7 @@ CancellationToken cancellationToken
return new()
{
Name = name,
- Implements = implements.Distinct().ToEquatableReadOnlyList(),
+ Implements = implements.Distinct(StringComparer.Ordinal).ToEquatableReadOnlyList(),
};
}
diff --git a/src/Immediate.Handlers.Generators/ImmediateHandlersGenerator.cs b/src/Immediate.Handlers.Generators/ImmediateHandlersGenerator.cs
index c8dbd643..84560276 100644
--- a/src/Immediate.Handlers.Generators/ImmediateHandlersGenerator.cs
+++ b/src/Immediate.Handlers.Generators/ImmediateHandlersGenerator.cs
@@ -7,7 +7,7 @@
namespace Immediate.Handlers.Generators.ImmediateHandlers;
[Generator]
-public partial class ImmediateHandlersGenerator : IIncrementalGenerator
+public sealed partial class ImmediateHandlersGenerator : IIncrementalGenerator
{
public void Initialize(IncrementalGeneratorInitializationContext context)
{
@@ -191,8 +191,10 @@ Template template
GenericType responseType,
IEnumerable enumerable) =>
enumerable
- .Where(b => b is null || ValidateType(b.RequestType, requestType))
- .Where(b => b is null || ValidateType(b.ResponseType, responseType))
+ .Where(b =>
+ (b is null || ValidateType(b.RequestType, requestType))
+ && (b is null || ValidateType(b.ResponseType, responseType))
+ )
.ToList();
private sealed record RenderBehavior
@@ -203,7 +205,7 @@ private sealed record RenderBehavior
private static List BuildRenderBehaviors(List pipelineBehaviors)
{
- var typesCount = new Dictionary()
+ var typesCount = new Dictionary(StringComparer.Ordinal)
{
["HandleBehavior"] = 1,
};
@@ -224,7 +226,7 @@ string GetVariableNameSuffix(string typeName)
NonGenericTypeName = b!.NonGenericTypeName,
VariableName = b.Name[0..1].ToLowerInvariant()
+ b.Name[1..]
- + GetVariableNameSuffix(b.Name)
+ + GetVariableNameSuffix(b.Name),
})
.ToList();
#pragma warning restore CA1308 // Normalize strings to uppercase
@@ -234,7 +236,7 @@ string GetVariableNameSuffix(string typeName)
private static bool ValidateType(string? type, GenericType implementedTypes) =>
type is null
- || implementedTypes.Implements.Contains(type.Replace("_TRequest_", implementedTypes.Name));
+ || implementedTypes.Implements.Contains(type.Replace("_TRequest_", implementedTypes.Name), StringComparer.Ordinal);
private static Template GetTemplate(string name)
{
diff --git a/tests/Immediate.Handlers.FunctionalTests/Behavior/Constraints/Tests.Base.cs b/tests/Immediate.Handlers.FunctionalTests/Behavior/Constraints/Tests.Base.cs
index 3b7a55f1..e9b506d6 100644
--- a/tests/Immediate.Handlers.FunctionalTests/Behavior/Constraints/Tests.Base.cs
+++ b/tests/Immediate.Handlers.FunctionalTests/Behavior/Constraints/Tests.Base.cs
@@ -27,12 +27,12 @@ private static IServiceCollection ConfigureBehaviors(IServiceCollection services
}
}
-public class BehaviorWalker
+public sealed class BehaviorWalker
{
public IList BehaviorsRan { get; init; } = [];
}
-public class BehaviorA(BehaviorWalker walker) : Behavior where TRequest : A
+public sealed class BehaviorA(BehaviorWalker walker) : Behavior where TRequest : A
{
public override async ValueTask HandleAsync(TRequest request, CancellationToken cancellationToken)
{
@@ -41,7 +41,7 @@ public override async ValueTask HandleAsync(TRequest request, Cancell
}
}
-public class BehaviorB(BehaviorWalker walker) : Behavior where TRequest : B
+public sealed class BehaviorB(BehaviorWalker walker) : Behavior where TRequest : B
{
public override async ValueTask HandleAsync(TRequest request, CancellationToken cancellationToken)
{
@@ -50,7 +50,7 @@ public override async ValueTask HandleAsync(TRequest request, Cancell
}
}
-public class BehaviorC(BehaviorWalker walker) : Behavior where TRequest : C
+public sealed class BehaviorC(BehaviorWalker walker) : Behavior where TRequest : C
{
public override async ValueTask HandleAsync(TRequest request, CancellationToken cancellationToken)
{
@@ -59,7 +59,7 @@ public override async ValueTask HandleAsync(TRequest request, Cancell
}
}
-public class BehaviorD(BehaviorWalker walker) : Behavior where TRequest : D
+public sealed class BehaviorD(BehaviorWalker walker) : Behavior where TRequest : D
{
public override async ValueTask HandleAsync(TRequest request, CancellationToken cancellationToken)
{
diff --git a/tests/Immediate.Handlers.FunctionalTests/HandlerAbstraction/HandlerAbstractionTests.cs b/tests/Immediate.Handlers.FunctionalTests/HandlerAbstraction/HandlerAbstractionTests.cs
index e1b1f9d2..d15e2323 100644
--- a/tests/Immediate.Handlers.FunctionalTests/HandlerAbstraction/HandlerAbstractionTests.cs
+++ b/tests/Immediate.Handlers.FunctionalTests/HandlerAbstraction/HandlerAbstractionTests.cs
@@ -15,7 +15,7 @@ private static ValueTask HandleAsync(
}
}
-public class HandlerAbstractionTests
+public sealed class HandlerAbstractionTests
{
[Test]
public async Task NoBehaviorShouldReturnExpectedResponseForAbstraction()
diff --git a/tests/Immediate.Handlers.FunctionalTests/MultipleBehaviors/MultipleBehaviorsTests.cs b/tests/Immediate.Handlers.FunctionalTests/MultipleBehaviors/MultipleBehaviorsTests.cs
index 24c5b398..89af29fb 100644
--- a/tests/Immediate.Handlers.FunctionalTests/MultipleBehaviors/MultipleBehaviorsTests.cs
+++ b/tests/Immediate.Handlers.FunctionalTests/MultipleBehaviors/MultipleBehaviorsTests.cs
@@ -2,7 +2,7 @@
namespace Immediate.Handlers.FunctionalTests.MultipleBehaviors;
-public class Behavior1 : Behavior
+public sealed class Behavior1 : Behavior
where TRequest : List
{
public override async ValueTask HandleAsync(TRequest request, CancellationToken cancellationToken)
@@ -17,7 +17,7 @@ public override async ValueTask HandleAsync(TRequest request, Cancell
}
}
-public class Behavior2 : Behavior
+public sealed class Behavior2 : Behavior
where TRequest : List
{
public override async ValueTask HandleAsync(TRequest request, CancellationToken cancellationToken)
@@ -40,7 +40,7 @@ public override async ValueTask HandleAsync(TRequest request, Cancell
)]
public static partial class MultipleBehaviorHandler
{
- public class Query : List;
+ public sealed class Query : List;
private static async ValueTask HandleAsync(Query query, CancellationToken cancellationToken)
{
diff --git a/tests/Immediate.Handlers.FunctionalTests/NoBehaviors/ParameterizedTests.cs b/tests/Immediate.Handlers.FunctionalTests/NoBehaviors/ParameterizedTests.cs
index 09e2a64b..35f99550 100644
--- a/tests/Immediate.Handlers.FunctionalTests/NoBehaviors/ParameterizedTests.cs
+++ b/tests/Immediate.Handlers.FunctionalTests/NoBehaviors/ParameterizedTests.cs
@@ -19,7 +19,7 @@ private static ValueTask Handle(
public record AddendProvider(int Addend);
-public class ParameterizedTests
+public sealed class ParameterizedTests
{
[Test]
public async Task NoBehaviorShouldReturnExpectedResponse()
diff --git a/tests/Immediate.Handlers.FunctionalTests/NoBehaviors/ParameterlessTests.cs b/tests/Immediate.Handlers.FunctionalTests/NoBehaviors/ParameterlessTests.cs
index e8a8e9fe..ed612329 100644
--- a/tests/Immediate.Handlers.FunctionalTests/NoBehaviors/ParameterlessTests.cs
+++ b/tests/Immediate.Handlers.FunctionalTests/NoBehaviors/ParameterlessTests.cs
@@ -28,7 +28,7 @@ Query query
}
}
-public class ParameterlessTests
+public sealed class ParameterlessTests
{
[Test]
public async Task NoBehaviorShouldReturnExpectedResponse()
diff --git a/tests/Immediate.Handlers.Tests/AnalyzerTests/BehaviorAnalyzerTests/Tests.BehaviorTypeDoesNotUseUnboundedReference.cs b/tests/Immediate.Handlers.Tests/AnalyzerTests/BehaviorAnalyzerTests/Tests.BehaviorTypeDoesNotUseUnboundedReference.cs
index fee22cd9..58efccbf 100644
--- a/tests/Immediate.Handlers.Tests/AnalyzerTests/BehaviorAnalyzerTests/Tests.BehaviorTypeDoesNotUseUnboundedReference.cs
+++ b/tests/Immediate.Handlers.Tests/AnalyzerTests/BehaviorAnalyzerTests/Tests.BehaviorTypeDoesNotUseUnboundedReference.cs
@@ -4,7 +4,7 @@
namespace Immediate.Handlers.Tests.AnalyzerTests.BehaviorAnalyzerTests;
[System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1724:Type names should not match namespaces", Justification = "Not being consumed by other code")]
-public partial class Tests
+public sealed partial class Tests
{
[Test]
public async Task BehaviorTypeDoesNotUseUnboundedReference_Alerts() =>
diff --git a/tests/Immediate.Handlers.Tests/AnalyzerTests/BehaviorAnalyzerTests/Tests.BehaviorTypeIsValid.cs b/tests/Immediate.Handlers.Tests/AnalyzerTests/BehaviorAnalyzerTests/Tests.BehaviorTypeIsValid.cs
index 359062ba..0f2103e6 100644
--- a/tests/Immediate.Handlers.Tests/AnalyzerTests/BehaviorAnalyzerTests/Tests.BehaviorTypeIsValid.cs
+++ b/tests/Immediate.Handlers.Tests/AnalyzerTests/BehaviorAnalyzerTests/Tests.BehaviorTypeIsValid.cs
@@ -4,7 +4,7 @@
namespace Immediate.Handlers.Tests.AnalyzerTests.BehaviorAnalyzerTests;
[System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1724:Type names should not match namespaces", Justification = "Not being consumed by other code")]
-public partial class Tests
+public sealed partial class Tests
{
[Test]
public async Task BehaviorTypeIsValid_DoesNotAlert() =>
diff --git a/tests/Immediate.Handlers.Tests/AnalyzerTests/HandlerClassAnalyzerTests/Tests.HandlerClassNested.cs b/tests/Immediate.Handlers.Tests/AnalyzerTests/HandlerClassAnalyzerTests/Tests.HandlerClassNested.cs
index 37d5772a..038c07ed 100644
--- a/tests/Immediate.Handlers.Tests/AnalyzerTests/HandlerClassAnalyzerTests/Tests.HandlerClassNested.cs
+++ b/tests/Immediate.Handlers.Tests/AnalyzerTests/HandlerClassAnalyzerTests/Tests.HandlerClassNested.cs
@@ -3,7 +3,7 @@
namespace Immediate.Handlers.Tests.AnalyzerTests.HandlerClassAnalyzerTests;
-public partial class Tests
+public sealed partial class Tests
{
[Test]
public async Task HandlerClassNested_DoesAlert() =>
diff --git a/tests/Immediate.Handlers.Tests/CodeFixTests/Tests.HandleMethodDoesNotExist.cs b/tests/Immediate.Handlers.Tests/CodeFixTests/Tests.HandleMethodDoesNotExist.cs
index 4dca9420..1b9a3116 100644
--- a/tests/Immediate.Handlers.Tests/CodeFixTests/Tests.HandleMethodDoesNotExist.cs
+++ b/tests/Immediate.Handlers.Tests/CodeFixTests/Tests.HandleMethodDoesNotExist.cs
@@ -5,7 +5,7 @@
namespace Immediate.Handlers.Tests.CodeFixTests;
[System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1724:Type names should not match namespaces", Justification = "Not being consumed by other code")]
-public partial class Tests
+public sealed partial class Tests
{
[Test]
public async Task HandleMethodDoesNotExist() =>
diff --git a/tests/Immediate.Handlers.Tests/GeneratorTests/BehaviorTests.cs b/tests/Immediate.Handlers.Tests/GeneratorTests/BehaviorTests.cs
index fc39a720..501f12ca 100644
--- a/tests/Immediate.Handlers.Tests/GeneratorTests/BehaviorTests.cs
+++ b/tests/Immediate.Handlers.Tests/GeneratorTests/BehaviorTests.cs
@@ -79,14 +79,14 @@ public interface ILogger;
DriverReferenceAssemblies.Msdi =>
["Immediate.Handlers.Generators/Immediate.Handlers.Generators.ImmediateHandlers.ImmediateHandlersGenerator/IH.ServiceCollectionExtensions.g.cs"],
- _ => throw new UnreachableException(),
+ DriverReferenceAssemblies.None or _ => throw new UnreachableException(),
},
],
- result.GeneratedTrees.Select(t => t.FilePath.Replace("\\", "/", StringComparison.Ordinal))
+ result.GeneratedTrees.Select(t => t.FilePath.Replace('\\', '/'))
);
_ = await Verify(result)
- .UseParameters(string.Join("_", assemblies));
+ .UseParameters(string.Join('_', assemblies));
}
[Test]
@@ -228,14 +228,14 @@ public interface ILogger;
DriverReferenceAssemblies.Msdi =>
["Immediate.Handlers.Generators/Immediate.Handlers.Generators.ImmediateHandlers.ImmediateHandlersGenerator/IH.ServiceCollectionExtensions.g.cs"],
- _ => throw new UnreachableException(),
+ DriverReferenceAssemblies.None or _ => throw new UnreachableException(),
},
],
- result.GeneratedTrees.Select(t => t.FilePath.Replace("\\", "/", StringComparison.Ordinal))
+ result.GeneratedTrees.Select(t => t.FilePath.Replace('\\', '/'))
);
_ = await Verify(result)
- .UseParameters(string.Join("_", assemblies));
+ .UseParameters(string.Join('_', assemblies));
}
[Test]
@@ -297,13 +297,13 @@ CancellationToken __
DriverReferenceAssemblies.Msdi =>
["Immediate.Handlers.Generators/Immediate.Handlers.Generators.ImmediateHandlers.ImmediateHandlersGenerator/IH.ServiceCollectionExtensions.g.cs"],
- _ => throw new UnreachableException(),
+ DriverReferenceAssemblies.None or _ => throw new UnreachableException(),
},
],
- result.GeneratedTrees.Select(t => t.FilePath.Replace("\\", "/", StringComparison.Ordinal))
+ result.GeneratedTrees.Select(t => t.FilePath.Replace('\\', '/'))
);
_ = await Verify(result)
- .UseParameters(string.Join("_", assemblies));
+ .UseParameters(string.Join('_', assemblies));
}
}
diff --git a/tests/Immediate.Handlers.Tests/GeneratorTests/HandlerTests.cs b/tests/Immediate.Handlers.Tests/GeneratorTests/HandlerTests.cs
index f8175c3f..69511c75 100644
--- a/tests/Immediate.Handlers.Tests/GeneratorTests/HandlerTests.cs
+++ b/tests/Immediate.Handlers.Tests/GeneratorTests/HandlerTests.cs
@@ -2,7 +2,7 @@
namespace Immediate.Handlers.Tests.GeneratorTests;
-public class HandlerTests
+public sealed class HandlerTests
{
[Test]
[Arguments(DriverReferenceAssemblies.Normal)]
@@ -36,11 +36,11 @@ private static ValueTask HandleAsync(
[
"Immediate.Handlers.Generators/Immediate.Handlers.Generators.ImmediateHandlers.ImmediateHandlersGenerator/IH.Dummy.GetUsersQuery.g.cs",
],
- result.GeneratedTrees.Select(t => t.FilePath.Replace("\\", "/", StringComparison.Ordinal))
+ result.GeneratedTrees.Select(t => t.FilePath.Replace('\\', '/'))
);
_ = await Verify(result)
- .UseParameters(string.Join("_", assemblies));
+ .UseParameters(string.Join('_', assemblies));
}
[Test]
@@ -75,11 +75,11 @@ private static ValueTask HandleAsync(
[
"Immediate.Handlers.Generators/Immediate.Handlers.Generators.ImmediateHandlers.ImmediateHandlersGenerator/IH.Dummy.GetUsersQuery.g.cs",
],
- result.GeneratedTrees.Select(t => t.FilePath.Replace("\\", "/", StringComparison.Ordinal))
+ result.GeneratedTrees.Select(t => t.FilePath.Replace('\\', '/'))
);
_ = await Verify(result)
- .UseParameters(string.Join("_", assemblies));
+ .UseParameters(string.Join('_', assemblies));
}
[Test]
@@ -114,11 +114,11 @@ Query _
[
"Immediate.Handlers.Generators/Immediate.Handlers.Generators.ImmediateHandlers.ImmediateHandlersGenerator/IH.Dummy.GetUsersQuery.g.cs",
],
- result.GeneratedTrees.Select(t => t.FilePath.Replace("\\", "/", StringComparison.Ordinal))
+ result.GeneratedTrees.Select(t => t.FilePath.Replace('\\', '/'))
);
_ = await Verify(result)
- .UseParameters(string.Join("_", assemblies));
+ .UseParameters(string.Join('_', assemblies));
}
[Test]
@@ -158,11 +158,11 @@ private static ValueTask HandleAsync(
"Immediate.Handlers.Generators/Immediate.Handlers.Generators.ImmediateHandlers.ImmediateHandlersGenerator/IH.Dummy.GetUsersQuery.g.cs",
"Immediate.Handlers.Generators/Immediate.Handlers.Generators.ImmediateHandlers.ImmediateHandlersGenerator/IH.ServiceCollectionExtensions.g.cs",
],
- result.GeneratedTrees.Select(t => t.FilePath.Replace("\\", "/", StringComparison.Ordinal))
+ result.GeneratedTrees.Select(t => t.FilePath.Replace('\\', '/'))
);
_ = await Verify(result)
- .UseParameters(string.Join("_", assemblies));
+ .UseParameters(string.Join('_', assemblies));
}
[Test]
@@ -212,11 +212,11 @@ private static ValueTask HandleAsync(
"Immediate.Handlers.Generators/Immediate.Handlers.Generators.ImmediateHandlers.ImmediateHandlersGenerator/IH.Dummy.GetUsersQuery.g.cs",
"Immediate.Handlers.Generators/Immediate.Handlers.Generators.ImmediateHandlers.ImmediateHandlersGenerator/IH.ServiceCollectionExtensions.g.cs",
],
- result.GeneratedTrees.Select(t => t.FilePath.Replace("\\", "/", StringComparison.Ordinal))
+ result.GeneratedTrees.Select(t => t.FilePath.Replace('\\', '/'))
);
_ = await Verify(result)
- .UseParameters(string.Join("_", assemblies));
+ .UseParameters(string.Join('_', assemblies));
}
[Test]
@@ -265,11 +265,11 @@ private static ValueTask HandleAsync(
"Immediate.Handlers.Generators/Immediate.Handlers.Generators.ImmediateHandlers.ImmediateHandlersGenerator/IH.Dummy.GetUsersQuery.g.cs",
"Immediate.Handlers.Generators/Immediate.Handlers.Generators.ImmediateHandlers.ImmediateHandlersGenerator/IH.ServiceCollectionExtensions.g.cs",
],
- result.GeneratedTrees.Select(t => t.FilePath.Replace("\\", "/", StringComparison.Ordinal))
+ result.GeneratedTrees.Select(t => t.FilePath.Replace('\\', '/'))
);
_ = await Verify(result)
- .UseParameters(string.Join("_", assemblies));
+ .UseParameters(string.Join('_', assemblies));
}
[Test]
@@ -290,6 +290,6 @@ public sealed class Test;
);
_ = await Verify(result)
- .UseParameters(string.Join("_", assemblies));
+ .UseParameters(string.Join('_', assemblies));
}
}
diff --git a/tests/Immediate.Handlers.Tests/GeneratorTests/InvalidBehaviorsTests.cs b/tests/Immediate.Handlers.Tests/GeneratorTests/InvalidBehaviorsTests.cs
index 2f418eeb..e91a25b2 100644
--- a/tests/Immediate.Handlers.Tests/GeneratorTests/InvalidBehaviorsTests.cs
+++ b/tests/Immediate.Handlers.Tests/GeneratorTests/InvalidBehaviorsTests.cs
@@ -2,7 +2,7 @@
namespace Immediate.Handlers.Tests.GeneratorTests;
-public class InvalidBehaviorsTests
+public sealed class InvalidBehaviorsTests
{
[Test]
[Arguments(DriverReferenceAssemblies.Normal)]
@@ -63,11 +63,11 @@ public interface ILogger;
Assert.Equal(
[],
- result.GeneratedTrees.Select(t => t.FilePath.Replace("\\", "/", StringComparison.Ordinal))
+ result.GeneratedTrees.Select(t => t.FilePath.Replace('\\', '/'))
);
_ = await Verify(result)
- .UseParameters(string.Join("_", assemblies));
+ .UseParameters(string.Join('_', assemblies));
}
[Test]
@@ -130,11 +130,11 @@ public interface ILogger;
Assert.Equal(
[],
- result.GeneratedTrees.Select(t => t.FilePath.Replace("\\", "/", StringComparison.Ordinal))
+ result.GeneratedTrees.Select(t => t.FilePath.Replace('\\', '/'))
);
_ = await Verify(result)
- .UseParameters(string.Join("_", assemblies));
+ .UseParameters(string.Join('_', assemblies));
}
[Test]
@@ -197,11 +197,11 @@ public interface ILogger;
Assert.Equal(
[],
- result.GeneratedTrees.Select(t => t.FilePath.Replace("\\", "/", StringComparison.Ordinal))
+ result.GeneratedTrees.Select(t => t.FilePath.Replace('\\', '/'))
);
_ = await Verify(result)
- .UseParameters(string.Join("_", assemblies));
+ .UseParameters(string.Join('_', assemblies));
}
[Test]
@@ -256,11 +256,11 @@ public interface ILogger;
Assert.Equal(
[],
- result.GeneratedTrees.Select(t => t.FilePath.Replace("\\", "/", StringComparison.Ordinal))
+ result.GeneratedTrees.Select(t => t.FilePath.Replace('\\', '/'))
);
_ = await Verify(result)
- .UseParameters(string.Join("_", assemblies));
+ .UseParameters(string.Join('_', assemblies));
}
[Test]
@@ -325,11 +325,11 @@ public interface ILogger;
Assert.Equal(
[],
- result.GeneratedTrees.Select(t => t.FilePath.Replace("\\", "/", StringComparison.Ordinal))
+ result.GeneratedTrees.Select(t => t.FilePath.Replace('\\', '/'))
);
_ = await Verify(result)
- .UseParameters(string.Join("_", assemblies));
+ .UseParameters(string.Join('_', assemblies));
}
[Test]
@@ -394,11 +394,11 @@ public interface ILogger;
Assert.Equal(
[],
- result.GeneratedTrees.Select(t => t.FilePath.Replace("\\", "/", StringComparison.Ordinal))
+ result.GeneratedTrees.Select(t => t.FilePath.Replace('\\', '/'))
);
_ = await Verify(result)
- .UseParameters(string.Join("_", assemblies));
+ .UseParameters(string.Join('_', assemblies));
}
[Test]
@@ -461,10 +461,10 @@ public interface ILogger;
Assert.Equal(
[],
- result.GeneratedTrees.Select(t => t.FilePath.Replace("\\", "/", StringComparison.Ordinal))
+ result.GeneratedTrees.Select(t => t.FilePath.Replace('\\', '/'))
);
_ = await Verify(result)
- .UseParameters(string.Join("_", assemblies));
+ .UseParameters(string.Join('_', assemblies));
}
}
diff --git a/tests/Immediate.Handlers.Tests/GeneratorTests/InvalidHandlerTests.cs b/tests/Immediate.Handlers.Tests/GeneratorTests/InvalidHandlerTests.cs
index 0b31d626..0566935b 100644
--- a/tests/Immediate.Handlers.Tests/GeneratorTests/InvalidHandlerTests.cs
+++ b/tests/Immediate.Handlers.Tests/GeneratorTests/InvalidHandlerTests.cs
@@ -2,7 +2,7 @@
namespace Immediate.Handlers.Tests.GeneratorTests;
-public class InvalidHandlerTests
+public sealed class InvalidHandlerTests
{
[Test]
[Arguments(DriverReferenceAssemblies.Normal)]
@@ -31,11 +31,11 @@ public record Query;
Assert.Equal(
[],
- result.GeneratedTrees.Select(t => t.FilePath.Replace("\\", "/", StringComparison.Ordinal))
+ result.GeneratedTrees.Select(t => t.FilePath.Replace('\\', '/'))
);
_ = await Verify(result)
- .UseParameters(string.Join("_", assemblies));
+ .UseParameters(string.Join('_', assemblies));
}
[Test]
@@ -90,11 +90,11 @@ public interface ILogger;
Assert.Equal(
[],
- result.GeneratedTrees.Select(t => t.FilePath.Replace("\\", "/", StringComparison.Ordinal))
+ result.GeneratedTrees.Select(t => t.FilePath.Replace('\\', '/'))
);
_ = await Verify(result)
- .UseParameters(string.Join("_", assemblies));
+ .UseParameters(string.Join('_', assemblies));
}
[Test]
@@ -138,11 +138,11 @@ public interface ILogger;
Assert.Equal(
[],
- result.GeneratedTrees.Select(t => t.FilePath.Replace("\\", "/", StringComparison.Ordinal))
+ result.GeneratedTrees.Select(t => t.FilePath.Replace('\\', '/'))
);
_ = await Verify(result)
- .UseParameters(string.Join("_", assemblies));
+ .UseParameters(string.Join('_', assemblies));
}
[Test]
@@ -188,11 +188,11 @@ public interface ILogger;
Assert.Equal(
[],
- result.GeneratedTrees.Select(t => t.FilePath.Replace("\\", "/", StringComparison.Ordinal))
+ result.GeneratedTrees.Select(t => t.FilePath.Replace('\\', '/'))
);
_ = await Verify(result)
- .UseParameters(string.Join("_", assemblies));
+ .UseParameters(string.Join('_', assemblies));
}
[Test]
@@ -239,11 +239,11 @@ public interface ILogger;
Assert.Equal(
[],
- result.GeneratedTrees.Select(t => t.FilePath.Replace("\\", "/", StringComparison.Ordinal))
+ result.GeneratedTrees.Select(t => t.FilePath.Replace('\\', '/'))
);
_ = await Verify(result)
- .UseParameters(string.Join("_", assemblies));
+ .UseParameters(string.Join('_', assemblies));
}
[Test]
@@ -293,10 +293,10 @@ public interface ILogger;
Assert.Equal(
[],
- result.GeneratedTrees.Select(t => t.FilePath.Replace("\\", "/", StringComparison.Ordinal))
+ result.GeneratedTrees.Select(t => t.FilePath.Replace('\\', '/'))
);
_ = await Verify(result)
- .UseParameters(string.Join("_", assemblies));
+ .UseParameters(string.Join('_', assemblies));
}
}
diff --git a/tests/Immediate.Handlers.Tests/Helpers/ReferenceAssemblyHelpers.cs b/tests/Immediate.Handlers.Tests/Helpers/ReferenceAssemblyHelpers.cs
index 2360b46e..f6965513 100644
--- a/tests/Immediate.Handlers.Tests/Helpers/ReferenceAssemblyHelpers.cs
+++ b/tests/Immediate.Handlers.Tests/Helpers/ReferenceAssemblyHelpers.cs
@@ -1,3 +1,4 @@
+using System.Diagnostics;
using Microsoft.CodeAnalysis;
namespace Immediate.Handlers.Tests.Helpers;
@@ -25,12 +26,13 @@ public static IEnumerable GetAdditionalReferences(this Driver
return references;
// to be done with other renderers
- throw new NotImplementedException();
+ throw new UnreachableException();
}
}
public enum DriverReferenceAssemblies
{
+ None = 0,
Normal,
Msdi,
}