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

User-created Qualifier attributes #23

Open
benjamin-bader opened this issue Jul 27, 2013 · 2 comments
Open

User-created Qualifier attributes #23

benjamin-bader opened this issue Jul 27, 2013 · 2 comments
Milestone

Comments

@benjamin-bader
Copy link
Owner

NamedAttribute is privileged at this point; Keys knows what it is and how to accommodate it. This was done initially to make implementing Stiletto less complicated, but Now is the Right Time to add generalized qualifiers.

For example, instead of [Inject, Named("listen-port")], you could have [Inject, ListenPort]

declared like so:

[AttributeUsage(AttributeTargets.Property|AttributeTargets.Parameter|AttributeTargets.Method)]
public class ListenPortAttribute : QualifierAttribute {}
@benjamin-bader
Copy link
Owner Author

Stumbling block: how to handle ctor parameters and properties consistently between fody and runtime? This works in Java because annotations don't have executable code.

Can we create a string repr based on consistently-ordered fields and properties? It works in the compiled form, maybe, but how to access that at runtime without instantiating the attribute (thus allowing arbitrary code to run)?

@benjamin-bader
Copy link
Owner Author

Potential solution: CustomAttributeData.GetCustomAttributes in ReflectionOnly context; this gives us the raw ctor argumentes as stored in metadata. Can we do this on an assembly that's already loaded in execution context?

...goddamnit, that API doesn't exist in Silverlight!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant