Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Generator/Generators/CSharp/CSharpExpressionPrinter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ public string VisitParameter(Parameter parameter)
if (desugared.IsPrimitiveType() &&
(parameter.DefaultArgument.Declaration != null ||
parameter.DefaultArgument.Class == StatementClass.BinaryOperator))
return $"({desugared.Visit(typePrinter)}) {expression}";
return $"({desugared.Visit(typePrinter)}) ({expression})";
var finalType = (desugared.GetFinalPointee() ?? desugared).Desugar();
if (finalType.TryGetClass(out var @class) && @class.IsInterface)
return $@"({@class.Visit(typePrinter)}) ({
@class.OriginalClass.Visit(typePrinter)}) {expression}";
@class.OriginalClass.Visit(typePrinter)}) ({expression})";
return expression;
}

Expand Down Expand Up @@ -88,4 +88,4 @@ public string ToString(Type type)

private readonly TypePrinter typePrinter;
}
}
}
6 changes: 5 additions & 1 deletion tests/dotnet/Common/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1273,4 +1273,8 @@ extern "C"
s.field2 = 10;
return s;
}
} // extern "C"
} // extern "C"

void DLL_API FunctionWithFlagsAsDefaultParameter(int defaultParam)
{
}
2 changes: 2 additions & 0 deletions tests/dotnet/Common/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -1567,3 +1567,5 @@ extern "C"
DLL_API void takeConflictName(struct system* self);
DLL_API struct system freeFunctionReturnByValue();
} // extern "C"

void DLL_API FunctionWithFlagsAsDefaultParameter(int defaultParam = A | B);