Skip to content

Commit 3c1482c

Browse files
committed
Fix member name being same as type name, @tonisimakov99 review comment
1 parent b377db8 commit 3c1482c

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

src/Core/Silk.NET.BuildTools/Baking/ProfileBakery.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public static Profile Bake(string name, IReadOnlyList<Profile> impl, in BindTask
6363
CheckForDuplicates(profile);
6464
TypeMapper.MapEnums(profile); // we need to map the enums to make sure they are correct for their extension.
6565
EnumPostProcessor.Process(profile, task);
66+
StructPostProcessor.Process(profile, task);
6667
Console.WriteLine($"Created profile \"{name}\".");
6768
return profile;
6869
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.Linq;
5+
using Silk.NET.BuildTools.Common;
6+
7+
namespace Silk.NET.BuildTools.Baking;
8+
9+
public static class StructPostProcessor
10+
{
11+
public static void Process(Profile profile, BindTask task)
12+
{
13+
foreach (var proj in profile.Projects.Values)
14+
{
15+
foreach (var @struct in proj.Structs)
16+
{
17+
foreach (var field in @struct.Fields)
18+
{
19+
if (field.Name == @struct.Name)
20+
{
21+
// Risky to do at this stage (e.g. what if a struct has a function that references it) but sue
22+
// me, we'll fix it in 3.0.
23+
field.Name = @struct.Fields.Any(x => x.Name == "Value") ? $"M{field.Name}" : "Value";
24+
}
25+
}
26+
}
27+
}
28+
}
29+
}

src/Core/Silk.NET.BuildTools/Converters/Readers/VulkanReader.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,13 @@ IReadOnlyList<Struct> GetAllAliasesFromName(string? api, string structName)
346346

347347
var handleFuns = new List<ImplementedFunction>
348348
{
349-
new(toString, new StringBuilder("return Handle.ToString();"), toString, false)
349+
new
350+
(
351+
toString,
352+
new StringBuilder("return sizeof(nint) == 8 ? $\"0x{Handle:x16}\" : $\"0x{Handle:x8}\";"),
353+
toString,
354+
false
355+
)
350356
};
351357

352358
foreach (var h in spec.Handles)

0 commit comments

Comments
 (0)