Skip to content

Commit 35e6058

Browse files
author
Tom Laird-McConnell
authored
Tomlm/fix deadlock regression when talking to emulator (#4569)
* fix deadlock * update echobot to use dialog for response.
1 parent 0fe9fd2 commit 35e6058

File tree

20 files changed

+81
-38
lines changed

20 files changed

+81
-38
lines changed

CSharp/EchoBot/App_Start/WebApiConfig.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System;
1+
using Newtonsoft.Json;
2+
using Newtonsoft.Json.Serialization;
3+
using System;
24
using System.Collections.Generic;
35
using System.Linq;
46
using System.Web.Http;
@@ -10,6 +12,16 @@ public static class WebApiConfig
1012
public static void Register(HttpConfiguration config)
1113
{
1214
// Web API configuration and services
15+
// Json settings
16+
config.Formatters.JsonFormatter.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
17+
config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
18+
config.Formatters.JsonFormatter.SerializerSettings.Formatting = Formatting.Indented;
19+
JsonConvert.DefaultSettings = () => new JsonSerializerSettings()
20+
{
21+
ContractResolver = new CamelCasePropertyNamesContractResolver(),
22+
Formatting = Newtonsoft.Json.Formatting.Indented,
23+
NullValueHandling = NullValueHandling.Ignore,
24+
};
1325

1426
// Web API routes
1527
config.MapHttpAttributeRoutes();

CSharp/EchoBot/Controllers/MessagesController.cs

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,36 @@
1-
using Microsoft.Bot.Connector;
1+
using Microsoft.Bot.Builder.Dialogs;
2+
using Microsoft.Bot.Connector;
23
using System;
3-
using System.Collections.Generic;
4-
using System.Linq;
5-
using System.Net;
64
using System.Net.Http;
75
using System.Threading.Tasks;
86
using System.Web.Http;
97

108
namespace EchoBot.Controllers
119
{
10+
[Serializable]
11+
public class RootDialog : IDialog<object>
12+
{
13+
public Task StartAsync(IDialogContext context)
14+
{
15+
context.Wait(MessageReceivedAsync);
16+
17+
return Task.CompletedTask;
18+
}
19+
20+
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable<object> result)
21+
{
22+
var activity = await result as Activity;
23+
24+
// calculate something for us to return
25+
int length = (activity.Text ?? string.Empty).Length;
26+
27+
// return our reply to the user
28+
await context.PostAsync($"You sent {activity.Text} which was {length} characters");
29+
30+
context.Wait(MessageReceivedAsync);
31+
}
32+
}
33+
1234
[BotAuthentication]
1335
public class MessagesController : ApiController
1436
{
@@ -17,10 +39,11 @@ public async Task Post([FromBody]Activity activity)
1739
{
1840
if (activity.Type == ActivityTypes.Message)
1941
{
20-
MicrosoftAppCredentials.AutoTokenRefreshTimeSpan = TimeSpan.FromSeconds(30);
42+
await Conversation.SendAsync(activity, () => new RootDialog());
43+
//MicrosoftAppCredentials.AutoTokenRefreshTimeSpan = TimeSpan.FromSeconds(30);
2144

22-
ConnectorClient client = new ConnectorClient(new Uri(activity.ServiceUrl), new MicrosoftAppCredentials());
23-
await client.Conversations.ReplyToActivityAsync(activity.CreateReply(activity.Text));
45+
//ConnectorClient client = new ConnectorClient(new Uri(activity.ServiceUrl), new MicrosoftAppCredentials());
46+
//await client.Conversations.ReplyToActivityAsync(activity.CreateReply(activity.Text));
2447
}
2548
}
2649
}

CSharp/EchoBot/EchoBot.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,14 @@
109109
<Folder Include="Models\" />
110110
</ItemGroup>
111111
<ItemGroup>
112+
<ProjectReference Include="..\Library\Microsoft.Bot.Builder.Autofac\Microsoft.Bot.Builder.Autofac.csproj">
113+
<Project>{2c145824-38dd-409c-ab52-b3538997726c}</Project>
114+
<Name>Microsoft.Bot.Builder.Autofac</Name>
115+
</ProjectReference>
116+
<ProjectReference Include="..\Library\Microsoft.Bot.Builder\Microsoft.Bot.Builder.csproj">
117+
<Project>{cdfec7d6-847e-4c13-956b-0a960ae3eb60}</Project>
118+
<Name>Microsoft.Bot.Builder</Name>
119+
</ProjectReference>
112120
<ProjectReference Include="..\Library\Microsoft.Bot.Connector.NetFramework\Microsoft.Bot.Connector.NetFramework.csproj">
113121
<Project>{df397efc-91db-4911-9971-c509926fc288}</Project>
114122
<Name>Microsoft.Bot.Connector.NetFramework</Name>

CSharp/Library/Microsoft.Bot.Builder.Autofac/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("3.15.2.0")]
36-
[assembly: AssemblyFileVersion("3.15.2.0")]
35+
[assembly: AssemblyVersion("3.15.2.1")]
36+
[assembly: AssemblyFileVersion("3.15.2.1")]
3737

3838
[assembly: InternalsVisibleTo("Microsoft.Bot.Builder.Tests")]
3939
[assembly: InternalsVisibleTo("Microsoft.Bot.Sample.Tests")]

CSharp/Library/Microsoft.Bot.Builder.Calling/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
// You can specify all the values or you can default the Build and Revision Numbers
3232
// by using the '*' as shown below:
3333
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly: AssemblyVersion("3.15.2.0")]
35-
[assembly: AssemblyFileVersion("3.15.2.0")]
34+
[assembly: AssemblyVersion("3.15.2.1")]
35+
[assembly: AssemblyFileVersion("3.15.2.1")]
3636

