diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateEffectDisplayNameProperty.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateEffectDisplayNameProperty.cs
index fb216133..953abbd6 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateEffectDisplayNameProperty.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateEffectDisplayNameProperty.cs
@@ -1,6 +1,7 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Security;
+using System.Text.RegularExpressions;
using ComputeSharp.SourceGeneration.Extensions;
using ComputeSharp.SourceGeneration.Helpers;
using ComputeSharp.SourceGeneration.Models;
@@ -16,6 +17,11 @@ partial class ID2D1ShaderGenerator
///
private static partial class EffectDisplayName
{
+ ///
+ /// A instance to find all newlines.
+ ///
+ private static readonly Regex NewLinesRegex = new("[\r\n\v]", RegexOptions.Compiled);
+
///
/// Extracts the effect display name info for the current shader.
///
@@ -53,8 +59,11 @@ partial class ID2D1ShaderGenerator
if (SymbolEqualityComparer.Default.Equals(attributeData.AttributeClass, effectIdAttributeSymbol) &&
attributeData.ConstructorArguments is [{ Value: string { Length: > 0 } value }])
{
+ // Remove new lines (the values cannot span multiple lines in XML)
+ string singleLineValue = NewLinesRegex.Replace(value, string.Empty);
+
// Make sure to escape any invalid XML characters
- string escapedValue = SecurityElement.Escape(value);
+ string escapedValue = SecurityElement.Escape(singleLineValue);
// Trim the display name as well
if (escapedValue.AsSpan().Trim() is { Length: > 0 } trimmedValue)