csnemes / tracer

Tracing rewriter using Fody
Apache License 2.0
94 stars 26 forks source link

ReadOnlySpan<char> results in "Cannot create boxed ByRef-like values." (System.InvalidProgramException) #83

Open seertenedos opened 5 years ago

seertenedos commented 5 years ago

TracingOn with a method like the one below throws an exception of type System.InvalidProgramException saying "Cannot create boxed ByRef-like values.".

Example method to duplicate

public void Test3(ReadOnlySpan path) {

    }

Happens in

csnemes commented 5 years ago

ReadOnlySpan is a ref struct which is a new feature in C#7.2. I have to change the rewriter to support it. As you cannot box a ref struct I think the only viable option is to skip this parameter from logging.

seertenedos commented 5 years ago

For a char span it can be converted to a string and from a string. Other spans are different.

On Tue, 30 Jul. 2019, 1:10 am Csaba Nemes, notifications@github.com wrote:

ReadOnlySpan is a ref struct which is a new feature in C#7.2. I have to change the rewriter to support it. As you cannot box a ref struct I think the only viable option is to skip this parameter from logging.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/csnemes/tracer/issues/83?email_source=notifications&email_token=AADB44MVM4G5NZMJ37AGA2DQB4B5NA5CNFSM4H4KE4NKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3BARWA#issuecomment-516032728, or mute the thread https://github.com/notifications/unsubscribe-auth/AADB44KM4GURCALJNVMYELLQB4B5NANCNFSM4H4KE4NA .

csnemes commented 5 years ago

The problem is that the log signature has to be very general, thus the method parameters are passed as an array of object. ref structs like ReadOnlySpan cannot be boxed and added to an object array.