in src/DotNetWorker.Core/FunctionMetadata/DefaultFunctionMetadata.cs [53:96]
private static string? HashFunctionId(DefaultFunctionMetadata function)
{
// We use uint to avoid the '-' sign when we .ToString() the result.
// This function is adapted from https://github.com/Azure/azure-functions-host/blob/71ecbb2c303214f96d7e17310681fd717180bdbb/src/WebJobs.Script/Utility.cs#L847-L863
static uint GetStableHash(string value)
{
unchecked
{
uint hash = 23;
foreach (char c in value)
{
hash = (hash * 31) + c;
}
return hash;
}
}
unchecked
{
bool atLeastOnePresent = false;
uint hash = 17;
if (function.Name is not null)
{
atLeastOnePresent = true;
hash = hash * 31 + GetStableHash(function.Name);
}
if (function.ScriptFile is not null)
{
atLeastOnePresent = true;
hash = hash * 31 + GetStableHash(function.ScriptFile);
}
if (function.EntryPoint is not null)
{
atLeastOnePresent = true;
hash = hash * 31 + GetStableHash(function.EntryPoint);
}
return atLeastOnePresent ? hash.ToString() : null;
}
}