Skip to content

Commit ed097fb

Browse files
committed
Merge branch 'feature/misc-improv-3.0' into feature/windowing-3.0
2 parents df88e68 + 74ddf75 commit ed097fb

31 files changed

+26240
-9846
lines changed

.config/dotnet-tools.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"isRoot": true,
44
"tools": {
55
"csharpier": {
6-
"version": "0.28.2",
6+
"version": "0.29.2",
77
"commands": [
88
"dotnet-csharpier"
99
]
1010
}
1111
}
12-
}
12+
}

Directory.Build.targets

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
<!-- Package versions for package references across all projects -->
1919
<ItemGroup>
20-
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="17.10.0" />
21-
<PackageReference Update="NUnit" Version="4.1.0" />
22-
<PackageReference Update="NUnit3TestAdapter" Version="4.5.0" />
20+
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="17.11.1" />
21+
<PackageReference Update="NUnit" Version="4.2.2" />
22+
<PackageReference Update="NUnit3TestAdapter" Version="4.6.0" />
2323
</ItemGroup>
2424

2525
</Project>

eng/benchmarks/Silk.NET.Maths.Benchmarks/Silk.NET.Maths.Benchmarks.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="BenchmarkDotNet" Version="0.13.12" />
10+
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
1111
</ItemGroup>
1212

1313
<ItemGroup>

