diff --git a/.build/Build.CI.cs b/.build/Build.CI.cs index 5cae5fa93..67857eddb 100644 --- a/.build/Build.CI.cs +++ b/.build/Build.CI.cs @@ -63,7 +63,7 @@ public static RocketSurgeonGitHubActionsConfiguration CiMiddleware(RocketSurgeon .ExcludeRepositoryConfigurationFiles() .Jobs.OfType() .First(z => z.Name.Equals("build", StringComparison.OrdinalIgnoreCase)); - _ = job + job .UseDotNetSdks("8.0", "9.0") .ConfigureStep(step => step.FetchDepth = 0) .PublishLogs(); @@ -73,7 +73,7 @@ public static RocketSurgeonGitHubActionsConfiguration CiMiddleware(RocketSurgeon public static RocketSurgeonGitHubActionsConfiguration LintStagedMiddleware(RocketSurgeonGitHubActionsConfiguration configuration) { - _ = configuration + configuration .Jobs.OfType() .First(z => z.Name.Equals("Build", StringComparison.OrdinalIgnoreCase)) .UseDotNetSdks("8.0", "9.0"); diff --git a/.editorconfig b/.editorconfig index 68e73b940..c554e22ab 100644 --- a/.editorconfig +++ b/.editorconfig @@ -2577,7 +2577,7 @@ roslynator_trailing_comma_style = omit_when_single_line roslynator_unity_code_analysis.enabled = false # Applicable to: rcs1169, rcs1213 -roslynator_use_anonymous_function_or_method_group = anonymous_function +roslynator_use_anonymous_function_or_method_group = method_group # Applicable to: rcs1207 roslynator_use_block_body_when_declaration_spans_over_multiple_lines = true @@ -4575,7 +4575,7 @@ resharper_braces_redundant = true resharper_break_template_declaration = line_break resharper_builtin_type_apply_to_native_integer = false resharper_can_use_global_alias = true -resharper_configure_await_analysis_mode = disabled +resharper_configure_await_analysis_mode = enabled resharper_constructor_or_destructor_body = block_body resharper_continuous_indent_multiplier = 1 resharper_continuous_line_indent = single diff --git a/sample/Sample.BlazorServer/Program.cs b/sample/Sample.BlazorServer/Program.cs index 7a26b6b60..e4cfafa2b 100644 --- a/sample/Sample.BlazorServer/Program.cs +++ b/sample/Sample.BlazorServer/Program.cs @@ -13,13 +13,13 @@ if (builder.Environment.IsDevelopment()) { - _ = app.UseDeveloperExceptionPage(); + app.UseDeveloperExceptionPage(); } else { - _ = app.UseExceptionHandler("/Error"); + app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. - _ = app.UseHsts(); + app.UseHsts(); } app.UseHttpsRedirection(); diff --git a/sample/Sample.BlazorWasm/Program.cs b/sample/Sample.BlazorWasm/Program.cs index 63aec726b..4bbd8dae4 100644 --- a/sample/Sample.BlazorWasm/Program.cs +++ b/sample/Sample.BlazorWasm/Program.cs @@ -15,33 +15,19 @@ public static class TestHandler { - [System.Diagnostics.DebuggerDisplay("{DebuggerDisplay,nq}")] + public record Request : IRequest { public string FirstName { get; set; } = null!; public string LastName { get; set; } = null!; - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - private string DebuggerDisplay - { - get - { - return ToString(); - } - } + } - [System.Diagnostics.DebuggerDisplay("{DebuggerDisplay,nq}")] + public record Response(string FullName) { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - private string DebuggerDisplay - { - get - { - return ToString(); - } - } + } [UsedImplicitly] @@ -49,11 +35,11 @@ private class RequestValidator : AbstractValidator { public RequestValidator() { - _ = RuleFor(x => x.FirstName) + RuleFor(x => x.FirstName) .NotEmpty() .MinimumLength(1) .MaximumLength(20); - _ = RuleFor(x => x.LastName) + RuleFor(x => x.LastName) .NotEmpty() .MinimumLength(1) .MaximumLength(50); diff --git a/sample/Sample.Command/Program.cs b/sample/Sample.Command/Program.cs index 30ec4e90a..a6061b7fb 100644 --- a/sample/Sample.Command/Program.cs +++ b/sample/Sample.Command/Program.cs @@ -28,34 +28,17 @@ ); await host.RunAsync(); -[System.Diagnostics.DebuggerDisplay("{DebuggerDisplay,nq}")] + public class InstanceThing { public string From => "DryIoc"; - - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - private string DebuggerDisplay - { - get - { - return ToString(); - } - } } -[System.Diagnostics.DebuggerDisplay("{DebuggerDisplay,nq}")] -[System.Diagnostics.DebuggerDisplay("{DebuggerDisplay,nq}")] + + public class Dump(IConfiguration configuration, ILogger logger, InstanceThing instanceThing) : Command { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - private string DebuggerDisplay - { - get - { - return ToString(); - } - } public override int Execute([NotNull] CommandContext context, [NotNull] AppSettings settings) { @@ -72,14 +55,6 @@ public override int Execute([NotNull] CommandContext context, [NotNull] AppSetti public class DefaultCommand(ILogger logger) : Command { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - private string DebuggerDisplay - { - get - { - return ToString(); - } - } public override int Execute([NotNull] CommandContext context, [NotNull] AppSettings settings) { diff --git a/sample/Sample.Pages/Program.cs b/sample/Sample.Pages/Program.cs index 61fc5bcb7..90fda5f25 100644 --- a/sample/Sample.Pages/Program.cs +++ b/sample/Sample.Pages/Program.cs @@ -16,13 +16,13 @@ if (builder.Environment.IsDevelopment()) { - _ = app.UseDeveloperExceptionPage(); + app.UseDeveloperExceptionPage(); } else { - _ = app.UseExceptionHandler("/Error"); + app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. - _ = app.UseHsts(); + app.UseHsts(); } app.UseHttpsRedirection(); diff --git a/sample/Sample.Pages/wwwroot/lib/bootstrap/dist/js/bootstrap.bundle.min.js b/sample/Sample.Pages/wwwroot/lib/bootstrap/dist/js/bootstrap.bundle.min.js index 9b8cf877f..bada25154 100644 --- a/sample/Sample.Pages/wwwroot/lib/bootstrap/dist/js/bootstrap.bundle.min.js +++ b/sample/Sample.Pages/wwwroot/lib/bootstrap/dist/js/bootstrap.bundle.min.js @@ -1399,7 +1399,7 @@ (t.offsets.popper = Vt(t.offsets.popper)); var m = a[u] + a[c] / 2 - p / 2, g = Nt(t.instance.popper), - _ = parseFloat(g['margin' + h], 10), + parseFloat(g['margin' + h], 10), v = parseFloat(g['border' + h + 'Width'], 10), y = m - t.offsets.popper[u] - _ - v; return ( @@ -1418,7 +1418,7 @@ if (oe(p.instance.modifiers, 'inner')) return p; if (p.flipped && p.placement === p.originalPlacement) return p; var g = Gt(p.instance.popper, p.instance.reference, m.padding, m.boundariesElement, p.positionFixed), - _ = p.placement.split('-')[0], + p.placement.split('-')[0], v = te(_), y = p.placement.split('-')[1] || '', E = []; diff --git a/sample/Sample.Restful/Program.cs b/sample/Sample.Restful/Program.cs index 7aa3ec5a4..21fcd42e5 100644 --- a/sample/Sample.Restful/Program.cs +++ b/sample/Sample.Restful/Program.cs @@ -69,7 +69,7 @@ internal class CustomHostedService(IOptions options) protected override Task ExecuteAsync(CancellationToken stoppingToken) { // ReSharper disable once UnusedVariable - _ = options.Value.A; + options.Value.A; return Task.CompletedTask; } } diff --git a/src/Analyzers.roslyn4.6/.editorconfig b/src/Analyzers.roslyn4.6/.editorconfig new file mode 100644 index 000000000..97a8c0fd3 --- /dev/null +++ b/src/Analyzers.roslyn4.6/.editorconfig @@ -0,0 +1,4 @@ +[*] +dotnet_style_prefer_collection_expression = false +roslynator_use_collection_expression = false +resharper_use_collection_expression_highlighting = none diff --git a/src/Analyzers/.editorconfig b/src/Analyzers/.editorconfig new file mode 100644 index 000000000..97a8c0fd3 --- /dev/null +++ b/src/Analyzers/.editorconfig @@ -0,0 +1,4 @@ +[*] +dotnet_style_prefer_collection_expression = false +roslynator_use_collection_expression = false +resharper_use_collection_expression_highlighting = none diff --git a/src/Analyzers/InheritFromGenerator.cs b/src/Analyzers/InheritFromGenerator.cs index 6629408a3..f93f10e57 100644 --- a/src/Analyzers/InheritFromGenerator.cs +++ b/src/Analyzers/InheritFromGenerator.cs @@ -12,21 +12,13 @@ namespace Rocket.Surgery.LaunchPad.Analyzers; /// A generator that is used to copy properties, fields and methods from one type onto another. /// [Generator] -[System.Diagnostics.DebuggerDisplay("{DebuggerDisplay,nq}")] + public class InheritFromGenerator : IIncrementalGenerator { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - private string DebuggerDisplay - { - get - { - return ToString(); - } - } internal static ImmutableHashSet GetExcludedMembers(INamedTypeSymbol targetSymbol, AttributeData attribute) { - _ = targetSymbol + targetSymbol .GetMembers() .Where(z => z.GetAttribute("ExcludeFromGenerationAttribute") is { } || z.GetAttribute("GenerationIgnoreAttribute") is { }); @@ -37,7 +29,7 @@ internal static ImmutableHashSet GetExcludedMembers(INamedTypeSymbol tar .GetMembers() .Where(z => z.GetAttribute("ExcludeFromGenerationAttribute") is { } || z.GetAttribute("GenerationIgnoreAttribute") is { })) { - _ = builder.Add(item.Name); + builder.Add(item.Name); } return builder.ToImmutable(); @@ -58,8 +50,8 @@ internal static ImmutableArray GetInheritableMemberSymbols(INam .GetAttributes() .Where(z => z.AttributeClass?.Name is "InheritFromAttribute") .Select( - attribute => ( GetInheritingSymbol(attribute) is not { } inheritFromSymbol ) - ? [] + attribute => GetInheritingSymbol(attribute) is not { } inheritFromSymbol + ? ImmutableArray.Empty : GetInheritableMemberSymbols(attribute, inheritFromSymbol, excludedProperties) ) .Aggregate( @@ -127,7 +119,7 @@ HashSet excludedProperties var excludeMembers = GetExcludedMembers(inheritFromSymbol, attribute); foreach (var excludedProperty in excludeMembers) { - _ = excludedProperties.Add(excludedProperty); + excludedProperties.Add(excludedProperty); } return inheritFromSymbol diff --git a/src/AspNetCore/Conventions/AspNetCoreConvention.cs b/src/AspNetCore/Conventions/AspNetCoreConvention.cs index 869328864..c3500fd1a 100644 --- a/src/AspNetCore/Conventions/AspNetCoreConvention.cs +++ b/src/AspNetCore/Conventions/AspNetCoreConvention.cs @@ -23,7 +23,7 @@ namespace Rocket.Surgery.LaunchPad.AspNetCore.Conventions; [PublicAPI] [ExportConvention] [ConventionCategory(ConventionCategory.Application)] -[System.Diagnostics.DebuggerDisplay("{DebuggerDisplay,nq}")] + public class AspNetCoreConvention(AspNetCoreOptions? options = null) : IServiceConvention { internal static void PopulateDefaultParts( @@ -90,15 +90,6 @@ private static IEnumerable GetAssemblyClosure(Assembly assembly) private readonly AspNetCoreOptions _options = options ?? new AspNetCoreOptions(); - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - private string DebuggerDisplay - { - get - { - return ToString(); - } - } - /// /// Registers the specified context. /// @@ -106,12 +97,11 @@ private string DebuggerDisplay /// /// /// TODO Edit XML Comment Template for Register - [RequiresUnreferencedCode()] public void Register(IConventionContext context, IConfiguration configuration, IServiceCollection services) { ArgumentNullException.ThrowIfNull(context); - _ = services + services .AddEndpointsApiExplorer() .AddMvcCore() .AddApiExplorer(); @@ -124,14 +114,14 @@ public void Register(IConventionContext context, IConfiguration configuration, I .SelectMany(f => GetApplicationPartAssemblies(f)) ); - _ = services.Configure( + services.Configure( options => { - _ = options.Filters.Add(); - _ = options.Filters.Add(); - _ = options.Filters.Add(); - _ = options.Filters.Add(0); - _ = options.Filters.Add(0); + options.Filters.Add(); + options.Filters.Add(); + options.Filters.Add(); + options.Filters.Add(0); + options.Filters.Add(0); } ); } diff --git a/src/Foundation/Conventions/DefaultConvention.cs b/src/Foundation/Conventions/DefaultConvention.cs index 134613c0e..02e93bf5e 100644 --- a/src/Foundation/Conventions/DefaultConvention.cs +++ b/src/Foundation/Conventions/DefaultConvention.cs @@ -16,17 +16,9 @@ namespace Rocket.Surgery.LaunchPad.Foundation.Conventions; [PublicAPI] [ExportConvention] [ConventionCategory(ConventionCategory.Core)] -[System.Diagnostics.DebuggerDisplay("{DebuggerDisplay,nq}")] + public class DefaultConvention : IServiceConvention, ISetupConvention { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - private string DebuggerDisplay - { - get - { - return ToString(); - } - } /// /// Registers the specified context. @@ -36,12 +28,12 @@ private string DebuggerDisplay /// public void Register(IConventionContext context, IConfiguration configuration, IServiceCollection services) { - _ = services + services .AddOptions() .AddLogging() .AddExecuteScopedServices(); - _ = services.AddCompiledServiceRegistrations(context.Assembly.GetCompiledTypeProvider()); + services.AddCompiledServiceRegistrations(context.Assembly.GetCompiledTypeProvider()); } void ISetupConvention.Register(IConventionContext context) => context.AddIfMissing("ExecutingAssembly", context.Require().Method.Module.Assembly); diff --git a/src/Foundation/Conventions/FluentValidationConvention.cs b/src/Foundation/Conventions/FluentValidationConvention.cs index 194f938e6..5b03d7d3a 100644 --- a/src/Foundation/Conventions/FluentValidationConvention.cs +++ b/src/Foundation/Conventions/FluentValidationConvention.cs @@ -32,20 +32,11 @@ namespace Rocket.Surgery.LaunchPad.Foundation.Conventions; [AfterConvention(typeof(MediatRConvention))] [AfterConvention(typeof(HealthChecksConvention))] [ConventionCategory(ConventionCategory.Core)] -[System.Diagnostics.DebuggerDisplay("{DebuggerDisplay,nq}")] + public class FluentValidationConvention(FoundationOptions? options = null) : IServiceConvention { private readonly FoundationOptions _options = options ?? new FoundationOptions(); - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - private string DebuggerDisplay - { - get - { - return ToString(); - } - } - /// /// Registers the specified context. /// @@ -56,7 +47,7 @@ public void Register(IConventionContext context, IConfiguration configuration, I { ArgumentNullException.ThrowIfNull(context); - _ = context.Assembly.GetCompiledTypeProvider() + context.Assembly.GetCompiledTypeProvider() .Scan( services, z => z @@ -79,13 +70,13 @@ public void Register(IConventionContext context, IConfiguration configuration, I )) { // need to do validations using ValidateOnStart - _ = services.Decorate(); - _ = services.AddSingleton(); - _ = services.AddSingleton(typeof(IValidateOptions<>), typeof(HealthCheckFluentValidationOptions<>)); + services.Decorate(); + services.AddSingleton(); + services.AddSingleton(typeof(IValidateOptions<>), typeof(HealthCheckFluentValidationOptions<>)); } else { - _ = services.AddSingleton(typeof(IValidateOptions<>), typeof(FluentValidationOptions<>)); + services.AddSingleton(typeof(IValidateOptions<>), typeof(FluentValidationOptions<>)); } services.TryAddEnumerable(ServiceDescriptor.Describe(typeof(IPipelineBehavior<,>), typeof(ValidationPipelineBehavior<,>), _options.MediatorLifetime)); diff --git a/src/Foundation/Conventions/MediatRConvention.cs b/src/Foundation/Conventions/MediatRConvention.cs index de6f7c29b..7a79b9225 100644 --- a/src/Foundation/Conventions/MediatRConvention.cs +++ b/src/Foundation/Conventions/MediatRConvention.cs @@ -21,20 +21,11 @@ namespace Rocket.Surgery.LaunchPad.Foundation.Conventions; [PublicAPI] [ExportConvention] [ConventionCategory(ConventionCategory.Core)] -[System.Diagnostics.DebuggerDisplay("{DebuggerDisplay,nq}")] + public class MediatRConvention(FoundationOptions? options = null) : IServiceConvention { private readonly FoundationOptions _options = options ?? new FoundationOptions(); - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - private string DebuggerDisplay - { - get - { - return ToString(); - } - } - /// /// Registers the specified context. /// @@ -49,10 +40,10 @@ public void Register(IConventionContext context, IConfiguration configuration, I throw new ArgumentException("No assemblies found that reference MediatR"); } - _ = services.AddMediatR( + services.AddMediatR( c => { - _ = c.RegisterServicesFromAssemblies(assemblies); + c.RegisterServicesFromAssemblies(assemblies); c.Lifetime = _options switch { { MediatorLifetime: ServiceLifetime.Singleton, } => ServiceLifetime.Singleton, diff --git a/src/Foundation/Conventions/OptionsConvention.cs b/src/Foundation/Conventions/OptionsConvention.cs index df0012984..6bfd09a66 100644 --- a/src/Foundation/Conventions/OptionsConvention.cs +++ b/src/Foundation/Conventions/OptionsConvention.cs @@ -15,7 +15,7 @@ namespace Rocket.Surgery.LaunchPad.Foundation.Conventions; [ExportConvention] [ConventionCategory(ConventionCategory.Core)] [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.NonPublicMethods)] -[System.Diagnostics.DebuggerDisplay("{DebuggerDisplay,nq}")] + public class OptionsConvention : IServiceConvention { [RequiresUnreferencedCode( @@ -38,15 +38,6 @@ IConfiguration config /// public OptionsConvention() => _configureMethod = GetType().GetMethod(nameof(Configure), BindingFlags.NonPublic | BindingFlags.Static)!; - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - private string DebuggerDisplay - { - get - { - return ToString(); - } - } - /// public void Register(IConventionContext context, IConfiguration configuration, IServiceCollection services) { @@ -65,7 +56,7 @@ public void Register(IConventionContext context, IConfiguration configuration, I foreach ((var options, var attribute) in classes.SelectMany(z => z.GetCustomAttributes(), (type, attribute) => (type, attribute))) { - _ = _configureMethod + _configureMethod .MakeGenericMethod(options) .Invoke(null, [services, attribute.OptionsName, configuration.GetSection(attribute.ConfigurationKey)]); } diff --git a/test/Extensions.Tests/ConventionFakeTest.cs b/test/Extensions.Tests/ConventionFakeTest.cs index 1bdc05e35..3ab025842 100644 --- a/test/Extensions.Tests/ConventionFakeTest.cs +++ b/test/Extensions.Tests/ConventionFakeTest.cs @@ -15,7 +15,7 @@ protected async Task Init(Action? action = null) var context = await ConventionContext.FromAsync(conventionContextBuilder); var configuration = await new ConfigurationBuilder().ApplyConventionsAsync(context); - _ = context.Set(configuration.Build()); + context.Set(configuration.Build()); Populate(await new ServiceCollection().ApplyConventionsAsync(context)); } diff --git a/test/Extensions.Tests/MediatRTests.cs b/test/Extensions.Tests/MediatRTests.cs index 35a01bff9..b3938a219 100644 --- a/test/Extensions.Tests/MediatRTests.cs +++ b/test/Extensions.Tests/MediatRTests.cs @@ -10,17 +10,9 @@ namespace Extensions.Tests; -[System.Diagnostics.DebuggerDisplay("{DebuggerDisplay,nq}")] + public class MediatRTests(ITestOutputHelper outputHelper) : AutoFakeTest(XUnitDefaults.CreateTestContext(outputHelper)) { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - private string DebuggerDisplay - { - get - { - return ToString(); - } - } [Fact] public async Task Test1() @@ -32,16 +24,16 @@ public async Task Test1() var sub = A.Fake>(); - _ = services.AddSingleton(sub); + services.AddSingleton(sub); - _ = services.Should().Contain(x => x.ServiceType == typeof(IMediator) && x.Lifetime == ServiceLifetime.Transient); + services.Should().Contain(x => x.ServiceType == typeof(IMediator) && x.Lifetime == ServiceLifetime.Transient); var r = services.BuildServiceProvider(); var mediator = r.GetRequiredService(); await mediator.Send(new Request()); - _ = A + A .CallTo(() => sub.Handle(A._, A>._, A._)) .MustHaveHappenedOnceExactly(); } @@ -61,9 +53,9 @@ public async Task Test2() var sub = A.Fake>(); - _ = services.AddSingleton(sub); + services.AddSingleton(sub); - _ = services + services .Should() .Contain( x => x.ServiceType == typeof(IMediator) && x.Lifetime == ServiceLifetime.Singleton @@ -75,22 +67,15 @@ public async Task Test2() await mediator.Send(new Request()); - _ = A + A .CallTo(() => sub.Handle(A._, A>._, A._)) .MustHaveHappenedOnceExactly(); } - [System.Diagnostics.DebuggerDisplay("{DebuggerDisplay,nq}")] + public class Request : IRequest { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - private string DebuggerDisplay - { - get - { - return ToString(); - } - } + } private class TestHandler : IRequestHandler diff --git a/test/Extensions.Tests/Validation/HealthCheckOptionsValidationTests.cs b/test/Extensions.Tests/Validation/HealthCheckOptionsValidationTests.cs index c6951a4a2..4e5af0fd4 100644 --- a/test/Extensions.Tests/Validation/HealthCheckOptionsValidationTests.cs +++ b/test/Extensions.Tests/Validation/HealthCheckOptionsValidationTests.cs @@ -11,31 +11,23 @@ namespace Extensions.Tests.Validation; -[System.Diagnostics.DebuggerDisplay("{DebuggerDisplay,nq}")] + public class HealthCheckOptionsValidationTests(ITestOutputHelper outputHelper) : AutoFakeTest(XUnitDefaults.CreateTestContext(outputHelper)), IAsyncLifetime { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - private string DebuggerDisplay - { - get - { - return ToString(); - } - } [Fact] public async Task Should_Validate_Options_And_Throw() { Func a = () => Container.Resolve>().Value; - _ = a.Should().NotThrow(); - _ = await Verify(Container.Resolve().Results); + a.Should().NotThrow(); + await Verify(Container.Resolve().Results); } [Fact] public async Task Should_Validate_Options_And_Pass() { var services = new ServiceCollection(); - _ = services + services .AddOptions() .Configure( options => @@ -48,15 +40,15 @@ public async Task Should_Validate_Options_And_Pass() ); Populate(services); Func a = () => Container.Resolve>().Value; - _ = a.Should().NotThrow(); - _ = await Verify(Container.Resolve().Results); + a.Should().NotThrow(); + await Verify(Container.Resolve().Results); } [Fact] public async Task Should_Validate_Options_And_Throw_If_Out_Of_Bounds() { var services = new ServiceCollection(); - _ = services + services .AddOptions() .Configure( options => @@ -69,8 +61,8 @@ public async Task Should_Validate_Options_And_Throw_If_Out_Of_Bounds() ); Populate(services); Func a = () => Container.Resolve>().Value; - _ = a.Should().NotThrow(); - _ = await Verify(Container.Resolve().Results); + a.Should().NotThrow(); + await Verify(Container.Resolve().Results); } [Fact] @@ -82,7 +74,7 @@ public async Task Should_Validate_Options_And_Throw_After_Application_Has_Starte .Should() .Throw() .Which.Failures; - _ = await Verify(failures); + await Verify(failures); } [Fact] @@ -90,7 +82,7 @@ public void Should_Validate_Options_And_Pass_After_Application_Has_Started() { Container.Resolve().ApplicationHasStarted = true; var services = new ServiceCollection(); - _ = services + services .AddOptions() .Configure( options => @@ -103,7 +95,7 @@ public void Should_Validate_Options_And_Pass_After_Application_Has_Started() ); Populate(services); Func a = () => Container.Resolve>().Value; - _ = a.Should().NotThrow(); + a.Should().NotThrow(); } [Fact] @@ -111,7 +103,7 @@ public async Task Should_Validate_Options_And_Throw_If_Out_Of_Bounds_After_Appli { Container.Resolve().ApplicationHasStarted = true; var services = new ServiceCollection(); - _ = services + services .AddOptions() .Configure( options => @@ -128,7 +120,7 @@ public async Task Should_Validate_Options_And_Throw_If_Out_Of_Bounds_After_Appli .Should() .Throw() .Which.Failures; - _ = await Verify(failures); + await Verify(failures); } private class Options @@ -143,10 +135,10 @@ private sealed class Validator : AbstractValidator { public Validator() { - _ = RuleFor(z => z.String).NotEmpty().NotNull(); - _ = RuleFor(z => z.Int).GreaterThan(0).LessThanOrEqualTo(100); - _ = RuleFor(z => z.Bool).NotEqual(false); - _ = RuleFor(z => z.Double).GreaterThanOrEqualTo(-100d).LessThanOrEqualTo(0d); + RuleFor(z => z.String).NotEmpty().NotNull(); + RuleFor(z => z.Int).GreaterThan(0).LessThanOrEqualTo(100); + RuleFor(z => z.Bool).NotEqual(false); + RuleFor(z => z.Double).GreaterThanOrEqualTo(-100d).LessThanOrEqualTo(0d); } } } diff --git a/test/Extensions.Tests/Validation/OptionsValidationTests.cs b/test/Extensions.Tests/Validation/OptionsValidationTests.cs index 9a619ec0f..2501b15ee 100644 --- a/test/Extensions.Tests/Validation/OptionsValidationTests.cs +++ b/test/Extensions.Tests/Validation/OptionsValidationTests.cs @@ -10,17 +10,9 @@ namespace Extensions.Tests.Validation; -[System.Diagnostics.DebuggerDisplay("{DebuggerDisplay,nq}")] + public class OptionsValidationTests(ITestOutputHelper outputHelper) : AutoFakeTest(XUnitDefaults.CreateTestContext(outputHelper)), IAsyncLifetime { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - private string DebuggerDisplay - { - get - { - return ToString(); - } - } [Fact] public async Task Should_Validate_Options_And_Throw() @@ -30,14 +22,14 @@ public async Task Should_Validate_Options_And_Throw() .Should() .Throw() .Which.Failures; - _ = await Verify(failures); + await Verify(failures); } [Fact] public void Should_Validate_Options_And_Pass() { var services = new ServiceCollection(); - _ = services + services .AddOptions() .Configure( options => @@ -50,14 +42,14 @@ public void Should_Validate_Options_And_Pass() ); Populate(services); Func a = () => Container.Resolve>().Value; - _ = a.Should().NotThrow(); + a.Should().NotThrow(); } [Fact] public async Task Should_Validate_Options_And_Throw_If_Out_Of_Bounds() { var services = new ServiceCollection(); - _ = services + services .AddOptions() .Configure( options => @@ -74,7 +66,7 @@ public async Task Should_Validate_Options_And_Throw_If_Out_Of_Bounds() .Should() .Throw() .Which.Failures; - _ = await Verify(failures); + await Verify(failures); } private class Options @@ -89,10 +81,10 @@ private class Validator : AbstractValidator { public Validator() { - _ = RuleFor(z => z.String).NotEmpty().NotNull(); - _ = RuleFor(z => z.Int).GreaterThan(0).LessThanOrEqualTo(100); - _ = RuleFor(z => z.Bool).NotEqual(false); - _ = RuleFor(z => z.Double).GreaterThanOrEqualTo(-100d).LessThanOrEqualTo(0d); + RuleFor(z => z.String).NotEmpty().NotNull(); + RuleFor(z => z.Int).GreaterThan(0).LessThanOrEqualTo(100); + RuleFor(z => z.Bool).NotEqual(false); + RuleFor(z => z.Double).GreaterThanOrEqualTo(-100d).LessThanOrEqualTo(0d); } } } diff --git a/test/Sample.Core.Tests/HandleTestHostBase.cs b/test/Sample.Core.Tests/HandleTestHostBase.cs index cef00051c..a33303ec7 100644 --- a/test/Sample.Core.Tests/HandleTestHostBase.cs +++ b/test/Sample.Core.Tests/HandleTestHostBase.cs @@ -41,7 +41,7 @@ public async Task InitializeAsync() ) .ApplyConventionsAsync(await ConventionContext.FromAsync(_context)); Populate(services); - _ = await Container.WithScoped().Invoke(context => context.Database.EnsureCreatedAsync()); + await Container.WithScoped().Invoke(context => context.Database.EnsureCreatedAsync()); } public async Task DisposeAsync() => await _connection!.DisposeAsync(); diff --git a/test/Sample.Graphql.Tests/Helpers/GraphQlExtension.cs b/test/Sample.Graphql.Tests/Helpers/GraphQlExtension.cs index 98467be0b..8730d8981 100644 --- a/test/Sample.Graphql.Tests/Helpers/GraphQlExtension.cs +++ b/test/Sample.Graphql.Tests/Helpers/GraphQlExtension.cs @@ -23,7 +23,7 @@ public void Dispose() { } public IHostBuilder Configure(IHostBuilder builder) { - _ = builder.ConfigureServices( + builder.ConfigureServices( z => z .AddW3CLogging(_ => { }) .AddHttpLogging(_ => { }) @@ -33,12 +33,12 @@ public IHostBuilder Configure(IHostBuilder builder) opt => opt.IncludeExceptionDetails = true ) ); - _ = builder.ConfigureServices( + builder.ConfigureServices( s => { - _ = s.AddHttpClient(); - _ = s.AddRocketClient(); - _ = s.ConfigureOptions(); + s.AddHttpClient(); + s.AddRocketClient(); + s.ConfigureOptions(); } ); @@ -60,17 +60,9 @@ public override void PostConfigure(string? name, HttpClientFactoryOptions option } } -[System.Diagnostics.DebuggerDisplay("{DebuggerDisplay,nq}")] + public class TestServerDiagnosticEventListener(ILogger logger) : ServerDiagnosticEventListener { - [System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)] - private string DebuggerDisplay - { - get - { - return ToString(); - } - } public override void HttpRequestError(HttpContext context, Exception exception) => logger.LogError(exception, "HttpRequestError");