Skip to content

Commit 947a079

Browse files
committed
chore(*): fix build warnings and use new Program.cs format
1 parent c02e09d commit 947a079

File tree

6 files changed

+24
-37
lines changed

6 files changed

+24
-37
lines changed

src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.0</TargetFramework>
4+
<TargetFramework>$(NetCoreAppVersion)</TargetFramework>
55
<PreserveCompilationContext>true</PreserveCompilationContext>
66
<AssemblyName>JsonApiDotNetCoreExample</AssemblyName>
77
<OutputType>Exe</OutputType>
@@ -13,7 +13,7 @@
1313
</ItemGroup>
1414

1515
<ItemGroup>
16-
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="$(AspNetCoreVersion)" />
16+
<PackageReference Include="Microsoft.AspNetCore" Version="$(AspNetCoreVersion)" />
1717
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="$(MicrosoftConfigurationVersion)" />
1818
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="$(MicrosoftConfigurationVersion)" />
1919
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="$(MicrosoftConfigurationVersion)" />
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,18 @@
1-
using System.IO;
1+
using Microsoft.AspNetCore;
22
using Microsoft.AspNetCore.Hosting;
3-
using Microsoft.Extensions.Configuration;
43

54
namespace JsonApiDotNetCoreExample
65
{
76
public class Program
87
{
98
public static void Main(string[] args)
109
{
11-
var config = new ConfigurationBuilder()
12-
.AddCommandLine(args)
13-
.AddEnvironmentVariables(prefix: "ASPNETCORE_")
14-
.Build();
10+
BuildWebHost(args).Run();
11+
}
1512

16-
var host = new WebHostBuilder()
17-
.UseConfiguration(config)
18-
.UseKestrel()
19-
.UseContentRoot(Directory.GetCurrentDirectory())
13+
public static IWebHost BuildWebHost(string[] args) =>
14+
WebHost.CreateDefaultBuilder(args)
2015
.UseStartup<Startup>()
2116
.Build();
22-
23-
host.Run();
24-
}
2517
}
2618
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.IO;
1+
using Microsoft.AspNetCore;
22
using Microsoft.AspNetCore.Hosting;
33

44
namespace NoEntityFrameworkExample
@@ -7,14 +7,12 @@ public class Program
77
{
88
public static void Main(string[] args)
99
{
10-
var host = new WebHostBuilder()
11-
.UseKestrel()
12-
.UseContentRoot(Directory.GetCurrentDirectory())
13-
.UseIISIntegration()
10+
BuildWebHost(args).Run();
11+
}
12+
13+
public static IWebHost BuildWebHost(string[] args) =>
14+
WebHost.CreateDefaultBuilder(args)
1415
.UseStartup<Startup>()
1516
.Build();
16-
17-
host.Run();
18-
}
1917
}
2018
}
+6-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.IO;
1+
using Microsoft.AspNetCore;
22
using Microsoft.AspNetCore.Hosting;
33

44
namespace ReportsExample
@@ -7,14 +7,12 @@ public class Program
77
{
88
public static void Main(string[] args)
99
{
10-
var host = new WebHostBuilder()
11-
.UseKestrel()
12-
.UseContentRoot(Directory.GetCurrentDirectory())
13-
.UseIISIntegration()
10+
BuildWebHost(args).Run();
11+
}
12+
13+
public static IWebHost BuildWebHost(string[] args) =>
14+
WebHost.CreateDefaultBuilder(args)
1415
.UseStartup<Startup>()
1516
.Build();
16-
17-
host.Run();
18-
}
1917
}
2018
}

test/JsonApiDotNetCoreExampleTests/Acceptance/CamelCasedModelsControllerTests.cs

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ public CamelCasedModelsControllerTests(TestFixture<Startup> fixture)
3535

3636
[Fact]
3737
public async Task Can_Get_CamelCasedModels()
38-
3938
{
4039
// Arrange
4140
var model = _faker.Generate();

test/JsonApiDotNetCoreExampleTests/Acceptance/TodoItemsControllerTests.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public async Task Can_Get_TodoItem_ById()
219219
Assert.Equal(todoItem.Description, deserializedBody.Description);
220220
Assert.Equal(todoItem.Ordinal, deserializedBody.Ordinal);
221221
Assert.Equal(todoItem.CreatedDate.ToString("G"), deserializedBody.CreatedDate.ToString("G"));
222-
Assert.Equal(null, deserializedBody.AchievedDate);
222+
Assert.Null(deserializedBody.AchievedDate);
223223
}
224224

225225
[Fact]
@@ -248,7 +248,7 @@ public async Task Can_Get_TodoItem_WithOwner()
248248
Assert.Equal(todoItem.Description, deserializedBody.Description);
249249
Assert.Equal(todoItem.Ordinal, deserializedBody.Ordinal);
250250
Assert.Equal(todoItem.CreatedDate.ToString("G"), deserializedBody.CreatedDate.ToString("G"));
251-
Assert.Equal(null, deserializedBody.AchievedDate);
251+
Assert.Null(deserializedBody.AchievedDate);
252252
}
253253

254254
[Fact]
@@ -301,7 +301,7 @@ public async Task Can_Post_TodoItem()
301301
Assert.Equal(HttpStatusCode.Created, response.StatusCode);
302302
Assert.Equal(todoItem.Description, deserializedBody.Description);
303303
Assert.Equal(todoItem.CreatedDate.ToString("G"), deserializedBody.CreatedDate.ToString("G"));
304-
Assert.Equal(null, deserializedBody.AchievedDate);
304+
Assert.Null(deserializedBody.AchievedDate);
305305
}
306306

307307
[Fact]
@@ -350,7 +350,7 @@ public async Task Can_Patch_TodoItem()
350350
Assert.Equal(newTodoItem.Description, deserializedBody.Description);
351351
Assert.Equal(newTodoItem.Ordinal, deserializedBody.Ordinal);
352352
Assert.Equal(newTodoItem.CreatedDate.ToString("G"), deserializedBody.CreatedDate.ToString("G"));
353-
Assert.Equal(null, deserializedBody.AchievedDate);
353+
Assert.Null(deserializedBody.AchievedDate);
354354
}
355355

356356
[Fact]
@@ -453,7 +453,7 @@ public async Task Can_Patch_TodoItemWithNullValue()
453453
Assert.Equal(newTodoItem.Description, deserializedBody.Description);
454454
Assert.Equal(newTodoItem.Ordinal, deserializedBody.Ordinal);
455455
Assert.Equal(newTodoItem.CreatedDate.ToString("G"), deserializedBody.CreatedDate.ToString("G"));
456-
Assert.Equal(null, deserializedBody.AchievedDate);
456+
Assert.Null(deserializedBody.AchievedDate);
457457
}
458458

459459
[Fact]

0 commit comments

Comments
 (0)