Skip to content

Latest commit

 

History

History
106 lines (90 loc) · 3.29 KB

obsolete-members.md

File metadata and controls

106 lines (90 loc) · 3.29 KB

Obsolete members

Members with an ObsoleteAttribute are ignored:

class WithObsolete
{
    [Obsolete]
    public string ObsoleteProperty { get; set; }

    public string OtherProperty { get; set; }
}

[Fact]
public Task WithObsoleteProp()
{
    var target = new WithObsolete
    {
        ObsoleteProperty = "value1",
        OtherProperty = "value2"
    };
    return Verify(target);
}

snippet source | anchor

Result:

{
  OtherProperty: value2
}

snippet source | anchor

Including Obsolete members

Obsolete members can be included using IncludeObsoletes:

[Fact]
public Task WithObsoletePropIncluded()
{
    var target = new WithObsolete
    {
        ObsoleteProperty = "value1",
        OtherProperty = "value2"
    };
    var settings = new VerifySettings();
    settings.IncludeObsoletes();
    return Verify(target, settings);
}

[Fact]
public Task WithObsoletePropIncludedFluent()
{
    var target = new WithObsolete
    {
        ObsoleteProperty = "value1",
        OtherProperty = "value2"
    };
    return Verify(target)
        .IncludeObsoletes();
}

snippet source | anchor

Or globally:

VerifierSettings.IncludeObsoletes();

snippet source | anchor

Result:

{
  ObsoleteProperty: value1,
  OtherProperty: value2
}

snippet source | anchor