Skip to content

Commit 1688d05

Browse files
committed
clean
1 parent 24149e4 commit 1688d05

File tree

17 files changed

+31
-39
lines changed

17 files changed

+31
-39
lines changed

src/CommandQuery.Abstractions/ICommand.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,11 @@ namespace CommandQuery
33
/// <summary>
44
/// Marker interface to represent a command.
55
/// </summary>
6-
public interface ICommand
7-
{
8-
}
6+
public interface ICommand;
97

108
/// <summary>
119
/// Marker interface to represent a command with result.
1210
/// </summary>
1311
/// <typeparam name="TResult">Result type.</typeparam>
14-
public interface ICommand<TResult>
15-
{
16-
}
12+
public interface ICommand<TResult>;
1713
}

src/CommandQuery.Abstractions/IQuery.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,5 @@ namespace CommandQuery
44
/// Marker interface to represent a query.
55
/// </summary>
66
/// <typeparam name="TResult">Result type.</typeparam>
7-
public interface IQuery<TResult>
8-
{
9-
}
7+
public interface IQuery<TResult>;
108
}

src/CommandQuery.AzureFunctions/Internal/HttpRequestExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ internal static class HttpRequestExtensions
1717
return null;
1818
}
1919

20-
using (var reader = new StreamReader(req.Body, bufferSize: 1024, detectEncodingFromByteOrderMarks: true, encoding: encoding ?? Encoding.UTF8, leaveOpen: true))
20+
using (var reader = new StreamReader(req.Body, encoding: encoding ?? Encoding.UTF8, detectEncodingFromByteOrderMarks: true, bufferSize: 1024, leaveOpen: true))
2121
{
2222
return await reader.ReadToEndAsync().ConfigureAwait(false);
2323
}

src/CommandQuery.Client/Internal/QueryExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ private static string QueryString(this object query)
3535

3636
Parameters(query, string.Empty);
3737

38-
return string.Join("&", result.ToArray());
38+
return string.Join("&", [.. result]);
3939

4040
void Parameters(object root, string prefix)
4141
{

src/CommandQuery.GoogleCloudFunctions/Internal/HttpExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ internal static class HttpExtensions
1818
return null;
1919
}
2020

21-
using (var reader = new StreamReader(req.Body, bufferSize: 1024, detectEncodingFromByteOrderMarks: true, encoding: encoding ?? Encoding.UTF8, leaveOpen: true))
21+
using (var reader = new StreamReader(req.Body, encoding: encoding ?? Encoding.UTF8, detectEncodingFromByteOrderMarks: true, bufferSize: 1024, leaveOpen: true))
2222
{
2323
return await reader.ReadToEndAsync().ConfigureAwait(false);
2424
}

src/CommandQuery/CommandTypeProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class CommandTypeProvider : TypeProvider, ICommandTypeProvider
1212
/// <param name="assemblies">The assemblies with commands to support.</param>
1313
/// <exception cref="CommandTypeException">Multiple commands with the same name was found.</exception>
1414
public CommandTypeProvider(params Assembly[] assemblies)
15-
: base(new[] { typeof(ICommand), typeof(ICommand<>) }, assemblies)
15+
: base([typeof(ICommand), typeof(ICommand<>)], assemblies)
1616
{
1717
}
1818

src/CommandQuery/Internal/ExceptionExtensions.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ internal static IError ToError(this QueryException exception)
3737
private static Dictionary<string, object>? GetDetails(Exception exception)
3838
{
3939
var properties = exception.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance)
40-
.Where(x => x.DeclaringType != typeof(Exception))
41-
.Where(x => x.GetValue(exception) != null)
40+
.Where(x => x.DeclaringType != typeof(Exception) && x.GetValue(exception) != null)
4241
.ToList();
4342

4443
return properties.Any() ? properties.ToDictionary(property => property.Name, property => property.GetValue(exception)) : null;

