Switched generated methods to explicit interface implementations

このコミットが含まれているのは:
Sergio Pedri committed 2021-07-21 14:09:22 +02:00
1 親 56b326a6e4
コミット bbb42e5367
6ファイル変更
+37 -34

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

+3 -2
ファイルの表示
@@ -79,7 +79,7 @@ namespace ComputeSharp.SourceGenerators
// This code produces a method declaration as follows:
//
// public readonly void BuildHlslString(ref ArrayPoolStringBuilder builder, int threadsX, int threadsY, int threadsZ)
// readonly void IShader.BuildHlslString(ref ArrayPoolStringBuilder builder, int threadsX, int threadsY, int threadsZ)
// {
// <BODY>
// }
@@ -87,7 +87,8 @@ namespace ComputeSharp.SourceGenerators
MethodDeclaration(
PredefinedType(Token(SyntaxKind.VoidKeyword)),
Identifier("BuildHlslString"))
.AddModifiers(Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.ReadOnlyKeyword))
.WithExplicitInterfaceSpecifier(ExplicitInterfaceSpecifier(IdentifierName(nameof(IShader))))
.AddModifiers(Token(SyntaxKind.ReadOnlyKeyword))
.AddParameterListParameters(
Parameter(Identifier("builder")).AddModifiers(Token(SyntaxKind.OutKeyword)).WithType(IdentifierName("ArrayPoolStringBuilder")),
Parameter(Identifier("threadsX")).WithType(PredefinedType(Token(SyntaxKind.IntKeyword))),
+6 -2
ファイルの表示
@@ -2,11 +2,14 @@
using System.Collections.Immutable;
using System.Diagnostics.Contracts;
using System.Linq;
using ComputeSharp.__Internals;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
#pragma warning disable CS0618
namespace ComputeSharp.SourceGenerators
{
/// <inheritdoc/>
@@ -17,7 +20,7 @@ namespace ComputeSharp.SourceGenerators
{
// This code produces a method declaration as follows:
//
// public readonly int GetDispatchId()
// readonly int IShader.GetDispatchId()
// {
// <BODY>
// }
@@ -25,7 +28,8 @@ namespace ComputeSharp.SourceGenerators
MethodDeclaration(
PredefinedType(Token(SyntaxKind.IntKeyword)),
Identifier("GetDispatchId"))
.AddModifiers(Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.ReadOnlyKeyword))
.WithExplicitInterfaceSpecifier(ExplicitInterfaceSpecifier(IdentifierName(nameof(IShader))))
.AddModifiers(Token(SyntaxKind.ReadOnlyKeyword))
.WithBody(GetShaderHashCodeBody(structDeclarationSymbol));
}
+6 -8
ファイルの表示
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using ComputeSharp.__Internals;
using ComputeSharp.Core.Helpers;
using ComputeSharp.SourceGenerators.Diagnostics;
using ComputeSharp.SourceGenerators.Extensions;
@@ -11,6 +12,8 @@ using Microsoft.CodeAnalysis.CSharp.Syntax;
using static ComputeSharp.SourceGenerators.Diagnostics.DiagnosticDescriptors;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
#pragma warning disable CS0618
namespace ComputeSharp.SourceGenerators
{
/// <inheritdoc/>
@@ -25,8 +28,7 @@ namespace ComputeSharp.SourceGenerators
{
// This code produces a method declaration as follows:
//
// public readonly void LoadDispatchData<TDataLoader>(ref TDataLoader loader, GraphicsDevice device, int x, int y, int z)
// where TDataLoader : struct, IDispatchDataLoader
// readonly void IShader.LoadDispatchData<TDataLoader>(ref TDataLoader loader, GraphicsDevice device, int x, int y, int z)
// {
// <BODY>
// }
@@ -34,7 +36,8 @@ namespace ComputeSharp.SourceGenerators
MethodDeclaration(
PredefinedType(Token(SyntaxKind.VoidKeyword)),
Identifier("LoadDispatchData"))
.AddModifiers(Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.ReadOnlyKeyword))
.WithExplicitInterfaceSpecifier(ExplicitInterfaceSpecifier(IdentifierName(nameof(IShader))))
.AddModifiers(Token(SyntaxKind.ReadOnlyKeyword))
.AddTypeParameterListParameters(TypeParameter(Identifier("TDataLoader")))
.AddParameterListParameters(
Parameter(Identifier("loader"))
@@ -44,11 +47,6 @@ namespace ComputeSharp.SourceGenerators
Parameter(Identifier("x")).WithType(PredefinedType(Token(SyntaxKind.IntKeyword))),
Parameter(Identifier("y")).WithType(PredefinedType(Token(SyntaxKind.IntKeyword))),
Parameter(Identifier("z")).WithType(PredefinedType(Token(SyntaxKind.IntKeyword))))
.AddConstraintClauses(
TypeParameterConstraintClause(IdentifierName("TDataLoader"))
.AddConstraints(
ClassOrStructConstraint(SyntaxKind.StructConstraint),
TypeConstraint(IdentifierName("IDispatchDataLoader"))))
.WithBody(Block(GetDispatchDataLoadingStatements(context, structDeclarationSymbol, out discoveredResources, out root32BitConstantsCount)));
}
+6 -8
ファイルの表示
@@ -1,10 +1,13 @@
using System;
using System.Collections.Generic;
using ComputeSharp.__Internals;
using ComputeSharp.SourceGenerators.Mappings;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
#pragma warning disable CS0618
namespace ComputeSharp.SourceGenerators
{
/// <inheritdoc/>
@@ -19,8 +22,7 @@ namespace ComputeSharp.SourceGenerators
{
// This code produces a method declaration as follows:
//
// public readonly void LoadDispatchMetadata<TMetadataLoader>(ref TMetadataLoader loader, out IntPtr result)
// where TMetadataLoader : struct, IDispatchMetadataLoader
// readonly void IShader.LoadDispatchMetadata<TMetadataLoader>(ref TMetadataLoader loader, out IntPtr result)
// {
// <BODY>
// }
@@ -28,7 +30,8 @@ namespace ComputeSharp.SourceGenerators
MethodDeclaration(
PredefinedType(Token(SyntaxKind.VoidKeyword)),
Identifier("LoadDispatchMetadata"))
.AddModifiers(Token(SyntaxKind.PublicKeyword), Token(SyntaxKind.ReadOnlyKeyword))
.WithExplicitInterfaceSpecifier(ExplicitInterfaceSpecifier(IdentifierName(nameof(IShader))))
.AddModifiers(Token(SyntaxKind.ReadOnlyKeyword))
.AddTypeParameterListParameters(TypeParameter(Identifier("TMetadataLoader")))
.AddParameterListParameters(
Parameter(Identifier("loader"))
@@ -37,11 +40,6 @@ namespace ComputeSharp.SourceGenerators
Parameter(Identifier("result"))
.AddModifiers(Token(SyntaxKind.OutKeyword))
.WithType(IdentifierName(typeof(IntPtr).Name)))
.AddConstraintClauses(
TypeParameterConstraintClause(IdentifierName("TMetadataLoader"))
.AddConstraints(
ClassOrStructConstraint(SyntaxKind.StructConstraint),
TypeConstraint(IdentifierName("IDispatchMetadataLoader"))))
.WithBody(Block(GetDispatchMetadataLoadingStatements(implicitTextureType, discoveredResources, root32BitConstantsCount, isSamplerUsed)));
}