Skip to content

Commit 14d8cac

Browse files
committed
warnings
1 parent 8708e97 commit 14d8cac

File tree

16 files changed

+49
-47
lines changed

16 files changed

+49
-47
lines changed

samples/CommandQuery.Sample.AWSLambda.Tests/CommandTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public async Task should_handle_errors()
3232
result.ShouldBeError("The command type 'FailCommand' could not be found");
3333
}
3434

35-
APIGatewayProxyRequest GetRequest(string content) => new APIGatewayProxyRequest { Body = content };
35+
static APIGatewayProxyRequest GetRequest(string content) => new() { Body = content };
3636
}
3737
}
3838
}

samples/CommandQuery.Sample.AWSLambda.Tests/QueryTests.cs

+9-9
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public void SetUp()
2525
public async Task should_work()
2626
{
2727
var result = await Subject.Handle(Request.QueryName("BarQuery"), Context);
28-
var value = result.As<Bar>();
28+
var value = result.As<Bar>()!;
2929

3030
value.Id.Should().Be(1);
3131
value.Value.Should().NotBeEmpty();
@@ -39,9 +39,9 @@ public async Task should_handle_errors()
3939
result.ShouldBeError("The query type 'FailQuery' could not be found");
4040
}
4141

42-
Query Subject;
43-
APIGatewayProxyRequest Request;
44-
ILambdaContext Context;
42+
Query Subject = null!;
43+
APIGatewayProxyRequest Request = null!;
44+
ILambdaContext Context = null!;
4545
}
4646

4747
public class when_using_the_real_function_via_Get
@@ -58,7 +58,7 @@ public void SetUp()
5858
public async Task should_work()
5959
{
6060
var result = await Subject.Handle(Request.QueryName("BarQuery"), Context);
61-
var value = result.As<Bar>();
61+
var value = result.As<Bar>()!;
6262

6363
value.Id.Should().Be(1);
6464
value.Value.Should().NotBeEmpty();
@@ -72,12 +72,12 @@ public async Task should_handle_errors()
7272
result.ShouldBeError("The query type 'FailQuery' could not be found");
7373
}
7474

75-
Query Subject;
76-
APIGatewayProxyRequest Request;
77-
ILambdaContext Context;
75+
Query Subject = null!;
76+
APIGatewayProxyRequest Request = null!;
77+
ILambdaContext Context = null!;
7878
}
7979

80-
static APIGatewayProxyRequest GetRequest(string method, string content = null, Dictionary<string, IList<string>> query = null)
80+
static APIGatewayProxyRequest GetRequest(string method, string? content = null, Dictionary<string, IList<string>>? query = null)
8181
{
8282
var request = new APIGatewayProxyRequest
8383
{

samples/CommandQuery.Sample.AWSLambda.Tests/ShouldExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public static void ShouldBeError(this APIGatewayProxyResponse result, string mes
1111
{
1212
result.Should().NotBeNull();
1313
result.StatusCode.Should().NotBe(200);
14-
var value = JsonSerializer.Deserialize<Error>(result.Body);
14+
var value = JsonSerializer.Deserialize<Error>(result.Body)!;
1515
value.Should().NotBeNull();
1616
value.Message.Should().Be(message);
1717
}

samples/CommandQuery.Sample.AWSLambda.Tests/TestExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public static APIGatewayProxyRequest CommandName(this APIGatewayProxyRequest req
2020
return request;
2121
}
2222

23-
public static T As<T>(this APIGatewayProxyResponse result)
23+
public static T? As<T>(this APIGatewayProxyResponse result)
2424
{
2525
return JsonSerializer.Deserialize<T>(result.Body);
2626
}

samples/CommandQuery.Sample.AspNetCore.V6.Tests/CommandControllerTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ public async Task should_handle_errors()
4646
(await result.Content.ReadAsStringAsync()).Should().BeEmpty();
4747
}
4848

49-
WebApplicationFactory<Program> Factory;
50-
HttpClient Client;
49+
WebApplicationFactory<Program> Factory = null!;
50+
HttpClient Client = null!;
5151
}
5252
}
5353
}

samples/CommandQuery.Sample.AspNetCore.V6.Tests/QueryControllerTests.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ public async Task should_handle_errors()
4949
(await result.Content.ReadAsStringAsync()).Should().BeEmpty();
5050
}
5151

52-
WebApplicationFactory<Program> Factory;
53-
HttpClient Client;
52+
WebApplicationFactory<Program> Factory = null!;
53+
HttpClient Client = null!;
5454
}
5555

5656
public class when_using_the_real_controller_via_Get
@@ -89,8 +89,8 @@ public async Task should_handle_errors()
8989
(await result.Content.ReadAsStringAsync()).Should().BeEmpty();
9090
}
9191

92-
WebApplicationFactory<Program> Factory;
93-
HttpClient Client;
92+
WebApplicationFactory<Program> Factory = null!;
93+
HttpClient Client = null!;
9494
}
9595
}
9696
}