src/CommandQuery/Internal/ReflectionExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ private static bool IsAssignableToGenericType(this Type type, Type genericType)
3636
{
3737
return type.GetInterfaces().Any(it => it.GetTypeInfo().IsGenericType && it.GetGenericTypeDefinition() == genericType)
3838
|| (type.GetTypeInfo().IsGenericType && type.GetGenericTypeDefinition() == genericType)
39-
|| (type.GetTypeInfo().BaseType != null && type.GetTypeInfo().BaseType.IsAssignableToGenericType(genericType));
39+
|| (type.GetTypeInfo().BaseType?.IsAssignableToGenericType(genericType) == true);
4040
}
4141
}
4242
}

src/CommandQuery/Internal/ServiceProviderExtensions.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System.Collections;
21
using System.Reflection;
32
using Microsoft.Extensions.DependencyInjection;
43

@@ -28,15 +27,15 @@ internal static IEnumerable<Type> GetAllServiceTypes(this IServiceProvider provi
2827
{
2928
if (provider is not ServiceProvider serviceProvider)
3029
{
31-
return Enumerable.Empty<Type>();
30+
return [];
3231
}
3332

3433
var callSiteFactory = GetPropertyValue(serviceProvider, "CallSiteFactory");
3534
var descriptors = GetPropertyValue(callSiteFactory, "Descriptors");
3635

3736
if (descriptors is not ServiceDescriptor[] array)
3837
{
39-
return Enumerable.Empty<Type>();
38+
return [];
4039
}
4140

4241
return array.Select(x => x.ServiceType).ToList();

src/CommandQuery/QueryTypeProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class QueryTypeProvider : TypeProvider, IQueryTypeProvider
1212
/// <param name="assemblies">The assemblies with queries to support.</param>
1313
/// <exception cref="QueryTypeException">Multiple queries with the same name was found.</exception>
1414
public QueryTypeProvider(params Assembly[] assemblies)
15-
: base(new[] { typeof(IQuery<>) }, assemblies)
15+
: base([typeof(IQuery<>)], assemblies)
1616
{
1717
}
1818

src/CommandQuery/TypeProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public abstract class TypeProvider
1919
protected TypeProvider(Type[] baseTypes, params Assembly[] assemblies)
2020
{
2121
_baseTypes = baseTypes;
22-
_types = new Dictionary<string, Type>();
22+
_types = [];
2323
LoadTypeCaches(assemblies);
2424
}
2525

tests/CommandQuery.AWSLambda.Tests/Internal/APIGatewayProxyRequestExtensionsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace CommandQuery.AWSLambda.Tests.Internal
77
{
88
public class APIGatewayProxyRequestExtensionsTests
99
{
10-
private readonly APIGatewayProxyRequest _request;
10+
private readonly APIGatewayProxyRequest _request = null;
1111

1212
[Test]
1313
public void Ok()

tests/CommandQuery.AspNetCore.Tests/CommandQueryControllerModelConventionTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,35 +17,35 @@ public async Task when_Apply()
1717

1818
void should_handle_CommandControllers_without_result()
1919
{
20-
var result = new ControllerModel(typeof(CommandController<FakeCommand>).GetTypeInfo(), new List<object>());
20+
var result = new ControllerModel(typeof(CommandController<FakeCommand>).GetTypeInfo(), []);
2121
Subject.Apply(result);
2222
result.ControllerName.Should().Be("FakeCommand");
2323
}
2424

2525
void should_handle_CommandControllers_with_result()
2626
{
27-
var result = new ControllerModel(typeof(CommandController<FakeResultCommand, FakeResult>).GetTypeInfo(), new List<object>());
27+
var result = new ControllerModel(typeof(CommandController<FakeResultCommand, FakeResult>).GetTypeInfo(), []);
2828
Subject.Apply(result);
2929
result.ControllerName.Should().Be("FakeResultCommand");
3030
}
3131

3232
void should_handle_QueryControllers()
3333
{
34-
var result = new ControllerModel(typeof(QueryController<FakeQuery, FakeResult>).GetTypeInfo(), new List<object>());
34+
var result = new ControllerModel(typeof(QueryController<FakeQuery, FakeResult>).GetTypeInfo(), []);
3535
Subject.Apply(result);
3636
result.ControllerName.Should().Be("FakeQuery");
3737
}
3838

3939
void should_not_handle_non_generic_controllers()
4040
{
41-
var result = new ControllerModel(typeof(ControllerBase).GetTypeInfo(), new List<object>());
41+
var result = new ControllerModel(typeof(ControllerBase).GetTypeInfo(), []);
4242
Subject.Apply(result);
4343
result.ControllerName.Should().BeNull();
4444
}
4545

4646
void should_not_handle_unknown_controllers()
4747
{
48-
var result = new ControllerModel(typeof(FakeController<>).GetTypeInfo(), new List<object>());
48+
var result = new ControllerModel(typeof(FakeController<>).GetTypeInfo(), []);
4949
Subject.Apply(result);
5050
result.ControllerName.Should().BeNull();
5151
}

tests/CommandQuery.AzureFunctions.Tests/FakeHttpData.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public FakeHttpRequestData(FunctionContext functionContext, string method = null
1515

1616
public override Stream Body { get; } = new MemoryStream();
1717

18-
public override HttpHeadersCollection Headers { get; } = new();
18+
public override HttpHeadersCollection Headers { get; } = [];
1919

2020
public override IReadOnlyCollection<IHttpCookie> Cookies { get; }
2121

@@ -38,7 +38,7 @@ public FakeHttpResponseData(FunctionContext functionContext) : base(functionCont
3838
}
3939

4040
public override HttpStatusCode StatusCode { get; set; }
41-
public override HttpHeadersCollection Headers { get; set; } = new();
41+
public override HttpHeadersCollection Headers { get; set; } = [];
4242
public override Stream Body { get; set; } = new MemoryStream();
4343
public override HttpCookies Cookies { get; }
4444
}

tests/CommandQuery.Benchmark/JsonBenchmarks.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ public void GlobalSetup()
1919
DateTime = DateTime.Parse("2021-07-04 20:31:48"),
2020
Guid = Guid.Parse("b665da2a-60fe-4f2b-baf1-9d766e2542d3"),
2121
NullableDouble = 2.1,
22-
Array = new[] { 1, 2 },
23-
IEnumerable = new[] { 3, 4 },
24-
List = new List<int> { 5, 6 }
22+
Array = [1, 2],
23+
IEnumerable = [3, 4],
24+
List = [5, 6]
2525
};
2626

2727
_systemTextJsonString = System.Text.Json.JsonSerializer.Serialize(_object);

tests/CommandQuery.Tests/Client/Integration/QueryClientIntegrationTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public async Task when_PostAsync()
2727
[Test]
2828
public async Task when_GetAsync()
2929
{
30-
var result = await Subject.GetAsync(new QuxQuery { Ids = new[] { Guid.NewGuid(), Guid.NewGuid() } });
30+
var result = await Subject.GetAsync(new QuxQuery { Ids = [Guid.NewGuid(), Guid.NewGuid()] });
3131
result.Should().NotBeNull();
3232

3333
Func<Task> act = () => Subject.GetAsync(new FailQuery());

tests/CommandQuery.Tests/Internal/ExceptionExtensionsTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ public void when_converting_CommandException_to_Error()
4747
DateTime = DateTime.Parse("2018-07-06"),
4848
Guid = Guid.Parse("3B10C34C-D423-4EC3-8811-DA2E0606E241"),
4949
NullableDouble = 2.1,
50-
Array = new[] { 1, 2 },
51-
IEnumerable = new[] { 3, 4 },
52-
List = new List<int> { 5, 6 },
50+
Array = [1, 2],
51+
IEnumerable = [3, 4],
52+
List = [5, 6],
5353
Enum = FakeEnum.Some
5454
};
5555

@@ -85,9 +85,9 @@ public void when_converting_QueryException_to_Error()
8585
DateTime = DateTime.Parse("2018-07-06"),
8686
Guid = Guid.Parse("3B10C34C-D423-4EC3-8811-DA2E0606E241"),
8787
NullableDouble = 2.1,
88-
Array = new[] { 1, 2 },
89-
IEnumerable = new[] { 3, 4 },
90-
List = new List<int> { 5, 6 },
88+
Array = [1, 2],
89+
IEnumerable = [3, 4],
90+
List = [5, 6],
9191
Enum = FakeEnum.Some
9292
};
9393

0 commit comments

Comments
 (0)