Skip to content

Commit

Permalink
Merge pull request #40 from simonmckenzie/fix/handle-boolean-default-…
Browse files Browse the repository at this point in the history
…values-correctly

Handle boolean default values correctly
  • Loading branch information
ChristianSauer authored Mar 19, 2024
2 parents 7c18cf6 + 5df7308 commit ff044e4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions AutomaticInterface/AutomaticInterface/Builder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ private static string GetMethodSignature(IParameterSymbol x)
var optionalValue = x.ExplicitDefaultValue switch
{
string => $" = \"{x.ExplicitDefaultValue}\"",
bool value => $" = {(value ? "true" : "false")}",
// struct
null when x.Type.IsValueType => $" = default({x.Type})",
null => " = null",
Expand Down
9 changes: 5 additions & 4 deletions AutomaticInterface/Tests/GeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public class DemoClass
public bool TryStartTransaction(
string file = "",
string member = "",
int line = 0)
int line = 0,
bool notify = true)
{
return true;
}
Expand All @@ -82,7 +83,7 @@ namespace AutomaticInterfaceExample
public partial interface IDemoClass
{
/// <inheritdoc />
bool TryStartTransaction(string file = "", string member = "", int line = 0);
bool TryStartTransaction(string file = "", string member = "", int line = 0, bool notify = true);

}
}
Expand Down Expand Up @@ -1885,7 +1886,7 @@ namespace AutomaticInterfaceExample
public partial interface IDemoClass
{
/// <inheritdoc />
Task<Stream?> GetFinalDocumentsByIDFails(string agreementID, string docType, bool amt = False, bool? attachSupportingDocuments = True, CancellationToken cancellationToken = null);
Task<Stream?> GetFinalDocumentsByIDFails(string agreementID, string docType, bool amt = false, bool? attachSupportingDocuments = true, CancellationToken cancellationToken = null);

}
}
Expand Down Expand Up @@ -1957,7 +1958,7 @@ namespace CustomNameSpace
public partial interface IDemoClass
{
/// <inheritdoc />
Task<Stream?> GetFinalDocumentsByIDFails(string agreementID, string docType, bool amt = False, bool? attachSupportingDocuments = True, CancellationToken cancellationToken = null);
Task<Stream?> GetFinalDocumentsByIDFails(string agreementID, string docType, bool amt = false, bool? attachSupportingDocuments = true, CancellationToken cancellationToken = null);

}
}
Expand Down

0 comments on commit ff044e4

Please sign in to comment.