Skip to content

Commit a9666fe

Browse files
committed
Add .NET 5.0 as a tested runtime
1 parent 57c548b commit a9666fe

File tree

13 files changed

+50
-30
lines changed

13 files changed

+50
-30
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<BaseIntermediateOutputPath>$(RepoRootPath)obj\$(MSBuildProjectName)\</BaseIntermediateOutputPath>
66
<BaseOutputPath Condition=" '$(BaseOutputPath)' == '' ">$(RepoRootPath)bin\$(MSBuildProjectName)\</BaseOutputPath>
77
<PackageOutputPath>$(RepoRootPath)bin\Packages\$(Configuration)\NuGet\</PackageOutputPath>
8-
<LangVersion>8.0</LangVersion>
8+
<LangVersion>9.0</LangVersion>
99
<Nullable>enable</Nullable>
1010
<AnalysisLevel>latest</AnalysisLevel>
1111
<GenerateDocumentationFile>true</GenerateDocumentationFile>

azure-pipelines/dotnet.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ steps:
1616
displayName: dotnet test -f net472
1717
inputs:
1818
command: test
19-
arguments: --no-build -c $(BuildConfiguration) -f net472 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings"
19+
arguments: --no-build -c $(BuildConfiguration) -f net472 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings" /bl:"$(Build.ArtifactStagingDirectory)/build_logs/test_net472.binlog"
2020
testRunTitle: net472-$(Agent.JobName)
2121
condition: and(ne(variables['OptProf'], 'true'), eq(variables['Agent.OS'], 'Windows_NT'))
2222

2323
- task: DotNetCoreCLI@2
2424
displayName: dotnet test -f netcoreapp2.1
2525
inputs:
2626
command: test
27-
arguments: --no-build -c $(BuildConfiguration) -f netcoreapp2.1 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings"
27+
arguments: --no-build -c $(BuildConfiguration) -f netcoreapp2.1 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings" /bl:"$(Build.ArtifactStagingDirectory)/build_logs/test_netcoreapp2.1.binlog"
2828
testRunTitle: netcoreapp2.1-$(Agent.JobName)
2929
workingDirectory: test/Microsoft.VisualStudio.Threading.Tests
3030
condition: ne(variables['OptProf'], 'true')
@@ -33,11 +33,20 @@ steps:
3333
displayName: dotnet test -f netcoreapp3.1
3434
inputs:
3535
command: test
36-
arguments: --no-build -c $(BuildConfiguration) -f netcoreapp3.1 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings"
36+
arguments: --no-build -c $(BuildConfiguration) -f netcoreapp3.1 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings" /bl:"$(Build.ArtifactStagingDirectory)/build_logs/test_netcoreapp3.1.binlog"
3737
testRunTitle: netcoreapp3.1-$(Agent.JobName)
3838
workingDirectory: test/Microsoft.VisualStudio.Threading.Tests
3939
condition: ne(variables['OptProf'], 'true')
4040

