diff --git a/src/Events.cs b/src/Events.cs
index 3a4d8799..ced44da9 100644
--- a/src/Events.cs
+++ b/src/Events.cs
@@ -80,7 +80,11 @@ public void MemoryStreamCreated(Guid guid, string? tag, long requestedSize, long
{
if (this.IsEnabled(EventLevel.Verbose, EventKeywords.None))
{
+#if NET8_0_OR_GREATER
+ this.WriteEvent(1, new EventSource.EventSourcePrimitive[] { guid, tag ?? string.Empty, requestedSize, actualSize });
+#else
this.WriteEvent(1, guid, tag ?? string.Empty, requestedSize, actualSize);
+#endif
}
}
@@ -97,7 +101,11 @@ public void MemoryStreamDisposed(Guid guid, string? tag, long lifetimeMs, string
{
if (this.IsEnabled(EventLevel.Verbose, EventKeywords.None))
{
+#if NET8_0_OR_GREATER
+ this.WriteEvent(2, new EventSource.EventSourcePrimitive[] { guid, tag ?? string.Empty, lifetimeMs, allocationStack ?? string.Empty, disposeStack ?? string.Empty });
+#else
this.WriteEvent(2, guid, tag ?? string.Empty, lifetimeMs, allocationStack ?? string.Empty, disposeStack ?? string.Empty);
+#endif
}
}
@@ -116,8 +124,13 @@ public void MemoryStreamDoubleDispose(Guid guid, string? tag, string? allocation
{
if (this.IsEnabled())
{
+#if NET8_0_OR_GREATER
+ this.WriteEvent(3, new EventSource.EventSourcePrimitive[] { guid, tag ?? string.Empty, allocationStack ?? string.Empty,
+ disposeStack1 ?? string.Empty, disposeStack2 ?? string.Empty });
+#else
this.WriteEvent(3, guid, tag ?? string.Empty, allocationStack ?? string.Empty,
disposeStack1 ?? string.Empty, disposeStack2 ?? string.Empty);
+#endif
}
}
@@ -133,7 +146,11 @@ public void MemoryStreamFinalized(Guid guid, string? tag, string? allocationStac
{
if (this.IsEnabled())
{
+#if NET8_0_OR_GREATER
+ this.WriteEvent(4, new EventSource.EventSourcePrimitive[] { guid, tag ?? string.Empty, allocationStack ?? string.Empty });
+#else
this.WriteEvent(4, guid, tag ?? string.Empty, allocationStack ?? string.Empty);
+#endif
}
}
@@ -150,7 +167,11 @@ public void MemoryStreamToArray(Guid guid, string? tag, string? stack, long size
{
if (this.IsEnabled(EventLevel.Verbose, EventKeywords.None))
{
+#if NET8_0_OR_GREATER
+ this.WriteEvent(5, new EventSource.EventSourcePrimitive[] { guid, tag ?? string.Empty, stack ?? string.Empty, size });
+#else
this.WriteEvent(5, guid, tag ?? string.Empty, stack ?? string.Empty, size);
+#endif
}
}
@@ -209,7 +230,11 @@ public void MemoryStreamNonPooledLargeBufferCreated(Guid guid, string? tag, long
{
if (this.IsEnabled(EventLevel.Verbose, EventKeywords.None))
{
+#if NET8_0_OR_GREATER
+ this.WriteEvent(9, new EventSource.EventSourcePrimitive[] { guid, tag ?? string.Empty, requiredSize, allocationStack ?? string.Empty });
+#else
this.WriteEvent(9, guid, tag ?? string.Empty, requiredSize, allocationStack ?? string.Empty);
+#endif
}
}
@@ -232,7 +257,11 @@ public void MemoryStreamDiscardBuffer(Guid guid, string? tag, MemoryStreamBuffer
{
if (this.IsEnabled(EventLevel.Warning, EventKeywords.None))
{
+#if NET8_0_OR_GREATER
+ this.WriteEvent(10, new EventSource.EventSourcePrimitive[] { guid, tag ?? string.Empty, bufferType, reason, smallBlocksFree, smallPoolBytesFree, smallPoolBytesInUse, largeBlocksFree, largePoolBytesFree, largePoolBytesInUse });
+#else
this.WriteEvent(10, guid, tag ?? string.Empty, bufferType, reason, smallBlocksFree, smallPoolBytesFree, smallPoolBytesInUse, largeBlocksFree, largePoolBytesFree, largePoolBytesInUse);
+#endif
}
}
@@ -250,7 +279,11 @@ public void MemoryStreamOverCapacity(Guid guid, string? tag, long requestedCapac
{
if (this.IsEnabled())
{
+#if NET8_0_OR_GREATER
+ this.WriteEvent(11, new EventSource.EventSourcePrimitive[] { guid, tag ?? string.Empty, requestedCapacity, maxCapacity, allocationStack ?? string.Empty });
+#else
this.WriteEvent(11, guid, tag ?? string.Empty, requestedCapacity, maxCapacity, allocationStack ?? string.Empty);
+#endif
}
}
}
diff --git a/src/Microsoft.IO.RecyclableMemoryStream.csproj b/src/Microsoft.IO.RecyclableMemoryStream.csproj
index 5d6a3fdf..29d9dff3 100644
--- a/src/Microsoft.IO.RecyclableMemoryStream.csproj
+++ b/src/Microsoft.IO.RecyclableMemoryStream.csproj
@@ -41,7 +41,11 @@
true
-
+
+
+ true
+
+