3737
//[assembly: AssemblyKeyFileAttribute(@"..\\..\\buildtools\\35MSSharedLib1024.snk")]
3838
//[assembly: AssemblyDelaySignAttribute(true)]

CSharp/Library/Microsoft.Bot.Builder.FormFlow.Json/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
// You can specify all the values or you can default the Build and Revision Numbers
3434
// by using the '*' as shown below:
3535
// [assembly: AssemblyVersion("1.0.*")]
36-
[assembly: AssemblyVersion("3.15.2.0")]
37-
[assembly: AssemblyFileVersion("3.15.2.0")]
36+
[assembly: AssemblyVersion("3.15.2.1")]
37+
[assembly: AssemblyFileVersion("3.15.2.1")]
3838

3939
[assembly: InternalsVisibleTo("Microsoft.Bot.Builder.Tests")]
4040
[assembly: InternalsVisibleTo("Microsoft.Bot.Sample.Tests")]

CSharp/Library/Microsoft.Bot.Builder.History/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
// You can specify all the values or you can default the Build and Revision Numbers
3232
// by using the '*' as shown below:
3333
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly: AssemblyVersion("3.15.2.0")]
35-
[assembly: AssemblyFileVersion("3.15.2.0")]
34+
[assembly: AssemblyVersion("3.15.2.1")]
35+
[assembly: AssemblyFileVersion("3.15.2.1")]
3636

3737
//[assembly: AssemblyKeyFileAttribute(@"..\\..\\buildtools\\35MSSharedLib1024.snk")]
3838
//[assembly: AssemblyDelaySignAttribute(true)]

