Skip to content

Commit

Permalink
fix: #493 handle newlines in strings emitted into typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
ascott18 committed Dec 19, 2024
1 parent ecc95f2 commit b740044
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

- `c-select` `open-on-clear` prop once again functions as expected.
- `c-select` now closes when changing focus to other elements on the page
- Multi-line strings now emit correctly into generated metadata (e.g. a multi-line description for a property)

# 5.2.1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,14 @@ public class ComplexModel
public string AdminReadableString { get; set; }

[Restrict<AuthenticatedRestriction>]
[Display(Description = """
This is a multiline string in an attribute.
This is a second line in the string.
""")]
public string RestrictedString { get; set; }

[Restrict<AuthenticatedRestriction>]
[Display(Description = "This is a multiline string\n via explicit escaped newline")]
public string RestrictInit { get; init; }

[Read(RoleNames.Admin)]
Expand Down
2 changes: 2 additions & 0 deletions src/IntelliTect.Coalesce/Utilities/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ public static string ToCamelCase(this string s)
[return: System.Diagnostics.CodeAnalysis.NotNullIfNotNull("str")]
public static string? EscapeStringLiteralForTypeScript(this string? str) => str?
.Replace(@"\", @"\\")
.Replace("\r", @"\r")
.Replace("\n", @"\n")
.Replace("\"", "\\\"");

[return: System.Diagnostics.CodeAnalysis.NotNullIfNotNull("str")]
Expand Down
2 changes: 2 additions & 0 deletions src/test-targets/metadata.g.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/test-targets/models.g.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/test-targets/viewmodels.g.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b740044

Please sign in to comment.