Reporter |
|
---|---|
Created | Apr 6, 2018 6:34:24 PM |
Updated | Apr 6, 2018 6:34:33 PM |
Subsystem | Code Analysis |
Assignee | Ivan Serduk (IvanSerduk) |
Priority | Normal |
State | Submitted |
Type | Bug |
Fix version | No Fix versions |
Affected versions | No Affected versions |
Fixed In Version ReSharper | Undefined |
VsVersion | All Versions |
Just upgraded to R# 2018.1 EAP 6 (and VS 2017 15.6.5) and I'm now getting intellisense errors when assigning readonly fields inside the constructor of a "readonly struct".
If I change "readonly struct" to a regular "struct" (but keep the field readonly) the error goes away.
If I keep "readonly struct" but replace "this.Id = id" by just "Id = id" then the error also goes away.
–FAIL
–OK
–OK
–FAIL
If I change "readonly struct" to a regular "struct" (but keep the field readonly) the error goes away.
If I keep "readonly struct" but replace "this.Id = id" by just "Id = id" then the error also goes away.
–FAIL
public readonly struct Foo
{
public readonly string Id;
public Foo(string id)
{
this.Id = id; // ERROR: "Class 'this' is immutable. Cannot modify struct members when accessed struct is not classified as a variable"
}
}
–OK
public struct Foo // not readonly
{
public readonly string Id;
public Foo(string id)
{
this.Id = id; // OK
}
}
–OK
–FAIL
public readonly struct Foo // readonly
{
public readonly string Id;
public Foo(string id)
{
Id = id; // OK
}
}