Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit bd1911e

Browse files
authored
Update the System.Runtime and System.Memory ref based on new buildtools (#28906)
* Update the System.Runtime and System.Memory ref based on new buildtools * Fix HttpContent TryGetBuffer and update System.Runtime ref * Update System.Memory ref and fix PipeAwaitable (assign CancellationTokenRegistration) * Fix 'use of unassigned local' error in System.Memory performance tests
1 parent 960aae8 commit bd1911e

File tree

5 files changed

+68
-29
lines changed

5 files changed

+68
-29
lines changed

src/System.IO.Pipelines/src/System/IO/Pipelines/PipeAwaitable.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public PipeAwaitable(bool completed, bool useSynchronizationContext)
2929
_canceledState = CanceledState.NotCanceled;
3030
_completion = completed ? s_awaitableIsCompleted : s_awaitableIsNotCompleted;
3131
_completionState = null;
32+
_cancellationTokenRegistration = default;
3233
_synchronizationContext = null;
3334
_executionContext = null;
3435
_useSynchronizationContext = useSynchronizationContext;
@@ -41,7 +42,7 @@ public PipeAwaitable(bool completed, bool useSynchronizationContext)
4142
[MethodImpl(MethodImplOptions.AggressiveInlining)]
4243
public CancellationTokenRegistration AttachToken(CancellationToken cancellationToken, Action<object> callback, object state)
4344
{
44-
CancellationTokenRegistration oldRegistration;
45+
CancellationTokenRegistration oldRegistration = default;
4546
if (!cancellationToken.Equals(_cancellationToken))
4647
{
4748
oldRegistration = _cancellationTokenRegistration;

src/System.Memory/ref/System.Memory.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public static void Reverse<T>(this System.Span<T> span) { }
9292
public readonly partial struct Memory<T>
9393
{
9494
private readonly object _dummy;
95+
private readonly int _dummyPrimitive;
9596
public Memory(System.Buffers.MemoryManager<T> manager, int start, int length) { throw null; }
9697
public Memory(T[] array) { throw null; }
9798
public Memory(T[] array, int start, int length) { throw null; }
@@ -120,6 +121,7 @@ public void CopyTo(System.Memory<T> destination) { }
120121
public readonly partial struct ReadOnlyMemory<T>
121122
{
122123
private readonly object _dummy;
124+
private readonly int _dummyPrimitive;
123125
public ReadOnlyMemory(T[] array) { throw null; }
124126
public ReadOnlyMemory(T[] array, int start, int length) { throw null; }
125127
public static System.ReadOnlyMemory<T> Empty { get { throw null; } }
@@ -144,6 +146,7 @@ public void CopyTo(System.Memory<T> destination) { }
144146
public readonly ref partial struct ReadOnlySpan<T>
145147
{
146148
private readonly object _dummy;
149+
private readonly int _dummyPrimitive;
147150
[System.CLSCompliantAttribute(false)]
148151
public unsafe ReadOnlySpan(void* pointer, int length) { throw null; }
149152
public ReadOnlySpan(T[] array) { throw null; }
@@ -172,13 +175,15 @@ public void CopyTo(System.Span<T> destination) { }
172175
public ref partial struct Enumerator
173176
{
174177
private object _dummy;
178+
private int _dummyPrimitive;
175179
public ref readonly T Current { get { throw null; } }
176180
public bool MoveNext() { throw null; }
177181
}
178182
}
179183
public readonly partial struct SequencePosition : System.IEquatable<System.SequencePosition>
180184
{
181185
private readonly object _dummy;
186+
private readonly int _dummyPrimitive;
182187
public SequencePosition(object @object, int integer) { throw null; }
183188
[System.ComponentModel.EditorBrowsableAttribute((System.ComponentModel.EditorBrowsableState)(1))]
184189
public override bool Equals(object obj) { throw null; }
@@ -195,6 +200,7 @@ public ref partial struct Enumerator
195200
public readonly ref partial struct Span<T>
196201
{
197202
private readonly object _dummy;
203+
private readonly int _dummyPrimitive;
198204
[System.CLSCompliantAttribute(false)]
199205
public unsafe Span(void* pointer, int length) { throw null; }
200206
public Span(T[] array) { throw null; }
@@ -226,6 +232,7 @@ public void Fill(T value) { }
226232
public ref partial struct Enumerator
227233
{
228234
private object _dummy;
235+
private int _dummyPrimitive;
229236
public ref T Current { get { throw null; } }
230237
public bool MoveNext() { throw null; }
231238
}
@@ -258,6 +265,7 @@ public partial interface IPinnable
258265
public partial struct MemoryHandle : System.IDisposable
259266
{
260267
private object _dummy;
268+
private int _dummyPrimitive;
261269
[System.CLSCompliantAttribute(false)]
262270
public unsafe MemoryHandle(void* pointer, System.Runtime.InteropServices.GCHandle handle = default(System.Runtime.InteropServices.GCHandle), System.Buffers.IPinnable pinnable = null) { throw null; }
263271
[System.CLSCompliantAttribute(false)]
@@ -302,6 +310,7 @@ protected ReadOnlySequenceSegment() { }
302310
public readonly partial struct ReadOnlySequence<T>
303311
{
304312
private readonly object _dummy;
313+
private readonly int _dummyPrimitive;
305314
public static readonly System.Buffers.ReadOnlySequence<T> Empty;
306315
public ReadOnlySequence(System.Buffers.ReadOnlySequenceSegment<T> startSegment, int startIndex, System.Buffers.ReadOnlySequenceSegment<T> endSegment, int endIndex) { throw null; }
307316
public ReadOnlySequence(System.ReadOnlyMemory<T> memory) { throw null; }
@@ -330,14 +339,15 @@ public readonly partial struct ReadOnlySequence<T>
330339
public partial struct Enumerator
331340
{
332341
private object _dummy;
342+
private int _dummyPrimitive;
333343
public Enumerator(in System.Buffers.ReadOnlySequence<T> sequence) { throw null; }
334344
public System.ReadOnlyMemory<T> Current { get { throw null; } }
335345
public bool MoveNext() { throw null; }
336346
}
337347
}
338348
public readonly partial struct StandardFormat : System.IEquatable<System.Buffers.StandardFormat>
339349
{
340-
private readonly int _dummy;
350+
private readonly int _dummyPrimitive;
341351
public const byte MaxPrecision = (byte)99;
342352
public const byte NoPrecision = (byte)255;
343353
public StandardFormat(char symbol, byte precision = (byte)255) { throw null; }

src/System.Memory/tests/Performance/Perf.Memory.Slice.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ private static void ReadOnlyMemory_Char_GetSpanThenSlice(int numberOfChars)
123123
public static void ReadOnlyMemory_Byte_TryGetArray()
124124
{
125125
ReadOnlyMemory<byte> memory = new byte[1];
126-
ArraySegment<byte> result;
126+
ArraySegment<byte> result = default;
127127

128128
foreach (BenchmarkIteration iteration in Benchmark.Iterations)
129129
{
@@ -144,7 +144,7 @@ public static void ReadOnlyMemory_Byte_TryGetArray()
144144
public static void ReadOnlyMemory_Char_TryGetArray()
145145
{
146146
ReadOnlyMemory<char> memory = new char[1];
147-
ArraySegment<char> result;
147+
ArraySegment<char> result = default;
148148

149149
foreach (BenchmarkIteration iteration in Benchmark.Iterations)
150150
{

src/System.Net.Http/src/System/Net/Http/HttpContent.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,12 @@ internal void SetBuffer(byte[] buffer, int offset, int count)
143143

144144
internal bool TryGetBuffer(out ArraySegment<byte> buffer)
145145
{
146-
return _bufferedContent != null && _bufferedContent.TryGetBuffer(out buffer);
146+
if (_bufferedContent != null)
147+
{
148+
return _bufferedContent.TryGetBuffer(out buffer);
149+
}
150+
buffer = default;
151+
return false;
147152
}
148153

149154
protected HttpContent()

0 commit comments

Comments
 (0)