Skip to content

Commit f23a991

Browse files
committed
Multicast service resolver data
1 parent e9c62a2 commit f23a991

File tree

4 files changed

+70
-1
lines changed

4 files changed

+70
-1
lines changed

WPILib.sln

+15
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "datalog.test", "test\datalo
5353
EndProject
5454
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "hal.test", "test\hal.test\hal.test.csproj", "{88C326DC-0E40-40B9-86B5-95157FF37D95}"
5555
EndProject
56+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wpinet.test", "test\wpinet.test\wpinet.test.csproj", "{3ACBB266-7A74-47EE-B1F2-115EA0FF64E3}"
57+
EndProject
5658
Global
5759
GlobalSection(SolutionConfigurationPlatforms) = preSolution
5860
Debug|Any CPU = Debug|Any CPU
@@ -315,6 +317,18 @@ Global
315317
{88C326DC-0E40-40B9-86B5-95157FF37D95}.Release|x64.Build.0 = Release|Any CPU
316318
{88C326DC-0E40-40B9-86B5-95157FF37D95}.Release|x86.ActiveCfg = Release|Any CPU
317319
{88C326DC-0E40-40B9-86B5-95157FF37D95}.Release|x86.Build.0 = Release|Any CPU
320+
{3ACBB266-7A74-47EE-B1F2-115EA0FF64E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
321+
{3ACBB266-7A74-47EE-B1F2-115EA0FF64E3}.Debug|Any CPU.Build.0 = Debug|Any CPU
322+
{3ACBB266-7A74-47EE-B1F2-115EA0FF64E3}.Debug|x64.ActiveCfg = Debug|Any CPU
323+
{3ACBB266-7A74-47EE-B1F2-115EA0FF64E3}.Debug|x64.Build.0 = Debug|Any CPU
324+
{3ACBB266-7A74-47EE-B1F2-115EA0FF64E3}.Debug|x86.ActiveCfg = Debug|Any CPU
325+
{3ACBB266-7A74-47EE-B1F2-115EA0FF64E3}.Debug|x86.Build.0 = Debug|Any CPU
326+
{3ACBB266-7A74-47EE-B1F2-115EA0FF64E3}.Release|Any CPU.ActiveCfg = Release|Any CPU
327+
{3ACBB266-7A74-47EE-B1F2-115EA0FF64E3}.Release|Any CPU.Build.0 = Release|Any CPU
328+
{3ACBB266-7A74-47EE-B1F2-115EA0FF64E3}.Release|x64.ActiveCfg = Release|Any CPU
329+
{3ACBB266-7A74-47EE-B1F2-115EA0FF64E3}.Release|x64.Build.0 = Release|Any CPU
330+
{3ACBB266-7A74-47EE-B1F2-115EA0FF64E3}.Release|x86.ActiveCfg = Release|Any CPU
331+
{3ACBB266-7A74-47EE-B1F2-115EA0FF64E3}.Release|x86.Build.0 = Release|Any CPU
318332
EndGlobalSection
319333
GlobalSection(SolutionProperties) = preSolution
320334
HideSolutionNode = FALSE
@@ -340,5 +354,6 @@ Global
340354
{92BE0A00-437A-43BF-9793-2995FDB3DC23} = {DB664556-4BF0-4874-8CB6-DC24E60A67AF}
341355
{49B1AC50-4FD0-4524-85BA-FC26AD1EEBBA} = {AD95ECD8-E708-4FB4-9B7E-A8A8EF3FCB3E}
342356
{88C326DC-0E40-40B9-86B5-95157FF37D95} = {AD95ECD8-E708-4FB4-9B7E-A8A8EF3FCB3E}
357+
{3ACBB266-7A74-47EE-B1F2-115EA0FF64E3} = {AD95ECD8-E708-4FB4-9B7E-A8A8EF3FCB3E}
343358
EndGlobalSection
344359
EndGlobal

src/wpinet/Natives/MulticastServiceResolver.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static partial class MulticastServiceResolver
4949
[return: MarshalUsing(typeof(ManagedFreeArrayMarshaller<,>), CountElementName = nameof(dataCount))]
5050
public static unsafe partial ServiceData[] GetMulticastServiceResolverData(MulticastServiceResolverHandle handle, out int dataCount);
5151

52-
[LibraryImport("wpinet", EntryPoint = "WPI_FreeMulticastServiceResolverData")]
52+
[LibraryImport("wpinet", EntryPoint = "WPI_FreeServiceData")]
5353
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
5454
public static unsafe partial void FreeMulticastServiceResolverData(ServiceDataRaw* serviceData, int dataCount);
5555
}

test/wpinet.test/SymbolVerifier.cs

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System.Reflection;
2+
using System.Runtime.InteropServices;
3+
using Xunit;
4+
5+
namespace WPINet.Test;
6+
7+
public class SymbolVerifier
8+
{
9+
[Fact]
10+
public void VerifySymbols()
11+
{
12+
Assembly assemblyType = typeof(ServiceData).Assembly;
13+
// Find all native methods
14+
var foundMethods =
15+
assemblyType.GetTypes()
16+
.SelectMany(x => x.GetMethods(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public))
17+
.Where(x => x.Attributes.HasFlag(MethodAttributes.PinvokeImpl))
18+
.Select(x => (x, x.GetCustomAttribute<DllImportAttribute>()))
19+
.Where(x => x.Item2 != null)
20+
.Select(x => (Method: x.x, Dll: x.Item2!.Value, EntryPoint: x.Item2.EntryPoint ?? x.x.Name));
21+
22+
Dictionary<string, nint> libraries = [];
23+
foreach (var method in foundMethods)
24+
{
25+
if (!libraries.ContainsKey(method.Dll))
26+
{
27+
libraries[method.Dll] = NativeLibrary.Load(method.Dll, assemblyType, DllImportSearchPath.UseDllDirectoryForDependencies);
28+
}
29+
30+
var library = libraries[method.Dll];
31+
Assert.True(NativeLibrary.TryGetExport(library, method.EntryPoint, out _),
32+
$"Failed to find symbol {method.EntryPoint} in {method.Dll}");
33+
}
34+
}
35+
}

test/wpinet.test/wpinet.test.csproj

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<ItemGroup>
4+
<ProjectReference Include="..\..\src\wpinet\wpinet.csproj" />
5+
</ItemGroup>
6+
7+
<ItemGroup>
8+
<PackageReference Update="coverlet.collector" Version="6.0.2">
9+
<PrivateAssets>all</PrivateAssets>
10+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
11+
</PackageReference>
12+
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="17.11.1" />
13+
<PackageReference Update="xunit.runner.visualstudio" Version="2.8.2">
14+
<PrivateAssets>all</PrivateAssets>
15+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
16+
</PackageReference>
17+
</ItemGroup>
18+
19+
</Project>

0 commit comments

Comments
 (0)