Issue with "use object initiliazer" in ReSharper 4

Hello

I have the following code:

CreateUriRequest uriRequest = new CreateUriRequest();
uriRequest.UriData = new UriData();
uriRequest.UriData.Id = 0;
uriRequest.UriData.Status = 1;
uriRequest.UriData.UriTypeId = 1;
uriRequest.UriData.UriValue = "12345";
uriRequest.UriData.ValidityPeriod = new
DateRangeData(DateTime.Now.AddDays(-1), DateTime.Now.AddDays(1));

For the line new CreateUriRequest() I can refactor to "use object
initiliazer" which results in the following incorrect code:

CreateUriRequest uriRequest = new CreateUriRequest {
UriData =
new UriData(),
Id = 0,
Status =
1,
UriTypeId
= 1,
UriValue
= "12345",
ValidityPeriod
= new DateRangeData(DateTime.Now.AddDays(-1), DateTime.Now.AddDays(1))
};

It is incorrect because the properties Id, Status, UriTypeId, UriValue and
ValidityPeriod are properties of UriData.

I agree though that the code is a bit smelly but still :)

Regards

Gabriel Lozano-Moran

1 comment
Comment actions Permalink

Hello,

We appreciate your feedback. The corresponding JIRA request has been created,
and you are welcome to monitor its status at http://www.jetbrains.net/jira/browse/RSRP-58432.

You may want to check our request tracking policy here: http://www.jetbrains.net/confluence/display/ReSharper/ReSharperIssueTracker

Best regards,
- Development Team.


0

Please sign in to leave a comment.