Skip to content

Commit 0e8964e

Browse files
CopilotYunchuWang
andcommitted
Address review feedback - add TypeKind.Error check and make returnType nullable
Co-authored-by: YunchuWang <[email protected]>
1 parent b7a0de6 commit 0e8964e

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/Generators/AzureFunctions/DurableFunction.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public DurableFunction(
2929
string name,
3030
DurableFunctionKind kind,
3131
TypedParameter parameter,
32-
ITypeSymbol returnType,
32+
ITypeSymbol? returnType,
3333
bool returnsVoid,
3434
HashSet<string> requiredNamespaces)
3535
{
@@ -38,7 +38,7 @@ public DurableFunction(
3838
this.Name = name;
3939
this.Kind = kind;
4040
this.Parameter = parameter;
41-
this.ReturnType = SyntaxNodeUtility.GetRenderedTypeExpression(returnType, false);
41+
this.ReturnType = returnType != null ? SyntaxNodeUtility.GetRenderedTypeExpression(returnType, false) : string.Empty;
4242
this.ReturnsVoid = returnsVoid;
4343
}
4444

@@ -63,7 +63,7 @@ public static bool TryParse(SemanticModel model, MethodDeclarationSyntax method,
6363
}
6464

6565
ITypeSymbol? returnTypeSymbol = model.GetTypeInfo(returnType).Type;
66-
if (returnTypeSymbol == null)
66+
if (returnTypeSymbol == null || returnTypeSymbol.TypeKind == TypeKind.Error)
6767
{
6868
function = null;
6969
return false;
@@ -144,11 +144,7 @@ public static bool TryParse(SemanticModel model, MethodDeclarationSyntax method,
144144

145145
requiredNamespaces!.UnionWith(GetRequiredGlobalNamespaces());
146146

147-
// For void returns, pass a dummy object type since the constructor needs an ITypeSymbol
148-
// but the ReturnsVoid flag will ensure it's not actually used for code generation
149-
ITypeSymbol returnTypeForConstructor = returnSymbol ?? model.Compilation.GetSpecialType(SpecialType.System_Object);
150-
151-
function = new DurableFunction(fullTypeName!, name, kind, parameter, returnTypeForConstructor, returnsVoid, requiredNamespaces);
147+
function = new DurableFunction(fullTypeName!, name, kind, parameter, returnSymbol, returnsVoid, requiredNamespaces);
152148
return true;
153149
}
154150

0 commit comments

Comments
 (0)