This allows inlining Span.Length accross versioning boundaries in R2R images. We are leaking the Span implementation details already because the Span indexer is treated as intrinsic. Marking a few more trivial methods as non-versionable should not do any future harm.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.CompilerServices;
-using EditorBrowsableState = System.ComponentModel.EditorBrowsableState;
-using EditorBrowsableAttribute = System.ComponentModel.EditorBrowsableAttribute;
+using System.Runtime.Versioning;
#pragma warning disable 0809 //warning CS0809: Obsolete member 'Span<T>.Equals(object)' overrides non-obsolete member 'object.Equals(object)'
/// </summary>
[IsReadOnly]
[IsByRefLike]
+ [NonVersionable]
public struct ReadOnlySpan<T>
{
/// <summary>A byref or a native ptr.</summary>
/// <summary>
/// The number of items in the read-only span.
/// </summary>
- public int Length => _length;
+ public int Length
+ {
+ [NonVersionable]
+ get
+ {
+ return _length;
+ }
+ }
/// <summary>
/// Returns true if Length is 0.
/// </summary>
- public bool IsEmpty => _length == 0;
+ public bool IsEmpty
+ {
+ [NonVersionable]
+ get
+ {
+ return _length == 0;
+ }
+ }
/// <summary>
/// Returns the specified element of the read-only span.
[Intrinsic]
#endif
[MethodImpl(MethodImplOptions.AggressiveInlining)]
+ [NonVersionable]
get
{
if ((uint)index >= (uint)_length)
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System.ComponentModel;
using System.Diagnostics;
-using System.Runtime;
using System.Runtime.CompilerServices;
-using EditorBrowsableState = System.ComponentModel.EditorBrowsableState;
-using EditorBrowsableAttribute = System.ComponentModel.EditorBrowsableAttribute;
+using System.Runtime.Versioning;
#pragma warning disable 0809 //warning CS0809: Obsolete member 'Span<T>.Equals(object)' overrides non-obsolete member 'object.Equals(object)'
/// </summary>
[IsReadOnly]
[IsByRefLike]
+ [NonVersionable]
public struct Span<T>
{
/// <summary>A byref or a native ptr.</summary>
/// <summary>
/// The number of items in the span.
/// </summary>
- public int Length => _length;
+ public int Length
+ {
+ [NonVersionable]
+ get
+ {
+ return _length;
+ }
+ }
/// <summary>
/// Returns true if Length is 0.
/// </summary>
- public bool IsEmpty => _length == 0;
+ public bool IsEmpty
+ {
+ [NonVersionable]
+ get
+ {
+ return _length == 0;
+ }
+ }
/// <summary>
/// Returns a reference to specified element of the Span.
[Intrinsic]
#endif
[MethodImpl(MethodImplOptions.AggressiveInlining)]
+ [NonVersionable]
get
{
if ((uint)index >= (uint)_length)
// See the LICENSE file in the project root for more information.
using System.Runtime.CompilerServices;
+using System.Runtime.Versioning;
namespace System
{
// ByReference<T> is meant to be used to represent "ref T" fields. It is working
// around lack of first class support for byref fields in C# and IL. The JIT and
// type loader has special handling for it that turns it into a thin wrapper around ref T.
+ [NonVersionable]
internal struct ByReference<T>
{
private IntPtr _value;