<!--
TODO: Remove pinned version once arcade supplies a compiler that enables the repo to compile.
-->
- <MicrosoftNetCompilersToolsetVersion>4.4.0-3.22452.8</MicrosoftNetCompilersToolsetVersion>
+ <MicrosoftNetCompilersToolsetVersion>4.4.0-3.22479.16</MicrosoftNetCompilersToolsetVersion>
<StaticCsVersion>0.2.0</StaticCsVersion>
<!-- SDK dependencies -->
<MicrosoftDotNetApiCompatTaskVersion>8.0.100-alpha.1.22462.3</MicrosoftDotNetApiCompatTaskVersion>
Span<ParameterCopyBackAction> shouldCopyBackParameters = new(ref argStorage._copyBack0, argCount);
StackAllocatedByRefs byrefStorage = default;
+#pragma warning disable CS8500
IntPtr* pByRefStorage = (IntPtr*)&byrefStorage;
+#pragma warning restore CS8500
CheckArguments(
copyOfParameters,
Span<ParameterCopyBackAction> shouldCopyBackParameters = new(ref argStorage._copyBack0, 1);
StackAllocatedByRefs byrefStorage = default;
+#pragma warning disable 8500
IntPtr* pByRefStorage = (IntPtr*)&byrefStorage;
+#pragma warning restore 8500
CheckArguments(
copyOfParameters,
StackAllocedArguments argStorage = default;
StackAllocatedByRefs byrefStorage = default;
+#pragma warning disable 8500
CheckArguments(ref argStorage._arg0!, (ByReference*)&byrefStorage, parameters, binderBundle);
+#pragma warning restore 8500
try
{
+#pragma warning disable 8500
ret = ref RawCalliHelper.Call(InvokeThunk, (void*)methodToCall, ref thisArg, ref ret, &byrefStorage);
+#pragma warning restore 8500
DebugAnnotations.PreviousCallContainsDebuggerStepInCode();
}
catch (Exception e) when (wrapInTargetInvocationException)
IntPtr* pStorage = stackalloc IntPtr[2 * argCount];
NativeMemory.Clear(pStorage, (nuint)(2 * argCount) * (nuint)sizeof(IntPtr));
- ByReference* pByRefStorage = (ByReference*)(pStorage + argCount);
+#pragma warning disable 8500
+ void* pByRefStorage = (ByReference*)(pStorage + argCount);
+#pragma warning restore 8500
RuntimeImports.GCFrameRegistration regArgStorage = new(pStorage, (uint)argCount, areByRefs: false);
RuntimeImports.GCFrameRegistration regByRefStorage = new(pByRefStorage, (uint)argCount, areByRefs: true);
private unsafe void CheckArguments(
ref object copyOfParameters,
- ByReference* byrefParameters,
+ void* byrefParameters,
object?[] parameters,
BinderBundle binderBundle)
{
Unsafe.Add(ref copyOfParameters, i) = arg!;
- byrefParameters[i] = new ByReference(ref (argumentInfo.Transform & Transform.Reference) != 0 ?
+#pragma warning disable 8500, 9094
+ ((ByReference*)byrefParameters)[i] = new ByReference(ref (argumentInfo.Transform & Transform.Reference) != 0 ?
ref Unsafe.As<object, byte>(ref Unsafe.Add(ref copyOfParameters, i)) : ref arg.GetRawData());
+#pragma warning restore 8500, 9094
}
}
<TargetFramework>netstandard2.0</TargetFramework>
<!-- Don't add references to the netstandard platform since this is a core assembly -->
<DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
+ <Features>noRefSafetyRulesAttribute=true</Features>
</PropertyGroup>
<ItemGroup>
<Platforms>x86;x64</Platforms>
<PlatformTarget>AnyCPU</PlatformTarget>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <Features>noRefSafetyRulesAttribute=true</Features>
</PropertyGroup>
<ItemGroup>
private int _length;
private fixed uint _blocks[MaxBlockCount];
- public static void Add(ref BigInteger lhs, ref BigInteger rhs, out BigInteger result)
+ public static void Add(scoped ref BigInteger lhs, scoped ref BigInteger rhs, out BigInteger result)
{
// determine which operand has the smaller length
ref BigInteger large = ref (lhs._length < rhs._length) ? ref rhs : ref lhs;
}
}
- public static int Compare(ref BigInteger lhs, ref BigInteger rhs)
+ public static int Compare(scoped ref BigInteger lhs, scoped ref BigInteger rhs)
{
Debug.Assert(unchecked((uint)(lhs._length)) <= MaxBlockCount);
Debug.Assert(unchecked((uint)(rhs._length)) <= MaxBlockCount);
return (lastIndex * BitsPerBlock) + CountSignificantBits(value._blocks[lastIndex]);
}
- public static void DivRem(ref BigInteger lhs, ref BigInteger rhs, out BigInteger quo, out BigInteger rem)
+ public static void DivRem(scoped ref BigInteger lhs, scoped ref BigInteger rhs, out BigInteger quo, out BigInteger rem)
{
// This is modified from the libraries BigIntegerCalculator.DivRem.cs implementation:
// https://github.com/dotnet/runtime/blob/main/src/libraries/System.Runtime.Numerics/src/System/Numerics/BigIntegerCalculator.DivRem.cs
if (digit > 0)
{
+ // rem and rhs have different lifetimes here and compiler is warning
+ // about potential for one to copy into the other. This is a place
+ // ref scoped parameters would alleviate.
+ // https://github.com/dotnet/roslyn/issues/64393
+#pragma warning disable CS9080
// Now it's time to subtract our current quotient
uint carry = SubtractDivisor(ref rem, n, ref rhs, digit);
Debug.Assert(carry == 1);
}
+#pragma warning restore CS9080
}
// We have the digit!
return quotient;
}
- public static void Multiply(ref BigInteger lhs, uint value, out BigInteger result)
+ public static void Multiply(scoped ref BigInteger lhs, uint value, out BigInteger result)
{
if (lhs._length <= 1)
{
}
}
- public static void Multiply(ref BigInteger lhs, ref BigInteger rhs, out BigInteger result)
+ public static void Multiply(scoped ref BigInteger lhs, scoped ref BigInteger rhs, out BigInteger result)
{
if (lhs._length <= 1)
{
Multiply(ref this, value, out this);
}
- public void Multiply(ref BigInteger value)
+ public void Multiply(scoped ref BigInteger value)
{
if (value._length <= 1)
{
}
}
- public static void SetValue(out BigInteger result, ref BigInteger value)
+ public static void SetValue(out BigInteger result, scoped ref BigInteger value)
{
int rhsLength = value._length;
result._length = rhsLength;
0x8e679c2f5e44ff8f, 0x570f09eaa7ea7648
};
- private static void AccumulateDecimalDigitsIntoBigInteger(ref NumberBuffer number, uint firstIndex, uint lastIndex, out BigInteger result)
+ private static void AccumulateDecimalDigitsIntoBigInteger(scoped ref NumberBuffer number, uint firstIndex, uint lastIndex, out BigInteger result)
{
BigInteger.SetZero(out result);
shouldCopyBack[i] = copyBackArg;
copyOfParameters[i] = arg;
+#pragma warning disable 8500
if (isValueType)
{
#if !MONO // Temporary until Mono is updated.
ByReference objRef = ByReference.Create(ref copyOfParameters[i]);
*(ByReference*)(byrefParameters + i) = objRef;
}
+#pragma warning restore 8500
}
}
Span<ParameterCopyBackAction> shouldCopyBackParameters = new(ref argStorage._copyBack0, argCount);
StackAllocatedByRefs byrefStorage = default;
+#pragma warning disable 8500
IntPtr* pByRefStorage = (IntPtr*)&byrefStorage;
+#pragma warning restore 8500
CheckArguments(
copyOfParameters,
Span<ParameterCopyBackAction> shouldCopyBackParameters = new(ref argStorage._copyBack0, argCount);
StackAllocatedByRefs byrefStorage = default;
+#pragma warning disable 8500
IntPtr* pByRefStorage = (IntPtr*)&byrefStorage;
+#pragma warning restore 8500
CheckArguments(
copyOfParameters,
Span<ParameterCopyBackAction> shouldCopyBackParameters = new(ref argStorage._copyBack0, argCount);
StackAllocatedByRefs byrefStorage = default;
+#pragma warning disable 8500
IntPtr* pByRefStorage = (IntPtr*)&byrefStorage;
+#pragma warning restore 8500
CheckArguments(
copyOfParameters,
/// Returns the span for the given reader.
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public static ReadOnlySpan<byte> GetSpan(this ref Utf8JsonReader reader)
+ public static ReadOnlySpan<byte> GetSpan(this scoped ref Utf8JsonReader reader)
{
return reader.HasValueSequence ? reader.ValueSequence.ToArray() : reader.ValueSpan;
}
Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= propertyName.Length);
char[]? propertyArray = null;
+ scoped Span<char> escapedPropertyName;
if (firstEscapeIndexProp != -1)
{
int length = JsonWriterHelper.GetMaxEscapedLength(propertyName.Length, firstEscapeIndexProp);
- scoped Span<char> escapedPropertyName;
if (length > JsonConstants.StackallocCharThreshold)
{
propertyArray = ArrayPool<char>.Shared.Rent(length);
Debug.Assert(int.MaxValue / JsonConstants.MaxExpansionFactorWhileEscaping >= utf8PropertyName.Length);
byte[]? propertyArray = null;
+ scoped Span<byte> escapedPropertyName;
if (firstEscapeIndexProp != -1)
{
int length = JsonWriterHelper.GetMaxEscapedLength(utf8PropertyName.Length, firstEscapeIndexProp);
- scoped Span<byte> escapedPropertyName;
if (length > JsonConstants.StackallocByteThreshold)
{
propertyArray = ArrayPool<byte>.Shared.Rent(length);
char[]? valueArray = null;
char[]? propertyArray = null;
+ scoped Span<char> escapedValue;
if (firstEscapeIndexVal != -1)
{
int length = JsonWriterHelper.GetMaxEscapedLength(value.Length, firstEscapeIndexVal);
- scoped Span<char> escapedValue;
if (length > JsonConstants.StackallocCharThreshold)
{
valueArray = ArrayPool<char>.Shared.Rent(length);
value = escapedValue.Slice(0, written);
}
+ scoped Span<char> escapedPropertyName;
+
if (firstEscapeIndexProp != -1)
{
int length = JsonWriterHelper.GetMaxEscapedLength(propertyName.Length, firstEscapeIndexProp);
- scoped Span<char> escapedPropertyName;
if (length > JsonConstants.StackallocCharThreshold)
{
propertyArray = ArrayPool<char>.Shared.Rent(length);
byte[]? valueArray = null;
byte[]? propertyArray = null;
+ scoped Span<byte> escapedValue;
if (firstEscapeIndexVal != -1)
{
int length = JsonWriterHelper.GetMaxEscapedLength(utf8Value.Length, firstEscapeIndexVal);
- scoped Span<byte> escapedValue;
if (length > JsonConstants.StackallocByteThreshold)
{
valueArray = ArrayPool<byte>.Shared.Rent(length);
utf8Value = escapedValue.Slice(0, written);
}
+ scoped Span<byte> escapedPropertyName;
+
if (firstEscapeIndexProp != -1)
{
int length = JsonWriterHelper.GetMaxEscapedLength(utf8PropertyName.Length, firstEscapeIndexProp);
- scoped Span<byte> escapedPropertyName;
if (length > JsonConstants.StackallocByteThreshold)
{
propertyArray = ArrayPool<byte>.Shared.Rent(length);
byte[]? valueArray = null;
char[]? propertyArray = null;
+ scoped Span<byte> escapedValue;
if (firstEscapeIndexVal != -1)
{
int length = JsonWriterHelper.GetMaxEscapedLength(utf8Value.Length, firstEscapeIndexVal);
- scoped Span<byte> escapedValue;
if (length > JsonConstants.StackallocByteThreshold)
{
valueArray = ArrayPool<byte>.Shared.Rent(length);
utf8Value = escapedValue.Slice(0, written);
}
+ scoped Span<char> escapedPropertyName;
+
if (firstEscapeIndexProp != -1)
{
int length = JsonWriterHelper.GetMaxEscapedLength(propertyName.Length, firstEscapeIndexProp);
- scoped Span<char> escapedPropertyName;
if (length > JsonConstants.StackallocCharThreshold)
{
propertyArray = ArrayPool<char>.Shared.Rent(length);
char[]? valueArray = null;
byte[]? propertyArray = null;
+ scoped Span<char> escapedValue;
if (firstEscapeIndexVal != -1)
{
int length = JsonWriterHelper.GetMaxEscapedLength(value.Length, firstEscapeIndexVal);
- scoped Span<char> escapedValue;
if (length > JsonConstants.StackallocCharThreshold)
{
valueArray = ArrayPool<char>.Shared.Rent(length);
value = escapedValue.Slice(0, written);
}
+ scoped Span<byte> escapedPropertyName;
+
if (firstEscapeIndexProp != -1)
{
int length = JsonWriterHelper.GetMaxEscapedLength(utf8PropertyName.Length, firstEscapeIndexProp);
- scoped Span<byte> escapedPropertyName;
if (length > JsonConstants.StackallocByteThreshold)
{
propertyArray = ArrayPool<byte>.Shared.Rent(length);
/// <param name="equivalences">If <paramref name="c"/> is involved in case conversion, then equivalences will contain the
/// span of character which should be considered equal to <paramref name="c"/> in a case-insensitive comparison.</param>
/// <returns><see langword="true"/> if <paramref name="c"/> is involved in case conversion; otherwise, <see langword="false"/></returns>
- public static bool TryFindCaseEquivalencesForCharWithIBehavior(char c, CultureInfo culture, ref RegexCaseBehavior mappingBehavior, out ReadOnlySpan<char> equivalences)
+ public static bool TryFindCaseEquivalencesForCharWithIBehavior(char c, CultureInfo culture, scoped ref RegexCaseBehavior mappingBehavior, out ReadOnlySpan<char> equivalences)
{
if ((c | 0x20) == 'i' || (c | 0x01) == '\u0131')
{