Fixed filenames for generated files
このコミットが含まれているのは:
1 親
ebe1859a18
コミット
b6cd1916c3
4ファイル変更
+21
-5
検索条件に一致するファイルはありません
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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]_[<TGENERATOR>]_[<SYMBOL_FULLNAME>]"</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}]";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする