|
7 | 7 |
|
8 | 8 | namespace Wasmtime.Tests
|
9 | 9 | {
|
| 10 | +#if NETFRAMEWORK // the following code is a polyfill as it already exists in .Net |
| 11 | + using System.Runtime.CompilerServices; |
| 12 | + using System.Collections; |
| 13 | + |
| 14 | + sealed class ReferenceEqualityComparer : IEqualityComparer<object?>, IEqualityComparer |
| 15 | + { |
| 16 | + private ReferenceEqualityComparer() { } |
| 17 | + |
| 18 | + /// <summary> |
| 19 | + /// Gets the singleton <see cref="ReferenceEqualityComparer"/> instance. |
| 20 | + /// </summary> |
| 21 | + public static ReferenceEqualityComparer Instance { get; } = new ReferenceEqualityComparer(); |
| 22 | + |
| 23 | + /// <summary> |
| 24 | + /// Determines whether two object references refer to the same object instance. |
| 25 | + /// </summary> |
| 26 | + /// <param name="x">The first object to compare.</param> |
| 27 | + /// <param name="y">The second object to compare.</param> |
| 28 | + /// <returns> |
| 29 | + /// <see langword="true"/> if both <paramref name="x"/> and <paramref name="y"/> refer to the same object instance |
| 30 | + /// or if both are <see langword="null"/>; otherwise, <see langword="false"/>. |
| 31 | + /// </returns> |
| 32 | + /// <remarks> |
| 33 | + /// This API is a wrapper around <see cref="object.ReferenceEquals(object?, object?)"/>. |
| 34 | + /// It is not necessarily equivalent to calling <see cref="object.Equals(object?, object?)"/>. |
| 35 | + /// </remarks> |
| 36 | + public new bool Equals(object? x, object? y) => ReferenceEquals(x, y); |
| 37 | + |
| 38 | + /// <summary> |
| 39 | + /// Returns a hash code for the specified object. The returned hash code is based on the object |
| 40 | + /// identity, not on the contents of the object. |
| 41 | + /// </summary> |
| 42 | + /// <param name="obj">The object for which to retrieve the hash code.</param> |
| 43 | + /// <returns>A hash code for the identity of <paramref name="obj"/>.</returns> |
| 44 | + /// <remarks> |
| 45 | + /// This API is a wrapper around <see cref="RuntimeHelpers.GetHashCode(object)"/>. |
| 46 | + /// It is not necessarily equivalent to calling <see cref="object.GetHashCode()"/>. |
| 47 | + /// </remarks> |
| 48 | + public int GetHashCode(object? obj) |
| 49 | + { |
| 50 | + // Depending on target framework, RuntimeHelpers.GetHashCode might not be annotated |
| 51 | + // with the proper nullability attribute. We'll suppress any warning that might |
| 52 | + // result. |
| 53 | + return RuntimeHelpers.GetHashCode(obj!); |
| 54 | + } |
| 55 | + } |
| 56 | +#endif |
| 57 | + |
10 | 58 | public class WasiTests
|
11 | 59 | {
|
12 | 60 | [Theory]
|
@@ -70,7 +118,7 @@ public void ItHasSpecifiedEnvironment(string path)
|
70 | 118 |
|
71 | 119 | for (int i = 0; i < env.Count; ++i)
|
72 | 120 | {
|
73 |
| - var kvp = memory.ReadNullTerminatedString(memory.ReadInt32(i * 4)).Split("="); |
| 121 | + var kvp = memory.ReadNullTerminatedString(memory.ReadInt32(i * 4)).Split('='); |
74 | 122 | Assert.Equal(env[kvp[0]], kvp[1]);
|
75 | 123 | }
|
76 | 124 | }
|
|
0 commit comments