-
Notifications
You must be signed in to change notification settings - Fork 356
/
Copy pathFunctionNameAttribute.cs
37 lines (32 loc) · 1.26 KB
/
FunctionNameAttribute.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
using System.Text.RegularExpressions;
namespace Microsoft.Azure.WebJobs
{
/// <summary>
/// Attribute used to indicate the name to use for a job function.
/// </summary>
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
public sealed class FunctionNameAttribute : Attribute
{
private string _name;
/// <summary>
/// Initializes a new instance of the <see cref="FunctionNameAttribute"/> class with a given name.
/// </summary>
/// <param name="name">Name of the function.</param>
public FunctionNameAttribute(string name)
{
this._name = name;
}
/// <summary>
/// Gets the function name.
/// </summary>
public string Name => _name;
/// <summary>
/// Validation for name.
/// RegexOptions.Compiled is specifically removed as it impacts the cold start.
/// </summary>
public static readonly Regex FunctionNameValidationRegex = new Regex(@"^[a-z][a-z0-9_\-]{0,127}$(?<!^host$)", RegexOptions.IgnoreCase);
}
}