Use string literal in global using directives generator
このコミットが含まれているのは:
1 親
3c08e42c14
コミット
15da94aba3
4ファイル変更
+107
-160
検索条件に一致するファイルはありません
@@ -1,5 +1,3 @@
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using Microsoft.CodeAnalysis;
|
||||
|
||||
namespace ComputeSharp.Core.SourceGenerators;
|
||||
@@ -10,19 +8,114 @@ namespace ComputeSharp.Core.SourceGenerators;
|
||||
[Generator(LanguageNames.CSharp)]
|
||||
public sealed class GlobalUsingDirectivesGenerator : IIncrementalGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// The generated global using directives to emit.
|
||||
/// </summary>
|
||||
private const string GlobalUsingDirectives =
|
||||
"""
|
||||
// <auto-generated/>
|
||||
#pragma warning disable
|
||||
|
||||
global using bool2 = global::ComputeSharp.Bool2;
|
||||
global using bool3 = global::ComputeSharp.Bool3;
|
||||
global using bool4 = global::ComputeSharp.Bool4;
|
||||
global using bool1x1 = global::ComputeSharp.Bool1x1;
|
||||
global using bool1x2 = global::ComputeSharp.Bool1x2;
|
||||
global using bool1x3 = global::ComputeSharp.Bool1x3;
|
||||
global using bool1x4 = global::ComputeSharp.Bool1x4;
|
||||
global using bool2x1 = global::ComputeSharp.Bool2x1;
|
||||
global using bool2x2 = global::ComputeSharp.Bool2x2;
|
||||
global using bool2x3 = global::ComputeSharp.Bool2x3;
|
||||
global using bool2x4 = global::ComputeSharp.Bool2x4;
|
||||
global using bool3x1 = global::ComputeSharp.Bool3x1;
|
||||
global using bool3x2 = global::ComputeSharp.Bool3x2;
|
||||
global using bool3x3 = global::ComputeSharp.Bool3x3;
|
||||
global using bool3x4 = global::ComputeSharp.Bool3x4;
|
||||
global using bool4x1 = global::ComputeSharp.Bool4x1;
|
||||
global using bool4x2 = global::ComputeSharp.Bool4x2;
|
||||
global using bool4x3 = global::ComputeSharp.Bool4x3;
|
||||
global using bool4x4 = global::ComputeSharp.Bool4x4;
|
||||
global using double2 = global::ComputeSharp.Double2;
|
||||
global using double3 = global::ComputeSharp.Double3;
|
||||
global using double4 = global::ComputeSharp.Double4;
|
||||
global using double1x1 = global::ComputeSharp.Double1x1;
|
||||
global using double1x2 = global::ComputeSharp.Double1x2;
|
||||
global using double1x3 = global::ComputeSharp.Double1x3;
|
||||
global using double1x4 = global::ComputeSharp.Double1x4;
|
||||
global using double2x1 = global::ComputeSharp.Double2x1;
|
||||
global using double2x2 = global::ComputeSharp.Double2x2;
|
||||
global using double2x3 = global::ComputeSharp.Double2x3;
|
||||
global using double2x4 = global::ComputeSharp.Double2x4;
|
||||
global using double3x1 = global::ComputeSharp.Double3x1;
|
||||
global using double3x2 = global::ComputeSharp.Double3x2;
|
||||
global using double3x3 = global::ComputeSharp.Double3x3;
|
||||
global using double3x4 = global::ComputeSharp.Double3x4;
|
||||
global using double4x1 = global::ComputeSharp.Double4x1;
|
||||
global using double4x2 = global::ComputeSharp.Double4x2;
|
||||
global using double4x3 = global::ComputeSharp.Double4x3;
|
||||
global using double4x4 = global::ComputeSharp.Double4x4;
|
||||
global using float2 = global::ComputeSharp.Float2;
|
||||
global using float3 = global::ComputeSharp.Float3;
|
||||
global using float4 = global::ComputeSharp.Float4;
|
||||
global using float1x1 = global::ComputeSharp.Float1x1;
|
||||
global using float1x2 = global::ComputeSharp.Float1x2;
|
||||
global using float1x3 = global::ComputeSharp.Float1x3;
|
||||
global using float1x4 = global::ComputeSharp.Float1x4;
|
||||
global using float2x1 = global::ComputeSharp.Float2x1;
|
||||
global using float2x2 = global::ComputeSharp.Float2x2;
|
||||
global using float2x3 = global::ComputeSharp.Float2x3;
|
||||
global using float2x4 = global::ComputeSharp.Float2x4;
|
||||
global using float3x1 = global::ComputeSharp.Float3x1;
|
||||
global using float3x2 = global::ComputeSharp.Float3x2;
|
||||
global using float3x3 = global::ComputeSharp.Float3x3;
|
||||
global using float3x4 = global::ComputeSharp.Float3x4;
|
||||
global using float4x1 = global::ComputeSharp.Float4x1;
|
||||
global using float4x2 = global::ComputeSharp.Float4x2;
|
||||
global using float4x3 = global::ComputeSharp.Float4x3;
|
||||
global using float4x4 = global::ComputeSharp.Float4x4;
|
||||
global using int2 = global::ComputeSharp.Int2;
|
||||
global using int3 = global::ComputeSharp.Int3;
|
||||
global using int4 = global::ComputeSharp.Int4;
|
||||
global using int1x1 = global::ComputeSharp.Int1x1;
|
||||
global using int1x2 = global::ComputeSharp.Int1x2;
|
||||
global using int1x3 = global::ComputeSharp.Int1x3;
|
||||
global using int1x4 = global::ComputeSharp.Int1x4;
|
||||
global using int2x1 = global::ComputeSharp.Int2x1;
|
||||
global using int2x2 = global::ComputeSharp.Int2x2;
|
||||
global using int2x3 = global::ComputeSharp.Int2x3;
|
||||
global using int2x4 = global::ComputeSharp.Int2x4;
|
||||
global using int3x1 = global::ComputeSharp.Int3x1;
|
||||
global using int3x2 = global::ComputeSharp.Int3x2;
|
||||
global using int3x3 = global::ComputeSharp.Int3x3;
|
||||
global using int3x4 = global::ComputeSharp.Int3x4;
|
||||
global using int4x1 = global::ComputeSharp.Int4x1;
|
||||
global using int4x2 = global::ComputeSharp.Int4x2;
|
||||
global using int4x3 = global::ComputeSharp.Int4x3;
|
||||
global using int4x4 = global::ComputeSharp.Int4x4;
|
||||
global using uint2 = global::ComputeSharp.UInt2;
|
||||
global using uint3 = global::ComputeSharp.UInt3;
|
||||
global using uint4 = global::ComputeSharp.UInt4;
|
||||
global using uint1x1 = global::ComputeSharp.UInt1x1;
|
||||
global using uint1x2 = global::ComputeSharp.UInt1x2;
|
||||
global using uint1x3 = global::ComputeSharp.UInt1x3;
|
||||
global using uint1x4 = global::ComputeSharp.UInt1x4;
|
||||
global using uint2x1 = global::ComputeSharp.UInt2x1;
|
||||
global using uint2x2 = global::ComputeSharp.UInt2x2;
|
||||
global using uint2x3 = global::ComputeSharp.UInt2x3;
|
||||
global using uint2x4 = global::ComputeSharp.UInt2x4;
|
||||
global using uint3x1 = global::ComputeSharp.UInt3x1;
|
||||
global using uint3x2 = global::ComputeSharp.UInt3x2;
|
||||
global using uint3x3 = global::ComputeSharp.UInt3x3;
|
||||
global using uint3x4 = global::ComputeSharp.UInt3x4;
|
||||
global using uint4x1 = global::ComputeSharp.UInt4x1;
|
||||
global using uint4x2 = global::ComputeSharp.UInt4x2;
|
||||
global using uint4x3 = global::ComputeSharp.UInt4x3;
|
||||
global using uint4x4 = global::ComputeSharp.UInt4x4;
|
||||
""";
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Initialize(IncrementalGeneratorInitializationContext context)
|
||||
{
|
||||
context.RegisterPostInitializationOutput(static context =>
|
||||
{
|
||||
const string filename = "ComputeSharp.Core.SourceGenerators.EmbeddedResources.GlobalUsingDirectives.cs";
|
||||
|
||||
using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(filename);
|
||||
using StreamReader reader = new(stream);
|
||||
|
||||
string globalUsingDirectives = reader.ReadToEnd();
|
||||
|
||||
context.AddSource("GlobalUsingDirectives.g.cs", globalUsingDirectives);
|
||||
});
|
||||
context.RegisterPostInitializationOutput(static context => context.AddSource($"{nameof(GlobalUsingDirectives)}.g.cs", GlobalUsingDirectives));
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする