coverlet icon indicating copy to clipboard operation
coverlet copied to clipboard

[F#]Auto-properties are not implicitly covered

Open SteveGilham opened this issue 6 years ago • 7 comments

Writing unit tests for auto-properties is a futile exercise; they are essentially noise (as is the coverage or otherwise of such properties).

Auto-properties in code exercised by coverlet are marked as uncovered by default be they C#

    public class Class1
    {
        string Property { get; set; }
    }

or F#

type Class1 () =
  member val Property= String.Empty with get, set

SteveGilham avatar May 03 '18 15:05 SteveGilham

Any updates on this feature?

lucasbflopes avatar Mar 25 '19 22:03 lucasbflopes

@tonerdo do you agree on adding -skipautoprops(opencover name)? I don't have a strong opinion on "exclude always" vs "switch"

MarcoRossignoli avatar May 06 '19 14:05 MarcoRossignoli

At the moment we can achieve this using ExcludeByAttribute thank's to https://github.com/tonerdo/coverlet/pull/477#issuecomment-512515625

MarcoRossignoli avatar Jul 18 '19 07:07 MarcoRossignoli

Closing because we can use /p:ExcludeByAttribute=\"CompilerGeneratedAttribute\"

MarcoRossignoli avatar Oct 14 '19 07:10 MarcoRossignoli

Sorry, F# auto-properties of the form

  type MyClass() =
    member val Property = 0 with get, set

are not marked [CompilerGenerated] -- the F# compiler does its own thing here.

The key to identify these ones is by a backing field with name Property@

SteveGilham avatar Oct 14 '19 17:10 SteveGilham

Ugh...sorry to you for my ignorance...didn't know, I'm not familiar with F# compiler. I'm thinking to add a F# lib on tests to handle the cases. Thank's Steve.

MarcoRossignoli avatar Oct 14 '19 17:10 MarcoRossignoli