-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Missing discussion of allowed expressions for attribute constructor arguments #6428
Comments
It would also be nice to see some discussion of how I deal with dependency injection for these constructors. Perhaps it's not allowed at all? |
@phillijw For these constructors, you mostly can do DI indirectly through passing in Thanks! |
This issue has been closed as part of the issue backlog grooming process outlined in #22351. That automated process may have closed some issues that should be addressed. If you think this is one of them, reopen it with a comment explaining why. Tag the |
@BillWagner This is still an issue. |
@dotnet/docs @akoeplinger ^ |
I’m not sure exactly where this belongs. Perhaps it belongs in the Applying Attributes article instead. But it could also make sense here because the allowed constructor expressions limits the types of parameters one can meaningfully accept in an attribute’s constructor.
The expressions allowed as parameters to attributes are very limited. I think it includes constant expressions (notably including the useful
nameof()
) plus a at least one one exceptiontypeof(TypeName)
(if not other special expressions). It might also be worth discussing howCallerInformationAttribute
can be applied to an attribute constructor’s parameters to get the name of the member the attribute is being applied to.I expected this to be documented, but I can’t find the documentation for it. I looked in these places:
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
The text was updated successfully, but these errors were encountered: