Move MethodInfoExtensions to ComputeSharp.Dynamic

このコミットが含まれているのは:
Sergio Pedri committed 2023-02-25 01:28:52 +01:00
1 親 940f90df9b
コミット fc0a3d2746
4ファイル変更
+11 -39

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

+39
ファイルの表示
@@ -0,0 +1,39 @@
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
namespace ComputeSharp.Extensions;
/// <summary>
/// A <see langword="class"/> that provides extension methods for the <see cref="MethodInfo"/> type.
/// </summary>
internal static class MethodInfoExtensions
{
/// <summary>
/// Gets a fully qualified name for the input method, including parameters.
/// </summary>
/// <param name="method">The input <see cref="MethodInfo"/> instance.</param>
/// <returns>A fully qualified name for <paramref name="method"/>, including parameters.</returns>
public static string GetFullyQualifiedName(this MethodInfo method)
{
string parameters = string.Join(", ", method.GetParameters().Select(static p => p.ParameterType.FullName));
// Fixup the method name for static local functions in global statements. This only needs to
// be done when the method is in a type with fully qualified name "Program", as that's the only
// case where it might happen. If the declaring type has a name, it can't be that for sure.
(string declaringType, string methodName) = (method.DeclaringType!.FullName!, method.Name) switch
{
("Program", var name) => ("Program", Regex.Replace(name, @"<<Main>\$>g__(\w+)\|\d+_\d+", static m => m.Groups[1].Value)),
(var type, var name) => (type, name)
};
if (method.IsGenericMethod)
{
string arguments = string.Join(", ", method.GetGenericArguments().Select(static t => t.FullName));
return $"{declaringType}.{methodName}<{arguments}>({parameters})";
}
return $"{declaringType}.{methodName}({parameters})";
}
}
+1 -1
ファイルの表示
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using ComputeSharp.Core.Extensions;
using ComputeSharp.Extensions;
#pragma warning disable IDE0052
+8 -36
ファイルの表示
@@ -25,26 +25,14 @@
just copy the right native libraries to the output directory, with no subfolders. -->
<When Condition="'$(Platform)' == 'x64' OR '$(CI_RUNNER_DOTNET_TEST_PLATFORM)' == 'x64'">
<ItemGroup>
<None Include="Libraries\x64\dxcompiler.dll"
Link="dxcompiler.dll"
Visible="False"
CopyToOutputDirectory="PreserveNewest" />
<None Include="Libraries\x64\dxil.dll"
Link="dxil.dll"
Visible="False"
CopyToOutputDirectory="PreserveNewest" />
<None Include="Libraries\x64\dxcompiler.dll" Link="dxcompiler.dll" Visible="False" CopyToOutputDirectory="PreserveNewest" />
<None Include="Libraries\x64\dxil.dll" Link="dxil.dll" Visible="False" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
</When>
<When Condition="'$(Platform)' == 'ARM64' OR '$(CI_RUNNER_DOTNET_TEST_PLATFORM)' == 'x64'">
<ItemGroup>
<None Include="Libraries\arm64\dxcompiler.dll"
Link="dxcompiler.dll"
Visible="False"
CopyToOutputDirectory="PreserveNewest" />
<None Include="Libraries\arm64\dxil.dll"
Link="dxil.dll"
Visible="False"
CopyToOutputDirectory="PreserveNewest" />
<None Include="Libraries\arm64\dxcompiler.dll" Link="dxcompiler.dll" Visible="False" CopyToOutputDirectory="PreserveNewest" />
<None Include="Libraries\arm64\dxil.dll" Link="dxil.dll" Visible="False" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
</When>
@@ -57,26 +45,10 @@
while still not causing any change in the final NuGet package (Link isn't looked up there). -->
<Otherwise>
<ItemGroup>
<None Include="Libraries\x64\dxcompiler.dll"
Link="runtimes\win-x64\native\dxcompiler.dll"
Visible="False"
CopyToOutputDirectory="PreserveNewest"
PackFolder="runtimes\win-x64\native" />
<None Include="Libraries\x64\dxil.dll"
Link="runtimes\win-x64\native\dxil.dll"
Visible="False"
CopyToOutputDirectory="PreserveNewest"
PackFolder="runtimes\win-x64\native" />
<None Include="Libraries\arm64\dxcompiler.dll"
Link="runtimes\win-arm64\native\dxcompiler.dll"
Visible="False"
CopyToOutputDirectory="PreserveNewest"
PackFolder="runtimes\win-arm64\native" />
<None Include="Libraries\arm64\dxil.dll"
Link="runtimes\win-arm64\native\dxil.dll"
Visible="False"
CopyToOutputDirectory="PreserveNewest"
PackFolder="runtimes\win-arm64\native" />
<None Include="Libraries\x64\dxcompiler.dll" Link="runtimes\win-x64\native\dxcompiler.dll" Visible="False" CopyToOutputDirectory="PreserveNewest" PackFolder="runtimes\win-x64\native" />
<None Include="Libraries\x64\dxil.dll" Link="runtimes\win-x64\native\dxil.dll" Visible="False" CopyToOutputDirectory="PreserveNewest" PackFolder="runtimes\win-x64\native" />
<None Include="Libraries\arm64\dxcompiler.dll" Link="runtimes\win-arm64\native\dxcompiler.dll" Visible="False" CopyToOutputDirectory="PreserveNewest" PackFolder="runtimes\win-arm64\native" />
<None Include="Libraries\arm64\dxil.dll" Link="runtimes\win-arm64\native\dxil.dll" Visible="False" CopyToOutputDirectory="PreserveNewest" PackFolder="runtimes\win-arm64\native" />
</ItemGroup>
</Otherwise>
</Choose>