coverlet icon indicating copy to clipboard operation
coverlet copied to clipboard

ExcludeByAttribute obsolete excludes ref-struct

Open Turnerj opened this issue 4 years ago • 4 comments

Admittedly I could just not exclude obsolete attributes but basically, a ref-struct actually has an obsolete intentionally added by the compiler.

Here is an example of a recently compiled code that I intentionally decompiled to find this "hidden" obsolete attribute.

image

Microsoft has documentation about it and why it is there too: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-7.2/span-safety#metadata-representation-or-ref-like-structs

Is there a way that coverlet could exclude obsolete without excluding ref-struct? Ideally in a way that doesn't require hard coding the files in the runsettings config.

Turnerj avatar Jul 30 '21 14:07 Turnerj

I'm happy to try making a fix for this - haven't dug into any of the code though to see how I would go about it (plus want to know how you'd want it done - if you want it at all).

I figure I could check if "IsByRefLike" attribute is also configured and then prevent it being excluded or something.

Turnerj avatar Jul 30 '21 14:07 Turnerj

Thanks for reporting this, mmm not great that "alternative" for us. Need to think a bit about it. Because if after I want to really exclude obsolete also on this types, it would be a problem. But maybe in that case we can exclude using simple exclude and go for that specific class name.

cc: @petli @daveMueller @tonerdo

MarcoRossignoli avatar Aug 14 '21 11:08 MarcoRossignoli

Looks like the obsolete attribute for ref types will always have a fixed message on it, that may help with allowing exclusion of actually obsolete ref-types

Khitiara avatar Oct 09 '22 00:10 Khitiara

This issue is stale because it has been open for 3 months with no activity.

github-actions[bot] avatar Sep 10 '23 01:09 github-actions[bot]