Filter newlines from effect display names
このコミットが含まれているのは:
1 親
8acb8b0b1a
コミット
7fc302312d
1ファイル変更
+10
-1
+10
-1
@@ -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
|
||||
/// </summary>
|
||||
private static partial class EffectDisplayName
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see cref="Regex"/> instance to find all newlines.
|
||||
/// </summary>
|
||||
private static readonly Regex NewLinesRegex = new("[\r\n\v]", RegexOptions.Compiled);
|
||||
|
||||
/// <summary>
|
||||
/// Extracts the effect display name info for the current shader.
|
||||
/// </summary>
|
||||
@@ -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)
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする