Fixed filenames for generated files

このコミットが含まれているのは:
Sergio Pedri committed 2020-11-27 15:37:45 +01:00
1 親 ebe1859a18
コミット b6cd1916c3
4ファイル変更
+21 -5

検索条件に一致するファイルはありません

+17
ファイルの表示
@@ -1,5 +1,6 @@
using System.Diagnostics.Contracts;
using System.Text;
using System.Text.RegularExpressions;
using Microsoft.CodeAnalysis;
namespace ComputeSharp.SourceGenerators.Extensions
@@ -54,5 +55,21 @@ namespace ComputeSharp.SourceGenerators.Extensions
{
return symbol.ToDisplayString(FullyQualifiedWithoutGlobalAndParametersFormat);
}
/// <summary>
/// Gets a valid filename for a target symbol and generator type.
/// </summary>
/// <typeparam name="TGenerator">The generator type processing the input symbol.</typeparam>
/// <param name="symbol">The symbol being processed.</param>
/// <returns>A filename in the form "[ComputeSharp]_[&lt;TGENERATOR&gt;]_[&lt;SYMBOL_FULLNAME&gt;]"</returns>
[Pure]
public static string GetGeneratedFileName<TGenerator>(this INamedTypeSymbol symbol)
{
string
metadataName = symbol.GetFullMetadataName(),
fixedName = metadataName.Replace('`', '-').Replace('+', '.');
return $"[{nameof(ComputeSharp)}]_[{typeof(TGenerator).Name}]_[{fixedName}]";
}
}
}