Skip to content

Commit 08e1837

Browse files
#1479 Rework conditional packages in v6 branch including adding net 6 (#1482)
* Have added net 6 as a TFM and implement conditional packages Revert NetworkOrderDeserializer Have ported some changes from V7 + Reviewed conditional compiles * Bump Erlang and RabbitMQ versions for CI --------- Co-authored-by: Luke Bakken <[email protected]>
1 parent 1b9a40d commit 08e1837

24 files changed

+1063
-62
lines changed

.ci/versions.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"erlang": "26.0.2",
3-
"rabbitmq": "3.12.4"
2+
"erlang": "26.2.3",
3+
"rabbitmq": "3.13.0"
44
}

projects/RabbitMQ.Client.OAuth2/RabbitMQ.Client.OAuth2.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net462;netstandard2.0</TargetFrameworks>
4+
<TargetFrameworks>net462;netstandard2.0;net6.0</TargetFrameworks>
55
<NoWarn>$(NoWarn);CS1591</NoWarn>
66
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
77
<AssemblyTitle>RabbitMQ OAuth2 Client Library for .NET</AssemblyTitle>
@@ -59,6 +59,9 @@
5959
<ItemGroup>
6060
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
6161
<PackageReference Include="MinVer" Version="4.3.0" PrivateAssets="all" />
62+
</ItemGroup>
63+
64+
<ItemGroup Condition="$(TargetFramework) == 'net462' OR $(TargetFramework) == 'netstandard2.0'">
6265
<PackageReference Include="System.Net.Http.Json" Version="7.0.1" />
6366
<PackageReference Include="System.Text.Json" Version="7.0.2" />
6467
</ItemGroup>

projects/RabbitMQ.Client/RabbitMQ.Client.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net462;netstandard2.0</TargetFrameworks>
4+
<TargetFrameworks>net462;netstandard2.0;net6.0</TargetFrameworks>
55
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
66
<NoWarn>$(NoWarn);CS1591</NoWarn>
77
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
@@ -60,10 +60,10 @@
6060
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
6161

6262
<PackageReference Include="MinVer" Version="4.3.0" PrivateAssets="All" />
63-
<PackageReference Include="System.Threading.Channels" Version="7.0.0" />
6463
</ItemGroup>
6564

66-
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'">
65+
<ItemGroup Condition="$(TargetFramework) == 'net462' OR $(TargetFramework) == 'netstandard2.0'">
66+
<PackageReference Include="System.Threading.Channels" Version="7.0.0" />
6767
<PackageReference Include="System.Memory" Version="4.5.5" />
6868
</ItemGroup>
6969

