Skip to content

Commit 10969cc

Browse files
authored
Merge pull request #758 from AArnott/netcoreapp3.1
Retarget to netcoreapp3.1 and test on net5.0
2 parents cd07295 + a9666fe commit 10969cc

16 files changed

+51
-32
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/Microsoft.VisualStudio.Threading.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>netstandard2.0;netcoreapp3.0;net472</TargetFrameworks>
4-
<CheckEolTargetFramework>false</CheckEolTargetFramework>
3+
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net472</TargetFrameworks>
54

65
<Summary>Async synchronization primitives, async collections, TPL and dataflow extensions.</Summary>
76
<Description>Async synchronization primitives, async collections, TPL and dataflow extensions. The JoinableTaskFactory allows synchronously blocking the UI thread for async work. This package is applicable to any .NET application (not just Visual Studio).</Description>

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
}

src/Microsoft.VisualStudio.Threading/netcoreapp3.0/PublicAPI.Shipped.txt renamed to src/Microsoft.VisualStudio.Threading/netcoreapp3.1/PublicAPI.Shipped.txt

File renamed without changes.

src/Microsoft.VisualStudio.Threading/netcoreapp3.0/PublicAPI.Unshipped.txt renamed to src/Microsoft.VisualStudio.Threading/netcoreapp3.1/PublicAPI.Unshipped.txt

File renamed without changes.

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

0 commit comments

Comments
 (0)