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

Add source generator to emit supporting attribute types #181

Conversation

Sergio0694
Copy link
Collaborator

Closes #168

Overview

This PR includes a new dnne-analyzers project, bundling (for now) a generator that produces the supporting attribute types. The setup is pretty much the same as that used in ComputeSharp, the MVVM Toolkit, and several other generators. We have the generator project, a bundled .targets file that is included in the NuGet package that ensures analyzers are either loaded correctly or otherwise produces useful warnings for users, and then some basic props to build and pack the analyzer.

@AaronRobinsonMSFT
Copy link
Owner

@Sergio0694 Thanks for the help here. I think we need to update to .NET 7 so we can use C# 11. Also, I think the pseudo package is busted. I tried to update it, but the analyzer isn't being chained in as expected. I tried to manually load it in the ExportingAssembly test project but I'm missing something on how analyzers are expected to be loaded.

@Sergio0694
Copy link
Collaborator Author

I've updated the .NET SDK pulled in from the CI script to be .NET 7 👍
We can keep .NET 6 as TFM in the various projects, of course.

@Sergio0694 Sergio0694 force-pushed the user/sergiopedri/roslyn-generator branch from 3997e8e to 79e5e09 Compare November 5, 2023 17:26
@Sergio0694 Sergio0694 force-pushed the user/sergiopedri/roslyn-generator branch from e1b7eba to 889f8c4 Compare November 5, 2023 17:44
Copy link
Owner

@AaronRobinsonMSFT AaronRobinsonMSFT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add a note in the readme about when users may need to define those types.

src/dnne-analyzers/AttributesGenerator.cs Show resolved Hide resolved
readme.md Outdated Show resolved Hide resolved
@Sergio0694
Copy link
Collaborator Author

The resulting package from the CI looks good 😄

image

Question: can't remember, are all .props files in the \build folder picked up by default? As in, don't need anything else here?

Import new targets file using DNNE.targets
@AaronRobinsonMSFT AaronRobinsonMSFT merged commit 4ea06f6 into AaronRobinsonMSFT:master Nov 6, 2023
@Sergio0694 Sergio0694 deleted the user/sergiopedri/roslyn-generator branch November 6, 2023 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use source generator to generate attributes
2 participants