Skip to content

Commit abab355

Browse files
committed
fixed the source gen
1 parent 23dcba0 commit abab355

File tree

5 files changed

+15
-5
lines changed

5 files changed

+15
-5
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Build NuGet Packages
33
on:
44
push:
55
branches:
6-
- main
6+
- net8
77

88
jobs:
99
check-nuget:

.github/workflows/pr.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Run Build and Tests on Pull Request
33
on:
44
pull_request:
55
branches:
6-
- main
6+
- net8
77

88
jobs:
99
pr:

src/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<PackageTags>ticker;queue;cron;time;scheduler;fire-and-forget</PackageTags>
99
<PackageIcon>icon.jpg</PackageIcon>
1010
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
11-
<Version>8.0.0-beta.6</Version>
11+
<Version>8.0.0-beta.8</Version>
1212
<LangVersion>latest</LangVersion>
1313
</PropertyGroup>
1414

src/TickerQ.SourceGenerator/Generators/DelegateGenerator.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ public static string GenerateDelegateCode(
5959
HashSet<string> typeNameConflicts = null)
6060
{
6161
var sb = new StringBuilder(1024); // Delegate methods are medium-sized
62-
var asyncFlag = (methodInfo.UsesGenericContext || isAwaitable) ? "async " : "";
62+
// Only use async if we actually need to await something (generic context conversion or awaitable method)
63+
// This ensures we always have an await when async is used
64+
var needsAsync = methodInfo.UsesGenericContext || isAwaitable;
65+
var asyncFlag = needsAsync ? "async " : "";
6366
var cronExprFlag = string.IsNullOrEmpty(cronExpression) ? "string.Empty" : $"\"{cronExpression}\"";
6467

6568
// Generate delegate registration with proper multiline format
@@ -145,6 +148,7 @@ private static void GenerateMethodCall(
145148
}
146149

147150
var parameters = string.Join(", ", parametersList);
151+
var isVoidMethod = !SourceGeneratorUtilities.IsMethodAwaitable(methodDeclaration);
148152

149153
if (SourceGeneratorUtilities.IsMethodAwaitable(methodDeclaration))
150154
{
@@ -153,6 +157,12 @@ private static void GenerateMethodCall(
153157
else
154158
{
155159
sb.AppendLine($" {methodCall}({parameters});");
160+
// If method is void, we must return Task.CompletedTask to satisfy the Task-returning delegate
161+
// This is required whether the lambda is async or not
162+
if (isVoidMethod)
163+
{
164+
sb.AppendLine(" return Task.CompletedTask;");
165+
}
156166
}
157167
}
158168

src/TickerQ.SourceGenerator/TickerQIncrementalSourceGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,4 +756,4 @@ private static IParameterSymbol GetPrimaryConstructorParameterSymbol(
756756

757757
// All utility methods moved to SourceGeneratorUtilities class
758758
}
759-
}
759+
}

0 commit comments

Comments
 (0)