projects/RabbitMQ.Client/client/exceptions/AlreadyClosedException.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ namespace RabbitMQ.Client.Exceptions
3636
/// <summary>Thrown when the application tries to make use of a
3737
/// session or connection that has already been shut
3838
/// down.</summary>
39-
#if !NETSTANDARD1_5
4039
[Serializable]
41-
#endif
4240
public class AlreadyClosedException : OperationInterruptedException
4341
{
4442
///<summary>Construct an instance containing the given

projects/RabbitMQ.Client/client/exceptions/AuthenticationFailureException.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ namespace RabbitMQ.Client.Exceptions
3535
{
3636
/// <summary> Thrown when the cause is an
3737
/// authentication failure. </summary>
38-
#if !NETSTANDARD1_5
3938
[Serializable]
40-
#endif
4139
public class AuthenticationFailureException : PossibleAuthenticationFailureException
4240
{
4341
public AuthenticationFailureException(string msg) : base(msg)

projects/RabbitMQ.Client/client/exceptions/BrokerUnreachableException.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ namespace RabbitMQ.Client.Exceptions
3636
{
3737
///<summary>Thrown when no connection could be opened during a
3838
///ConnectionFactory.CreateConnection attempt.</summary>
39-
#if !NETSTANDARD1_5
4039
[Serializable]
41-
#endif
4240
public class BrokerUnreachableException : IOException
4341
{
4442
///<summary>Construct a BrokerUnreachableException. The inner exception is

projects/RabbitMQ.Client/client/exceptions/ChannelAllocationException.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ namespace RabbitMQ.Client.Exceptions
3636
/// <summary> Thrown when a SessionManager cannot allocate a new
3737
/// channel number, or the requested channel number is already in
3838
/// use. </summary>
39-
#if !NETSTANDARD1_5
4039
[Serializable]
41-
#endif
4240
public class ChannelAllocationException : ProtocolViolationException
4341
{
4442
/// <summary>

projects/RabbitMQ.Client/client/exceptions/ConnectFailureException.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@
3434
namespace RabbitMQ.Client.Exceptions
3535
{
3636
/// <summary>Thrown when a connection to the broker fails</summary>
37-
#if !NETSTANDARD1_5
3837
[Serializable]
39-
#endif
4038
public class ConnectFailureException : ProtocolViolationException
4139
{
4240
public ConnectFailureException(string msg, Exception inner)

projects/RabbitMQ.Client/client/exceptions/OperationInterruptedException.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ namespace RabbitMQ.Client.Exceptions
4040
/// operation, an OperationInterruptedException will be thrown to
4141
/// the caller of IModel.QueueDeclare.
4242
/// </summary>
43-
#if !NETSTANDARD1_5
4443
[Serializable]
45-
#endif
4644
public class OperationInterruptedException
4745
// TODO: inherit from OperationCanceledException
4846
: RabbitMQClientException

projects/RabbitMQ.Client/client/exceptions/PacketNotRecognizedException.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ namespace RabbitMQ.Client.Exceptions
4141
///The peer's {'A','M','Q','P',txHi,txLo,major,minor} packet is
4242
///decoded into instances of this class.
4343
///</remarks>
44-
#if !NETSTANDARD1_5
4544
[Serializable]
46-
#endif
4745
public class PacketNotRecognizedException : RabbitMQClientException
4846
{
4947
///<summary>Fills the new instance's properties with the values passed in.</summary>

projects/RabbitMQ.Client/client/exceptions/PossibleAuthenticationFailureException.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ namespace RabbitMQ.Client.Exceptions
3535
{
3636
/// <summary> Thrown when the likely cause is an
3737
/// authentication failure. </summary>
38-
#if !NETSTANDARD1_5
3938
[Serializable]
40-
#endif
4139
public class PossibleAuthenticationFailureException : RabbitMQClientException
4240
{
4341
public PossibleAuthenticationFailureException(string msg, Exception inner) : base(msg, inner)

projects/RabbitMQ.Client/client/exceptions/ProtocolVersionMismatchException.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ namespace RabbitMQ.Client.Exceptions
3636
///<summary>Thrown to indicate that the peer does not support the
3737
///wire protocol version we requested immediately after opening
3838
///the TCP socket.</summary>
39-
#if !NETSTANDARD1_5
4039
[Serializable]
41-
#endif
4240
public class ProtocolVersionMismatchException : ProtocolViolationException
4341
{
4442
///<summary>Fills the new instance's properties with the values passed in.</summary>

projects/RabbitMQ.Client/client/exceptions/ProtocolViolationException.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@
3333

3434
namespace RabbitMQ.Client.Exceptions
3535
{
36-
#if !NETSTANDARD1_5
3736
[Serializable]
38-
#endif
3937
public class ProtocolViolationException : RabbitMQClientException
4038
{
4139
public ProtocolViolationException(string message) : base(message)

projects/RabbitMQ.Client/client/exceptions/RabbitMQClientException.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@
3333

3434
namespace RabbitMQ.Client.Exceptions
3535
{
36-
#if !NETSTANDARD1_5
3736
[Serializable]
38-
#endif
3937
public abstract class RabbitMQClientException : Exception
4038
{
4139
/// <summary>Initializes a new instance of the <see cref="RabbitMQClientException" /> class.</summary>

projects/RabbitMQ.Client/client/exceptions/UnexpectedMethodException.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ namespace RabbitMQ.Client.Exceptions
3636
/// <summary>
3737
/// Thrown when the model receives an RPC reply that it wasn't expecting.
3838
/// </summary>
39-
#if !NETSTANDARD1_5
4039
[Serializable]
41-
#endif
4240
public class UnexpectedMethodException : ProtocolViolationException
4341
{
4442
public UnexpectedMethodException(IMethod method)

projects/RabbitMQ.Client/client/exceptions/UnsupportedMethodException.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ namespace RabbitMQ.Client.Exceptions
3636
/// <summary>
3737
/// Thrown when the model receives an RPC request it cannot satisfy.
3838
/// </summary>
39-
#if !NETSTANDARD1_5
4039
[Serializable]
41-
#endif
4240
public class UnsupportedMethodException : NotSupportedException
4341
{
4442
public UnsupportedMethodException(string methodName)

projects/RabbitMQ.Client/client/exceptions/UnsupportedMethodFieldException.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ namespace RabbitMQ.Client.Exceptions
3737
/// because the version of the protocol the model is implementing
3838
/// does not contain a definition for the field in
3939
/// question.</summary>
40-
#if !NETSTANDARD1_5
4140
[Serializable]
42-
#endif
4341
public class UnsupportedMethodFieldException : NotSupportedException
4442
{
4543
public UnsupportedMethodFieldException(string methodName, string fieldName)

projects/RabbitMQ.Client/client/exceptions/WireFormattingException.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ namespace RabbitMQ.Client.Exceptions
3535
{
3636
/// <summary> Thrown when the wire-formatting code cannot encode a
3737
/// particular .NET value to AMQP protocol format. </summary>
38-
#if !NETSTANDARD1_5
3938
[Serializable]
40-
#endif
4139
public class WireFormattingException : ProtocolViolationException
4240
{
4341
///<summary>Construct a WireFormattingException with no

projects/RabbitMQ.Client/client/logging/RabbitMqClientEventSource.cs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ namespace RabbitMQ.Client.Logging
3838
[EventSource(Name = "rabbitmq-dotnet-client")]
3939
public sealed class RabbitMqClientEventSource : EventSource
4040
{
41+
public static readonly RabbitMqClientEventSource Log = new RabbitMqClientEventSource();
4142
public class Keywords
4243
{
4344
public const EventKeywords Log = (EventKeywords)1;
@@ -47,8 +48,6 @@ public RabbitMqClientEventSource() : base(EventSourceSettings.EtwSelfDescribingE
4748
{
4849
}
4950

50-
public static RabbitMqClientEventSource Log = new RabbitMqClientEventSource();
51-
5251
[Event(1, Message = "INFO", Keywords = Keywords.Log, Level = EventLevel.Informational)]
5352
public void Info(string message)
5453
{
@@ -67,20 +66,25 @@ public void Warn(string message)
6766
public void Error(string message, RabbitMqExceptionDetail ex)
6867
{
6968
if (IsEnabled())
69+
#if NET6_0_OR_GREATER
7070
WriteExceptionEvent(message, ex);
71+
#else
72+
WriteEvent(3, message, ex);
73+
#endif
7174
}
7275

7376
[NonEvent]
74-
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "The properties are preserved with the DynamicallyAccessedMembers attribute.")]
75-
private void WriteExceptionEvent<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] T>(string message, T ex)
77+
public void Error(string message, Exception ex)
7678
{
77-
WriteEvent(3, message, ex);
79+
Error(message, new RabbitMqExceptionDetail(ex));
7880
}
7981

80-
[NonEvent]
81-
public void Error(string message, Exception ex)
82+
#if NET6_0_OR_GREATER
83+
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "The properties are preserved with the DynamicallyAccessedMembers attribute.")]
84+
private void WriteExceptionEvent<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] T>(string message, T ex)
8285
{
83-
Error(message, new RabbitMqExceptionDetail(ex));
86+
WriteEvent(3, message, ex);
8487
}
88+
#endif
8589
}
8690
}

projects/RabbitMQ.Client/util/NetworkOrderDeserializer.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ internal static double ReadDouble(ReadOnlySpan<byte> span)
1515
throw new ArgumentOutOfRangeException(nameof(span), "Insufficient length to decode Double from memory.");
1616
}
1717
ulong val = ReadUInt64(span);
18-
#elif NETSTANDARD
18+
#else
1919
ulong val = BinaryPrimitives.ReadUInt64BigEndian(span);
2020
#endif
2121
return Unsafe.As<ulong, double>(ref val);
@@ -31,7 +31,7 @@ internal static short ReadInt16(ReadOnlySpan<byte> span)
3131
}
3232

3333
return (short)ReadUInt16(span);
34-
#elif NETSTANDARD
34+
#else
3535
return BinaryPrimitives.ReadInt16BigEndian(span);
3636
#endif
3737
}
@@ -46,7 +46,7 @@ internal static int ReadInt32(ReadOnlySpan<byte> span)
4646
}
4747

4848
return (int)ReadUInt32(span);
49-
#elif NETSTANDARD
49+
#else
5050
return BinaryPrimitives.ReadInt32BigEndian(span);
5151
#endif
5252
}
@@ -61,7 +61,7 @@ internal static long ReadInt64(ReadOnlySpan<byte> span)
6161
}
6262

6363
return (long)ReadUInt64(span);
64-
#elif NETSTANDARD
64+
#else
6565
return BinaryPrimitives.ReadInt64BigEndian(span);
6666
#endif
6767
}
@@ -76,7 +76,7 @@ internal static float ReadSingle(ReadOnlySpan<byte> span)
7676
}
7777

7878
uint num = ReadUInt32(span);
79-
#elif NETSTANDARD
79+
#else
8080
uint num = BinaryPrimitives.ReadUInt32BigEndian(span);
8181
#endif
8282
return Unsafe.As<uint, float>(ref num);
@@ -92,7 +92,7 @@ internal static ushort ReadUInt16(ReadOnlySpan<byte> span)
9292
}
9393

9494
return (ushort)((span[0] << 8) | span[1]);
95-
#elif NETSTANDARD
95+
#else
9696
return BinaryPrimitives.ReadUInt16BigEndian(span);
9797
#endif
9898
}
@@ -107,7 +107,7 @@ internal static uint ReadUInt32(ReadOnlySpan<byte> span)
107107
}
108108

109109
return (uint)((span[0] << 24) | (span[1] << 16) | (span[2] << 8) | span[3]);
110-
#elif NETSTANDARD
110+
#else
111111
return BinaryPrimitives.ReadUInt32BigEndian(span);
112112
#endif
113113
}
@@ -124,7 +124,7 @@ internal static ulong ReadUInt64(ReadOnlySpan<byte> span)
124124
uint num1 = (uint)((span[0] << 24) | (span[1] << 16) | (span[2] << 8) | span[3]);
125125
uint num2 = (uint)((span[4] << 24) | (span[5] << 16) | (span[6] << 8) | span[7]);
126126
return ((ulong)num1 << 32) | num2;
127-
#elif NETSTANDARD
127+
#else
128128
return BinaryPrimitives.ReadUInt64BigEndian(span);
129129
#endif
130130
}

projects/RabbitMQ.Client/util/NetworkOrderSerializer.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ internal static void WriteDouble(Span<byte> span, double val)
2525
span[5] = (byte)((tempVal >> 16) & 0xFF);
2626
span[6] = (byte)((tempVal >> 8) & 0xFF);
2727
span[7] = (byte)(tempVal & 0xFF);
28-
#elif NETSTANDARD
28+
#else
2929
long tempVal = BitConverter.DoubleToInt64Bits(val);
3030
BinaryPrimitives.WriteInt64BigEndian(span, tempVal);
3131
#endif
@@ -42,7 +42,7 @@ internal static void WriteInt16(Span<byte> span, short val)
4242

4343
span[0] = (byte)((val >> 8) & 0xFF);
4444
span[1] = (byte)(val & 0xFF);
45-
#elif NETSTANDARD
45+
#else
4646
BinaryPrimitives.WriteInt16BigEndian(span, val);
4747
#endif
4848
}
@@ -60,7 +60,7 @@ internal static void WriteInt32(Span<byte> span, int val)
6060
span[1] = (byte)((val >> 16) & 0xFF);
6161
span[2] = (byte)((val >> 8) & 0xFF);
6262
span[3] = (byte)(val & 0xFF);
63-
#elif NETSTANDARD
63+
#else
6464
BinaryPrimitives.WriteInt32BigEndian(span, val);
6565
#endif
6666
}
@@ -82,7 +82,7 @@ internal static void WriteInt64(Span<byte> span, long val)
8282
span[5] = (byte)((val >> 16) & 0xFF);
8383
span[6] = (byte)((val >> 8) & 0xFF);
8484
span[7] = (byte)(val & 0xFF);
85-
#elif NETSTANDARD
85+
#else
8686
BinaryPrimitives.WriteInt64BigEndian(span, val);
8787
#endif
8888
}
@@ -101,7 +101,7 @@ internal static void WriteSingle(Span<byte> span, float val)
101101
span[1] = (byte)((tempVal >> 16) & 0xFF);
102102
span[2] = (byte)((tempVal >> 8) & 0xFF);
103103
span[3] = (byte)(tempVal & 0xFF);
104-
#elif NETSTANDARD
104+
#else
105105
int tempVal = Unsafe.As<float, int>(ref val);
106106
BinaryPrimitives.WriteInt32BigEndian(span, tempVal);
107107
#endif
@@ -118,7 +118,7 @@ internal static void WriteUInt16(Span<byte> span, ushort val)
118118

119119
span[0] = (byte)((val >> 8) & 0xFF);
120120
span[1] = (byte)(val & 0xFF);
121-
#elif NETSTANDARD
121+
#else
122122
BinaryPrimitives.WriteUInt16BigEndian(span, val);
123123
#endif
124124
}
@@ -136,7 +136,7 @@ internal static void WriteUInt32(Span<byte> span, uint val)
136136
span[1] = (byte)((val >> 16) & 0xFF);
137137
span[2] = (byte)((val >> 8) & 0xFF);
138138
span[3] = (byte)(val & 0xFF);
139-
#elif NETSTANDARD
139+
#else
140140
BinaryPrimitives.WriteUInt32BigEndian(span, val);
141141
#endif
142142
}
@@ -159,7 +159,7 @@ internal static void WriteUInt64(Span<byte> span, ulong val)
159159
span[5] = (byte)((val >> 16) & 0xFF);
160160
span[6] = (byte)((val >> 8) & 0xFF);
161161
span[7] = (byte)(val & 0xFF);
162-
#elif NETSTANDARD
162+
#else
163163
BinaryPrimitives.WriteUInt64BigEndian(span, val);
164164
#endif
165165
}

0 commit comments

Comments
 (0)