Skip to content

Commit b0d5222

Browse files
CopilotYunchuWang
andcommitted
Refactor project type checking to use HashSet for better maintainability
Co-authored-by: YunchuWang <[email protected]>
1 parent e1488de commit b0d5222

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/Generators/DurableTaskSourceGenerator.cs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -325,15 +325,25 @@ static bool DetermineIsDurableFunctions(Compilation compilation, string? project
325325
if (!string.IsNullOrWhiteSpace(projectType))
326326
{
327327
// Explicit configuration takes precedence
328-
if (projectType!.Equals("DurableFunctions", StringComparison.OrdinalIgnoreCase) ||
329-
projectType.Equals("Functions", StringComparison.OrdinalIgnoreCase) ||
330-
projectType.Equals("AzureFunctions", StringComparison.OrdinalIgnoreCase))
328+
HashSet<string> functionsTypes = new(StringComparer.OrdinalIgnoreCase)
329+
{
330+
"DurableFunctions",
331+
"Functions",
332+
"AzureFunctions"
333+
};
334+
335+
HashSet<string> workerTypes = new(StringComparer.OrdinalIgnoreCase)
336+
{
337+
"DurableTaskScheduler",
338+
"Worker",
339+
"DurableTaskWorker"
340+
};
341+
342+
if (functionsTypes.Contains(projectType!))
331343
{
332344
return true;
333345
}
334-
else if (projectType.Equals("DurableTaskScheduler", StringComparison.OrdinalIgnoreCase) ||
335-
projectType.Equals("Worker", StringComparison.OrdinalIgnoreCase) ||
336-
projectType.Equals("DurableTaskWorker", StringComparison.OrdinalIgnoreCase))
346+
else if (workerTypes.Contains(projectType!))
337347
{
338348
return false;
339349
}

0 commit comments

Comments
 (0)