Skip to content

Commit

Permalink
chore: no warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
richardschneider committed Aug 23, 2019
1 parent 6fa15cc commit 937d84b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/PeerTalk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<RootNamespace>PeerTalk</RootNamespace>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
<DebugType>portable</DebugType>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

<!-- developer build is always 0.42 -->
<AssemblyVersion>0.42</AssemblyVersion>
Expand Down
6 changes: 6 additions & 0 deletions src/PubSub/NotificationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ public Task PublishAsync(string topic, Stream message, CancellationToken cancel
{
using (var ms = new MemoryStream())
{
#pragma warning disable VSTHRD103
message.CopyTo(ms);
#pragma warning disable VSTHRD103
return PublishAsync(topic, ms.ToArray(), cancel);
}
}
Expand All @@ -178,6 +180,9 @@ public async Task SubscribeAsync(string topic, Action<IPublishedMessage> handler
{
var topicHandler = new TopicHandler { Topic = topic, Handler = handler };
topicHandlers.Add(topicHandler);

// TODO: need a better way.
#pragma warning disable VSTHRD101
cancellationToken.Register(async () =>
{
topicHandlers.Remove(topicHandler);
Expand All @@ -186,6 +191,7 @@ public async Task SubscribeAsync(string topic, Action<IPublishedMessage> handler
await Task.WhenAll(Routers.Select(r => r.LeaveTopicAsync(topic, CancellationToken.None))).ConfigureAwait(false);
}
});
#pragma warning restore VSTHRD101

// Tell routers if first time.
if (topicHandlers.Count(t => t.Topic == topic) == 1)
Expand Down
2 changes: 1 addition & 1 deletion src/Swarm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ async Task<PeerConnection> DialAsync(Peer remote, IEnumerable<MultiAddress> addr
{
var attempts = possibleAddresses
.Select(a => DialAsync(remote, a, cts.Token));
connection = await TaskHelper.WhenAnyResult(attempts, cts.Token).ConfigureAwait(false);
connection = await TaskHelper.WhenAnyResultAsync(attempts, cts.Token).ConfigureAwait(false);
cts.Cancel(); // stop other dialing tasks.
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/TaskHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static class TaskHelper
/// Returns the result of the first task that is not
/// faulted or canceled.
/// </remarks>
public static async Task<T> WhenAnyResult<T>(
public static async Task<T> WhenAnyResultAsync<T>(
IEnumerable<Task<T>> tasks,
CancellationToken cancel)
{
Expand Down

0 comments on commit 937d84b

Please sign in to comment.