Merge pull request #702 from Sergio0694/dev/keep-instance-identifiers

Keep original identifiers for instance methods
このコミットが含まれているのは:
Sergio Pedri authored and GitHub committed 2023-12-04 22:42:58 +01:00
コミット 2a2b5b08c5
12ファイル変更
+18 -28

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

+1 -1
ファイルの表示
@@ -74,7 +74,7 @@ public class BlasBenchmark : IDisposable
private ReadWriteBuffer<float>? bufferY;
/// <summary>
/// A <see cref="System.Random"/> instance to initialize the tensors.
/// A <see cref="Random"/> instance to initialize the tensors.
/// </summary>
private readonly Random random = new();
@@ -17,7 +17,7 @@ public sealed partial class HlslGaussianBlurProcessor
internal sealed partial class Implementation : ImageProcessor<ImageSharpRgba32>
{
/// <summary>
/// The <see cref="ComputeSharp.GraphicsDevice"/> instance in use.
/// The <see cref="GraphicsDevice"/> instance in use.
/// </summary>
private readonly GraphicsDevice graphicsDevice;
+1 -1
ファイルの表示
@@ -61,7 +61,7 @@ public sealed partial class HlslGaussianBlurProcessor : IImageProcessor
}
/// <summary>
/// The <see cref="ComputeSharp.GraphicsDevice"/> instance in use.
/// The <see cref="GraphicsDevice"/> instance in use.
/// </summary>
private readonly GraphicsDevice graphicsDevice;
+2 -2
ファイルの表示
@@ -75,7 +75,7 @@ internal unsafe struct ICanvasFactoryNative
/// was not previously registered, or <see cref="S.S_FALSE"/> if <paramref name="resource"/> was already registered.
/// </returns>
/// <remarks>
/// The method validates at runtime that <paramref name="resource"/> is an <see cref="ComputeSharp.Win32.ID2D1Image"/>
/// The method validates at runtime that <paramref name="resource"/> is an <see cref="ID2D1Image"/>
/// and that <paramref name="wrapper"/> is an <see cref="global::Microsoft.Graphics.Canvas.ICanvasImage"/>. Additionally,
/// <paramref name="wrapper"/> has to implement <c>IWeakReferenceSource</c> for this method to be successful.
/// </remarks>
@@ -98,7 +98,7 @@ internal unsafe struct ICanvasFactoryNative
/// resource was previously registered and could be correctly unregistered, <see cref="S.S_FALSE"/> otherwise.
/// </returns>
/// <remarks>
/// The method validates at runtime that <paramref name="resource"/> is an <see cref="ComputeSharp.Win32.ID2D1Image"/>.
/// The method validates at runtime that <paramref name="resource"/> is an <see cref="ID2D1Image"/>.
/// </remarks>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[VtblIndex(8)]
+1 -1
ファイルの表示
@@ -56,7 +56,7 @@ internal unsafe struct ICanvasImageInterop : IComObject
}
/// <summary>
/// Gets an <see cref="ID2D1Image"/> from an <see cref="ICanvasImageInterop.Interface"/> instance.
/// Gets an <see cref="ID2D1Image"/> from an <see cref="Interface"/> instance.
/// </summary>
/// <param name="device">The input canvas device (as a marshalled <see cref="global::Microsoft.Graphics.Canvas.CanvasDevice"/>).</param>
/// <param name="deviceContext">
+1 -1
ファイルの表示
@@ -22,7 +22,7 @@ internal static unsafe class ResourceManager
/// <summary>
/// Gets or creates an <see cref="IGraphicsEffectSource"/> instance for a native resource.
/// </summary>
/// <param name="device">The input canvas device (as a marshalled <see cref="Microsoft.Graphics.Canvas.CanvasDevice"/>).</param>
/// <param name="device">The input canvas device (as a marshalled <see cref="CanvasDevice"/>).</param>
/// <param name="resource">The input native resource to create a wrapper for.</param>
/// <param name="dpi">The realization DPIs for <paramref name="resource"/></param>
/// <returns>The resulting <see cref="IGraphicsEffectSource"/> wrapper instance.</returns>
+4 -14
ファイルの表示
@@ -78,7 +78,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter
/// <param name="constructors">The collection of discovered constructors for custom struct types.</param>
/// <param name="constantDefinitions">The collection of discovered constant definitions.</param>
/// <param name="diagnostics">The collection of produced <see cref="DiagnosticInfo"/> instances.</param>
/// <param name="token">The <see cref="System.Threading.CancellationToken"/> value for the current operation.</param>
/// <param name="token">The <see cref="CancellationToken"/> value for the current operation.</param>
/// <param name="isEntryPoint">Whether or not the current instance is processing a shader entry point.</param>
public ShaderSourceRewriter(
INamedTypeSymbol shaderType,
@@ -112,7 +112,7 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter
/// <param name="constructors">The collection of discovered constructors for custom struct types.</param>
/// <param name="constantDefinitions">The collection of discovered constant definitions.</param>
/// <param name="diagnostics">The collection of produced <see cref="DiagnosticInfo"/> instances.</param>
/// <param name="token">The <see cref="System.Threading.CancellationToken"/> value for the current operation.</param>
/// <param name="token">The <see cref="CancellationToken"/> value for the current operation.</param>
private ShaderSourceRewriter(
SemanticModelProvider semanticModel,
ICollection<INamedTypeSymbol> discoveredTypes,
@@ -581,8 +581,6 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter
{
DiscoveredTypes.Add(structTypeSymbol);
string methodIdentifier = method.GetFullyQualifiedMetadataName().ToHlslIdentifierName();
// Same as for static methods, ensure the method is available in source, and process it if so
if (!this.instanceMethods.ContainsKey(method))
{
@@ -605,18 +603,10 @@ internal sealed partial class ShaderSourceRewriter : HlslSourceRewriter
MethodDeclarationSyntax processedMethod = shaderSourceRewriter.Visit(methodNode)!.WithoutTrivia();
this.instanceMethods.Add(method, processedMethod.WithIdentifier(Identifier(methodIdentifier)));
this.instanceMethods.Add(method, processedMethod);
}
// Rewrite the expression depending on its type:
// - If it's a simple member expression, change the identifier name: eg. foo.Bar(...) => foo.NewName(...)
// - If it's an identifier name, change it directly: eg. Bar(...) => NewName(...)
return updatedNode.Expression switch
{
MemberAccessExpressionSyntax memberAccess => updatedNode.WithExpression(memberAccess.WithName(IdentifierName(methodIdentifier))),
IdentifierNameSyntax identifierName => updatedNode.WithExpression(IdentifierName(methodIdentifier)),
_ => throw new NotSupportedException($"Unsupported instance method expression type \"{updatedNode.Expression.GetType()}\".")
};
return updatedNode;
}
}
}
+1 -1
ファイルの表示
@@ -24,7 +24,7 @@ namespace ComputeSharp.SourceGeneration.SyntaxRewriters;
/// <param name="discoveredTypes">The set of discovered custom types.</param>
/// <param name="constantDefinitions">The collection of discovered constant definitions.</param>
/// <param name="diagnostics">The collection of produced <see cref="DiagnosticInfo"/> instances.</param>
/// <param name="token">The <see cref="System.Threading.CancellationToken"/> value for the current operation.</param>
/// <param name="token">The <see cref="CancellationToken"/> value for the current operation.</param>
internal sealed partial class StaticFieldRewriter(
SemanticModelProvider semanticModel,
ICollection<INamedTypeSymbol> discoveredTypes,
+1 -1
ファイルの表示
@@ -116,7 +116,7 @@ public static partial class GraphicsDeviceExtensions
/// }
/// </code>
/// <para>All dispatched shaders will be executed as soon as the context goes out of scope.</para>
/// <para>Asynchronous execution is also supported, through the <see cref="System.IAsyncDisposable"/> interface:</para>
/// <para>Asynchronous execution is also supported, through the <see cref="IAsyncDisposable"/> interface:</para>
/// <code>
/// await using (var context = device.CreateComputeContext())
/// {
+2 -2
ファイルの表示
@@ -18,7 +18,7 @@ internal static class DXGIFormatHelper
/// </summary>
/// <typeparam name="T">The input type argument to get the corresponding <see cref="DXGI_FORMAT"/> for.</typeparam>
/// <returns>The <see cref="DXGI_FORMAT"/> value corresponding to <typeparamref name="T"/>.</returns>
/// <exception cref="System.ArgumentException">Thrown when the input type <typeparamref name="T"/> is not supported.</exception>
/// <exception cref="ArgumentException">Thrown when the input type <typeparamref name="T"/> is not supported.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static DXGI_FORMAT GetForType<T>()
where T : unmanaged
@@ -54,7 +54,7 @@ internal static class DXGIFormatHelper
/// </summary>
/// <typeparam name="T">The input type argument to check.</typeparam>
/// <returns>Whether or not the input type corresponds to a normalized format.</returns>
/// <exception cref="System.ArgumentException">Thrown when the input type <typeparamref name="T"/> is not supported.</exception>
/// <exception cref="ArgumentException">Thrown when the input type <typeparamref name="T"/> is not supported.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsNormalizedType<T>()
where T : unmanaged
+1 -1
ファイルの表示
@@ -14,7 +14,7 @@ internal static class ResourceStateHelper
/// Gets the corresponding <see cref="D3D12_RESOURCE_STATES"/> value for the input resource state.
/// </summary>
/// <returns>The <see cref="D3D12_RESOURCE_STATES"/> value corresponding to the input resource state.</returns>
/// <exception cref="System.ArgumentException">Thrown when the input value is not valid.</exception>
/// <exception cref="ArgumentException">Thrown when the input value is not valid.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static D3D12_RESOURCE_STATES GetD3D12ResourceStates(ResourceState resourceState)
{
+2 -2
ファイルの表示
@@ -340,8 +340,8 @@ public static class GraphicsDeviceExtensions
{
return type switch
{
_ when type == typeof(ReadOnlyTexture3D<>) => device.AllocateReadOnlyTexture3D<T>(data),
_ when type == typeof(ReadWriteTexture3D<>) => device.AllocateReadWriteTexture3D<T>(data),
_ when type == typeof(ReadOnlyTexture3D<>) => device.AllocateReadOnlyTexture3D(data),
_ when type == typeof(ReadWriteTexture3D<>) => device.AllocateReadWriteTexture3D(data),
_ => throw new ArgumentException($"Invalid type: {type}", nameof(type))
};
}