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

Convention-based FunctionName & HttpTrigger Routes #257

Open
pauldalyii opened this issue Sep 26, 2017 · 1 comment

Comments

Projects
None yet
1 participant
@pauldalyii
Copy link

commented Sep 26, 2017

To enable MVC-like conventions within functions, I wish:

there was a parameter-less version of the FunctionNameAttribute that would default the name to:
$"{typeof(<class>).Namespace}.{nameof(<class>)}"

the HttpTriggerAttribute Route property was optional and would default to:
$"{typeof(<class>).Namespace}.{nameof(<class>)}".Replace('.', '/');

The goal would be so that these two would produce the same result.

image

image

Note: I think the snippets above might need more logic. For example, I'd prefer to not include the first namespace if there is more than one (eg: "Service" from the screenshot above). The first namespace is often just the solution name or something that you don't necessarily want reflected in the route.

@pauldalyii

This comment has been minimized.

Copy link
Author

commented Oct 3, 2017

I realize that FunctionNameAttribute can't call typeof(<callingclass>).Namespace. I wish C# supported [CallerClassName] and [CallerNamespaceName] similar to [CallerMemberName].

Anyway, edit 2 on this SO post describes a method for obtain details on the calling class that might enable convention-based naming for functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.