C# Mark Properties in foreign assemblies as obsolete?
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.
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.
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.
精彩评论