Differentiate Between Obsolete Warnings #91337
-
Background and ProblemAt my job we have a very large c# code base. We have turned on all warnings as errors except for the obsolete warnings (CS0618 and CS0612). Since our code base is so large we can't clean up everything in one pull request, so we use the ObsoleteAttribute to tell developers to use a different method while we are cleaning up the old method. This blocks us from upgrading CS0618 and CS0612 to errors. There is a problem with this. Currently we have about 1000 obsolete warnings. When we go to upgrade a dependency all of these warnings hide new warnings added. For example, here. Ideas1 Custom Warning CodesUpdate the ObsoleteAttribute to let us pass in a custom error code. Then, we can mark CS0618 and CS0612 as errors and set custom error codes for the methods we mark as obsolete but don't fix right away. 2 Warnings BaselineCreate a warnings baseline. Android has a concept called a warnings baseline.
eslint has a concept of lint-todo. Can you add something like this so that we can create a baseline of our current warnings? Then, when new warnings (or errors) are introduced, we'd be aware of them. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
The ObsoleteAttribute.DiagnosticId property was added in .NET 5. |
Beta Was this translation helpful? Give feedback.
-
Can't you simply suppress all your existing Obsolete warnings in GlobalSuppressions.cs? |
Beta Was this translation helpful? Give feedback.
The ObsoleteAttribute.DiagnosticId property was added in .NET 5.