EasyAbp / AbpHelper.CLI

Providing code generation and more features to help you develop applications and modules with the ABP framework.
MIT License
285 stars 95 forks source link

Warning,CS1717,Assignment made to same variable; did you mean to assign something else? #128

Closed mrs01dev closed 3 years ago

mrs01dev commented 3 years ago

All c# class constructors generated via EasyAbp AbpHelper.CLI has an issue : Severity Code Description Project File Line Suppression State Warning,CS1717,Assignment made to same variable; did you mean to assign something else? I solve this issue by two regular expression replacement (using notepad Plus Plus): First replace: (.) (.),\r\n with \1 _\2,\r\n

Second replace: (.) = (.);\r\n with \1 = _\2;\r\n

wakuflair commented 3 years ago

Could you give an example about the issue?

mrs01dev commented 3 years ago

Here is a sample class:

namespace IssueTracking.Domain.Issues { public class Issue : AggregateRoot { public Guid repositoryId { get; set; } public string title { get; set; } public string text { get; set; } public Guid? assignedUserId { get; set; } public bool isClosed { get; set; } = false;

    protected Issue()
    {
    }

    public Issue(
        Guid id,
        Guid repositoryId,
        string title,
        string text,
        Guid? assignedUserId,
        bool isClosed

    ) : base(id)
    {
        repositoryId = repositoryId;
        title = title;
        text = text;
        assignedUserId = assignedUserId;
        isClosed = isClosed;

    }
}

}

The correct constructor -prefix parameters with _ underscore symbol - is public Issue( Guid id, Guid _repositoryId, string _title, string _text, Guid? _assignedUserId, bool _isClosed

    ) : base(id)
    {
        repositoryId = _repositoryId;
        title = _title;
        text = _text;
        assignedUserId = _assignedUserId;
        isClosed = _isClosed;

    }

camelCase Style is used instead of PascalCase For public fields, public properties , that is the reason. Thanks.

wakuflair commented 3 years ago

As you said, public properties should be PascalCase, then the warning would be gone.