Skip to content

Commit 4c9aa8f

Browse files
authored
Merge pull request #1518 from kengibous/rsc-csharp-example-update
chore: update to dotnet 8, drop startup.cs and use CloudAdapter
2 parents 12ec12c + 00ec02d commit 4c9aa8f

File tree

5 files changed

+42
-80
lines changed

5 files changed

+42
-80
lines changed

samples/bot-receive-channel-messages-withRSC/csharp/ReceiveMessagesWithRSC/AdapterWithErrorHandler.cs

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33
//
4-
// Generated with Bot Builder V4 SDK Template for Visual Studio CoreBot v4.14.0
54

65
using Microsoft.Bot.Builder.Integration.AspNet.Core;
76
using Microsoft.Bot.Builder.TraceExtensions;
87
using Microsoft.Extensions.Configuration;
98
using Microsoft.Extensions.Logging;
9+
using System.Net.Http;
1010

1111
namespace ReceiveMessagesWithRSC
1212
{
13-
public class AdapterWithErrorHandler : BotFrameworkHttpAdapter
13+
public class AdapterWithErrorHandler : CloudAdapter
1414
{
15-
public AdapterWithErrorHandler(IConfiguration configuration, ILogger<BotFrameworkHttpAdapter> logger)
16-
: base(configuration, logger)
15+
public AdapterWithErrorHandler(
16+
IConfiguration configuration,
17+
IHttpClientFactory httpClientFactory,
18+
ILogger<IBotFrameworkHttpAdapter> logger)
19+
: base(configuration, httpClientFactory, logger)
1720
{
1821
OnTurnError = async (turnContext, exception) =>
1922
{
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,40 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33
//
4-
// Generated with Bot Builder V4 SDK Template for Visual Studio EchoBot v4.14.0
54

5+
using Microsoft.AspNetCore.Builder;
66
using Microsoft.AspNetCore.Hosting;
7+
using Microsoft.Bot.Builder;
8+
using Microsoft.Bot.Builder.Integration.AspNet.Core;
9+
using Microsoft.Extensions.DependencyInjection;
710
using Microsoft.Extensions.Hosting;
11+
using ReceiveMessagesWithRSC;
12+
using ReceiveMessagesWithRSC.Bots;
813

9-
namespace ReceiveMessagesWithRSC
10-
{
11-
public class Program
12-
{
13-
public static void Main(string[] args)
14-
{
15-
CreateHostBuilder(args).Build().Run();
16-
}
14+
var builder = WebApplication.CreateBuilder(args);
15+
16+
builder.Services.AddHttpClient().AddControllers().AddNewtonsoftJson();
17+
builder.Services.AddSingleton<IBotFrameworkHttpAdapter, AdapterWithErrorHandler>();
18+
builder.Services.AddTransient<IBot, ActivityBot>();
1719

18-
public static IHostBuilder CreateHostBuilder(string[] args) =>
19-
Host.CreateDefaultBuilder(args)
20-
.ConfigureWebHostDefaults(webBuilder =>
21-
{
22-
webBuilder.UseStartup<Startup>();
23-
});
24-
}
20+
var app = builder.Build();
21+
22+
if (!app.Environment.IsDevelopment())
23+
{
24+
app.UseHsts();
2525
}
26+
else
27+
{
28+
app.UseDeveloperExceptionPage();
29+
}
30+
31+
app.UseDefaultFiles()
32+
.UseStaticFiles()
33+
.UseWebSockets()
34+
.UseRouting()
35+
.UseAuthorization()
36+
.UseEndpoints(endpoints =>
37+
{
38+
endpoints.MapControllers();
39+
});
40+
app.Run();

samples/bot-receive-channel-messages-withRSC/csharp/ReceiveMessagesWithRSC/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This feature shown in this sample is currently available in Public Developer Pre
1111

1212
## Prerequisites
1313

14-
- [.NET Core SDK](https://dotnet.microsoft.com/download) version 6.0
14+
- [.NET Core SDK](https://dotnet.microsoft.com/download) version 8.0
1515

1616
```bash
1717
# determine dotnet version

samples/bot-receive-channel-messages-withRSC/csharp/ReceiveMessagesWithRSC/ReceiveMessagesWithRSC.csproj

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

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<LangVersion>latest</LangVersion>
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.11" />
10-
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.18.1" />
9+
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.11" />
10+
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.22.9" />
1111
</ItemGroup>
1212

1313
<ItemGroup>

samples/bot-receive-channel-messages-withRSC/csharp/ReceiveMessagesWithRSC/Startup.cs

-56
This file was deleted.

0 commit comments

Comments
 (0)