Still use _supportedAttributes list until ServiceBusAttributes have [Binding]

This commit is contained in:
Ahmed ElSayed 2017-05-01 16:25:32 -07:00
Родитель bda42928b3
Коммит af9e317480
2 изменённых файлов: 32 добавлений и 2 удалений

Просмотреть файл

@ -4,6 +4,7 @@ using System.Linq;
using System.Reflection;
using Microsoft.NET.Sdk.Functions.MakeFunction;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
namespace MakeFunctionJson
{
@ -22,6 +23,32 @@ namespace MakeFunctionJson
return name.ToLowerFirstCharacter();
}
private static readonly HashSet<string> _supportedAttributes = new HashSet<string>
{
// These 2 attributes are not handled currently.
// They can go either on class, method, or parameter.
// The code flow now assumes 1:1 mapping of attributes on parameters to function.json binding.
// "StorageAccountAttribute",
// "ServiceBusAccountAttribute",
"BlobAttribute",
"BlobTriggerAttribute",
"QueueAttribute",
"QueueTriggerAttribute",
"TableAttribute",
"EventHubAttribute",
"EventHubTriggerAttribute",
"TimerTriggerAttribute",
"DocumentDBAttribute",
"ApiHubTableAttribute",
"MobileTableAttribute",
"ServiceBusTriggerAttribute",
"ServiceBusAttribute",
"TwilioSmsAttribute",
"NotificationHubAttribute",
"HttpTriggerAttribute"
};
/// <summary>
///
/// </summary>
@ -30,9 +57,11 @@ namespace MakeFunctionJson
public static bool IsWebJobsAttribute(this Attribute attribute)
{
#if NET46
return attribute.GetType().GetCustomAttributes().Any(a => a.GetType().FullName == "Microsoft.Azure.WebJobs.Description.BindingAttribute");
return attribute.GetType().GetCustomAttributes().Any(a => a.GetType().FullName == "Microsoft.Azure.WebJobs.Description.BindingAttribute")
|| _supportedAttributes.Contains(attribute.GetType().Name);
#else
return attribute.GetType().GetTypeInfo().GetCustomAttributes().Any(a => a.GetType().FullName == "Microsoft.Azure.WebJobs.Description.BindingAttribute");
return attribute.GetType().GetTypeInfo().GetCustomAttributes().Any(a => a.GetType().FullName == "Microsoft.Azure.WebJobs.Description.BindingAttribute")
|| _supportedAttributes.Contains(attribute.GetType().Name);
#endif
}

Просмотреть файл

@ -62,6 +62,7 @@ namespace MakeFunctionJson
// Clear AuthLevel from httpTrigger that has a webHook property
var webHook = bindings.FirstOrDefault(b => b["type"]?.ToString() == "httpTrigger" && b["webHookType"]?.ToString() != null);
if (webHook != null)
{
webHook.Remove("authLevel");