Skip to content

Commit

Permalink
Merge pull request #1004 from AArnott/moreTFMs
Browse files Browse the repository at this point in the history
Add net5.0 and net5.0-windows TFMs
  • Loading branch information
AArnott committed Mar 25, 2022
2 parents e64b8c7 + 12f7483 commit e149f42
Show file tree
Hide file tree
Showing 16 changed files with 983 additions and 23 deletions.
9 changes: 9 additions & 0 deletions azure-pipelines/dotnet.yml
Expand Up @@ -38,6 +38,15 @@ steps:
workingDirectory: test/Microsoft.VisualStudio.Threading.Tests
condition: ne(variables['OptProf'], 'true')

- task: DotNetCoreCLI@2
displayName: dotnet test -f net5.0-windows
inputs:
command: test
arguments: --no-build -c $(BuildConfiguration) -f net5.0-windows --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-windows.binlog"
testRunTitle: net5.0-windows-$(Agent.JobName)
workingDirectory: test/Microsoft.VisualStudio.Threading.Tests
condition: and(ne(variables['OptProf'], 'true'), eq(variables['Agent.OS'], 'Windows_NT'))

# We have to artifically run this script so that the extra .nupkg is produced for variables/InsertConfigValues.ps1 to notice.
- powershell: azure-pipelines\artifacts\VSInsertion.ps1
displayName: Prepare VSInsertion artifact
Expand Down
2 changes: 0 additions & 2 deletions src/Microsoft.VisualStudio.Threading/AsyncReaderWriterLock.cs
Expand Up @@ -1104,9 +1104,7 @@ private bool TryIssueLock(Awaiter awaiter, bool previouslyQueued, bool skipPendi
// an accidental execution fork that is exposing concurrency inappropriately.
if (this.CanCurrentThreadHoldActiveLock && !(SynchronizationContext.Current is NonConcurrentSynchronizationContext))
{
#if NETFRAMEWORK || NETCOREAPP // Assertion failures crash on .NET Core < 3.0
Report.Fail("Dangerous request for read lock from fork of write lock.");
#endif
Verify.FailOperation(Strings.DangerousReadLockRequestFromWriteLockFork);
}

Expand Down
6 changes: 6 additions & 0 deletions src/Microsoft.VisualStudio.Threading/AwaitExtensions.cs
Expand Up @@ -10,6 +10,7 @@ namespace Microsoft.VisualStudio.Threading
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Runtime.ExceptionServices;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Win32;
Expand Down Expand Up @@ -122,6 +123,11 @@ public static async Task<int> WaitForExitAsync(this Process process, Cancellatio
/// </returns>
public static Task WaitForChangeAsync(this RegistryKey registryKey, bool watchSubtree = true, RegistryChangeNotificationFilters change = RegistryChangeNotificationFilters.Value | RegistryChangeNotificationFilters.Subkey, CancellationToken cancellationToken = default(CancellationToken))
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
throw new PlatformNotSupportedException();
}

Requires.NotNull(registryKey, nameof(registryKey));

return WaitForRegistryChangeAsync(registryKey.Handle, watchSubtree, change, cancellationToken);
Expand Down
14 changes: 7 additions & 7 deletions src/Microsoft.VisualStudio.Threading/Dgml.cs
Expand Up @@ -33,12 +33,12 @@ internal static XDocument Create(out XElement nodes, out XElement links, string
new XAttribute("Layout", layout)));
if (direction is object)
{
dgml.Root.Add(new XAttribute("GraphDirection", direction));
dgml.Root!.Add(new XAttribute("GraphDirection", direction));
}

nodes = new XElement(XName.Get("Nodes", Namespace));
links = new XElement(XName.Get("Links", Namespace));
dgml.Root.Add(nodes);
dgml.Root!.Add(nodes);
dgml.Root.Add(links);
dgml.WithCategories(Category("Contains", isContainment: true));
return dgml;
Expand Down Expand Up @@ -107,7 +107,7 @@ internal static XElement Link(string source, string target)

internal static XElement Link(XElement source, XElement target)
{
return Link(source.Attribute("Id").Value, target.Attribute("Id").Value);
return Link(source.Attribute("Id")!.Value, target.Attribute("Id")!.Value);
}

internal static XDocument WithLink(this XDocument document, XElement link)
Expand Down Expand Up @@ -192,7 +192,7 @@ internal static XElement ContainedBy(this XElement node, string containerId, XDo
Requires.NotNull(node, nameof(node));
Requires.NotNullOrEmpty(containerId, nameof(containerId));

document.WithLink(Link(containerId, node.Attribute("Id").Value).WithCategories("Contains"));
document.WithLink(Link(containerId, node.Attribute("Id")!.Value).WithCategories("Contains"));
return node;
}

