Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/guide/messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -427,14 +427,14 @@ public class SerializedMessage : ISerializable

public byte[] Write()
{
return Encoding.Default.GetBytes(Name);
return Encoding.UTF8.GetBytes(Name);
}

// You'll need at least C# 11 for static methods
// on interfaces!
public static object Read(byte[] bytes)
{
var name = Encoding.Default.GetString(bytes);
var name = Encoding.UTF8.GetString(bytes);
return new SerializedMessage { Name = name };
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/messaging/message-bus.md
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ IMessageBus bus = host.MessageBus();
// The raw message data, but pretend this was sourced from a database
// table or some other non-Wolverine storage in your system
byte[] messageData
= Encoding.Default.GetBytes("{\"Name\": \"George Karlaftis\"}");
= Encoding.UTF8.GetBytes("{\"Name\": \"George Karlaftis\"}");
```
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Transports/RabbitMQ/Wolverine.RabbitMQ.Tests/sending_raw_messages.cs#L164-L176' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_context_for_raw_message_sending' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->
Expand Down
4 changes: 2 additions & 2 deletions docs/guide/messaging/transports/sqs/interoperability.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public class CustomSqsMapper : ISqsEnvelopeMapper
public string BuildMessageBody(Envelope envelope)
{
// Serialized data from the Wolverine message
return Encoding.Default.GetString(envelope.Data);
return Encoding.UTF8.GetString(envelope.Data);
}

// Specify header values for the SQS message from the Wolverine envelope
Expand All @@ -81,7 +81,7 @@ public class CustomSqsMapper : ISqsEnvelopeMapper
public void ReadEnvelopeData(Envelope envelope, string messageBody,
IDictionary<string, MessageAttributeValue> attributes)
{
envelope.Data = Encoding.Default.GetBytes(messageBody);
envelope.Data = Encoding.UTF8.GetBytes(messageBody);

if (attributes.TryGetValue("tenant-id", out var att))
{
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/interop.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public void UseNServiceBusInterop()
{
if (props.Headers.TryGetValue("NServiceBus.ReplyToAddress", out var raw))
{
var queueName = (raw is byte[] b ? Encoding.Default.GetString(b) : raw.ToString())!;
var queueName = (raw is byte[] b ? Encoding.UTF8.GetString(b) : raw.ToString())!;
e.ReplyUri = new Uri($"{_parent.Protocol}://queue/{queueName}");
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Wolverine.Http/NewtonsoftHttpSerialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public async Task WriteJsonAsync(HttpContext context, object? body)

var responseStream = response.Body;

await using var textWriter = new HttpResponseStreamWriter(responseStream, Encoding.Default, _bufferSize, _bytePool,
await using var textWriter = new HttpResponseStreamWriter(responseStream, Encoding.UTF8, _bufferSize, _bytePool,
ArrayPool<char>.Shared);
using var jsonWriter = new JsonTextWriter(textWriter)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ public class SerializedMessage : ISerializable

public byte[] Write()
{
return Encoding.Default.GetBytes(Name);
return Encoding.UTF8.GetBytes(Name);
}

// You'll need at least C# 11 for static methods
// on interfaces!
public static object Read(byte[] bytes)
{
var name = Encoding.Default.GetString(bytes);
var name = Encoding.UTF8.GetString(bytes);
return new SerializedMessage { Name = name };
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Testing/SlowTests/intrinsic_serialization_end_to_end.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ public class SerializedMessage : ISerializable

public byte[] Write()
{
return Encoding.Default.GetBytes(Name);
return Encoding.UTF8.GetBytes(Name);
}

public static object Read(byte[] bytes)
{
var name = Encoding.Default.GetString(bytes);
var name = Encoding.UTF8.GetString(bytes);
return new SerializedMessage { Name = name };
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ public class CustomSqsMapper : ISqsEnvelopeMapper
public string BuildMessageBody(Envelope envelope)
{
// Serialized data from the Wolverine message
return Encoding.Default.GetString(envelope.Data!);
return Encoding.UTF8.GetString(envelope.Data!);
}

// Specify header values for the SQS message from the Wolverine envelope
Expand All @@ -405,7 +405,7 @@ public IEnumerable<KeyValuePair<string, MessageAttributeValue>> ToAttributes(Env
public void ReadEnvelopeData(Envelope envelope, string messageBody,
IDictionary<string, MessageAttributeValue> attributes)
{
envelope.Data = Encoding.Default.GetBytes(messageBody);
envelope.Data = Encoding.UTF8.GetBytes(messageBody);

if (attributes.TryGetValue("tenant-id", out var att))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ void ReadReplyUri(Envelope e, ServiceBusReceivedMessage serviceBusReceivedMessag
if (serviceBusReceivedMessage.ApplicationProperties.TryGetValue("NServiceBus.ReplyToAddress",
out var raw))
{
var queueName = (raw is byte[] b ? Encoding.Default.GetString(b) : raw.ToString())!;
var queueName = (raw is byte[] b ? Encoding.UTF8.GetString(b) : raw.ToString())!;
e.ReplyUri = new Uri($"{Parent.Protocol}://queue/{queueName}");
}
}
Expand All @@ -255,7 +255,7 @@ void ReadReplyUri(Envelope e, ServiceBusReceivedMessage serviceBusReceivedMessag
// Incoming
if (m.ApplicationProperties.TryGetValue("NServiceBus.EnclosedMessageTypes", out var raw))
{
var typeName = (raw is byte[] b ? Encoding.Default.GetString(b) : raw.ToString())!;
var typeName = (raw is byte[] b ? Encoding.UTF8.GetString(b) : raw.ToString())!;
if (typeName.IsNotEmpty())
{
var messageType = Type.GetType(typeName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ void ReadReplyUri(Envelope e, ServiceBusReceivedMessage serviceBusReceivedMessag
if (serviceBusReceivedMessage.ApplicationProperties.TryGetValue("NServiceBus.ReplyToAddress",
out var raw))
{
var queueName = (raw is byte[] b ? Encoding.Default.GetString(b) : raw.ToString())!;
var queueName = (raw is byte[] b ? Encoding.UTF8.GetString(b) : raw.ToString())!;
e.ReplyUri = new Uri($"{Parent.Protocol}://queue/{queueName}");
}
}
Expand All @@ -265,7 +265,7 @@ void ReadReplyUri(Envelope e, ServiceBusReceivedMessage serviceBusReceivedMessag
{
if (msg.ApplicationProperties.TryGetValue("NServiceBus.EnclosedMessageTypes", out var raw))
{
var typeName = (raw is byte[] b ? Encoding.Default.GetString(b) : raw.ToString())!;
var typeName = (raw is byte[] b ? Encoding.UTF8.GetString(b) : raw.ToString())!;
if (typeName.IsNotEmpty())
{
var messageType = Type.GetType(typeName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ void ReadReplyUri(Envelope e, ServiceBusReceivedMessage serviceBusReceivedMessag
if (serviceBusReceivedMessage.ApplicationProperties.TryGetValue("NServiceBus.ReplyToAddress",
out var raw))
{
var queueName = (raw is byte[] b ? Encoding.Default.GetString(b) : raw.ToString())!;
var queueName = (raw is byte[] b ? Encoding.UTF8.GetString(b) : raw.ToString())!;
e.ReplyUri = new Uri($"{Parent.Protocol}://queue/{queueName}");
}
}
Expand All @@ -161,7 +161,7 @@ void ReadReplyUri(Envelope e, ServiceBusReceivedMessage serviceBusReceivedMessag
{
if (msg.ApplicationProperties.TryGetValue("NServiceBus.EnclosedMessageTypes", out var raw))
{
var typeName = (raw is byte[] b ? Encoding.Default.GetString(b) : raw.ToString())!;
var typeName = (raw is byte[] b ? Encoding.UTF8.GetString(b) : raw.ToString())!;
if (typeName.IsNotEmpty())
{
var messageType = Type.GetType(typeName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void MapEnvelopeToOutgoing(Envelope envelope, Message<string, byte[]> out
}
else if (envelope.Message != null)
{
outgoing.Value = Encoding.Default.GetBytes(JsonSerializer.Serialize(envelope.Message, _options));
outgoing.Value = Encoding.UTF8.GetBytes(JsonSerializer.Serialize(envelope.Message, _options));
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ public KafkaEnvelopeMapper(Endpoint endpoint) : base(endpoint)

protected override void writeOutgoingHeader(Message<string, byte[]> outgoing, string key, string value)
{
outgoing.Headers.Add(key, Encoding.Default.GetBytes(value));
outgoing.Headers.Add(key, Encoding.UTF8.GetBytes(value));
}

protected override bool tryReadIncomingHeader(Message<string, byte[]> incoming, string key, out string value)
{
if (incoming.Headers.TryGetLastBytes(key, out var bytes))
{
value = Encoding.Default.GetString(bytes);
value = Encoding.UTF8.GetString(bytes);
return true;
}

Expand All @@ -35,7 +35,7 @@ protected override void writeIncomingHeaders(Message<string, byte[]> incoming, E
foreach (var header in incoming.Headers)
{
var bytes = header.GetValueBytes();
envelope.Headers[header.Key] = bytes != null ? Encoding.Default.GetString(bytes) : null;
envelope.Headers[header.Key] = bytes != null ? Encoding.UTF8.GetString(bytes) : null;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Transports/Kafka/Wolverine.Kafka/KafkaTopic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public async ValueTask<bool> CheckAsync()
await client.ProduceAsync(TopicName, new Message<string, byte[]>
{
Key = "ping",
Value = Encoding.Default.GetBytes("ping")
Value = Encoding.UTF8.GetBytes("ping")
});


Expand Down
2 changes: 1 addition & 1 deletion src/Transports/Kafka/Wolverine.Kafka/KafkaTopicGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public override bool TryBuildDeadLetterSender(IWolverineRuntime runtime, out ISe
await client.ProduceAsync(topicName, new Message<string, byte[]>
{
Key = "ping",
Value = System.Text.Encoding.Default.GetBytes("ping")
Value = System.Text.Encoding.UTF8.GetBytes("ping")
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/Transports/MQTT/Wolverine.MQTT.Tests/connectivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public async Task can_connect_to_a_local_broker()

managedClient.ApplicationMessageReceivedAsync += e =>
{
_output.WriteLine(">> RECEIVED: " + e.ApplicationMessage.Topic + ", " + Encoding.Default.GetString(e.ApplicationMessage.PayloadSegment));
_output.WriteLine(">> RECEIVED: " + e.ApplicationMessage.Topic + ", " + Encoding.UTF8.GetString(e.ApplicationMessage.PayloadSegment));
return CompletedTask.Instance;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public async Task ReceiveAsync(MqttApplicationMessageReceivedEventArgs args)
{
_logger.LogError(e, "Error trying to map an incoming MQTT message {MessageId} to an Envelope",
args.ApplicationMessage.CorrelationData != null
? Encoding.Default.GetString(args.ApplicationMessage.CorrelationData)
? Encoding.UTF8.GetString(args.ApplicationMessage.CorrelationData)
: "(none)");

// MoveToErrorsAsync keys the envelope by Id; the mapper threw before
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public static async Task send_messages_with_raw_data()
// The raw message data, but pretend this was sourced from a database
// table or some other non-Wolverine storage in your system
byte[] messageData
= Encoding.Default.GetBytes("{\"Name\": \"George Karlaftis\"}");
= Encoding.UTF8.GetBytes("{\"Name\": \"George Karlaftis\"}");

#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void ReadReplyUri(Envelope e, IReadOnlyBasicProperties props)
{
if (props.Headers!.TryGetValue("NServiceBus.ReplyToAddress", out var raw))
{
var queueName = (raw is byte[] b ? Encoding.Default.GetString(b) : raw!.ToString())!;
var queueName = (raw is byte[] b ? Encoding.UTF8.GetString(b) : raw!.ToString())!;
e.ReplyUri = new Uri($"{_parent.Protocol}://queue/{queueName}");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected override bool tryReadIncomingHeader(IReadOnlyBasicProperties incoming,

if (incoming.Headers.TryGetValue(key, out var raw))
{
value = (raw is byte[] b ? Encoding.Default.GetString(b) : raw!.ToString())!;
value = (raw is byte[] b ? Encoding.UTF8.GetString(b) : raw!.ToString())!;
return true;
}

Expand All @@ -82,7 +82,7 @@ protected override void writeIncomingHeaders(IReadOnlyBasicProperties incoming,
foreach (var pair in incoming.Headers)
{
envelope.Headers[pair.Key] =
pair.Value is byte[] b ? Encoding.Default.GetString(b) : pair.Value?.ToString();
pair.Value is byte[] b ? Encoding.UTF8.GetString(b) : pair.Value?.ToString();
}
}
}
Loading