Skip to content

Commit 7393864

Browse files
authored
Merge pull request #3 from waxtell/develop
Target net8.0
2 parents 70deeda + 0802f0e commit 7393864

File tree

11 files changed

+184
-195
lines changed

11 files changed

+184
-195
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ jobs:
88
runs-on: ubuntu-latest
99

1010
steps:
11-
- uses: actions/checkout@v1
12-
- name: Setup .NET Core
13-
uses: actions/setup-dotnet@v1
11+
- uses: actions/checkout@v4
12+
- name: Setup .NET
13+
uses: actions/setup-dotnet@v4
1414
with:
15-
dotnet-version: 3.1.100
15+
dotnet-version: 8.0.x
1616
- name: Build with dotnet
1717
run: dotnet build --configuration Release

.github/workflows/publishtonuget.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
name: publish to nuget
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v1
11+
- uses: actions/checkout@v4
1212

1313
# Publish
1414
- name: Publish NuGet

SampleApp9000/Controllers/WeatherForecastController.cs

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,35 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using Microsoft.AspNetCore.Mvc;
5-
using Microsoft.Extensions.Logging;
65

7-
namespace SampleApp9000.Controllers
8-
{
9-
[ApiController]
10-
[Route("/test/[controller]")]
11-
public class WeatherForecastController : ControllerBase
12-
{
13-
private static readonly string[] Summaries = new[]
14-
{
15-
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
16-
};
17-
18-
private readonly ILogger<WeatherForecastController> _logger;
6+
namespace SampleApp9000.Controllers;
197

20-
public WeatherForecastController(ILogger<WeatherForecastController> logger)
21-
{
22-
_logger = logger;
23-
}
8+
[ApiController]
9+
[Route("/test/[controller]")]
10+
public class WeatherForecastController : ControllerBase
11+
{
12+
private static readonly string[] Summaries =
13+
[
14+
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
15+
];
2416

25-
[HttpGet]
26-
public IEnumerable<WeatherForecast> Get()
27-
{
28-
var rng = new Random();
29-
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
30-
{
31-
Date = DateTime.Now.AddDays(index),
32-
TemperatureC = rng.Next(-20, 55),
33-
Summary = Summaries[rng.Next(Summaries.Length)]
34-
})
35-
.ToArray();
36-
}
17+
[HttpGet]
18+
public IEnumerable<WeatherForecast> Get()
19+
{
20+
var rng = new Random();
21+
return
22+
[
23+
.. Enumerable
24+
.Range(1, 5)
25+
.Select
26+
(
27+
index => new WeatherForecast
28+
{
29+
Date = DateTime.Now.AddDays(index),
30+
TemperatureC = rng.Next(-20, 55),
31+
Summary = Summaries[rng.Next(Summaries.Length)]
32+
}
33+
)
34+
];
3735
}
38-
}
36+
}

SampleApp9000/Extensions/OpenApiServerExtensions.cs

Lines changed: 0 additions & 13 deletions
This file was deleted.

SampleApp9000/Program.cs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
using Microsoft.AspNetCore.Hosting;
22
using Microsoft.Extensions.Hosting;
33

4-
namespace SampleApp9000
4+
namespace SampleApp9000;
5+
6+
public class Program
57
{
6-
public class Program
8+
public static void Main(string[] args)
79
{
8-
public static void Main(string[] args)
9-
{
10-
CreateHostBuilder(args).Build().Run();
11-
}
12-
13-
public static IHostBuilder CreateHostBuilder(string[] args) =>
14-
Host.CreateDefaultBuilder(args)
15-
.ConfigureWebHostDefaults(webBuilder =>
16-
{
17-
webBuilder.UseStartup<Startup>();
18-
});
10+
CreateHostBuilder(args).Build().Run();
1911
}
20-
}
12+
13+
public static IHostBuilder CreateHostBuilder(string[] args) =>
14+
Host.CreateDefaultBuilder(args)
15+
.ConfigureWebHostDefaults(webBuilder =>
16+
{
17+
webBuilder.UseStartup<Startup>();
18+
});
19+
}

SampleApp9000/SampleApp9000.csproj

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
</PropertyGroup>
66

7+
<ItemGroup>
8+
<PackageReference Include="Swashbuckle.Servers.Extension" Version="1.1.0" />
9+
</ItemGroup>
10+
711
<ItemGroup>
812
<ProjectReference Include="..\Swashbuckle.Rebase.Extensions\Swashbuckle.Rebase.Extensions.csproj" />
913
</ItemGroup>
1014

15+
<ItemGroup>
16+
<Folder Include="Extensions\" />
17+
</ItemGroup>
18+
1119

1220
</Project>

SampleApp9000/Startup.cs

Lines changed: 61 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,82 @@
11
using Microsoft.AspNetCore.Builder;
22
using Microsoft.AspNetCore.Hosting;
3-
using Microsoft.OpenApi.Models;
4-
using Microsoft.Extensions.Configuration;
53
using Microsoft.Extensions.DependencyInjection;
64
using Microsoft.Extensions.Hosting;
7-
using SampleApp9000.Extensions;
5+
using Microsoft.OpenApi;
86
using Swashbuckle.Rebase.Extensions;
7+
using Swashbuckle.Servers.Extension.Extensions;
98

