-
Notifications
You must be signed in to change notification settings - Fork 753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement DnnDeprecated source generator for types #5754
Implement DnnDeprecated source generator for types #5754
Conversation
847c605
to
a499e1a
Compare
a499e1a
to
6515f4b
Compare
6515f4b
to
e27eac0
Compare
e27eac0
to
c261ab4
Compare
c261ab4
to
469283b
Compare
469283b
to
fd95188
Compare
This PR is ready for review. All I also removed a number of Since |
DNN Platform/DotNetNuke.DependencyInjection/Extensions/TypeExtensions.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We discussed this during a technical meeting and agreed this was a great way forward for our management of our API.
Summary
This PR introduces a source generator into the DNN codebase. This allows the replacement of
Obsolete
attributes with a new attribute,DnnDeprecated
. Usage of the new attribute allows the formatting of the deprecation message to be consistent. It could also, potentially, incorporate a simpler way to link to related documentation, when appropriate.Implementation Details
This source generator requires that the members which are decorated with the attribute to be marked
partial
, so that another file can be generated that includes the actualObsolete
attribute. This means that methods and nested types need their enclosing types to also be markedpartial
.Drawbacks
Because this source generator relies on members being marked
partial
, it only applies to members which can bepartial
. This rules out constructors, finalizers, overloaded operators, property declarations, and event declarations.It's possible to create a different system which generates these members with the
Obsolete
attribute, but it will be difficult to find a straightforward approach where the cost is less than the benefit.