== Why is this an issue?

Read-only fields and properties (properties with only an auto-implemented getter) can only be set in a constructor or as part of their declaration. A read-only member that isn't set in either place will retain its default value for the life of the object. At best, such properties clutter the source code. At worst, they are bugs. 


=== Noncompliant code example

[source,csharp]
----
class Person 
{
  int Age { get; }  // Noncompliant; will always be 0.

  Person () {}
}
----


=== Compliant solution

[source,csharp]
----
class Person 
{
  int Age { get; } = 42;

  Person () {}
}
----



ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)

=== on 11 May 2015, 14:08:33 Dinesh Bolkensteyn wrote:
LGTM - note that there seems to be a compiler warning for this already (it's already reported in Visual Studio).

=== on 15 Mar 2016, 09:48:41 Tamas Vajk wrote:
\[~dinesh.bolkensteyn] Thanks, I've set the VS reference flag.

=== on 7 Apr 2016, 14:50:26 Tamas Vajk wrote:
Could you check this RSPEC? I modified it from readonly fields to properties.

=== on 7 Apr 2016, 17:11:20 Ann Campbell wrote:
Give it another read-through [~tamas.vajk]. I've made some changes.

=== on 15 Apr 2016, 11:13:37 Tamas Vajk wrote:
Note: I added back the fields, because VS doesn't report them as you type, it reports them only when you compile the code.

endif::env-github,rspecator-view[]