samples/CommandQuery.Sample.AzureFunctions.V6.Tests/CommandTests.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public void SetUp()
2828
context.SetupProperty(c => c.InstanceServices, serviceProvider);
2929
ExecutionContext = context.Object;
3030

31-
Subject = new Command(serviceProvider.GetService<ICommandFunction>(), serviceProvider.GetService<ILoggerFactory>());
31+
Subject = new Command(serviceProvider.GetService<ICommandFunction>()!, serviceProvider.GetService<ILoggerFactory>()!);
3232
}
3333

3434
[Test]
@@ -69,8 +69,8 @@ HttpRequestData GetHttpRequestData(string content)
6969
return request.Object;
7070
}
7171

72-
FunctionContext ExecutionContext;
73-
Command Subject;
72+
FunctionContext ExecutionContext = null!;
73+
Command Subject = null!;
7474
}
7575
}
7676
}

samples/CommandQuery.Sample.AzureFunctions.V6.Tests/QueryTests.cs

+9-9
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public void SetUp()
3030
context.SetupProperty(c => c.InstanceServices, serviceProvider);
3131
ExecutionContext = context.Object;
3232

33-
Subject = new Query(serviceProvider.GetService<IQueryFunction>(), serviceProvider.GetService<ILoggerFactory>());
33+
Subject = new Query(serviceProvider.GetService<IQueryFunction>()!, serviceProvider.GetService<ILoggerFactory>()!);
3434
}
3535

3636
[Test]
@@ -41,7 +41,7 @@ public async Task should_work()
4141
var result = await Subject.Run(req, ExecutionContext, "BarQuery");
4242
var value = await result.AsAsync<Bar>();
4343

44-
value.Id.Should().Be(1);
44+
value!.Id.Should().Be(1);
4545
value.Value.Should().NotBeEmpty();
4646
}
4747

@@ -55,8 +55,8 @@ public async Task should_handle_errors()
5555
await result.ShouldBeErrorAsync("The query type 'FailQuery' could not be found");
5656
}
5757

58-
FunctionContext ExecutionContext;
59-
Query Subject;
58+
FunctionContext ExecutionContext = null!;
59+
Query Subject = null!;
6060
}
6161

6262
public class when_using_the_real_function_via_Get
@@ -73,7 +73,7 @@ public void SetUp()
7373
context.SetupProperty(c => c.InstanceServices, serviceProvider);
7474
ExecutionContext = context.Object;
7575

76-
Subject = new Query(serviceProvider.GetService<IQueryFunction>(), serviceProvider.GetService<ILoggerFactory>());
76+
Subject = new Query(serviceProvider.GetService<IQueryFunction>()!, serviceProvider.GetService<ILoggerFactory>()!);
7777
}
7878

7979
[Test]
@@ -84,7 +84,7 @@ public async Task should_work()
8484
var result = await Subject.Run(req, ExecutionContext, "BarQuery");
8585
var value = await result.AsAsync<Bar>();
8686

87-
value.Id.Should().Be(1);
87+
value!.Id.Should().Be(1);
8888
value.Value.Should().NotBeEmpty();
8989
}
9090

@@ -98,11 +98,11 @@ public async Task should_handle_errors()
9898
await result.ShouldBeErrorAsync("The query type 'FailQuery' could not be found");
9999
}
100100

101-
FunctionContext ExecutionContext;
102-
Query Subject;
101+
FunctionContext ExecutionContext = null!;
102+
Query Subject = null!;
103103
}
104104

105-
static HttpRequestData GetHttpRequestData(FunctionContext executionContext, string method, string content = null, string url = null)
105+
static HttpRequestData GetHttpRequestData(FunctionContext executionContext, string method, string? content = null, string? url = null)
106106
{
107107
var request = new Mock<HttpRequestData>(executionContext);
108108
request.Setup(r => r.Method).Returns(method);

samples/CommandQuery.Sample.AzureFunctions.V6.Tests/ShouldExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public static async Task ShouldBeErrorAsync(this HttpResponseData result, string
1616
result.Body.Position = 0;
1717
var value = await JsonSerializer.DeserializeAsync<Error>(result.Body);
1818
value.Should().NotBeNull();
19-
value.Message.Should().Be(message);
19+
value!.Message.Should().Be(message);
2020
}
2121
}
2222
}

