Question

I'd like to mark some specific properties in a foreign assembly that i'm referencing as obsolete. Is it possible to do so? Or is it possible to get a compiler warning/error if a specific property is used?

We have our own DateTime class for specific tests and i want everyone to use them and not the normal DateTime.Now and DateTime.Today properties.

Was it helpful?

Solution

You could change the foreign assembly using e.g. CECIL. However this is a lot of work.

Usually the best way to archieve this is to use a build tool. Most build chains also have a tool to test for code compliance. And in those it's easy to add a rule to emit a warning when specific properties/methods are used.

OTHER TIPS

No, you can't change the metadata of foreign types, and AFAIK it isn't possible to generate a warning if a specific foreign type/member is used.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top