Expand Down Expand Up @@ -230,7 +230,7 @@ internal static XDocument WithStyle(this XDocument document, string categoryId,
Requires.NotNull(properties, nameof(properties));
Requires.NotNullOrEmpty(targetType, nameof(targetType));

XElement? container = document.Root.Element(StylesName);
XElement? container = document.Root!.Element(StylesName);
if (container is null)
{
document.Root.Add(container = new XElement(StylesName));
Expand All @@ -241,7 +241,7 @@ internal static XDocument WithStyle(this XDocument document, string categoryId,
new XAttribute("TargetType", targetType),
new XAttribute("GroupLabel", categoryId),
new XElement(XName.Get("Condition", Namespace), new XAttribute("Expression", "HasCategory('" + categoryId + "')")));
style.Add(properties.Select(p => new XElement(XName.Get("Setter", Namespace), new XAttribute("Property", p.Key), new XAttribute("Value", p.Value))));
style.Add(properties.Select(p => new XElement(XName.Get("Setter", Namespace), new XAttribute("Property", p.Key), new XAttribute("Value", p.Value!))));

container.Add(style);

Expand Down Expand Up @@ -274,7 +274,7 @@ private static XElement GetRootElement(this XDocument document, XName name)
Requires.NotNull(document, nameof(document));
Requires.NotNull(name, nameof(name));

XElement? container = document.Root.Element(name);
XElement? container = document.Root!.Element(name);
if (container is null)
{
document.Root.Add(container = new XElement(name));
Expand Down
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#if NETFRAMEWORK
#if NETFRAMEWORK || WINDOWS

namespace Microsoft.VisualStudio.Threading
{
Expand Down
Expand Up @@ -129,15 +129,15 @@ private static ICollection<XElement> CreateCollectionContainingTaskLinks(Diction
foreach (JoinableTaskFactory.SingleExecuteProtector? pendingTasksElement in pendingTask.MainThreadQueueContents)
{
queueIndex++;
XElement? callstackNode = Dgml.Node(node.Attribute("Id").Value + "MTQueue#" + queueIndex, GetAsyncReturnStack(pendingTasksElement));
XElement? callstackNode = Dgml.Node(node.Attribute("Id")!.Value + "MTQueue#" + queueIndex, GetAsyncReturnStack(pendingTasksElement));
XElement? callstackLink = Dgml.Link(callstackNode, node);
result.Add(Tuple.Create(callstackNode, callstackLink));
}

foreach (JoinableTaskFactory.SingleExecuteProtector? pendingTasksElement in pendingTask.ThreadPoolQueueContents)
{
queueIndex++;
XElement? callstackNode = Dgml.Node(node.Attribute("Id").Value + "TPQueue#" + queueIndex, GetAsyncReturnStack(pendingTasksElement));
XElement? callstackNode = Dgml.Node(node.Attribute("Id")!.Value + "TPQueue#" + queueIndex, GetAsyncReturnStack(pendingTasksElement));
XElement? callstackLink = Dgml.Link(callstackNode, node);
result.Add(Tuple.Create(callstackNode, callstackLink));
}
Expand Down
2 changes: 0 additions & 2 deletions src/Microsoft.VisualStudio.Threading/JoinableTaskFactory.cs
Expand Up @@ -650,9 +650,7 @@ private static void VerifyNoNonConcurrentSyncContext()
// Don't use Verify.Operation here to avoid loading a string resource in success cases.
if (SynchronizationContext.Current is AsyncReaderWriterLock.NonConcurrentSynchronizationContext)
{
#if NETFRAMEWORK || NETCOREAPP // Assertion failures crash on .NET Core < 3.0
Report.Fail(Strings.NotAllowedUnderURorWLock); // pops a CHK assert dialog, but doesn't throw.
#endif
Verify.FailOperation(Strings.NotAllowedUnderURorWLock); // actually throws, even in RET.
}
}
Expand Down
@@ -1,13 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net472</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net5.0;net472</TargetFrameworks>

<Summary>Async synchronization primitives, async collections, TPL and dataflow extensions.</Summary>
<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>
<PackageTags>Threading Async Lock Synchronization Threadsafe</PackageTags>

<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))">
<TargetFrameworks>$(TargetFrameworks);net5.0-windows</TargetFrameworks>
<UseWPF Condition=" '$(TargetFramework)' != 'net5.0' ">true</UseWPF>
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Update="Strings.resx">
<Generator>ResXFileCodeGenerator</Generator>
Expand Down

0 comments on commit e149f42

Please sign in to comment.