DapperLib / DapperAOT

Build time tools in the flavor of Dapper
Other
349 stars 19 forks source link

feat: warn about ambiguous properties/fields #107

Closed DeagleGross closed 5 months ago

DeagleGross commented 7 months ago

Original issue: https://github.com/DapperLib/Dapper/issues/1993

added the rules: 1) if properties of type have same normalized names -> DAP046 is reported: Properties have same name '{normalizedMemberName}' after normalization and can be conflated example:

public class Data
{
    public string First_Name { get; set; }
    public string FirstName { get; set; }
}

2) if fields of type have same normalized names -> DAP047 is reported: Fields have same name '{normalizedMemberName}' after normalization and can be conflated

public class Data
{
    public string first_name;
    public string _firstName;
}

Note: I changed the locations calculations reported for properties. For ElementMember representing public string Name { get; set; } property, calling member.GetLocation() will return Span, wrapping the whole property definition (including modifiers, getter and setter).

I thought that standard way of reporting errors is to link the diagnostic with the member name. For example (not related to Dapper) - duplicate property names of type: image

So I decided to bring such a consistency to the diagnostics. Also fields are reported only on the names (not the full field definition). Let me know if that change should be reverted

Closes #65