2 " ": ( / ), - , ReSharper .
, . :
var someScreenLocation = new ScreenLocation(1,1);
var locationOne = someScreenLocation.ToExactLocation();
var locationTwo = someScreenLocation.ToExactLocation();
someScreenLocation.X = 3;
var locationThree = someScreenLocation.ToExactLocation();
, ( , , ). , locationOne locationTwo ( ), , , locationThree , ( ) .
, X Y readonly ( ).
ReSharper , - , Pure, .
, ReSharper "" readonly. ReSharper:
struct Point
{
public int X;
public int Y;
public Point(int x, int y){X = x;Y = y;}
public void Mutate(){X++;}
public Point TheoreticallyPure(){return new Point(1, 1);}
[Pure] public Point MarkedPure(){ return new Point(1, 1);}
}
class WithReadonlyField
{
public readonly Point P;
public WithReadonlyField()
{
P = new Point();
P.TheoreticallyPure();
P.MarkedPure();
P.Mutate();
P = new Point().MarkedPure();
}
public void NormalMethod()
{
P.Mutate();
}
}
# readonly , ReSharper "" ( , Mutate readonly P, NormalMethod, ).
" readonly... , , "
, ReSharper , .