From d06e8fd3edef6bc8ba909bbe9614e0a679e42837 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 29 Dec 2020 00:52:33 +0100 Subject: [PATCH] Minor code refactoring --- .../{ => __Internals}/IComputeShaderSourceAttribute.cs | 2 +- .../{ => __Internals}/ShaderMethodSourceAttribute.cs | 2 +- .../Helpers/__Internals/GraphicsResourceHelper.cs | 8 +++++++- .../ComputeSharp.SourceGenerators.csproj | 6 +++--- .../IComputeShaderDataLoaderGenerator.cs | 4 ++-- .../IComputeShaderHashCodeGenerator.cs | 4 ++-- 6 files changed, 16 insertions(+), 10 deletions(-) rename src/ComputeSharp.Core/Attributes/{ => __Internals}/IComputeShaderSourceAttribute.cs (97%) rename src/ComputeSharp.Core/Attributes/{ => __Internals}/ShaderMethodSourceAttribute.cs (98%) diff --git a/src/ComputeSharp.Core/Attributes/IComputeShaderSourceAttribute.cs b/src/ComputeSharp.Core/Attributes/__Internals/IComputeShaderSourceAttribute.cs similarity index 97% rename from src/ComputeSharp.Core/Attributes/IComputeShaderSourceAttribute.cs rename to src/ComputeSharp.Core/Attributes/__Internals/IComputeShaderSourceAttribute.cs index fb77a534..163d3d5d 100644 --- a/src/ComputeSharp.Core/Attributes/IComputeShaderSourceAttribute.cs +++ b/src/ComputeSharp.Core/Attributes/__Internals/IComputeShaderSourceAttribute.cs @@ -13,7 +13,7 @@ namespace ComputeSharp.__Internals /// This attribute is not meant to be directly used by applications using ComputeSharp. [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] [EditorBrowsable(EditorBrowsableState.Never)] - [Obsolete("This attribute is meant to be used from the source generator only")] + [Obsolete("This attribute is not intended to be used directly by user code")] public sealed class IComputeShaderSourceAttribute : Attribute { /// diff --git a/src/ComputeSharp.Core/Attributes/ShaderMethodSourceAttribute.cs b/src/ComputeSharp.Core/Attributes/__Internals/ShaderMethodSourceAttribute.cs similarity index 98% rename from src/ComputeSharp.Core/Attributes/ShaderMethodSourceAttribute.cs rename to src/ComputeSharp.Core/Attributes/__Internals/ShaderMethodSourceAttribute.cs index 094c43ab..195ea4d2 100644 --- a/src/ComputeSharp.Core/Attributes/ShaderMethodSourceAttribute.cs +++ b/src/ComputeSharp.Core/Attributes/__Internals/ShaderMethodSourceAttribute.cs @@ -15,7 +15,7 @@ namespace ComputeSharp.__Internals /// This attribute is not meant to be directly used by applications using ComputeSharp. [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] [EditorBrowsable(EditorBrowsableState.Never)] - [Obsolete("This attribute is meant to be used from the source generator only")] + [Obsolete("This attribute is not intended to be used directly by user code")] public sealed class ShaderMethodSourceAttribute : Attribute { /// diff --git a/src/ComputeSharp.Graphics/Helpers/__Internals/GraphicsResourceHelper.cs b/src/ComputeSharp.Graphics/Helpers/__Internals/GraphicsResourceHelper.cs index 9d364b20..cf210dd2 100644 --- a/src/ComputeSharp.Graphics/Helpers/__Internals/GraphicsResourceHelper.cs +++ b/src/ComputeSharp.Graphics/Helpers/__Internals/GraphicsResourceHelper.cs @@ -11,7 +11,7 @@ namespace ComputeSharp.__Internals /// A helper class with some proxy methods to expose to generated code in external projects. /// [EditorBrowsable(EditorBrowsableState.Never)] - [Obsolete("This type is meant to be used from the source generator only")] + [Obsolete("This type is not intended to be used directly by user code")] public static class GraphicsResourceHelper { /// @@ -19,6 +19,8 @@ namespace ComputeSharp.__Internals /// /// The input instance to check. /// The target instance in use. + [EditorBrowsable(EditorBrowsableState.Never)] + [Obsolete("This method is not intended to be called directly by user code")] [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ulong ValidateAndGetGpuDescriptorHandle(Buffer buffer, GraphicsDevice device) where T : unmanaged @@ -34,6 +36,8 @@ namespace ComputeSharp.__Internals /// /// The input instance to check. /// The target instance in use. + [EditorBrowsable(EditorBrowsableState.Never)] + [Obsolete("This method is not intended to be called directly by user code")] [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ulong ValidateAndGetGpuDescriptorHandle(Texture2D buffer, GraphicsDevice device) where T : unmanaged @@ -49,6 +53,8 @@ namespace ComputeSharp.__Internals /// /// The input instance to check. /// The target instance in use. + [EditorBrowsable(EditorBrowsableState.Never)] + [Obsolete("This method is not intended to be called directly by user code")] [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ulong ValidateAndGetGpuDescriptorHandle(Texture3D buffer, GraphicsDevice device) where T : unmanaged diff --git a/src/ComputeSharp.SourceGenerators/ComputeSharp.SourceGenerators.csproj b/src/ComputeSharp.SourceGenerators/ComputeSharp.SourceGenerators.csproj index 566c816a..04f729f7 100644 --- a/src/ComputeSharp.SourceGenerators/ComputeSharp.SourceGenerators.csproj +++ b/src/ComputeSharp.SourceGenerators/ComputeSharp.SourceGenerators.csproj @@ -1,4 +1,4 @@ - + netstandard2.0 @@ -15,9 +15,9 @@ and to match members based on full name, so the types being in the generator assembly are not an issue.--> - - + + diff --git a/src/ComputeSharp.SourceGenerators/IComputeShaderDataLoaderGenerator.cs b/src/ComputeSharp.SourceGenerators/IComputeShaderDataLoaderGenerator.cs index 72af86c8..66bcaf40 100644 --- a/src/ComputeSharp.SourceGenerators/IComputeShaderDataLoaderGenerator.cs +++ b/src/ComputeSharp.SourceGenerators/IComputeShaderDataLoaderGenerator.cs @@ -53,7 +53,7 @@ namespace ComputeSharp.SourceGenerators // internal static partial class DispatchDataLoader // { // [System.ComponentModel.EditorBrowsable(EditorBrowsableState.Never)] - // [System.Obsolete("This method is intended for internal usage only")] + // [System.Obsolete("This method is not intended to be called directly by user code")] // public static int LoadDispatchData(GraphicsDevice device, in ShaderType shader, ref ulong r0, ref byte r1) // { // ... @@ -80,7 +80,7 @@ namespace ComputeSharp.SourceGenerators Attribute(IdentifierName("Obsolete")).AddArgumentListArguments( AttributeArgument(LiteralExpression( SyntaxKind.StringLiteralExpression, - Literal("This method is intended for internal usage only"))))))).AddModifiers( + Literal("This method is not intended to be called directly by user code"))))))).AddModifiers( Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.StaticKeyword)).AddParameterListParameters( Parameter(Identifier("device")).WithType(IdentifierName("ComputeSharp.Graphics.GraphicsDevice")), diff --git a/src/ComputeSharp.SourceGenerators/IComputeShaderHashCodeGenerator.cs b/src/ComputeSharp.SourceGenerators/IComputeShaderHashCodeGenerator.cs index 2632d94f..654e3f7f 100644 --- a/src/ComputeSharp.SourceGenerators/IComputeShaderHashCodeGenerator.cs +++ b/src/ComputeSharp.SourceGenerators/IComputeShaderHashCodeGenerator.cs @@ -53,7 +53,7 @@ namespace ComputeSharp.SourceGenerators // internal static partial class HashCodeProvider // { // [System.ComponentModel.EditorBrowsable(EditorBrowsableState.Never)] - // [System.Obsolete("This method is intended for internal usage only")] + // [System.Obsolete("This method is not intended to be called directly by user code")] // public static int CombineHashCode(int hash, in ShaderType shader) // { // return ...; @@ -79,7 +79,7 @@ namespace ComputeSharp.SourceGenerators Attribute(IdentifierName("Obsolete")).AddArgumentListArguments( AttributeArgument(LiteralExpression( SyntaxKind.StringLiteralExpression, - Literal("This method is intended for internal usage only"))))))).AddModifiers( + Literal("This method is not intended to be called directly by user code"))))))).AddModifiers( Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.StaticKeyword)).AddParameterListParameters( Parameter(Identifier("hash")).WithType(PredefinedType(Token(SyntaxKind.IntKeyword))),