Custom Pattern for ReadOnly C# Properties


I'm looking to create a custom pattern to generate an error when properties with a specific attribute do not contain a setter. It would match something like this:

public int Test { get; }

I can get this to work for public properties only. How do I specify a placeholder that would allow public/private/protected modifiers?

Comment actions Permalink

Hello Ryan!


Thank you for contacting us.

Please try omitting public/private modifier in your pattern. 

Hope it helps.

Thank you.

Comment actions Permalink

That worked. Thank you.


Please sign in to leave a comment.