c# - Enforcing public setter -


i ran serialization error only manifested on 1 out of 3 machines tested on.

unable generate temporary class (result=1) error cs0200: property or indexer 'xxx' cannot assigned -- read 

it fixed removing 'private' following line in viewmodel:

public observablecollection<contact> recipients { get; private set; } 

i put commment:

// , set must public avoid serialization errors 

but i'd prefer enforcing setter public via code because comments forgotten when code re factored. i'd compile error if future developer change setter private.

i tried using [datacontract] & [datamember] attributes in hope enforce public setter.

is possible?

you can check whether properties of type readable , writable in following manner:

var t = typeof (someclass).getproperties().all(s => s.canread && s.canwrite);

and use contract check whether predicate matched. debug.assert these in tests. i'm can't cause compiler errors result of changing accessor on property on fly, closest can get.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -