Skip to content

Add readonly modifier to standard library structs. #904

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 25 additions & 22 deletions standard/standard-library.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ It is expected that a conforming C# implementation will supply a significantly

## C.2 Standard Library Types defined in ISO/IEC 23271

> *Note:* Some `struct` types below have the `readonly` modifier. This modifier was not available
> when ISO/IEC 23271 was released, but is required for conforming implementations of this specification. *end note*

```csharp
namespace System
{
Expand Down Expand Up @@ -91,10 +94,10 @@ namespace System
public AttributeTargets ValidOn { get; }
}

public struct Boolean { }
public struct Byte { }
public struct Char { }
public struct Decimal { }
public readonly struct Boolean { }
public readonly struct Byte { }
public readonly struct Char { }
public readonly struct Decimal { }
public abstract class Delegate { }

public class DivideByZeroException : ArithmeticException
Expand All @@ -104,7 +107,7 @@ namespace System
public DivideByZeroException(string message, Exception innerException);
}

public struct Double { }
public readonly struct Double { }

public abstract class Enum : ValueType
{
Expand Down Expand Up @@ -137,10 +140,10 @@ namespace System
Exception innerException);
}

public struct Int16 { }
public struct Int32 { }
public struct Int64 { }
public struct IntPtr { }
public readonly struct Int16 { }
public readonly struct Int32 { }
public readonly struct Int64 { }
public readonly struct IntPtr { }

public class InvalidCastException : Exception
{
Expand Down Expand Up @@ -215,8 +218,8 @@ namespace System
public OverflowException(string message, Exception innerException);
}

public struct SByte { }
public struct Single { }
public readonly struct SByte { }
public readonly struct Single { }

public sealed class StackOverflowException : Exception
{
Expand All @@ -240,10 +243,10 @@ namespace System
Exception innerException);
}

public struct UInt16 { }
public struct UInt32 { }
public struct UInt64 { }
public struct UIntPtr { }
public readonly struct UInt16 { }
public readonly struct UInt32 { }
public readonly struct UInt64 { }
public readonly struct UIntPtr { }

public struct ValueTuple<T1>
{
Expand Down Expand Up @@ -506,16 +509,16 @@ namespace System.Runtime.CompilerServices
void OnCompleted(Action continuation);
}

public struct TaskAwaiter : ICriticalNotifyCompletion, INotifyCompletion
public readonly struct TaskAwaiter : ICriticalNotifyCompletion, INotifyCompletion
{
public bool IsCompleted { get; }
public void GetResult();
}

public struct TaskAwaiter<T> : ICriticalNotifyCompletion, INotifyCompletion
public readonly struct TaskAwaiter<TResult> : ICriticalNotifyCompletion, INotifyCompletion
{
public bool IsCompleted { get; }
public T GetResult();
public TResult GetResult();
}

public readonly struct ValueTaskAwaiter : ICriticalNotifyCompletion, INotifyCompletion
Expand All @@ -524,10 +527,10 @@ namespace System.Runtime.CompilerServices
public void GetResult();
}

public readonly struct ValueTaskAwaiter<T> : ICriticalNotifyCompletion, INotifyCompletion
public readonly struct ValueTaskAwaiter<TResult> : ICriticalNotifyCompletion, INotifyCompletion
{
public bool IsCompleted { get; }
public T GetResult();
public TResult GetResult();
}

}
Expand Down Expand Up @@ -556,12 +559,12 @@ namespace System.Threading.Tasks
```csharp
namespace System
{
public ref struct ReadOnlySpan<T>
public readonly ref struct ReadOnlySpan<T>
{
public int Length { get; }
public ref readonly T this[int index] { get; }
}
public ref struct Span<T>
public readonly ref struct Span<T>
{
public int Length { get; }
public ref T this[int index] { get; }
Expand Down