diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateEffectIdProperty.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateEffectIdProperty.Syntax.cs
index e23348f7..b9bdcc22 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateEffectIdProperty.Syntax.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateEffectIdProperty.Syntax.cs
@@ -1,4 +1,5 @@
using ComputeSharp.D2D1.SourceGenerators.Models;
+using ComputeSharp.SourceGeneration.Extensions;
using ComputeSharp.SourceGeneration.Helpers;
namespace ComputeSharp.D2D1.SourceGenerators;
@@ -16,6 +17,8 @@ partial class ID2D1ShaderGenerator
/// The instance to write into.
public static void WriteSyntax(D2D1ShaderInfo info, IndentedTextWriter writer)
{
+ writer.WriteLine("/// ");
+ writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator));
writer.WriteLine("readonly ref readonly global::System.Guid global::ComputeSharp.D2D1.__Internals.ID2D1Shader.EffectId");
using (writer.WriteBlock())
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateEffectMetadataProperties.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateEffectMetadataProperties.Syntax.cs
index c78732ad..a5cc487a 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateEffectMetadataProperties.Syntax.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateEffectMetadataProperties.Syntax.cs
@@ -1,4 +1,5 @@
using ComputeSharp.D2D1.SourceGenerators.Models;
+using ComputeSharp.SourceGeneration.Extensions;
using ComputeSharp.SourceGeneration.Helpers;
namespace ComputeSharp.D2D1.SourceGenerators;
@@ -57,6 +58,8 @@ partial class ID2D1ShaderGenerator
/// The instance to write into.
private static void WriteEffectMetadataSyntax(string propertyName, string? metadataValue, IndentedTextWriter writer)
{
+ writer.WriteLine("/// ");
+ writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator));
writer.Write($"readonly string? global::ComputeSharp.D2D1.__Internals.ID2D1Shader.{propertyName} => ");
// Append null or the metadata value as a string literal
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateHlslSourceProperty.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateHlslSourceProperty.Syntax.cs
index 18b07eb7..e0b0f645 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateHlslSourceProperty.Syntax.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateHlslSourceProperty.Syntax.cs
@@ -1,4 +1,5 @@
using ComputeSharp.D2D1.SourceGenerators.Models;
+using ComputeSharp.SourceGeneration.Extensions;
using ComputeSharp.SourceGeneration.Helpers;
namespace ComputeSharp.D2D1.SourceGenerators;
@@ -16,6 +17,8 @@ partial class ID2D1ShaderGenerator
/// The instance to write into.
public static void WriteSyntax(D2D1ShaderInfo info, IndentedTextWriter writer)
{
+ writer.WriteLine("/// ");
+ writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator));
writer.WriteLine("readonly string global::ComputeSharp.D2D1.__Internals.ID2D1Shader.HlslSource =>");
writer.IncreaseIndent();
writer.WriteLine("\"\"\"");
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateInitializeFromDispatchDataMethod.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateInitializeFromDispatchDataMethod.Syntax.cs
index 32b0acb7..4dfa6969 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateInitializeFromDispatchDataMethod.Syntax.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateInitializeFromDispatchDataMethod.Syntax.cs
@@ -1,4 +1,5 @@
using ComputeSharp.D2D1.SourceGenerators.Models;
+using ComputeSharp.SourceGeneration.Extensions;
using ComputeSharp.SourceGeneration.Helpers;
namespace ComputeSharp.D2D1.SourceGenerators;
@@ -16,6 +17,8 @@ partial class ID2D1ShaderGenerator
/// The instance to write into.
public static void WriteSyntax(D2D1ShaderInfo info, IndentedTextWriter writer)
{
+ writer.WriteLine("/// ");
+ writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator));
writer.WriteLine("readonly void global::ComputeSharp.D2D1.__Internals.ID2D1Shader.InitializeFromDispatchData(global::System.ReadOnlySpan data)");
using (writer.WriteBlock())
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateInputCountProperty.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateInputCountProperty.Syntax.cs
index ba8579df..bbde29e1 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateInputCountProperty.Syntax.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateInputCountProperty.Syntax.cs
@@ -1,4 +1,5 @@
using ComputeSharp.D2D1.SourceGenerators.Models;
+using ComputeSharp.SourceGeneration.Extensions;
using ComputeSharp.SourceGeneration.Helpers;
namespace ComputeSharp.D2D1.SourceGenerators;
@@ -18,6 +19,8 @@ partial class ID2D1ShaderGenerator
/// The instance to write into.
public static void WriteSyntax(D2D1ShaderInfo info, IndentedTextWriter writer)
{
+ writer.WriteLine("/// ");
+ writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator));
writer.WriteLine($"readonly int global::ComputeSharp.D2D1.__Internals.ID2D1Shader.InputCount => {info.InputTypes.Length};");
}
}
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateInputDescriptionsProperty.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateInputDescriptionsProperty.Syntax.cs
index 0af11a60..ad20fe54 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateInputDescriptionsProperty.Syntax.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateInputDescriptionsProperty.Syntax.cs
@@ -19,6 +19,8 @@ partial class ID2D1ShaderGenerator
/// The instance to write into.
public static void WriteSyntax(D2D1ShaderInfo info, IndentedTextWriter writer)
{
+ writer.WriteLine("/// ");
+ writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator));
writer.Write("readonly global::System.ReadOnlyMemory global::ComputeSharp.D2D1.__Internals.ID2D1Shader.InputDescriptions => ");
// If there are no input descriptions, just return a default expression.
@@ -53,9 +55,7 @@ partial class ID2D1ShaderGenerator
writer.WriteLine($$"""/// """);
writer.WriteLine($$"""/// A container type for additional data needed by the shader.""");
writer.WriteLine($$"""/// """);
- writer.WriteLine($$"""[global::System.CodeDom.Compiler.GeneratedCode("{{typeof(ID2D1ShaderGenerator).FullName}}", "{{typeof(ID2D1ShaderGenerator).Assembly.GetName().Version}}")]""");
- writer.WriteLine($$"""[global::System.Diagnostics.DebuggerNonUserCode]""");
- writer.WriteLine($$"""[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]""");
+ writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator));
writer.WriteLine($$"""file static class Data""");
using (writer.WriteBlock())
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateInputTypesProperty.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateInputTypesProperty.Syntax.cs
index dc114166..ea98461e 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateInputTypesProperty.Syntax.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateInputTypesProperty.Syntax.cs
@@ -17,6 +17,8 @@ partial class ID2D1ShaderGenerator
/// The instance to write into.
public static void WriteSyntax(D2D1ShaderInfo info, IndentedTextWriter writer)
{
+ writer.WriteLine("/// ");
+ writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator));
writer.Write("readonly global::System.ReadOnlyMemory global::ComputeSharp.D2D1.__Internals.ID2D1Shader.InputTypes => ");
// If there are no inputs, simply return a default expression. Otherwise, create
@@ -50,9 +52,7 @@ partial class ID2D1ShaderGenerator
writer.WriteLine($$"""/// """);
writer.WriteLine($$"""/// A implementation to get the input types.""");
writer.WriteLine($$"""/// """);
- writer.WriteLine($$"""[global::System.CodeDom.Compiler.GeneratedCode("{{typeof(ID2D1ShaderGenerator).FullName}}", "{{typeof(ID2D1ShaderGenerator).Assembly.GetName().Version}}")]""");
- writer.WriteLine($$"""[global::System.Diagnostics.DebuggerNonUserCode]""");
- writer.WriteLine($$"""[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]""");
+ writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator));
writer.WriteLine($$"""file sealed class InputTypesMemoryManager : global::System.Buffers.MemoryManager""");
using (writer.WriteBlock())
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadBytecodeMethod.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadBytecodeMethod.Syntax.cs
index 3ef62dc6..ef657cc5 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadBytecodeMethod.Syntax.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadBytecodeMethod.Syntax.cs
@@ -1,5 +1,6 @@
using System.Linq;
using ComputeSharp.D2D1.SourceGenerators.Models;
+using ComputeSharp.SourceGeneration.Extensions;
using ComputeSharp.SourceGeneration.Helpers;
using Microsoft.CodeAnalysis;
@@ -18,6 +19,8 @@ partial class ID2D1ShaderGenerator
/// The instance to write into.
public static void WriteShaderProfileSyntax(D2D1ShaderInfo info, IndentedTextWriter writer)
{
+ writer.WriteLine("/// ");
+ writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator));
writer.WriteLine($"readonly ComputeSharp.D2D1.D2D1ShaderProfile global::ComputeSharp.D2D1.__Internals.ID2D1Shader.ShaderProfile => global::ComputeSharp.D2D1.D2D1ShaderProfile.{info.HlslInfoKey.EffectiveShaderProfile};");
}
@@ -36,6 +39,8 @@ partial class ID2D1ShaderGenerator
.Select(static name => $"global::ComputeSharp.D2D1.D2D1CompileOptions.{name.Trim()}")
.Aggregate("", static (left, right) => left.Length > 0 ? $"{left} | {right}" : right);
+ writer.WriteLine("/// ");
+ writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator));
writer.WriteLine($"readonly ComputeSharp.D2D1.D2D1CompileOptions global::ComputeSharp.D2D1.__Internals.ID2D1Shader.CompileOptions => {compileOptionsExpression};");
}
@@ -46,6 +51,8 @@ partial class ID2D1ShaderGenerator
/// The instance to write into.
public static void WriteHlslBytecodeSyntax(D2D1ShaderInfo info, IndentedTextWriter writer)
{
+ writer.WriteLine("/// ");
+ writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator));
writer.Write("readonly global::System.ReadOnlyMemory global::ComputeSharp.D2D1.__Internals.ID2D1Shader.HlslBytecode => ");
// If there is no bytecode, just return a default expression.
@@ -79,9 +86,7 @@ partial class ID2D1ShaderGenerator
writer.WriteLine($$"""/// """);
writer.WriteLine($$"""/// implementation to get the HLSL bytecode.""");
writer.WriteLine($$"""/// """);
- writer.WriteLine($$"""[global::System.CodeDom.Compiler.GeneratedCode("{{typeof(ID2D1ShaderGenerator).FullName}}", "{{typeof(ID2D1ShaderGenerator).Assembly.GetName().Version}}")]""");
- writer.WriteLine($$"""[global::System.Diagnostics.DebuggerNonUserCode]""");
- writer.WriteLine($$"""[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]""");
+ writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator));
writer.WriteLine($$"""file sealed class HlslBytecodeMemoryManager : global::System.Buffers.MemoryManager""");
using (writer.WriteBlock())
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadDispatchDataMethod.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadDispatchDataMethod.Syntax.cs
index 5a9605fd..ba98b07f 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadDispatchDataMethod.Syntax.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateLoadDispatchDataMethod.Syntax.cs
@@ -18,6 +18,8 @@ partial class ID2D1ShaderGenerator
/// The instance to write into.
public static void WriteSyntax(D2D1ShaderInfo info, IndentedTextWriter writer)
{
+ writer.WriteLine("/// ");
+ writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator));
writer.WriteLine("readonly unsafe void global::ComputeSharp.D2D1.__Internals.ID2D1Shader.LoadDispatchData(ref TLoader loader)");
using (writer.WriteBlock())
@@ -85,9 +87,7 @@ partial class ID2D1ShaderGenerator
writer.WriteLine($$"""/// """);
writer.WriteLine($$"""/// A type representing the constant buffer native layout for .""");
writer.WriteLine($$"""/// """);
- writer.WriteLine($$"""[global::System.CodeDom.Compiler.GeneratedCode("{{typeof(ID2D1ShaderGenerator).FullName}}", "{{typeof(ID2D1ShaderGenerator).Assembly.GetName().Version}}")]""");
- writer.WriteLine($$"""[global::System.Diagnostics.DebuggerNonUserCode]""");
- writer.WriteLine($$"""[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]""");
+ writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator));
writer.WriteLine($$"""[global::System.Runtime.InteropServices.StructLayout(global::System.Runtime.InteropServices.LayoutKind.Explicit, Size = {{info.ConstantBufferSizeInBytes}})]""");
writer.WriteLine($$"""file struct ConstantBuffer""");
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateOutputBufferProperties.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateOutputBufferProperties.Syntax.cs
index 8a6400c0..ca889f0e 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateOutputBufferProperties.Syntax.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateOutputBufferProperties.Syntax.cs
@@ -1,5 +1,6 @@
using System;
using ComputeSharp.D2D1.SourceGenerators.Models;
+using ComputeSharp.SourceGeneration.Extensions;
using ComputeSharp.SourceGeneration.Helpers;
namespace ComputeSharp.D2D1.SourceGenerators;
@@ -25,6 +26,8 @@ partial class ID2D1ShaderGenerator
false => "default"
};
+ writer.WriteLine("/// ");
+ writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator));
writer.WriteLine($"readonly ComputeSharp.D2D1.D2D1BufferPrecision global::ComputeSharp.D2D1.__Internals.ID2D1Shader.BufferPrecision => {bufferPrecisionExpression};");
}
@@ -42,6 +45,8 @@ partial class ID2D1ShaderGenerator
false => "default"
};
+ writer.WriteLine("/// ");
+ writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator));
writer.WriteLine($"readonly ComputeSharp.D2D1.D2D1ChannelDepth global::ComputeSharp.D2D1.__Internals.ID2D1Shader.ChannelDepth => {channelDepthExpression};");
}
}
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreatePixelOptionsProperty.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreatePixelOptionsProperty.Syntax.cs
index 2c408811..f5207ece 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreatePixelOptionsProperty.Syntax.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreatePixelOptionsProperty.Syntax.cs
@@ -1,4 +1,5 @@
using ComputeSharp.D2D1.SourceGenerators.Models;
+using ComputeSharp.SourceGeneration.Extensions;
using ComputeSharp.SourceGeneration.Helpers;
namespace ComputeSharp.D2D1.SourceGenerators;
@@ -23,6 +24,8 @@ partial class ID2D1ShaderGenerator
false => "default"
};
+ writer.WriteLine("/// ");
+ writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator));
writer.WriteLine($"readonly ComputeSharp.D2D1.D2D1PixelOptions global::ComputeSharp.D2D1.__Internals.ID2D1Shader.PixelOptions => {pixelOptionsExpression};");
}
}
diff --git a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateResourceTextureDescriptionsProperty.Syntax.cs b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateResourceTextureDescriptionsProperty.Syntax.cs
index 4514e9f9..b20e0d0e 100644
--- a/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateResourceTextureDescriptionsProperty.Syntax.cs
+++ b/src/ComputeSharp.D2D1.SourceGenerators/ID2D1ShaderGenerator.CreateResourceTextureDescriptionsProperty.Syntax.cs
@@ -19,6 +19,8 @@ partial class ID2D1ShaderGenerator
/// The instance to write into.
public static void WriteSyntax(D2D1ShaderInfo info, IndentedTextWriter writer)
{
+ writer.WriteLine("/// ");
+ writer.WriteGeneratedAttributes(typeof(ID2D1ShaderGenerator));
writer.Write("readonly global::System.ReadOnlyMemory global::ComputeSharp.D2D1.__Internals.ID2D1Shader.ResourceTextureDescriptions => ");
// If there are no resource texture descriptions, just return a default expression.
diff --git a/src/ComputeSharp.SourceGeneration/Extensions/IndentedTextWriterExtensions.cs b/src/ComputeSharp.SourceGeneration/Extensions/IndentedTextWriterExtensions.cs
index f7b1f2a6..1b27e198 100644
--- a/src/ComputeSharp.SourceGeneration/Extensions/IndentedTextWriterExtensions.cs
+++ b/src/ComputeSharp.SourceGeneration/Extensions/IndentedTextWriterExtensions.cs
@@ -8,6 +8,23 @@ namespace ComputeSharp.SourceGeneration.Extensions;
///
internal static class IndentedTextWriterExtensions
{
+ ///
+ /// Writes the following attributes into a target writer:
+ ///
+ /// [global::System.CodeDom.Compiler.GeneratedCode("...", "...")]
+ /// [global::System.Diagnostics.DebuggerNonUserCode]
+ /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
+ ///
+ ///
+ /// The instance to write into.
+ /// The type of the running generator.
+ public static void WriteGeneratedAttributes(this IndentedTextWriter writer, Type generatorType)
+ {
+ writer.WriteLine($$"""[global::System.CodeDom.Compiler.GeneratedCode("{{generatorType.FullName}}", "{{generatorType.Assembly.GetName().Version}}")]""");
+ writer.WriteLine($$"""[global::System.Diagnostics.DebuggerNonUserCode]""");
+ writer.WriteLine($$"""[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]""");
+ }
+
///
/// Writes a series of members separated by one line between each of them.
///