|
| 1 | +# API Review 04/08/2025 |
| 2 | + |
| 3 | +## Raise the `AppDomain.UnhandledException` event for exceptions outside the runtime. |
| 4 | + |
| 5 | +**Approved** | [#runtime/102730](https://github.com/dotnet/runtime/issues/102730#issuecomment-2787199046) | [Video](https://www.youtube.com/watch?v=mwzPjJocAXc&t=0h0m0s) |
| 6 | + |
| 7 | +* Changed the argument type to `object` to match UnhandledExceptionEventArgs.ExceptionObject |
| 8 | + * Changing it to UnhandledExceptionEventArgs was discussed, but dismissed. |
| 9 | +* We inserted "AppDomain", yielding `RaiseAppDomainUnhandledExceptionEvent`, to clearly distinguish between AppDomain.UnhandledException and ExceptionHandling's UnhandledExceptionHandler. |
| 10 | + |
| 11 | +```C# |
| 12 | +namespace System.Runtime.ExceptionServices; |
| 13 | + |
| 14 | +public static partial class ExceptionHandling |
| 15 | +{ |
| 16 | + public static void RaiseAppDomainUnhandledExceptionEvent(object exception); |
| 17 | +} |
| 18 | +``` |
| 19 | +## HybridCache: span-based fetch |
| 20 | + |
| 21 | +**Approved** | [#runtime/112866](https://github.com/dotnet/runtime/issues/112866#issuecomment-2787257651) | [Video](https://www.youtube.com/watch?v=mwzPjJocAXc&t=0h31m40s) |
| 22 | + |
| 23 | + |
| 24 | +* We made the protected span overload public |
| 25 | + * And added the sibling method to match string. |
| 26 | +* Added a note that the new APIs are .NET 10+, even though the class is .NET Standard 2.0 |
| 27 | + |
| 28 | +```C# |
| 29 | +namespace Microsoft.Extensions.Caching.Hybrid; |
| 30 | + |
| 31 | +public abstract partial class HybridCache |
| 32 | +{ |
| 33 | +#if NET_10_OR_GREATER |
| 34 | + public ValueTask<T> GetOrCreateAsync<T>( |
| 35 | + ReadOnlySpan<char> key, |
| 36 | + Func<CancellationToken, ValueTask<T>> factory, |
| 37 | + HybridCacheEntryOptions? options = null, |
| 38 | + IEnumerable<string!>? tags = null, |
| 39 | + CancellationToken cancellationToken = default); |
| 40 | + |
| 41 | + public virtual ValueTask<T> GetOrCreateAsync<TState, T>( |
| 42 | + ReadOnlySpan<char> key, |
| 43 | + TState state, |
| 44 | + Func<TState, CancellationToken, ValueTask<T>> factory, |
| 45 | + HybridCacheEntryOptions? options = null, |
| 46 | + IEnumerable<string>? tags = null, |
| 47 | + CancellationToken cancellationToken = default) |
| 48 | + { |
| 49 | + return GetOrCreateAsync(key.ToString(), state, factory, options, tags, cancellationToken); |
| 50 | + } |
| 51 | + |
| 52 | + public ValueTask<T> GetOrCreateAsync<T>( |
| 53 | + ref DefaultInterpolatedStringHandler key, |
| 54 | + Func<CancellationToken, ValueTask<T>> factory, |
| 55 | + HybridCacheEntryOptions? options = null, |
| 56 | + IEnumerable<string>? tags = null, |
| 57 | + CancellationToken cancellationToken = default); |
| 58 | + |
| 59 | + public ValueTask<T> GetOrCreateAsync<TState, T>( |
| 60 | + ref DefaultInterpolatedStringHandler key, |
| 61 | + TState state, |
| 62 | + Func<TState, CancellationToken, ValueTask<T>> factory, |
| 63 | + HybridCacheEntryOptions? options = null, |
| 64 | + IEnumerable<string>? tags = null, |
| 65 | + CancellationToken cancellationToken = default); |
| 66 | +#endif |
| 67 | +} |
| 68 | +``` |
| 69 | +## Add AVX-VNNI-INT8 and AVX-VNNI-INT16 API |
| 70 | + |
| 71 | +**Approved** | [#runtime/112586](https://github.com/dotnet/runtime/issues/112586#issuecomment-2787271818) | [Video](https://www.youtube.com/watch?v=mwzPjJocAXc&t=0h54m5s) |
| 72 | + |
| 73 | +* Looks good as proposed |
| 74 | + |
| 75 | +```C# |
| 76 | +namespace System.Runtime.Intrinsics.X86 |
| 77 | +{ |
| 78 | + [Intrinsic] |
| 79 | + [CLSCompliant(false)] |
| 80 | + public abstract class AvxVnniInt8 : Avx2 |
| 81 | + { |
| 82 | + internal AvxVnniInt8() { } |
| 83 | + |
| 84 | + public static new bool IsSupported { get => IsSupported; } |
| 85 | + |
| 86 | + [Intrinsic] |
| 87 | + public new abstract class X64 : Avx2.X64 |
| 88 | + { |
| 89 | + internal X64() { } |
| 90 | + |
| 91 | + public static new bool IsSupported { get => IsSupported; } |
| 92 | + } |
| 93 | + |
| 94 | + // VPDPBSSD xmm1, xmm2, xmm3/m128 |
| 95 | + public static Vector128<int> MultiplyWideningAndAdd(Vector128<int> addend, Vector128<sbyte> left, Vector128<sbyte> right) => MultiplyWideningAndAdd(addend, left, right); |
| 96 | + |
| 97 | + // VPDPBSUD xmm1, xmm2, xmm3/m128 |
| 98 | + public static Vector128<int> MultiplyWideningAndAdd(Vector128<int> addend, Vector128<sbyte> left, Vector128<byte> right) => MultiplyWideningAndAdd(addend, left, right); |
| 99 | + |
| 100 | + // VPDPBUUD xmm1, xmm2, xmm3/m128 |
| 101 | + public static Vector128<uint> MultiplyWideningAndAdd(Vector128<uint> addend, Vector128<byte> left, Vector128<byte> right) => MultiplyWideningAndAdd(addend, left, right); |
| 102 | + |
| 103 | + // VPDPBSSD ymm1, ymm2, ymm3/m256 |
| 104 | + public static Vector256<int> MultiplyWideningAndAdd(Vector256<int> addend, Vector256<sbyte> left, Vector256<sbyte> right) => MultiplyWideningAndAdd(addend, left, right); |
| 105 | + |
| 106 | + // VPDPBSUD ymm1, ymm2, ymm3/m256 |
| 107 | + public static Vector256<int> MultiplyWideningAndAdd(Vector256<int> addend, Vector256<sbyte> left, Vector256<byte> right) => MultiplyWideningAndAdd(addend, left, right); |
| 108 | + |
| 109 | + // VPDPBUUD ymm1, ymm2, ymm3/m256 |
| 110 | + public static Vector256<uint> MultiplyWideningAndAdd(Vector256<uint> addend, Vector256<byte> left, Vector256<byte> right) => MultiplyWideningAndAdd(addend, left, right); |
| 111 | + |
| 112 | + // VPDPBSSDS xmm1, xmm2, xmm3/m128 |
| 113 | + public static Vector128<int> MultiplyWideningAndAddSaturate(Vector128<int> addend, Vector128<sbyte> left, Vector128<sbyte> right) => MultiplyWideningAndAddSaturate(addend, left, right); |
| 114 | + |
| 115 | + // VPDPBSUDS xmm1, xmm2, xmm3/m128 |
| 116 | + public static Vector128<int> MultiplyWideningAndAddSaturate(Vector128<int> addend, Vector128<sbyte> left, Vector128<byte> right) => MultiplyWideningAndAddSaturate(addend, left, right); |
| 117 | + |
| 118 | + // VPDPBUUDS xmm1, xmm2, xmm3/m128 |
| 119 | + public static Vector128<uint> MultiplyWideningAndAddSaturate(Vector128<uint> addend, Vector128<byte> left, Vector128<byte> right) => MultiplyWideningAndAddSaturate(addend, left, right); |
| 120 | + |
| 121 | + // VPDPBSSDS ymm1, ymm2, ymm3/m256 |
| 122 | + public static Vector256<int> MultiplyWideningAndAddSaturate(Vector256<int> addend, Vector256<sbyte> left, Vector256<sbyte> right) => MultiplyWideningAndAddSaturate(addend, left, right); |
| 123 | + |
| 124 | + // VPDPBSUDS ymm1, ymm2, ymm3/m256 |
| 125 | + public static Vector256<int> MultiplyWideningAndAddSaturate(Vector256<int> addend, Vector256<sbyte> left, Vector256<byte> right) => MultiplyWideningAndAddSaturate(addend, left, right); |
| 126 | + |
| 127 | + // VPDPBUUDS ymm1, ymm2, ymm3/m256 |
| 128 | + public static Vector256<uint> MultiplyWideningAndAddSaturate(Vector256<uint> addend, Vector256<byte> left, Vector256<byte> right) => MultiplyWideningAndAddSaturate(addend, left, right); |
| 129 | + |
| 130 | + [Intrinsic] |
| 131 | + public abstract class V512 |
| 132 | + { |
| 133 | + internal V512() { } |
| 134 | + |
| 135 | + public static bool IsSupported { get => IsSupported; } |
| 136 | + |
| 137 | + // VPDPBSSD zmm1{k1}{z}, zmm2, zmm3/m512/m32bcst |
| 138 | + public static Vector512<int> MultiplyWideningAndAdd(Vector512<int> addend, Vector512<sbyte> left, Vector512<sbyte> right) => MultiplyWideningAndAdd(addend, left, right); |
| 139 | + |
| 140 | + // VPDPBSUD zmm1{k1}{z}, zmm2, zmm3/m512/m32bcst |
| 141 | + public static Vector512<int> MultiplyWideningAndAdd(Vector512<int> addend, Vector512<sbyte> left, Vector512<byte> right) => MultiplyWideningAndAdd(addend, left, right); |
| 142 | + |
| 143 | + // VPDPBUUD zmm1{k1}{z}, zmm2, zmm3/m512/m32bcst |
| 144 | + public static Vector512<uint> MultiplyWideningAndAdd(Vector512<uint> addend, Vector512<byte> left, Vector512<byte> right) => MultiplyWideningAndAdd(addend, left, right); |
| 145 | + |
| 146 | + // VPDPBSSDS zmm1{k1}{z}, zmm2, zmm3/m512/m32bcst |
| 147 | + public static Vector512<int> MultiplyWideningAndAddSaturate(Vector512<int> addend, Vector512<sbyte> left, Vector512<sbyte> right) => MultiplyWideningAndAddSaturate(addend, left, right); |
| 148 | + |
| 149 | + // VPDPBSUDS zmm1{k1}{z}, zmm2, zmm3/m512/m32bcst |
| 150 | + public static Vector512<int> MultiplyWideningAndAddSaturate(Vector512<int> addend, Vector512<sbyte> left, Vector512<byte> right) => MultiplyWideningAndAddSaturate(addend, left, right); |
| 151 | + |
| 152 | + // VPDPBUUDS zmm1{k1}{z}, zmm2, zmm3/m512/m32bcst |
| 153 | + public static Vector512<uint> MultiplyWideningAndAddSaturate(Vector512<uint> addend, Vector512<byte> left, Vector512<byte> right) => MultiplyWideningAndAddSaturate(addend, left, right); |
| 154 | + } |
| 155 | + } |
| 156 | + |
| 157 | + [Intrinsic] |
| 158 | + [CLSCompliant(false)] |
| 159 | + public abstract class AvxVnniInt16 : Avx2 |
| 160 | + { |
| 161 | + internal AvxVnniInt16() { } |
| 162 | + |
| 163 | + public static new bool IsSupported { get => IsSupported; } |
| 164 | + |
| 165 | + /// <summary>Provides access to the x86 AVX-VNNI-INT8 hardware instructions, that are only available to 64-bit processes, via intrinsics.</summary> |
| 166 | + [Intrinsic] |
| 167 | + public new abstract class X64 : Avx2.X64 |
| 168 | + { |
| 169 | + internal X64() { } |
| 170 | + |
| 171 | + public static new bool IsSupported { get => IsSupported; } |
| 172 | + } |
| 173 | + |
| 174 | + // VPDPWSUD xmm1, xmm2, xmm3/m128 |
| 175 | + public static Vector128<int> MultiplyWideningAndAdd(Vector128<int> addend, Vector128<short> left, Vector128<ushort> right) => MultiplyWideningAndAdd(addend, left, right); |
| 176 | + |
| 177 | + // VPDPWUSD xmm1, xmm2, xmm3/m128 |
| 178 | + public static Vector128<int> MultiplyWideningAndAdd(Vector128<int> addend, Vector128<ushort> left, Vector128<short> right) => MultiplyWideningAndAdd(addend, left, right); |
| 179 | + |
| 180 | + // VPDPWUUD xmm1, xmm2, xmm3/m128 |
| 181 | + public static Vector128<uint> MultiplyWideningAndAdd(Vector128<uint> addend, Vector128<ushort> left, Vector128<ushort> right) => MultiplyWideningAndAdd(addend, left, right); |
| 182 | + |
| 183 | + // VPDPWSUD ymm1, ymm2, ymm3/m256 |
| 184 | + public static Vector256<int> MultiplyWideningAndAdd(Vector256<int> addend, Vector256<short> left, Vector256<ushort> right) => MultiplyWideningAndAdd(addend, left, right); |
| 185 | + |
| 186 | + // VPDPWUSD ymm1, ymm2, ymm3/m256 |
| 187 | + public static Vector256<int> MultiplyWideningAndAdd(Vector256<int> addend, Vector256<ushort> left, Vector256<short> right) => MultiplyWideningAndAdd(addend, left, right); |
| 188 | + |
| 189 | + // VPDPWUUD ymm1, ymm2, ymm3/m256 |
| 190 | + public static Vector256<uint> MultiplyWideningAndAdd(Vector256<uint> addend, Vector256<ushort> left, Vector256<ushort> right) => MultiplyWideningAndAdd(addend, left, right); |
| 191 | + |
| 192 | + // VPDPWSUDS xmm1, xmm2, xmm3/m128 |
| 193 | + public static Vector128<int> MultiplyWideningAndAddSaturate(Vector128<int> addend, Vector128<short> left, Vector128<ushort> right) => MultiplyWideningAndAddSaturate(addend, left, right); |
| 194 | + |
| 195 | + // VPDPWUSDS xmm1, xmm2, xmm3/m128 |
| 196 | + public static Vector128<int> MultiplyWideningAndAddSaturate(Vector128<int> addend, Vector128<ushort> left, Vector128<short> right) => MultiplyWideningAndAddSaturate(addend, left, right); |
| 197 | + |
| 198 | + // VPDPWUUDS xmm1, xmm2, xmm3/m128 |
| 199 | + public static Vector128<uint> MultiplyWideningAndAddSaturate(Vector128<uint> addend, Vector128<ushort> left, Vector128<ushort> right) => MultiplyWideningAndAddSaturate(addend, left, right); |
| 200 | + |
| 201 | + // VPDPWSUDS ymm1, ymm2, ymm3/m256 |
| 202 | + public static Vector256<int> MultiplyWideningAndAddSaturate(Vector256<int> addend, Vector256<short> left, Vector256<ushort> right) => MultiplyWideningAndAddSaturate(addend, left, right); |
| 203 | + |
| 204 | + // VPDPWUSDS ymm1, ymm2, ymm3/m256 |
| 205 | + public static Vector256<int> MultiplyWideningAndAddSaturate(Vector256<int> addend, Vector256<ushort> left, Vector256<short> right) => MultiplyWideningAndAddSaturate(addend, left, right); |
| 206 | + |
| 207 | + // VPDPWUUDS ymm1, ymm2, ymm3/m256 |
| 208 | + public static Vector256<uint> MultiplyWideningAndAddSaturate(Vector256<uint> addend, Vector256<ushort> left, Vector256<ushort> right) => MultiplyWideningAndAddSaturate(addend, left, right); |
| 209 | + |
| 210 | + /// <summary>Provides access to the x86 AVX10.2/512 hardware instructions for AVX-VNNI-INT16 via intrinsics.</summary> |
| 211 | + [Intrinsic] |
| 212 | + public abstract class V512 |
| 213 | + { |
| 214 | + internal V512() { } |
| 215 | + |
| 216 | + public static bool IsSupported { get => IsSupported; } |
| 217 | + |
| 218 | + // VPDPWSUD zmm1{k1}{z}, zmm2, zmm3/m512/m32bcst |
| 219 | + public static Vector512<int> MultiplyWideningAndAdd(Vector512<int> addend, Vector512<short> left, Vector512<ushort> right) => MultiplyWideningAndAdd(addend, left, right); |
| 220 | + |
| 221 | + // VPDPWUSD zmm1{k1}{z}, zmm2, zmm3/m512/m32bcst |
| 222 | + public static Vector512<int> MultiplyWideningAndAdd(Vector512<int> addend, Vector512<ushort> left, Vector512<short> right) => MultiplyWideningAndAdd(addend, left, right); |
| 223 | + |
| 224 | + // VPDPWUUD zmm1{k1}{z}, zmm2, zmm3/m512/m32bcst |
| 225 | + public static Vector512<uint> MultiplyWideningAndAdd(Vector512<uint> addend, Vector512<ushort> left, Vector512<ushort> right) => MultiplyWideningAndAdd(addend, left, right); |
| 226 | + |
| 227 | + // VPDPWSUDS zmm1{k1}{z}, zmm2, zmm3/m512/m32bcst |
| 228 | + public static Vector512<int> MultiplyWideningAndAddSaturate(Vector512<int> addend, Vector512<short> left, Vector512<ushort> right) => MultiplyWideningAndAddSaturate(addend, left, right); |
| 229 | + |
| 230 | + // VPDPWUSDS zmm1{k1}{z}, zmm2, zmm3/m512/m32bcst |
| 231 | + public static Vector512<int> MultiplyWideningAndAddSaturate(Vector512<int> addend, Vector512<ushort> left, Vector512<short> right) => MultiplyWideningAndAddSaturate(addend, left, right); |
| 232 | + |
| 233 | + // VPDPWUUDS zmm1{k1}{z}, zmm2, zmm3/m512/m32bcst |
| 234 | + public static Vector512<uint> MultiplyWideningAndAddSaturate(Vector512<uint> addend, Vector512<ushort> left, Vector512<ushort> right) => MultiplyWideningAndAddSaturate(addend, left, right); |
| 235 | + } |
| 236 | + } |
| 237 | +} |
| 238 | +``` |
| 239 | +## ClaimsIdentity to perform case-sensitive comparison |
| 240 | + |
| 241 | +**Approved** | [#runtime/113562](https://github.com/dotnet/runtime/issues/113562#issuecomment-2787339679) | [Video](https://www.youtube.com/watch?v=mwzPjJocAXc&t=1h1m39s) |
| 242 | + |
| 243 | +* Instead of constructor overload explosions, we added a default-argument constructor to enable the new parameter. |
| 244 | +* The new ctor parameter should not be exposed as a property (until there's a compelling reason) to avoid confusion where a derived type exists solely to add ordinal semantics but the property defaults to OrdinalIgnoreCase. |
| 245 | +* The ctors should throw for the culture-sensitive options, at least until they are well understood in context. |
| 246 | + |
| 247 | +```C# |
| 248 | +namespace System.Security.Claims |
| 249 | +{ |
| 250 | + public partial class ClaimsIdentity |
| 251 | + { |
| 252 | + public ClaimsIdentity( |
| 253 | + IIdentity? identity = null, |
| 254 | + IEnumerable<Claim>? claims = null, |
| 255 | + string? authenticationType = null, |
| 256 | + string? nameType = null, |
| 257 | + string? roleType = null, |
| 258 | + StringComparison stringComparison = StringComparison.OrdinalIgnoreCase); |
| 259 | + } |
| 260 | +} |
| 261 | +``` |
| 262 | +## change 'Unsafe.AsPointer' parameter to be 'ref readonly' |
| 263 | + |
| 264 | +**Approved** | [#runtime/114189](https://github.com/dotnet/runtime/issues/114189#issuecomment-2787351311) | [Video](https://www.youtube.com/watch?v=mwzPjJocAXc&t=1h25m2s) |
| 265 | + |
| 266 | +* Looks good as proposed |
| 267 | + |
| 268 | +```diff |
| 269 | +namespace System.Runtime.CompilerServices |
| 270 | +{ |
| 271 | + public static class Unsafe |
| 272 | + { |
| 273 | +- public static void* AsPointer<T>(ref T value); |
| 274 | ++ public static void* AsPointer<T>(ref readonly T value); |
| 275 | + } |
| 276 | +} |
| 277 | +``` |
| 278 | +## Add APIs to WebSocket which allow it to be read as a Stream |
| 279 | + |
| 280 | +**Approved** | [#runtime/111217](https://github.com/dotnet/runtime/issues/111217#issuecomment-2787433647) | [Video](https://www.youtube.com/watch?v=mwzPjJocAXc&t=1h30m31s) |
| 281 | + |
| 282 | +* Changed the constructor to a triad of factory methods. |
| 283 | + * That both enables the multiple-frame-single-message scenario and should give the caller pause as to which mode they want. |
| 284 | + |
| 285 | +```C# |
| 286 | +namespace System.Net.WebSockets; |
| 287 | + |
| 288 | +public class WebSocketStream : Stream |
| 289 | +{ |
| 290 | + internal WebSocketStream(); |
| 291 | + |
| 292 | + public WebSocket WebSocket { get; } |
| 293 | + |
| 294 | + public static WebSocketStream Create(WebSocket webSocket, bool ownsWebSocket = false); |
| 295 | + public static WebSocketStream CreateWritableMessageStream(WebSocket webSocket); |
| 296 | + public static WebSocketStream CreateReadableMessageStream(WebSocket webSocket); |
| 297 | + |
| 298 | + ... // relevant Stream overrides |
| 299 | +} |
| 300 | +``` |
0 commit comments