Custom Pattern for ReadOnly C# Properties

Answered

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:

[PersistableInt]
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?

2 comments
Comment actions Permalink

Hello Ryan!

 

Thank you for contacting us.

Please try omitting public/private modifier in your pattern. 

Hope it helps.

Thank you.

1
Comment actions Permalink

That worked. Thank you.

0

Please sign in to leave a comment.