CSharp/Library/Microsoft.Bot.Builder/ConnectorEx/IConnectorClientFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public ConnectorClientFactory(IAddress address, MicrosoftAppCredentials credenti
134134
if (IsEmulator(this.address))
135135
{
136136
// Send the mode notification (emulated OAuthCards or not) to the emulator
137-
Task.WaitAll(oauthClient.OAuthApi.SendEmulateOAuthCardsAsync(emulateOAuthCards.Value));
137+
Task.Run(async () => await oauthClient.OAuthApi.SendEmulateOAuthCardsAsync(emulateOAuthCards.Value).ConfigureAwait(false)).Wait();
138138
}
139139

140140
oauthClients[key] = oauthClient;

CSharp/Library/Microsoft.Bot.Builder/Microsoft.Bot.Builder.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<dependency id="Autofac" version="3.5.2"/>
2929
<dependency id="Chronic.Signed" version="0.3.2" />
3030
<dependency id="Microsoft.AspNet.WebAPI.Core" version="5.2.3" />
31-
<dependency id="Microsoft.Bot.Connector" version="3.15.2.0" />
31+
<dependency id="Microsoft.Bot.Connector" version="3.15.2.1" />
3232
<dependency id="Microsoft.Rest.ClientRuntime" version="2.3.2" />
3333
<dependency id="Newtonsoft.Json" version="9.0.1" />
3434
<dependency id="System.IdentityModel.Tokens.Jwt" version="5.1.4" />

CSharp/Library/Microsoft.Bot.Builder/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
// You can specify all the values or you can default the Build and Revision Numbers
3434
// by using the '*' as shown below:
3535
// [assembly: AssemblyVersion("1.0.*")]
36-
[assembly: AssemblyVersion("3.15.2.0")]
37-
[assembly: AssemblyFileVersion("3.15.2.0")]
36+
[assembly: AssemblyVersion("3.15.2.1")]
37+
[assembly: AssemblyFileVersion("3.15.2.1")]
3838

3939

4040
[assembly: InternalsVisibleTo("Microsoft.Bot.Builder.Tests")]

CSharp/Library/Microsoft.Bot.Connector.AspNetCore/Microsoft.Bot.Connector.AspNetCore.nuspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
33
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
44
<id>Microsoft.Bot.Connector.AspNetCore</id>
5-
<version>1.1.3.13</version>
5+
<version>1.1.3.14</version>
66
<authors>Microsoft</authors>
77
<owners>microsoft, BotFramework, nugetbotbuilder </owners>
88
<iconUrl>https://bots.botframework.com/Client/Images/bot-framework-default-7.png</iconUrl>
@@ -22,7 +22,7 @@
2222
<dependency id="Newtonsoft.Json" version="9.0.1" />
2323
<dependency id="System.IdentityModel.Tokens.Jwt" version="5.1.4" />
2424
<dependency id="Microsoft.AspNetCore.Mvc.Core" version="1.1.4" />
25-
<dependency id="Microsoft.Bot.Connector" version="3.15.2.0" />
25+
<dependency id="Microsoft.Bot.Connector" version="3.15.2.1" />
2626
</group>
2727
</dependencies>
2828
</metadata>

CSharp/Library/Microsoft.Bot.Connector.AspNetCore/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
[assembly: AssemblyCulture("")]
1313

1414

15-
[assembly: AssemblyVersion("1.1.3.13")]
16-
[assembly: AssemblyFileVersion("1.1.3.13")]
15+
[assembly: AssemblyVersion("1.1.3.14")]
16+
[assembly: AssemblyFileVersion("1.1.3.14")]
1717

1818
//[assembly: AssemblyKeyFileAttribute(@"..\\..\\buildtools\\35MSSharedLib1024.snk")]
1919
//[assembly: AssemblyDelaySignAttribute(true)]

CSharp/Library/Microsoft.Bot.Connector.AspNetCore2/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
[assembly: AssemblyCulture("")]
1111

1212

13-
[assembly: AssemblyVersion("2.0.1.5")]
14-
[assembly: AssemblyFileVersion("2.0.1.5")]
13+
[assembly: AssemblyVersion("2.0.1.6")]
14+
[assembly: AssemblyFileVersion("2.0.1.6")]
1515

1616
//[assembly: AssemblyKeyFileAttribute(@"..\\..\\buildtools\\35MSSharedLib1024.snk")]
1717
//[assembly: AssemblyDelaySignAttribute(true)]

CSharp/Library/Microsoft.Bot.Connector.AspNetCore2/Microsoft.Bot.Connector.AspNetCore2.nuspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
33
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
44
<id>Microsoft.Bot.Connector.AspNetCore</id>
5-
<version>2.0.1.5</version>
5+
<version>2.0.1.6</version>
66
<authors>Microsoft</authors>
77
<owners>microsoft, BotFramework, nugetbotbuilder </owners>
88
<iconUrl>https://bots.botframework.com/Client/Images/bot-framework-default-7.png</iconUrl>
@@ -19,7 +19,7 @@
1919
<dependency id="Microsoft.AspNetCore.Authentication.JwtBearer" version="2.0.0" />
2020
<dependency id="Microsoft.AspNetCore.Mvc" version="2.0.0" />
2121
<dependency id="Microsoft.Rest.ClientRuntime" version="2.3.10" />
22-
<dependency id="Microsoft.Bot.Connector" version="3.15.2.0" />
22+
<dependency id="Microsoft.Bot.Connector" version="3.15.2.1" />
2323
</group>
2424
</dependencies>
2525
</metadata>

CSharp/Library/Microsoft.Bot.Connector.Falcon/Microsoft.Bot.Connector.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
33
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
44
<id>Microsoft.Bot.Connector</id>
5-
<version>3.15.2.0</version>
5+
<version>3.15.2.1</version>
66
<authors>Microsoft</authors>
77
<owners>microsoft, BotFramework, nugetbotbuilder </owners>
88
<iconUrl>https://bots.botframework.com/Client/Images/bot-framework-default-7.png</iconUrl>

CSharp/Library/Microsoft.Bot.Connector.Falcon/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
[assembly: AssemblyTrademark("")]
1111
[assembly: AssemblyCulture("")]
1212

13-
[assembly: AssemblyVersion("3.15.2.0")]
14-
[assembly: AssemblyFileVersion("3.15.2.0")]
13+
[assembly: AssemblyVersion("3.15.2.1")]
14+
[assembly: AssemblyFileVersion("3.15.2.1")]
1515

1616
//[assembly: AssemblyKeyFileAttribute(@"..\\..\\buildtools\\35MSSharedLib1024.snk")]
1717
//[assembly: AssemblyDelaySignAttribute(true)]
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using System.Reflection;
22
using System.Resources;
33

4-
[assembly: AssemblyVersion("3.15.2.0")]
5-
[assembly: AssemblyFileVersion("3.15.2.0")]
4+
[assembly: AssemblyVersion("3.15.2.1")]
5+
[assembly: AssemblyFileVersion("3.15.2.1")]
66

77
//[assembly: AssemblyKeyFileAttribute(@"..\\..\\buildtools\\35MSSharedLib1024.snk")]
88
//[assembly: AssemblyDelaySignAttribute(true)]

CSharp/Library/Microsoft.Bot.Connector.NetFramework/Microsoft.Bot.Connector.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
33
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
44
<id>Microsoft.Bot.Connector</id>
5-
<version>3.15.2.0</version>
5+
<version>3.15.2.1</version>
66
<authors>Microsoft</authors>
77
<owners>microsoft, BotFramework, nugetbotbuilder </owners>
88
<iconUrl>https://bots.botframework.com/Client/Images/bot-framework-default-7.png</iconUrl>

CSharp/Library/Microsoft.Bot.Connector.NetFramework/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
[assembly: AssemblyTrademark("")]
1111
[assembly: AssemblyCulture("")]
1212

13-
[assembly: AssemblyVersion("3.15.2.0")]
14-
[assembly: AssemblyFileVersion("3.15.2.0")]
13+
[assembly: AssemblyVersion("3.15.2.1")]
14+
[assembly: AssemblyFileVersion("3.15.2.1")]
1515

1616
//[assembly: AssemblyKeyFileAttribute(@"..\\..\\buildtools\\35MSSharedLib1024.snk")]
1717
//[assembly: AssemblyDelaySignAttribute(true)]
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using System.Reflection;
22
using System.Runtime.InteropServices;
33

4-
[assembly: AssemblyVersion("3.15.2.0")]
5-
[assembly: AssemblyFileVersion("3.15.2.0")]
4+
[assembly: AssemblyVersion("3.15.2.1")]
5+
[assembly: AssemblyFileVersion("3.15.2.1")]
66

77
//[assembly: AssemblyKeyFileAttribute(@"..\\..\\buildtools\\35MSSharedLib1024.snk")]
88
//[assembly: AssemblyDelaySignAttribute(true)]

0 commit comments

Comments
 (0)