Skip to content

Latest commit

 

History

History
56 lines (42 loc) · 1.12 KB

KO0001.md

File metadata and controls

56 lines (42 loc) · 1.12 KB

KO0001: Properties on content types should have matching sort and source order

Property Value
Id KO0001
Category Optimizely
Severity Information
Code fix Yes

Example

Code with Diagnostic

[ContentType]
public class Block {
    [Display(Order = 2)]
    public virtual string Prop2 { get; set; }

    [Display(Order = 1)]
    public virtual string Prop1 { get; set; }
}

Code with Fix

[ContentType]
public class Block {
    [Display(Order = 1)]
    public virtual string Prop1 { get; set; }

    [Display(Order = 2)]
    public virtual string Prop2 { get; set; }
}

Alternatively

[ContentType]
public class Block {
    [Display(Order = 1)]
    public virtual string Prop2 { get; set; }

    [Display(Order = 2)]
    public virtual string Prop1 { get; set; }
}

Remarks

Will only analyze classes with an attribute named "ContentType".

Will emit a diagnostic for the following since the properties are not ordered in the source as they are with the DisplayAttribute.