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

RSRP-287773: Encapsulate field on struct bug

$
0
0
Reporter tobi (thymin) tobi (thymin)
Created Jan 14, 2012 9:47:15 PM
Updated Jan 14, 2012 9:47:15 PM
Priority Normal
Type Unspecified
Fix versions No Fix versions
State Submitted
Assignee Unassigned
Subsystem No subsystem
Affected versions No Affected versions
Fixed in build No Fixed in build
code:

public struct WordMatchStatistics
{
public string Word;
public int DocumentMatchCount;
public int FieldMatchCount;
public int OccurenceCount;

public WordMatchStatistics(string word, int documentMatchCount, int fieldMatchCount, int occurenceCount)
{
Word = word;
DocumentMatchCount = documentMatchCount;
FieldMatchCount = fieldMatchCount;
OccurenceCount = occurenceCount;
}
}

now encapsulate "Word" to an auto property. you get:


public struct WordMatchStatistics
{
public string Word { get; set; }
public int DocumentMatchCount;
public int FieldMatchCount;
public int OccurenceCount;

public WordMatchStatistics(string word, int documentMatchCount, int fieldMatchCount, int occurenceCount)
{
Word = word;
DocumentMatchCount = documentMatchCount;
FieldMatchCount = fieldMatchCount;
OccurenceCount = occurenceCount;
}
}

Which causes a compiler error (reference to this not yet allowed). In a struct you need:

public WordMatchStatistics(string word, int documentMatchCount, int fieldMatchCount, int occurenceCount)
: this() //<—-
{

Viewing all articles
Browse latest Browse all 106942

Trending Articles



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