10-
namespace SampleApp9000
9+
namespace SampleApp9000;
10+
11+
public class Startup
1112
{
12-
public class Startup
13+
// This method gets called by the runtime. Use this method to add services to the container.
14+
public void ConfigureServices(IServiceCollection services)
1315
{
14-
public Startup(IConfiguration configuration)
15-
{
16-
Configuration = configuration;
17-
}
18-
19-
public IConfiguration Configuration { get; }
16+
services.AddControllers();
2017

21-
// This method gets called by the runtime. Use this method to add services to the container.
22-
public void ConfigureServices(IServiceCollection services)
18+
services.AddSwaggerGen(c =>
2319
{
24-
services.AddControllers();
25-
26-
services.AddSwaggerGen(c =>
27-
{
28-
c.SwaggerDoc
29-
(
30-
"sampleapp",
31-
new OpenApiInfo
32-
{
33-
Title = "Sample App 9000",
34-
Version = "1.0.0",
35-
Description = "Provides a simple example of the tool"
36-
}
37-
);
38-
});
39-
}
20+
c.SwaggerDoc
21+
(
22+
"sampleapp",
23+
new OpenApiInfo
24+
{
25+
Title = "Sample App 9000",
26+
Version = "1.0.0",
27+
Description = "Provides a simple example of the tool"
28+
}
29+
);
30+
});
31+
}
4032

41-
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
42-
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
33+
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
34+
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
35+
{
36+
if (env.IsDevelopment())
4337
{
44-
if (env.IsDevelopment())
45-
{
46-
app.UseDeveloperExceptionPage();
47-
}
38+
app.UseDeveloperExceptionPage();
39+
}
4840

49-
app.UseHttpsRedirection();
41+
app.UseHttpsRedirection();
5042

51-
app.UseRouting();
43+
app.UseRouting();
5244

53-
app.UseAuthorization();
54-
app.UseSwagger
55-
(
56-
options =>
45+
app.UseAuthorization();
46+
app.UseSwagger
47+
(
48+
options =>
49+
{
50+
options.PreSerializeFilters.Add((swagger, httpReq) =>
5751
{
58-
options.PreSerializeFilters.Add((swagger, httpReq) =>
52+
if (!string.IsNullOrWhiteSpace(httpReq?.Host.Value))
5953
{
60-
if (!string.IsNullOrWhiteSpace(httpReq?.Host.Value))
61-
{
62-
swagger.Servers.Add
63-
(
64-
new OpenApiServer { Url = $"{httpReq.Scheme}://{httpReq.Host.Value}{{basePath}}" }
65-
.WithVariable("basePath", new OpenApiServerVariable { Default = "/test" })
66-
);
67-
}
68-
});
54+
swagger.Servers ??= [];
6955

70-
options.RemoveRoot("/test");
71-
}
72-
);
56+
swagger.Servers.Add
57+
(
58+
new OpenApiServer { Url = $"{httpReq.Scheme}://{httpReq.Host.Value}{{basePath}}" }
59+
.WithVariable("basePath", new OpenApiServerVariable { Default = "/test" })
60+
);
61+
}
62+
});
7363

74-
// Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
75-
// specifying the Swagger JSON endpoint.
76-
app.UseSwaggerUI(x =>
77-
{
78-
x.DocumentTitle = "SampleApp9000";
79-
x.SwaggerEndpoint("/swagger/sampleapp/swagger.json", "Sample App 9000");
80-
x.RoutePrefix = string.Empty;
81-
});
64+
options.RemoveRoot("/test");
65+
}
66+
);
8267

83-
app.UseEndpoints(endpoints =>
84-
{
85-
endpoints.MapControllers();
86-
});
87-
}
68+
// Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.),
69+
// specifying the Swagger JSON endpoint.
70+
app.UseSwaggerUI(x =>
71+
{
72+
x.DocumentTitle = "SampleApp9000";
73+
x.SwaggerEndpoint("/swagger/sampleapp/swagger.json", "Sample App 9000");
74+
x.RoutePrefix = string.Empty;
75+
});
76+
77+
app.UseEndpoints(endpoints =>
78+
{
79+
endpoints.MapControllers();
80+
});
8881
}
89-
}
82+
}

SampleApp9000/WeatherForecast.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
using System;
22

3-
namespace SampleApp9000
3+
namespace SampleApp9000;
4+
5+
public class WeatherForecast
46
{
5-
public class WeatherForecast
6-
{
7-
public DateTime Date { get; set; }
7+
public DateTime Date { get; set; }
88

9-
public int TemperatureC { get; set; }
9+
public int TemperatureC { get; set; }
1010

11-
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
11+
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
1212

13-
public string Summary { get; set; }
14-
}
15-
}
13+
public string Summary { get; set; }
14+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2+
<s:Boolean x:Key="/Default/UserDictionary/Words/=sampleapp/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

0 commit comments

Comments
 (0)