Quantcast
Channel: YouTrackReSharper (RSRP) - Bug and Issue Tracker
Viewing all articles
Browse latest Browse all 106942

RSRP-288357: Incorrect refactoring using object initializer

$
0
0
Reporter Alex Berezoutsky (fergard) Alex Berezoutsky (fergard)
Created Feb 16, 2012 7:59:56 PM
Updated Feb 17, 2012 11:10:29 AM
Priority Critical
Type Bug
Fix versions Next
State Submitted
Assignee Alexey Kuptsov (alexey.kuptsov)
Subsystem No subsystem
Affected versions 6.1.1
Fixed in build No Fixed in build
I have the following code in a builder class:

        public HashLogBuilder WithFolder(string folder, string extension, bool recursive)
        {
            var builder = new HashLogBuilder();
            builder._folders = new List<FolderDescription>(_folders);
            builder._folders.Add(new FolderDescription{Folder = folder, Extension = extension, Recursuve = recursive});
            builder._bytes = _bytes;
            return builder;
        }


The new keyword for the new HashlogBuilder suggests to use an object initializer. However when applied, this looses the additional line which adds a new folder:

        public HashLogBuilder WithFolder(string folder, string extension, bool recursive)
        {
            var builder = new HashLogBuilder {_folders = new List<FolderDescription>(_folders), _bytes = _bytes};
            return builder;
        }

Viewing all articles
Browse latest Browse all 106942

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>