samples/CommandQuery.Sample.AzureFunctions.V6.Tests/TestExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace CommandQuery.Sample.AzureFunctions.V6.Tests
66
{
77
public static class TestExtensions
88
{
9-
public static async Task<T> AsAsync<T>(this HttpResponseData result)
9+
public static async Task<T?> AsAsync<T>(this HttpResponseData result)
1010
{
1111
result.Body.Position = 0;
1212
return await JsonSerializer.DeserializeAsync<T>(result.Body);

samples/CommandQuery.Sample.Client/Program.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace CommandQuery.Sample.Client
1313
{
1414
public class Program
1515
{
16-
private static IServiceProvider _serviceProvider;
16+
private static IServiceProvider _serviceProvider = null!;
1717

1818
public static async Task Main(string[] args)
1919
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[*.cs]
2+
dotnet_diagnostic.CS8618.severity = none

samples/CommandQuery.Sample.GoogleCloudFunctions.Tests/CommandTests.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ public class when_using_the_real_function
1717
public void SetUp()
1818
{
1919
var serviceCollection = new ServiceCollection();
20-
new Startup().ConfigureServices(null, serviceCollection);
20+
new Startup().ConfigureServices(null!, serviceCollection);
2121
var serviceProvider = serviceCollection.BuildServiceProvider();
2222

23-
Subject = new Command(null, serviceProvider.GetService<ICommandFunction>());
23+
Subject = new Command(null!, serviceProvider.GetService<ICommandFunction>());
2424
}
2525

2626
[Test]
@@ -53,7 +53,7 @@ HttpContext GetHttpContext(string commandName, string content)
5353
return context;
5454
}
5555

56-
Command Subject;
56+
Command Subject = null!;
5757
}
5858
}
5959
}

samples/CommandQuery.Sample.GoogleCloudFunctions.Tests/QueryTests.cs

+9-9
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ public class when_using_the_real_function_via_Post
2020
public void SetUp()
2121
{
2222
var serviceCollection = new ServiceCollection();
23-
new Startup().ConfigureServices(null, serviceCollection);
23+
new Startup().ConfigureServices(null!, serviceCollection);
2424
var serviceProvider = serviceCollection.BuildServiceProvider();
2525

26-
Subject = new Query(null, serviceProvider.GetService<IQueryFunction>());
26+
Subject = new Query(null!, serviceProvider.GetService<IQueryFunction>());
2727
}
2828

2929
[Test]
@@ -34,7 +34,7 @@ public async Task should_work()
3434
await Subject.HandleAsync(context);
3535
var value = await context.Response.AsAsync<Bar>();
3636

37-
value.Id.Should().Be(1);
37+
value!.Id.Should().Be(1);
3838
value.Value.Should().NotBeEmpty();
3939
}
4040

@@ -48,7 +48,7 @@ public async Task should_handle_errors()
4848
await context.Response.ShouldBeErrorAsync("The query type 'FailQuery' could not be found");
4949
}
5050

51-
Query Subject;
51+
Query Subject = null!;
5252
}
5353

5454
public class when_using_the_real_function_via_Get
@@ -57,10 +57,10 @@ public class when_using_the_real_function_via_Get
5757
public void SetUp()
5858
{
5959
var serviceCollection = new ServiceCollection();
60-
new Startup().ConfigureServices(null, serviceCollection);
60+
new Startup().ConfigureServices(null!, serviceCollection);
6161
var serviceProvider = serviceCollection.BuildServiceProvider();
6262

63-
Subject = new Query(null, serviceProvider.GetService<IQueryFunction>());
63+
Subject = new Query(null!, serviceProvider.GetService<IQueryFunction>());
6464
}
6565

6666
[Test]
@@ -71,7 +71,7 @@ public async Task should_work()
7171
await Subject.HandleAsync(context);
7272
var value = await context.Response.AsAsync<Bar>();
7373

74-
value.Id.Should().Be(1);
74+
value!.Id.Should().Be(1);
7575
value.Value.Should().NotBeEmpty();
7676
}
7777

@@ -85,10 +85,10 @@ public async Task should_handle_errors()
8585
await context.Response.ShouldBeErrorAsync("The query type 'FailQuery' could not be found");
8686
}
8787

88-
Query Subject;
88+
Query Subject = null!;
8989
}
9090

91-
static HttpContext GetHttpContext(string queryName, string method, string content = null, Dictionary<string, string> query = null)
91+
static HttpContext GetHttpContext(string queryName, string method, string? content = null, Dictionary<string, string>? query = null)
9292
{
9393
var context = new DefaultHttpContext();
9494
context.Request.Path = new PathString("/api/query/" + queryName);

samples/CommandQuery.Sample.GoogleCloudFunctions.Tests/ShouldExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static async Task ShouldBeErrorAsync(this HttpResponse result, string mes
1515
result.Body.Position = 0;
1616
var value = await JsonSerializer.DeserializeAsync<Error>(result.Body);
1717
value.Should().NotBeNull();
18-
value.Message.Should().Be(message);
18+
value!.Message.Should().Be(message);
1919
}
2020
}
2121
}

samples/CommandQuery.Sample.GoogleCloudFunctions.Tests/TestExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace CommandQuery.Sample.GoogleCloudFunctions.Tests
66
{
77
public static class TestExtensions
88
{
9-
public static async Task<T> AsAsync<T>(this HttpResponse result)
9+
public static async Task<T?> AsAsync<T>(this HttpResponse result)
1010
{
1111
result.Body.Position = 0;
1212
return await JsonSerializer.DeserializeAsync<T>(result.Body);

0 commit comments

Comments
 (0)