Skip to content
Open
7 changes: 6 additions & 1 deletion src/NServiceBus.AcceptanceTesting/Support/DeepCopy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace System
using System.ArrayExtensions;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.CompilerServices;

[Diagnostics.CodeAnalysis.SuppressMessage("Code", "PS0025:Dictionary keys should implement IEquatable<T>",
Justification = "A DeepCopy algorithm requires reference counting necessitating dictionaries keyed on objects by reference")]
Expand Down Expand Up @@ -123,7 +124,11 @@ public override int GetHashCode(object obj)
return 0;
}

return obj.GetHashCode();
// RuntimeHelpers.GetHashCode returns the identity hash code, which avoids
// calling ValueType.GetHashCode() on structs marked with [InlineArray]
// (that throws NotSupportedException). This matches the BCL
// System.Collections.Generic.ReferenceEqualityComparer behavior.
return RuntimeHelpers.GetHashCode(obj);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2451,13 +2451,26 @@ namespace NServiceBus.Transport
Default = 1,
Isolated = 2,
}
public class DispatchProperties : System.Collections.Generic.Dictionary<string, string>
public class DispatchProperties : System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<string, string>>, System.Collections.Generic.IDictionary<string, string>, System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, string>>, System.Collections.Generic.IReadOnlyCollection<System.Collections.Generic.KeyValuePair<string, string>>, System.Collections.Generic.IReadOnlyDictionary<string, string>, System.Collections.IEnumerable
{
public DispatchProperties() { }
public DispatchProperties(System.Collections.Generic.Dictionary<string, string> properties) { }
public NServiceBus.DelayedDelivery.DelayDeliveryWith DelayDeliveryWith { get; set; }
public NServiceBus.Performance.TimeToBeReceived.DiscardIfNotReceivedBefore DiscardIfNotReceivedBefore { get; set; }
public NServiceBus.DelayedDelivery.DoNotDeliverBefore DoNotDeliverBefore { get; set; }
public DispatchProperties(System.Collections.Generic.IDictionary<string, string> properties) { }
public int Count { get; }
public NServiceBus.DelayedDelivery.DelayDeliveryWith? DelayDeliveryWith { get; set; }
public NServiceBus.Performance.TimeToBeReceived.DiscardIfNotReceivedBefore? DiscardIfNotReceivedBefore { get; set; }
public NServiceBus.DelayedDelivery.DoNotDeliverBefore? DoNotDeliverBefore { get; set; }
public bool IsReadOnly { get; }
public string this[string key] { get; set; }
public System.Collections.Generic.ICollection<string> Keys { get; }
public System.Collections.Generic.ICollection<string> Values { get; }
public void Add(string key, string value) { }
public void Clear() { }
public bool ContainsKey(string key) { }
public System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<string, string>> GetEnumerator() { }
public bool Remove(string key) { }
public bool TryAdd(string key, string value) { }
public bool TryGetValue(string key, [System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)] out string value) { }
}
public class ErrorContext
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ NServiceBus.Settings.IReadOnlySettings
NServiceBus.Settings.SettingsHolder
NServiceBus.StaticHeadersConfigExtensions
NServiceBus.SubscriptionMigrationModeSettings
NServiceBus.Transport.DispatchProperties
NServiceBus.Transport.ErrorContext
NServiceBus.Transport.IMessageDispatcher
NServiceBus.Transport.IMessageReceiver
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,21 @@ NServiceBus.Extensibility.ContextBag+Slot violates the following rules:
- Field Value of type System.Object is a reference type.
- The size cannot be determined because there are fields that are reference types.

NServiceBus.Transport.DispatchProperties+Slot violates the following rules:
- The following fields are public, so the type is not immutable:
- Field Key of type System.String is public.
- Field Value of type System.String is public.
- The following fields are reference types, which are potentially mutable:
- Field Key of type System.String is a reference type.
- Field Value of type System.String is a reference type.
- The size cannot be determined because there are fields that are reference types.

NServiceBus.Transport.ReceiveProperties+Slot violates the following rules:
- The following fields are public, so the type is not immutable:
- Field Key of type System.String is public.
- Field Value of type System.String is public.
- The following fields are reference types, which are potentially mutable:
- Field Key of type System.String is a reference type.
- Field Value of type System.String is a reference type.
- The size cannot be determined because there are fields that are reference types.

Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void Should_wrap_provided_dictionary()
}

[Test]
public void Should_be_same_reference_as_source()
public void Should_copy_from_provided_dictionary()
{
var source = new Dictionary<string, string> { ["Key"] = "Value" };
var properties = new ReceiveProperties(source);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ static TransportOperation[] ConvertToOutboxOperations(Transport.TransportOperati
return transportOperations;
}

static void SerializeRoutingStrategy(AddressTag addressTag, Dictionary<string, string> options)
static void SerializeRoutingStrategy(AddressTag addressTag, DispatchProperties options)
{
switch (addressTag)
{
Expand All @@ -128,7 +128,7 @@ static void SerializeRoutingStrategy(AddressTag addressTag, Dictionary<string, s
}
}

static AddressTag DeserializeRoutingStrategy(Dictionary<string, string> options)
static AddressTag DeserializeRoutingStrategy(DispatchProperties options)
{
if (options.Remove("Destination", out var destination))
{
Expand Down
Loading