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
3 changes: 3 additions & 0 deletions SourceGeneratorToolkit.Test/GeneratorBaseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,9 @@ public void TheHeaderCarriesTheCopyrightAndTheGeneratedMarker()
[DataRow("\n")]
[DataRow("\r\n")]
[DataRow("\r")]
[DataRow("\u0085")]
[DataRow("\u2028")]
[DataRow("\u2029")]
public void AMultiLineCopyrightIsCommentedOnEveryLine(string lineBreak)
{
string source = HeaderProbe.Write($"Copyright (c) Example.{lineBreak}{lineBreak}All rights reserved.");
Expand Down
8 changes: 5 additions & 3 deletions SourceGeneratorToolkit/GeneratorBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,10 @@ protected static CodeBlocker CreateCodeBlocker() =>
CodeBlocker.Create(CodeBlocker.DefaultIndentString, NewLines.Lf);

/// <summary>
/// The line breaks a copyright is split on, longest first so CRLF is one break rather than two.
/// Every line terminator the C# compiler recognises, which a copyright is split on so no text escapes its
/// comment. Longest first, so CRLF is one break rather than two.
/// </summary>
private static readonly string[] CopyrightLineBreaks = ["\r\n", "\n", "\r"];
private static readonly string[] CopyrightLineBreaks = ["\r\n", "\n", "\r", "\u0085", "\u2028", "\u2029"];

/// <summary>
/// Writes the header every generated file starts with.
Expand All @@ -121,7 +122,8 @@ protected static CodeBlocker CreateCodeBlocker() =>
/// <param name="copyright">
/// The copyright written above the generated-file marker, without its <c>//</c> prefix.
/// <see langword="null"/> or empty writes only the marker. A multi-line copyright is commented
/// line by line, whichever line break it uses, so a consumer's multi-line file header template
/// line by line at every line terminator the C# compiler recognises (CR, LF, CRLF, NEL,
/// LINE SEPARATOR and PARAGRAPH SEPARATOR), so a consumer's multi-line file header template
/// still compiles.
/// </param>
/// <remarks>
Expand Down
Loading