Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
thompson-tomo committed Mar 12, 2024
1 parent d557ffd commit 5330e26
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
Expand Up @@ -38,6 +38,7 @@ namespace RabbitMQ.Client.Logging
[EventSource(Name = "rabbitmq-dotnet-client")]
public sealed class RabbitMqClientEventSource : EventSource
{
public static readonly RabbitMqClientEventSource Log = new RabbitMqClientEventSource();
public class Keywords
{
public const EventKeywords Log = (EventKeywords)1;
Expand All @@ -47,8 +48,6 @@ public RabbitMqClientEventSource() : base(EventSourceSettings.EtwSelfDescribingE
{
}

public static readonly RabbitMqClientEventSource Log = new RabbitMqClientEventSource();

[Event(1, Message = "INFO", Keywords = Keywords.Log, Level = EventLevel.Informational)]
public void Info(string message)
{
Expand All @@ -67,20 +66,25 @@ public void Warn(string message)
public void Error(string message, RabbitMqExceptionDetail ex)
{
if (IsEnabled())
#if NET6_0_OR_GREATER
WriteExceptionEvent(message, ex);
#else
WriteEvent(3, message, ex);
#endif
}

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

[NonEvent]
public void Error(string message, Exception ex)
#if NET6_0_OR_GREATER
[UnconditionalSuppressMessage("Trimming", "IL2026", Justification = "The properties are preserved with the DynamicallyAccessedMembers attribute.")]
private void WriteExceptionEvent<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] T>(string message, T ex)
{
Error(message, new RabbitMqExceptionDetail(ex));
WriteEvent(3, message, ex);
}
#endif
}
}
16 changes: 8 additions & 8 deletions projects/RabbitMQ.Client/util/NetworkOrderDeserializer.cs
Expand Up @@ -15,7 +15,7 @@ internal static double ReadDouble(ReadOnlySpan<byte> span)
throw new ArgumentOutOfRangeException(nameof(span), "Insufficient length to decode Double from memory.");
}
ulong val = ReadUInt64(span);
#elif NETSTANDARD
#else
ulong val = BinaryPrimitives.ReadUInt64BigEndian(span);
#endif
return Unsafe.As<ulong, double>(ref val);
Expand All @@ -31,7 +31,7 @@ internal static short ReadInt16(ReadOnlySpan<byte> span)
}

return (short)ReadUInt16(span);
#elif NETSTANDARD
#else
return BinaryPrimitives.ReadInt16BigEndian(span);
#endif
}
Expand All @@ -46,7 +46,7 @@ internal static int ReadInt32(ReadOnlySpan<byte> span)
}

return (int)ReadUInt32(span);
#elif NETSTANDARD
#else
return BinaryPrimitives.ReadInt32BigEndian(span);
#endif
}
Expand All @@ -61,7 +61,7 @@ internal static long ReadInt64(ReadOnlySpan<byte> span)
}

return (long)ReadUInt64(span);
#elif NETSTANDARD
#else
return BinaryPrimitives.ReadInt64BigEndian(span);
#endif
}
Expand All @@ -76,7 +76,7 @@ internal static float ReadSingle(ReadOnlySpan<byte> span)
}

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

return (ushort)((span[0] << 8) | span[1]);
#elif NETSTANDARD
#else
return BinaryPrimitives.ReadUInt16BigEndian(span);
#endif
}
Expand All @@ -107,7 +107,7 @@ internal static uint ReadUInt32(ReadOnlySpan<byte> span)
}

return (uint)((span[0] << 24) | (span[1] << 16) | (span[2] << 8) | span[3]);
#elif NETSTANDARD
#else
return BinaryPrimitives.ReadUInt32BigEndian(span);
#endif
}
Expand All @@ -124,7 +124,7 @@ internal static ulong ReadUInt64(ReadOnlySpan<byte> span)
uint num1 = (uint)((span[0] << 24) | (span[1] << 16) | (span[2] << 8) | span[3]);
uint num2 = (uint)((span[4] << 24) | (span[5] << 16) | (span[6] << 8) | span[7]);
return ((ulong)num1 << 32) | num2;
#elif NETSTANDARD
#else
return BinaryPrimitives.ReadUInt64BigEndian(span);
#endif
}
Expand Down

0 comments on commit 5330e26

Please sign in to comment.