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

Resources extension: TemporaryDirectory: Allow @Dir to accept arguments #648

Open
jbduncan opened this issue Jun 1, 2022 · 2 comments
Open

Comments

@jbduncan
Copy link
Contributor

jbduncan commented Jun 1, 2022

Consider adding an arguments field to @Dir similarly to @New so that code like the following...

@Test
void test(@New(value = TemporaryDirectory.class, arguments = { "someDirectoryPrefix" }) Path tempDir) {
  // ...
}

...could be shortened to...

void test(@Dir("someDirectoryPrefix") Path tempDir) {
  // ...
}

Note that this would require a change in how ResourceExtension works, to allow annotations with an arguments field and which are indirectly/meta-annotated with @New(TemporaryDirectory.class) to have their arguments read by the extension.

This issue is a follow-up to #348 | #491.

@nipafx
Copy link
Member

nipafx commented Jul 7, 2022

Thank you for creating this issue. If I didn't miss anything, this would also allow us/users to introduce a shorthand for @Shared. Because @Shared always needs a name, this isn't possible at the moment, but if we figure out how to pass attributes on, that should overcome this limitation and allow for, e.g. @SharedDir(name = "foo").

Or even @SharedDir("foo") with this one weird trick?!

@Shared
public @interface SharedDir {
	@MapsToAttribute(type = Shared.class, name="name")
	String value();
}

Wow, I feel dirty now.

@jbduncan
Copy link
Contributor Author

jbduncan commented Jul 18, 2022

Yep, that was indeed my intention with raising this issue. Thanks for sharing your thoughts!

@SharedDir("foo") isn't "dirtier" than @SharedDir(name = "foo") in my opinion, but I can see why it would be desired. I never thought about having a sort of inner meta-attribute like @MapsToAttribute before, so it looks pretty neat to me.

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

No branches or pull requests

2 participants