Skip to content

Commit

Permalink
Fix dotnet build warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mtmk committed Oct 14, 2024
1 parent 4e42b11 commit b24562c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion examples/messaging/concurrent/csharp/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
// start processing messages in parallel.
var subscription = Task.Run(async () =>
{
await Parallel.ForEachAsync(nc.SubscribeAsync<string>("greet", cancellationToken: cts.Token), async (msg, _) =>
await Parallel.ForEachAsync(nc.SubscribeAsync<string>("greet", cancellationToken: cts.Token), (msg, _) =>
{
Console.WriteLine($"Received {msg.Data}");
return ValueTask.CompletedTask;
});
});

Expand Down
1 change: 1 addition & 0 deletions examples/messaging/json/csharp/messaging-json.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down
10 changes: 5 additions & 5 deletions examples/messaging/protobuf/csharp/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
// This request uses the default serializer for the connection assigned to connection options above.
// Alternatively we could've passed the individual serializer to the request method.
var reply = await nats.RequestAsync<GreetRequest, GreetReply>(subject: "greet", new GreetRequest { Name = "bob" });
Console.WriteLine($"Response = {reply.Data.Text}...");
Console.WriteLine($"Response = {reply.Data?.Text}...");

// Send an empty message to indicate we are done.
await nats.PublishAsync("greet");
Expand Down Expand Up @@ -115,7 +115,7 @@ public class GreetRequest : IMessage<GreetRequest>, IBufferMessage
{
public static readonly MessageParser<GreetRequest> Parser = new(() => new GreetRequest());

public string Name { get; set; }
public string? Name { get; set; }

public void MergeFrom(GreetRequest message) => Name = message.Name;

Expand All @@ -138,7 +138,7 @@ public void WriteTo(CodedOutputStream output)

public MessageDescriptor Descriptor => null!;

public bool Equals(GreetRequest other) => string.Equals(other?.Name, Name);
public bool Equals(GreetRequest? other) => string.Equals(other?.Name, Name);

public GreetRequest Clone() => new() { Name = Name };

Expand All @@ -162,7 +162,7 @@ public class GreetReply : IMessage<GreetReply>, IBufferMessage
{
public static readonly MessageParser<GreetReply> Parser = new(() => new GreetReply());

public string Text { get; set; }
public string? Text { get; set; }

public void MergeFrom(GreetReply message) => Text = message.Text;

Expand All @@ -185,7 +185,7 @@ public void WriteTo(CodedOutputStream output)

public MessageDescriptor Descriptor => null!;

public bool Equals(GreetReply other) => string.Equals(other?.Text, Text);
public bool Equals(GreetReply? other) => string.Equals(other?.Text, Text);

public GreetReply Clone() => new() { Text = Text };

Expand Down

0 comments on commit b24562c

Please sign in to comment.