generator.json

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"ExtractNestedTyping",
4444
"TransformHandles",
4545
"TransformFunctions",
46+
"TransformProperties",
4647
"PrettifyNames",
4748
"AddVTables"
4849
],
@@ -71,6 +72,7 @@
7172
"AddIncludes",
7273
"ClangScraper",
7374
"AddApiProfiles",
75+
"BakeSourceSets",
7476
"MixKhronosData",
7577
"AddOpaqueStructs",
7678
"TransformFunctions",
@@ -88,29 +90,33 @@
8890
"Profiles": [
8991
{
9092
"Profile": "gl",
91-
"SourceSubdirectory": "glcompat",
92-
"BakedOutputSubdirectory": "gl"
93+
"SourceSubdirectory": "glcompat"
9394
},
9495
{
9596
"Profile": "glcore",
9697
"SourceSubdirectory": "glcore",
97-
"BakedOutputSubdirectory": "gl",
9898
"MinVersion": "3.2"
9999
},
100100
{
101101
"Profile": "gles1",
102102
"SourceSubdirectory": "gles1",
103-
"BakedOutputSubdirectory": "gl",
104103
"MaxVersion": "2.0"
105104
},
106105
{
107106
"Profile": "gles2",
108107
"SourceSubdirectory": "gles2",
109-
"BakedOutputSubdirectory": "gl",
110108
"MinVersion": "2.0"
111109
}
112110
]
113111
},
112+
"BakeSourceSets": {
113+
"SourceSets": {
114+
"glcompat": "gl",
115+
"glcore": "gl",
116+
"gles1": "gl",
117+
"gles2": "gl"
118+
}
119+
},
114120
"AddOpaqueStructs": {
115121
"Names": [
116122
"GLsync"
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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.Runtime.InteropServices;
5+
6+
namespace Silk.NET.Core;
7+
8+
/// <summary>
9+
/// Represents a target type for UTF-8 string literals.
10+
/// </summary>
11+
/// <param name="bytes">The UTF-8 bytes.</param>
12+
public readonly ref struct Utf8String(ReadOnlySpan<byte> bytes)
13+
{
14+
/// <summary>
15+
/// Gets the UTF-8 byte representation of this string.
16+
/// </summary>
17+
public ReadOnlySpan<byte> Bytes { get; } = bytes;
18+
19+
/// <summary>
20+
/// Converts this string to a <see cref="Ref{T}"/>.
21+
/// </summary>
22+
/// <param name="str">The string.</param>
23+
/// <returns>The ref.</returns>
24+
public static implicit operator Ref<byte>(Utf8String str) => str.Bytes;
25+
26+
/// <summary>
27+
/// Converts this string to a <see cref="Ref{T}"/>.
28+
/// </summary>
29+
/// <param name="str">The string.</param>
30+
/// <returns>The ref.</returns>
31+
public static implicit operator Ref<sbyte>(Utf8String str) => (ReadOnlySpan<sbyte>)str;
32+
33+
/// <summary>
34+
/// Converts this string to a <see cref="ReadOnlySpan{T}"/>.
35+
/// </summary>
36+
/// <param name="str">The string.</param>
37+
/// <returns>The span.</returns>
38+
public static implicit operator ReadOnlySpan<byte>(Utf8String str) => str.Bytes;
39+
40+
/// <summary>
41+
/// Converts this string to a <see cref="Ref{T}"/>.
42+
/// </summary>
43+
/// <param name="str">The string.</param>
44+
/// <returns>The span.</returns>
45+
public static implicit operator ReadOnlySpan<sbyte>(Utf8String str) =>
46+
MemoryMarshal.Cast<byte, sbyte>(str);
47+
48+
// TODO add ptr casts once we have an analyzer for e.g. [KnownImmovable]
49+
50+
/// <summary>
51+
/// Converts this string to a <see cref="Ref"/>.
52+
/// </summary>
53+
/// <param name="str">The string.</param>
54+
/// <returns>The ref.</returns>
55+
public static implicit operator Ref(Utf8String str) => (Ref<byte>)str.Bytes;
56+
57+
/// <summary>
58+
/// Converts this string to a <see cref="string"/>.
59+
/// </summary>
60+
/// <param name="str">The string.</param>
61+
/// <returns>The string.</returns>
62+
public static implicit operator string(Utf8String str) => str.ToString();
63+
64+
/// <summary>
65+
/// Converts the given UTF-8 bytes to a <see cref="Utf8String"/>.
66+
/// </summary>
67+
/// <param name="bytes">The bytes.</param>
68+
/// <returns>The string.</returns>
69+
public static implicit operator Utf8String(ReadOnlySpan<byte> bytes) => new(bytes);
70+
71+
/// <summary>
72+
/// Converts the given UTF-8 bytes to a <see cref="Utf8String"/>.
73+
/// </summary>
74+
/// <param name="bytes">The bytes.</param>
75+
/// <returns>The string.</returns>
76+
public static implicit operator Utf8String(ReadOnlySpan<sbyte> bytes) =>
77+
MemoryMarshal.Cast<sbyte, byte>(bytes);
78+
79+
/// <inheritdoc />
80+
public override string ToString() => (string)(Ref<byte>)this;
81+
}

sources/Core/Core/Pointers/Ref.generic.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,18 +132,18 @@ public ref T this[nuint index]
132132
public static bool operator !=(NullPtr lh, Ref<T> rh) => (Ref<T>)lh != rh;
133133

134134
/// <summary>
135-
/// Creates a <see cref="Ref{T}"/> from a span
135+
/// Creates a <see cref="Ref{T}"/> from a span.
136136
/// </summary>
137-
/// <param name="span"></param>
137+
/// <param name="span">The span to create the ref from.</param>
138138
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
139139
public static implicit operator Ref<T>(Span<T> span) => new(ref span.GetPinnableReference());
140140

141141
/// <summary>
142-
/// Creates a <see cref="Ref{T}"/> from a span
142+
/// Creates a <see cref="Ref{T}"/> from a readonly span.
143143
/// </summary>
144-
/// <param name="span"></param>
145-
// TODO annotate requires readonly dest - const correctness etc
144+
/// <param name="span">The span to create the ref from.</param>
146145
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
146+
// TODO annotate requires readonly dest - const correctness etc
147147
public static implicit operator Ref<T>(ReadOnlySpan<T> span) =>
148148
new(ref Unsafe.AsRef(in span.GetPinnableReference()));
149149

sources/Core/Core/Silk.NET.Core.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
</ItemGroup>
1515

1616
<ItemGroup>
17-
<PackageReference Include="Fody" Version="6.8.1" PrivateAssets="all" />
18-
<PackageReference Include="InlineIL.Fody" Version="1.8.0" PrivateAssets="all" />
17+
<PackageReference Include="Fody" Version="6.8.2" PrivateAssets="all" />
18+
<PackageReference Include="InlineIL.Fody" Version="1.9.0" PrivateAssets="all" />
1919
</ItemGroup>
2020

2121
<!-- Dogfooding -->

0 commit comments

Comments
 (0)