Skip to content
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

Merged
merged 18 commits into from
Jul 25, 2023

Conversation

bdukes
Copy link
Contributor

@bdukes bdukes commented Jul 18, 2023

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 actual Obsolete attribute. This means that methods and nested types need their enclosing types to also be marked partial.

Drawbacks

Because this source generator relies on members being marked partial, it only applies to members which can be partial. 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.

@bdukes bdukes force-pushed the dnn-deprecated-source-generator branch from a499e1a to 6515f4b Compare July 20, 2023 20:17
@bdukes bdukes force-pushed the dnn-deprecated-source-generator branch from 6515f4b to e27eac0 Compare July 20, 2023 21:42
@bdukes bdukes force-pushed the dnn-deprecated-source-generator branch from e27eac0 to c261ab4 Compare July 21, 2023 14:14
@bdukes bdukes force-pushed the dnn-deprecated-source-generator branch from c261ab4 to 469283b Compare July 21, 2023 16:48
@bdukes bdukes force-pushed the dnn-deprecated-source-generator branch from 469283b to fd95188 Compare July 21, 2023 18:15
@bdukes bdukes changed the base branch from release/10.0.0 to develop July 21, 2023 18:16
@bdukes bdukes added this to the 9.12.1 milestone Jul 21, 2023
@bdukes bdukes marked this pull request as ready for review July 21, 2023 18:16
@bdukes bdukes requested review from valadas and mitchelsellers July 21, 2023 18:16
@bdukes
Copy link
Contributor Author

bdukes commented Jul 21, 2023

This PR is ready for review.

All Obsolete attributes have been touched, either being turned into DnnDeprecated or being updated to use the template that DnnDeprecated generates.

I also removed a number of Obsolete attributes which were on members where the type was already deprecated.

Since DnnDeprecated requires a version in which the member was deprecated, I tried to find that version where it wasn't already marked. I used 7.0.0 as a placeholder if the history of the deprecation pre-dates the git repo.

Copy link
Contributor

@donker donker left a 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.

@valadas valadas merged commit 92382c2 into dnnsoftware:develop Jul 25, 2023
@bdukes bdukes deleted the dnn-deprecated-source-generator branch July 25, 2023 19:08
@valadas valadas modified the milestones: 9.12.1, 9.13.0 Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants