Skip to content

Commit 3967abe

Browse files
committed
Fix build breaks
1 parent 6cf23b9 commit 3967abe

File tree

10 files changed

+44
-44
lines changed

10 files changed

+44
-44
lines changed

src/Microsoft.VisualStudio.Threading/InternalUtilities.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ internal static IEnumerable<string> GetAsyncReturnStackFrames(this Delegate cont
7878

7979
do
8080
{
81-
var state = GetStateMachineFieldValueOnSuffix(stateMachine, "__state");
81+
object? state = GetStateMachineFieldValueOnSuffix(stateMachine, "__state");
8282
yield return string.Format(
8383
CultureInfo.CurrentCulture,
8484
"{2}{0} (state: {1}, address: 0x{3:X8})",
@@ -194,13 +194,13 @@ private static IEnumerable<Delegate> FindContinuationDelegates(IAsyncStateMachin
194194
{
195195
Requires.NotNull(stateMachine, nameof(stateMachine));
196196

197-
var builder = GetStateMachineFieldValueOnSuffix(stateMachine, "__builder");
197+
object? builder = GetStateMachineFieldValueOnSuffix(stateMachine, "__builder");
198198
if (builder is null)
199199
{
200200
yield break;
201201
}
202202

203-
var task = GetFieldValue(builder, "m_task");
203+
object? task = GetFieldValue(builder, "m_task");
204204
if (task is null)
205205
{
206206
// Probably this builder is an instance of "AsyncTaskMethodBuilder", so we need to get its inner "AsyncTaskMethodBuilder<VoidTaskResult>"
@@ -224,15 +224,15 @@ private static IEnumerable<Delegate> FindContinuationDelegates(IAsyncStateMachin
224224
yield break;
225225
}
226226

227-
var continuationObject = continuationField.GetValue(task);
227+
object? continuationObject = continuationField.GetValue(task);
228228
if (continuationObject is null)
229229
{
230230
yield break;
231231
}
232232

233233
if (continuationObject is IEnumerable items)
234234
{
235-
foreach (var item in items)
235+
foreach (object? item in items)
236236
{
237237
Delegate? action = item as Delegate ?? GetFieldValue(item!, "m_action") as Delegate;
238238
if (action is object)

src/Microsoft.VisualStudio.Threading/ListOfOftenOne`1.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public void Add(T value)
6161
do
6262
{
6363
priorValue = Volatile.Read(ref this.value);
64-
var newValue = Combine(priorValue, value);
64+
object newValue = Combine(priorValue, value);
6565
fieldBeforeExchange = Interlocked.CompareExchange(ref this.value, newValue, priorValue);
6666
}
6767
while (priorValue != fieldBeforeExchange);
@@ -77,7 +77,7 @@ public void Remove(T value)
7777
do
7878
{
7979
priorValue = Volatile.Read(ref this.value);
80-
var newValue = Remove(priorValue, value);
80+
object? newValue = Remove(priorValue, value);
8181
fieldBeforeExchange = Interlocked.CompareExchange(ref this.value, newValue, priorValue);
8282
}
8383
while (priorValue != fieldBeforeExchange);

test/Microsoft.VisualStudio.Threading.Tests/AsyncLazyTests.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ public void ToStringForUncreatedValue()
390390
public async Task ToStringForCreatedValue()
391391
{
392392
var lazy = new AsyncLazy<int>(() => Task.FromResult<int>(3));
393-
var value = await lazy.GetValueAsync();
393+
int value = await lazy.GetValueAsync();
394394
string result = lazy.ToString();
395395
Assert.Equal(value.ToString(CultureInfo.InvariantCulture), result);
396396
}
@@ -485,7 +485,7 @@ async delegate
485485
// the Main thread waiting for it to complete.
486486
// This will deadlock unless the AsyncLazy joins
487487
// the value factory's async pump with the currently blocking one.
488-
var value = await lazy.GetValueAsync();
488+
object value = await lazy.GetValueAsync();
489489
Assert.NotNull(value);
490490
});
491491

@@ -523,7 +523,7 @@ async delegate
523523
},
524524
passJtfToLazyCtor ? asyncPump : null); // mix it up to exercise all the code paths in the ctor.
525525

526-
var backgroundRequest = Task.Run(async delegate
526+
Task<object> backgroundRequest = Task.Run(async delegate
527527
{
528528
return await lazy.GetValueAsync();
529529
});
@@ -532,7 +532,7 @@ async delegate
532532
Task<object>? foregroundRequest = lazy.GetValueAsync();
533533

534534
SingleThreadedTestSynchronizationContext.IFrame? frame = SingleThreadedTestSynchronizationContext.NewFrame();
535-
var combinedTask = Task.WhenAll(foregroundRequest, backgroundRequest);
535+
Task<object[]> combinedTask = Task.WhenAll(foregroundRequest, backgroundRequest);
536536
combinedTask.WithTimeout(UnexpectedTimeout).ContinueWith(_ => frame.Continue = false, TaskScheduler.Default);
537537
SingleThreadedTestSynchronizationContext.PushFrame(ctxt, frame);
538538

@@ -571,16 +571,16 @@ async delegate
571571
},
572572
asyncPump);
573573

574-
var backgroundRequest = Task.Run(async delegate
574+
Task<object> backgroundRequest = Task.Run(async delegate
575575
{
576576
return await lazy.GetValueAsync();
577577
});
578578

579579
Thread.Sleep(AsyncDelay); // Give the background thread time to call GetValueAsync(), but it doesn't yield (when the test was written).
580580
asyncPump.Run(async delegate
581581
{
582-
var foregroundValue = await lazy.GetValueAsync(this.TimeoutToken);
583-
var backgroundValue = await backgroundRequest;
582+
object foregroundValue = await lazy.GetValueAsync(this.TimeoutToken);
583+
object backgroundValue = await backgroundRequest;
584584
Assert.Same(foregroundValue, backgroundValue);
585585
});
586586
}
@@ -614,14 +614,14 @@ async delegate
614614
},
615615
asyncPump);
616616

617-
var backgroundRequest = Task.Run(async delegate
617+
Task<object> backgroundRequest = Task.Run(async delegate
618618
{
619619
return await lazy.GetValueAsync();
620620
});
621621

622622
Thread.Sleep(AsyncDelay); // Give the background thread time to call GetValueAsync(), but it doesn't yield (when the test was written).
623-
var foregroundValue = lazy.GetValue(this.TimeoutToken);
624-
var backgroundValue = asyncPump.Run(() => backgroundRequest);
623+
object foregroundValue = lazy.GetValue(this.TimeoutToken);
624+
object backgroundValue = asyncPump.Run(() => backgroundRequest);
625625
Assert.Same(foregroundValue, backgroundValue);
626626
}
627627

test/Microsoft.VisualStudio.Threading.Tests/AsyncReaderWriterLockTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4228,15 +4228,15 @@ public async Task SetLockDataNoLock()
42284228
lck.SetLockData(null);
42294229
Assert.Null(lck.GetLockData());
42304230

4231-
var value1 = new object();
4231+
object value1 = new object();
42324232
lck.SetLockData(value1);
42334233
Assert.Equal(value1, lck.GetLockData());
42344234

42354235
using (await lck.WriteLockAsync())
42364236
{
42374237
Assert.Null(lck.GetLockData());
42384238

4239-
var value2 = new object();
4239+
object value2 = new object();
42404240
lck.SetLockData(value2);
42414241
Assert.Equal(value2, lck.GetLockData());
42424242
}

test/Microsoft.VisualStudio.Threading.Tests/AsyncSemaphoreTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public async Task Contested_OneWaitsAtATime(int initialCount)
7878
// The second wave cannot enter the semaphore until space is available.
7979
for (int i = 0; i < initialCount; i++)
8080
{
81-
var nextContestedIndex = initialCount + i;
81+
int nextContestedIndex = initialCount + i;
8282
releasers[nextContestedIndex] = this.lck.EnterAsync();
8383
Assert.False(releasers[nextContestedIndex].IsCompleted);
8484
releasers[i].Result.Dispose(); // exit the semaphore with a previously assigned one.
@@ -108,7 +108,7 @@ public async Task Contested_ManyWaitAtATime(int initialCount)
108108
// The second wave cannot enter the semaphore until space is available.
109109
for (int i = 0; i < initialCount; i++)
110110
{
111-
var nextContestedIndex = initialCount + i;
111+
int nextContestedIndex = initialCount + i;
112112
releasers[nextContestedIndex] = this.lck.EnterAsync();
113113
Assert.False(releasers[nextContestedIndex].IsCompleted);
114114
}

test/Microsoft.VisualStudio.Threading.Tests/JoinableTaskContextTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public void ReportHangOnRun()
6969
{
7070
Tuple<TimeSpan, int, Guid>? tuple = await hangQueue.DequeueAsync(ct);
7171
TimeSpan duration = tuple.Item1;
72-
var iterations = tuple.Item2;
72+
int iterations = tuple.Item2;
7373
Guid id = tuple.Item3;
7474
Assert.True(lastDuration == TimeSpan.Zero || lastDuration < duration);
7575
Assert.Equal(lastIteration + 1, iterations);

test/Microsoft.VisualStudio.Threading.Tests/JoinableTaskTests.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public void RunFuncOfTaskOfTMTA()
4848
[Fact]
4949
public void LeaveAndReturnToMainThread()
5050
{
51-
var fullyCompleted = false;
51+
bool fullyCompleted = false;
5252
this.asyncPump.Run(async delegate
5353
{
5454
Assert.Equal(this.originalThreadManagedId, Environment.CurrentManagedThreadId);
@@ -238,7 +238,7 @@ public void SwitchToMainThreadAsyncTransitionsCanSeeAsyncLocals()
238238
Exception? delegateFailure = null;
239239

240240
var asyncLocal = new System.Threading.AsyncLocal<object>();
241-
var asyncLocalValue = new object();
241+
object asyncLocalValue = new object();
242242

243243
// The point of this test is to verify that the transitioning/transitioned
244244
// methods on the JoinableTaskFactory can see into the AsyncLocal<T>.Value
@@ -2235,7 +2235,7 @@ public void BeginAsyncWithResultOnMTAKicksOffOtherAsyncPumpWorkCanCompleteSynchr
22352235
}).Result;
22362236

22372237
Assert.False(joinable.Task.IsCompleted);
2238-
var result = joinable.Join();
2238+
int result = joinable.Join();
22392239
Assert.Equal<int>(5, result);
22402240
Assert.True(taskFinished);
22412241
Assert.True(joinable.Task.IsCompleted);
@@ -2631,7 +2631,7 @@ public void JoinWorkStealingRetainsThreadAffinityUI()
26312631
public void JoinWorkStealingRetainsThreadAffinityBackground()
26322632
{
26332633
bool synchronousCompletionStarting = false;
2634-
var asyncTask = Task.Run(delegate
2634+
Task<JoinableTask> asyncTask = Task.Run(delegate
26352635
{
26362636
return this.asyncPump.RunAsync(async delegate
26372637
{
@@ -4006,7 +4006,7 @@ public void JoinableTaskOfT_TaskPropertyBeforeReturning()
40064006
public void IsCompletedTrueDoesNotLock()
40074007
{
40084008
using var context = new JoinableTaskContext();
4009-
var syncContextLock = typeof(JoinableTaskContext).GetProperty("SyncContextLock", BindingFlags.NonPublic | BindingFlags.Instance)!.GetValue(context)!;
4009+
object syncContextLock = typeof(JoinableTaskContext).GetProperty("SyncContextLock", BindingFlags.NonPublic | BindingFlags.Instance)!.GetValue(context)!;
40104010
Assert.NotNull(syncContextLock);
40114011

40124012
JoinableTask joinableTask = context.Factory.RunAsync(() => Task.CompletedTask);
@@ -4038,7 +4038,7 @@ public void IsCompletedTrueDoesNotLock()
40384038
public void JoinCompletedDoesNotLock()
40394039
{
40404040
using var context = new JoinableTaskContext();
4041-
var syncContextLock = typeof(JoinableTaskContext).GetProperty("SyncContextLock", BindingFlags.NonPublic | BindingFlags.Instance)!.GetValue(context)!;
4041+
object syncContextLock = typeof(JoinableTaskContext).GetProperty("SyncContextLock", BindingFlags.NonPublic | BindingFlags.Instance)!.GetValue(context)!;
40424042
Assert.NotNull(syncContextLock);
40434043

40444044
JoinableTask joinableTask = context.Factory.RunAsync(() => Task.CompletedTask);
@@ -4070,7 +4070,7 @@ public void JoinCompletedDoesNotLock()
40704070
public void JoinAsyncCompletedDoesNotLock()
40714071
{
40724072
using var context = new JoinableTaskContext();
4073-
var syncContextLock = typeof(JoinableTaskContext).GetProperty("SyncContextLock", BindingFlags.NonPublic | BindingFlags.Instance)!.GetValue(context)!;
4073+
object syncContextLock = typeof(JoinableTaskContext).GetProperty("SyncContextLock", BindingFlags.NonPublic | BindingFlags.Instance)!.GetValue(context)!;
40744074
Assert.NotNull(syncContextLock);
40754075

40764076
JoinableTask joinableTask = context.Factory.RunAsync(() => Task.CompletedTask);
@@ -4106,7 +4106,7 @@ public void JoinAsyncCompletedDoesNotLock()
41064106
public void GetAwaiterCompletedDoesNotLock()
41074107
{
41084108
using var context = new JoinableTaskContext();
4109-
var syncContextLock = typeof(JoinableTaskContext).GetProperty("SyncContextLock", BindingFlags.NonPublic | BindingFlags.Instance)!.GetValue(context)!;
4109+
object syncContextLock = typeof(JoinableTaskContext).GetProperty("SyncContextLock", BindingFlags.NonPublic | BindingFlags.Instance)!.GetValue(context)!;
41104110
Assert.NotNull(syncContextLock);
41114111

41124112
JoinableTask joinableTask = context.Factory.RunAsync(() => Task.CompletedTask);
@@ -4140,7 +4140,7 @@ public void GetAwaiterCompletedDoesNotLock()
41404140
public void JoinCompletedTDoesNotLock()
41414141
{
41424142
using var context = new JoinableTaskContext();
4143-
var syncContextLock = typeof(JoinableTaskContext).GetProperty("SyncContextLock", BindingFlags.NonPublic | BindingFlags.Instance)!.GetValue(context)!;
4143+
object syncContextLock = typeof(JoinableTaskContext).GetProperty("SyncContextLock", BindingFlags.NonPublic | BindingFlags.Instance)!.GetValue(context)!;
41444144
Assert.NotNull(syncContextLock);
41454145

41464146
JoinableTask<int> joinableTask = context.Factory.RunAsync(() => Task.FromResult(0));
@@ -4172,7 +4172,7 @@ public void JoinCompletedTDoesNotLock()
41724172
public void JoinAsyncCompletedTDoesNotLock()
41734173
{
41744174
using var context = new JoinableTaskContext();
4175-
var syncContextLock = typeof(JoinableTaskContext).GetProperty("SyncContextLock", BindingFlags.NonPublic | BindingFlags.Instance)!.GetValue(context)!;
4175+
object syncContextLock = typeof(JoinableTaskContext).GetProperty("SyncContextLock", BindingFlags.NonPublic | BindingFlags.Instance)!.GetValue(context)!;
41764176
Assert.NotNull(syncContextLock);
41774177

41784178
JoinableTask<int> joinableTask = context.Factory.RunAsync(() => Task.FromResult(0));
@@ -4210,7 +4210,7 @@ public void JoinAsyncCompletedTDoesNotLock()
42104210
public void GetAwaiterCompletedTDoesNotLock()
42114211
{
42124212
using var context = new JoinableTaskContext();
4213-
var syncContextLock = typeof(JoinableTaskContext).GetProperty("SyncContextLock", BindingFlags.NonPublic | BindingFlags.Instance)!.GetValue(context)!;
4213+
object syncContextLock = typeof(JoinableTaskContext).GetProperty("SyncContextLock", BindingFlags.NonPublic | BindingFlags.Instance)!.GetValue(context)!;
42144214
Assert.NotNull(syncContextLock);
42154215

42164216
JoinableTask<int> joinableTask = context.Factory.RunAsync(() => Task.FromResult(0));
@@ -4520,7 +4520,7 @@ private WeakReference JoinableTaskReleasedBySyncContextAfterCompletion_Helper(ou
45204520

45214521
private void RunFuncOfTaskHelper()
45224522
{
4523-
var initialThread = Environment.CurrentManagedThreadId;
4523+
int initialThread = Environment.CurrentManagedThreadId;
45244524
this.asyncPump.Run(async delegate
45254525
{
45264526
Assert.Equal(initialThread, Environment.CurrentManagedThreadId);
@@ -4531,7 +4531,7 @@ private void RunFuncOfTaskHelper()
45314531

45324532
private void RunFuncOfTaskOfTHelper()
45334533
{
4534-
var initialThread = Environment.CurrentManagedThreadId;
4534+
int initialThread = Environment.CurrentManagedThreadId;
45354535
var expectedResult = new GenericParameterHelper();
45364536
GenericParameterHelper actualResult = this.asyncPump.Run(async delegate
45374537
{

test/Microsoft.VisualStudio.Threading.Tests/ProgressWithCompletionTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public void DoesNotDeadlockWhenCallbackCapturesSyncContext(bool captureMainThrea
162162
}
163163
else
164164
{
165-
var progressTask = Task.Run(progressFactory);
165+
Task<ProgressWithCompletion<GenericParameterHelper>> progressTask = Task.Run(progressFactory);
166166
progressTask.WaitWithoutInlining();
167167
progress = progressTask.Result;
168168
}

test/Microsoft.VisualStudio.Threading.Tests/SingleThreadedSynchronizationContextTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public void Post_DoesNotExecuteSynchronously()
127127
[Fact]
128128
public void Post_PushFrame()
129129
{
130-
var originalThreadId = Environment.CurrentManagedThreadId;
130+
int originalThreadId = Environment.CurrentManagedThreadId;
131131
var syncContext = new SingleThreadedSynchronizationContext();
132132
var frame = new SingleThreadedSynchronizationContext.Frame();
133133

@@ -164,7 +164,7 @@ public void Post_PushFrame()
164164
[Fact]
165165
public void Post_PushFrame_Throws()
166166
{
167-
var originalThreadId = Environment.CurrentManagedThreadId;
167+
int originalThreadId = Environment.CurrentManagedThreadId;
168168
var syncContext = new SingleThreadedSynchronizationContext();
169169
var frame = new SingleThreadedSynchronizationContext.Frame();
170170

@@ -184,7 +184,7 @@ public void Post_CapturesExecutionContext()
184184
{
185185
try
186186
{
187-
var expectedValue = new object();
187+
object expectedValue = new object();
188188
var actualValue = new TaskCompletionSource<object>();
189189

190190
var asyncLocal = new AsyncLocal<object>();

test/Microsoft.VisualStudio.Threading.Tests/TplExtensionsTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ public async Task NoThrowAwaitable_ValueTask_UnsafeOnCompleted_DoesNotCaptureExe
534534
public async Task NoThrowAwaitable_ValueTaskT_Succeeds()
535535
{
536536
var barrier = new TaskCompletionSource<object?>();
537-
var result = new object();
537+
object result = new object();
538538
var tcs = new TaskCompletionSource<object>();
539539
var test = Task.Run(async () =>
540540
{
@@ -885,7 +885,7 @@ public void FollowCancelableTaskToCompletionEndsInFault()
885885
[Fact]
886886
public async Task ToApmOfTWithNoTaskState()
887887
{
888-
var state = new object();
888+
object state = new object();
889889
var tcs = new TaskCompletionSource<int>();
890890
IAsyncResult? beginResult = null;
891891

@@ -912,7 +912,7 @@ public async Task ToApmOfTWithNoTaskState()
912912
[Fact]
913913
public async Task ToApmOfTWithMatchingTaskState()
914914
{
915-
var state = new object();
915+
object state = new object();
916916
var tcs = new TaskCompletionSource<int>(state);
917917
IAsyncResult? beginResult = null;
918918

@@ -939,7 +939,7 @@ public async Task ToApmOfTWithMatchingTaskState()
939939
[Fact]
940940
public async Task ToApmWithNoTaskState()
941941
{
942-
var state = new object();
942+
object state = new object();
943943
var tcs = new TaskCompletionSource<object?>();
944944
IAsyncResult? beginResult = null;
945945

@@ -966,7 +966,7 @@ public async Task ToApmWithNoTaskState()
966966
[Fact]
967967
public async Task ToApmWithMatchingTaskState()
968968
{
969-
var state = new object();
969+
object state = new object();
970970
var tcs = new TaskCompletionSource<object?>(state);
971971
IAsyncResult? beginResult = null;
972972

0 commit comments

Comments
 (0)