Skip to content

Commit 5330e26

Browse files
committed
WIP
1 parent d557ffd commit 5330e26

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

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 readonly 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
}

0 commit comments

Comments
 (0)