Fixed filenames for generated files

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

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

+2 -1
ファイルの表示
@@ -1,6 +1,7 @@
using System.Collections.Immutable;
using System.Linq;
using System.Text;
using ComputeSharp.SourceGenerators.Extensions;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
@@ -86,7 +87,7 @@ namespace ComputeSharp.SourceGenerators
.ToFullString();
// Add the partial type
context.AddSource($"__ComputeSharp_{typeof(AutoConstructorAttribute).FullName}_{structDeclarationSymbol.Name}", SourceText.From(source, Encoding.UTF8));
context.AddSource(structDeclarationSymbol.GetGeneratedFileName<AutoConstructorAttributeGenerator>(), SourceText.From(source, Encoding.UTF8));
}
}
}
+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}]";
}
}
}
+1 -1
ファイルの表示
@@ -75,7 +75,7 @@ namespace ComputeSharp.SourceGenerators
.ToFullString();
// Add the partial type
context.AddSource($"__ComputeSharp_{typeof(FieldAttribute).FullName}_{structDeclarationSymbol.Name}", SourceText.From(source, Encoding.UTF8));
context.AddSource(structDeclarationSymbol.GetGeneratedFileName<FieldAttributeGenerator>(), SourceText.From(source, Encoding.UTF8));
}
}
+1 -3
ファイルの表示
@@ -70,10 +70,8 @@ namespace ComputeSharp.SourceGenerators
.NormalizeWhitespace()
.ToFullString();
var generatedFileName = $"__ComputeSharp_{nameof(IComputeShaderSourceAttribute)}_{structDeclarationSymbol.Name}";
// Add the method source attribute
context.AddSource(generatedFileName, SourceText.From(source, Encoding.UTF8));
context.AddSource(structDeclarationSymbol.GetGeneratedFileName<IComputeShaderSourceAttributeGenerator>(), SourceText.From(source, Encoding.UTF8));
}
}