41+
- task: DotNetCoreCLI@2
42+
displayName: dotnet test -f net5.0
43+
inputs:
44+
command: test
45+
arguments: --no-build -c $(BuildConfiguration) -f net5.0 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true --settings "$(Build.Repository.LocalPath)/azure-pipelines/$(Agent.OS).runsettings" /bl:"$(Build.ArtifactStagingDirectory)/build_logs/test_net5.0.binlog"
46+
testRunTitle: net5.0-$(Agent.JobName)
47+
workingDirectory: test/Microsoft.VisualStudio.Threading.Tests
48+
condition: ne(variables['OptProf'], 'true')
49+
4150
# We have to artifically run this script so that the extra .nupkg is produced for variables/InsertConfigValues.ps1 to notice.
4251
- powershell: azure-pipelines\artifacts\VSInsertion.ps1
4352
displayName: Prepare VSInsertion artifact

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ public bool TryPeek([MaybeNullWhen(false)] out T value)
238238
public T Peek()
239239
{
240240
#pragma warning disable CS8717 // A member returning a [MaybeNull] value introduces a null value for a type parameter.
241-
if (!this.TryPeek(out T value))
241+
if (!this.TryPeek(out T? value))
242242
#pragma warning restore CS8717 // A member returning a [MaybeNull] value introduces a null value for a type parameter.
243243
{
244244
Verify.FailOperation(Strings.QueueEmpty);

src/Microsoft.VisualStudio.Threading/WeakKeyDictionary`2.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public TValue this[TKey key]
122122
public bool ContainsKey(TKey key)
123123
{
124124
#pragma warning disable CS8717 // A member returning a [MaybeNull] value introduces a null value for a type parameter.
125-
bool contained = this.TryGetValue(key, out TValue value);
125+
bool contained = this.TryGetValue(key, out TValue? value);
126126
#pragma warning restore CS8717 // A member returning a [MaybeNull] value introduces a null value for a type parameter.
127127
return contained;
128128
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
using Xunit.Abstractions;
1515
using Xunit.Sdk;
1616

17+
#pragma warning disable CA1416 // Validate platform compatibility
18+
1719
/// <summary>
1820
/// Tests functionality of the <see cref="AsyncReaderWriterLock"/> class.
1921
/// </summary>

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
using Xunit;
1515
using Xunit.Abstractions;
1616

17+
#pragma warning disable CA1416 // Validate platform compatibility
18+
1719
public partial class AwaitExtensionsTests : TestBase
1820
{
1921
public AwaitExtensionsTests(ITestOutputHelper logger)
@@ -390,8 +392,8 @@ public async Task WaitForExitAsync_ExitCode()
390392
{
391393
CreateNoWindow = true,
392394
WindowStyle = ProcessWindowStyle.Hidden,
393-
});
394-
int exitCode = await p.WaitForExitAsync();
395+
})!;
396+
int exitCode = await AwaitExtensions.WaitForExitAsync(p);
395397
Assert.Equal(55, exitCode);
396398
}
397399

@@ -404,9 +406,9 @@ public void WaitForExitAsync_AlreadyExited()
404406
{
405407
CreateNoWindow = true,
406408
WindowStyle = ProcessWindowStyle.Hidden,
407-
});
409+
})!;
408410
p.WaitForExit();
409-
Task<int> t = p.WaitForExitAsync();
411+
Task<int> t = AwaitExtensions.WaitForExitAsync(p);
410412
Assert.True(t.IsCompleted);
411413
Assert.Equal(55, t.Result);
412414
}
@@ -426,10 +428,10 @@ public async Task WaitForExitAsync_DoesNotCompleteTillKilled()
426428
{
427429
string processName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "cmd.exe" : "/bin/bash";
428430
int expectedExitCode = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? -1 : 128 + 9; // https://stackoverflow.com/a/1041309
429-
Process p = Process.Start(new ProcessStartInfo(processName) { CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden });
431+
Process p = Process.Start(new ProcessStartInfo(processName) { CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden })!;
430432
try
431433
{
432-
Task<int> t = p.WaitForExitAsync();
434+
Task<int> t = AwaitExtensions.WaitForExitAsync(p);
433435
Assert.False(t.IsCompleted);
434436
p.Kill();
435437
int exitCode = await t;
@@ -453,11 +455,11 @@ public async Task WaitForExitAsync_DoesNotCompleteTillKilled()
453455
public async Task WaitForExitAsync_Canceled()
454456
{
455457
string processName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "cmd.exe" : "/bin/bash";
456-
Process p = Process.Start(new ProcessStartInfo(processName) { CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden });
458+
Process p = Process.Start(new ProcessStartInfo(processName) { CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden })!;
457459
try
458460
{
459461
var cts = new CancellationTokenSource();
460-
Task<int> t = p.WaitForExitAsync(cts.Token);
462+
Task<int> t = AwaitExtensions.WaitForExitAsync(p, cts.Token);
461463
Assert.False(t.IsCompleted);
462464
cts.Cancel();
463465
await Assert.ThrowsAsync<TaskCanceledException>(() => t);
@@ -763,7 +765,7 @@ public async Task AwaitRegKeyChange_DoesNotPreventAppTerminationOnWin7()
763765
CreateNoWindow = true,
764766
WindowStyle = ProcessWindowStyle.Hidden,
765767
};
766-
Process testExeProcess = Process.Start(psi);
768+
Process testExeProcess = Process.Start(psi)!;
767769
try
768770
{
769771
// The assertion and timeout are interesting here:
@@ -773,7 +775,7 @@ public async Task AwaitRegKeyChange_DoesNotPreventAppTerminationOnWin7()
773775
// while other times it's really fast.
774776
// But when the dedicated thread is a background thread, it seems reliably fast.
775777
this.TimeoutTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(8));
776-
int exitCode = await testExeProcess.WaitForExitAsync(this.TimeoutToken);
778+
int exitCode = await AwaitExtensions.WaitForExitAsync(testExeProcess, this.TimeoutToken);
777779
Assert.Equal(0, exitCode);
778780
}
779781
finally

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public void OnHangDetected_Registration()
9999
});
100100
Assert.True(this.derivedNode.HangDetected.IsSet);
101101
Assert.True(this.derivedNode.FalseHangReportDetected.IsSet);
102-
Assert.Equal(this.derivedNode.HangReportCount, this.derivedNode.HangDetails.NotificationCount);
102+
Assert.Equal(this.derivedNode.HangReportCount, this.derivedNode.HangDetails!.NotificationCount);
103103
Assert.Equal(1, this.derivedNode.FalseHangReportCount);
104104

105105
// reset for the next verification
@@ -144,7 +144,7 @@ public void OnFalseHangReportDetected_OnlyOnce()
144144

145145
Assert.True(this.derivedNode.HangDetected.IsSet);
146146
Assert.True(this.derivedNode.FalseHangReportDetected.IsSet);
147-
Assert.Equal(this.derivedNode.HangDetails.HangId, this.derivedNode.FalseHangReportId);
147+
Assert.Equal(this.derivedNode.HangDetails!.HangId, this.derivedNode.FalseHangReportId);
148148
Assert.True(this.derivedNode.FalseHangReportTimeSpan >= this.derivedNode.HangDetails.HangDuration);
149149
Assert.True(this.derivedNode.HangReportCount >= 3);
150150
Assert.Equal(this.derivedNode.HangReportCount, this.derivedNode.HangDetails.NotificationCount);
@@ -166,7 +166,7 @@ public void OnHangDetected_Run_OnMainThread()
166166
});
167167
Assert.True(this.derivedNode.HangDetected.IsSet);
168168
Assert.NotNull(this.derivedNode.HangDetails);
169-
Assert.NotNull(this.derivedNode.HangDetails.EntryMethod);
169+
Assert.NotNull(this.derivedNode.HangDetails!.EntryMethod);
170170
Assert.Same(this.GetType(), this.derivedNode.HangDetails.EntryMethod!.DeclaringType);
171171
Assert.Contains(nameof(this.OnHangDetected_Run_OnMainThread), this.derivedNode.HangDetails.EntryMethod.Name, StringComparison.Ordinal);
172172

@@ -203,7 +203,7 @@ public void OnHangDetected_RunAsync_OnMainThread_BlamedMethodIsEntrypointNotBloc
203203
Assert.True(this.derivedNode.HangDetected.IsSet);
204204
JoinableTaskContext.HangDetails? hangDetails = this.derivedNode.FirstHangDetails;
205205
Assert.NotNull(hangDetails);
206-
Assert.NotNull(hangDetails.EntryMethod);
206+
Assert.NotNull(hangDetails!.EntryMethod);
207207

208208
// Verify that the original method that spawned the JoinableTask is the one identified as the entrypoint method.
209209
Assert.Same(this.GetType(), hangDetails.EntryMethod!.DeclaringType);
@@ -248,9 +248,9 @@ internal DerivedNode(JoinableTaskContext context)
248248

249249
internal List<JoinableTaskContext.HangDetails> AllHangDetails { get; } = new List<JoinableTaskContext.HangDetails>();
250250

251-
internal JoinableTaskContext.HangDetails HangDetails => this.AllHangDetails.LastOrDefault();
251+
internal JoinableTaskContext.HangDetails? HangDetails => this.AllHangDetails.LastOrDefault();
252252

253-
internal JoinableTaskContext.HangDetails FirstHangDetails => this.AllHangDetails.FirstOrDefault();
253+
internal JoinableTaskContext.HangDetails? FirstHangDetails => this.AllHangDetails.FirstOrDefault();
254254

255255
internal Guid FalseHangReportId { get; private set; }
256256

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ public void GetHangReportSimple()
393393
Assert.NotNull(report.ContentName);
394394
this.Logger.WriteLine(report.Content);
395395
var dgml = XDocument.Parse(report.Content);
396-
Assert.Equal("DirectedGraph", dgml.Root.Name.LocalName);
396+
Assert.Equal("DirectedGraph", dgml.Root!.Name.LocalName);
397397
Assert.Equal("http://schemas.microsoft.com/vs/2009/dgml", dgml.Root.Name.Namespace);
398398
}
399399

@@ -409,7 +409,7 @@ public void GetHangReportProducesDgmlWithNamedJoinableCollections()
409409
HangReportContribution? report = contributor.GetHangReport();
410410
this.Logger.WriteLine(report.Content);
411411
var dgml = XDocument.Parse(report.Content);
412-
IEnumerable<string>? collectionLabels = from node in dgml.Root.Element(XName.Get("Nodes", DgmlNamespace)).Elements()
412+
IEnumerable<string>? collectionLabels = from node in dgml.Root!.Element(XName.Get("Nodes", DgmlNamespace))!.Elements()
413413
where node.Attribute(XName.Get("Category"))?.Value == "Collection"
414414
select node.Attribute(XName.Get("Label"))?.Value;
415415
Assert.Contains(collectionLabels, label => label == jtcName);
@@ -432,7 +432,7 @@ public void GetHangReportProducesDgmlWithMethodNameRequestingMainThread()
432432
HangReportContribution? report = contributor.GetHangReport();
433433
this.Logger.WriteLine(report.Content);
434434
var dgml = XDocument.Parse(report.Content);
435-
IEnumerable<string>? collectionLabels = from node in dgml.Root.Element(XName.Get("Nodes", DgmlNamespace)).Elements()
435+
IEnumerable<string>? collectionLabels = from node in dgml.Root!.Element(XName.Get("Nodes", DgmlNamespace))!.Elements()
436436
where node.Attribute(XName.Get("Category"))?.Value == "Task"
437437
select node.Attribute(XName.Get("Label"))?.Value;
438438
Assert.Contains(collectionLabels, label => label.Contains(nameof(this.GetHangReportProducesDgmlWithMethodNameRequestingMainThread)));
@@ -455,7 +455,7 @@ public void GetHangReportProducesDgmlWithMethodNameYieldingOnMainThread()
455455
HangReportContribution? report = contributor.GetHangReport();
456456
this.Logger.WriteLine(report.Content);
457457
var dgml = XDocument.Parse(report.Content);
458-
IEnumerable<string>? collectionLabels = from node in dgml.Root.Element(XName.Get("Nodes", DgmlNamespace)).Elements()
458+
IEnumerable<string>? collectionLabels = from node in dgml.Root!.Element(XName.Get("Nodes", DgmlNamespace))!.Elements()
459459
where node.Attribute(XName.Get("Category"))?.Value == "Task"
460460
select node.Attribute(XName.Get("Label"))?.Value;
461461
Assert.Contains(collectionLabels, label => label.Contains(nameof(this.YieldingMethodAsync)));

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ protected JoinableTaskTestBase(ITestOutputHelper logger)
3838
this.testFrame = SingleThreadedTestSynchronizationContext.NewFrame();
3939

4040
// Suppress the assert dialog that appears and causes test runs to hang.
41-
Trace.Listeners.OfType<DefaultTraceListener>().Single().AssertUiEnabled = false;
41+
if (Trace.Listeners.OfType<DefaultTraceListener>().FirstOrDefault() is { } listener)
42+
{
43+
listener.AssertUiEnabled = false;
44+
}
4245
}
4346

4447
protected virtual JoinableTaskContext CreateJoinableTaskContext()

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3814,7 +3814,7 @@ public void JoinableTask_TaskPropertyBeforeReturning()
38143814
try
38153815
{
38163816
await joinableTaskStarted.WaitAsync();
3817-
observedJoinableTask = this.joinableCollection.Single();
3817+
observedJoinableTask = this.joinableCollection!.Single();
38183818
observedWrappedTask = observedJoinableTask.Task;
38193819
}
38203820
finally
@@ -3853,7 +3853,7 @@ public void JoinableTaskOfT_TaskPropertyBeforeReturning()
38533853
try
38543854
{
38553855
await joinableTaskStarted.WaitAsync();
3856-
observedJoinableTask = (JoinableTask<int>)this.joinableCollection.Single();
3856+
observedJoinableTask = (JoinableTask<int>)this.joinableCollection!.Single();
38573857
observedWrappedTask = observedJoinableTask.Task;
38583858
}
38593859
finally

0 commit comments

Comments
 (0)