You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
due to the call of this.WriteEvent, the library throws trim warnings since RequiresUnreferencedCodeAttribute is not currently propagated to the invoking methods.
Replace contents of Program.cs with: _ = new Microsoft.IO.RecyclableMemoryStreamManager();
Publish trimmed assembly, and show all trim warnings: dotnet publish -p:PublishTrimmed=true -p:EnableTrimAnalyzer=true -p:TrimmerSingleWarn=false
Expected result
The compilation and trimming concludes without any warnings
Actual result
The compilation emits trim warnings such as: /_/src/Events.cs(83,21): Trim analysis warning IL2026: Microsoft.IO.RecyclableMemoryStreamManager.Events.MemoryStreamCreated(Guid, String, Int64, Int64): Using member 'System.Diagnostics.Tracing.EventSource.WriteEvent(Int32, Object[])' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. EventSource will serialize the whole object graph. Trimmer will not safely handle this case because properties may be trimmed. /_/src/Events.cs(235,21): Trim analysis warning IL2026: Microsoft.IO.RecyclableMemoryStreamManager.Events.MemoryStreamDiscardBuffer(Guid, String, RecyclableMemoryStreamManager.Events.MemoryStreamBufferType, RecyclableMemoryStreamManager.Events.MemoryStreamDiscardReason, Int64, Int64, Int64, Int64, Int64, Int64): Using member 'System.Diagnostics.Tracing.EventSource.WriteEvent(Int32, Object[])' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. EventSource will serialize the whole object graph. Trimmer will not safely handle this case because properties may be trimmed.
Adding [RequiresUnreferencedCodeAttribute] to all methods calling this.WriteEvent would properly forward the trim warnings, not causing the library to produce trim warnings.
The text was updated successfully, but these errors were encountered:
Greetings,
due to the call of
this.WriteEvent
, the library throws trim warnings sinceRequiresUnreferencedCodeAttribute
is not currently propagated to the invoking methods.Minimal reproduction
dotnet new console
dotnet add package Microsoft.IO.RecyclableMemoryStream
Program.cs
with:_ = new Microsoft.IO.RecyclableMemoryStreamManager();
dotnet publish -p:PublishTrimmed=true -p:EnableTrimAnalyzer=true -p:TrimmerSingleWarn=false
Expected result
The compilation and trimming concludes without any warnings
Actual result
The compilation emits trim warnings such as:
/_/src/Events.cs(83,21): Trim analysis warning IL2026: Microsoft.IO.RecyclableMemoryStreamManager.Events.MemoryStreamCreated(Guid, String, Int64, Int64): Using member 'System.Diagnostics.Tracing.EventSource.WriteEvent(Int32, Object[])' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. EventSource will serialize the whole object graph. Trimmer will not safely handle this case because properties may be trimmed. /_/src/Events.cs(235,21): Trim analysis warning IL2026: Microsoft.IO.RecyclableMemoryStreamManager.Events.MemoryStreamDiscardBuffer(Guid, String, RecyclableMemoryStreamManager.Events.MemoryStreamBufferType, RecyclableMemoryStreamManager.Events.MemoryStreamDiscardReason, Int64, Int64, Int64, Int64, Int64, Int64): Using member 'System.Diagnostics.Tracing.EventSource.WriteEvent(Int32, Object[])' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. EventSource will serialize the whole object graph. Trimmer will not safely handle this case because properties may be trimmed.
Adding
[RequiresUnreferencedCodeAttribute]
to all methods callingthis.WriteEvent
would properly forward the trim warnings, not causing the library to produce trim warnings.The text was updated successfully, but these errors were encountered: