mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-26 19:11:04 +01:00
Code generator improvements (#940)
* Fix quotation marks escaping in multiline string * Add support for JsonPartialMatcher and JsonPartialWildcardMatcher in mapping code generator
This commit is contained in:
@@ -129,15 +129,25 @@ internal static class CSharpFormatter
|
||||
};
|
||||
}
|
||||
|
||||
public static string ToCSharpBooleanLiteral(bool value) => value ? "true" : "false";
|
||||
|
||||
public static string ToCSharpStringLiteral(string? value)
|
||||
{
|
||||
var escapedValue = value?.Replace("\"", "\\\"") ?? string.Empty;
|
||||
if (escapedValue.Contains("\n"))
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
return $"@\"{escapedValue}\"";
|
||||
return "\"\"";
|
||||
}
|
||||
|
||||
return $"\"{escapedValue}\"";
|
||||
if (value.Contains("\n"))
|
||||
{
|
||||
var escapedValue = value?.Replace("\"", "\"\"") ?? string.Empty;
|
||||
return $"@\"{escapedValue}\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
var escapedValue = value?.Replace("\"", "\\\"") ?? string.Empty;
|
||||
return $"\"{escapedValue}\"";
|
||||
}
|
||||
}
|
||||
|
||||
public static string FormatPropertyName(string propertyName)
|
||||
|
||||
Reference in New Issue
Block a user