diff --git a/.editorconfig b/.editorconfig index 4a47432ae4..69a8cdc018 100644 --- a/.editorconfig +++ b/.editorconfig @@ -210,7 +210,7 @@ dotnet_analyzer_diagnostic.category-Style.severity = warning dotnet_diagnostic.IDE0004.severity = suggestion # IDE0005: Remove unnecessary usings/imports -dotnet_diagnostic.IDE0005.severity = warning +dotnet_diagnostic.IDE0005.severity = none # Use explicit type instead of 'var' dotnet_diagnostic.IDE0008.severity = suggestion diff --git a/.vsts-dotnet-ci.yml b/.vsts-dotnet-ci.yml index 38f88c99b0..d538f655a8 100644 --- a/.vsts-dotnet-ci.yml +++ b/.vsts-dotnet-ci.yml @@ -234,8 +234,4 @@ jobs: continueOnError: true condition: always() -- template: /eng/common/templates/job/source-build.yml - parameters: - platform: - name: 'Managed' - container: 'mcr.microsoft.com/dotnet-buildtools/prereqs:centos-7' +- template: /eng/common/templates/jobs/source-build.yml diff --git a/Directory.Build.props b/Directory.Build.props index 6db67e877f..c3c6150b3c 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -43,6 +43,14 @@ false + + true + - - - - - - - - - - - - - - - - - - - - - - - diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index b8add39cd0..cee5de6253 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -1,9 +1,9 @@ - + https://github.com/dotnet/source-build-reference-packages - 525b6c35cc5c5c9b80b47044be2e4e77858d505a + 529fbc2aad419d0c1551d6685cc68be33e62a996 $([System.Text.RegularExpressions.Regex]::Match($([System.IO.File]::ReadAllText('$(MSBuildThisFileDirectory)..\global.json')), '"dotnet": "([^"]*)"').Groups.get_Item(1)) 4.2.0-1.22102.8 - 6.0.0-beta.23313.5 + 8.0.0-beta.23364.2 7.0.0 6.0.0 - 4.7.0-3.23361.9 - 6.7.0-rc.111 + 4.8.0-1.23372.1 + 6.8.0-preview.1.41 6.0.0 7.0.3 7.0.0 - 2.4.2 - - - - diff --git a/src/Framework/BuildException/BuildExceptionBase.cs b/src/Framework/BuildException/BuildExceptionBase.cs index acb93434e0..07db4994b9 100644 --- a/src/Framework/BuildException/BuildExceptionBase.cs +++ b/src/Framework/BuildException/BuildExceptionBase.cs @@ -31,6 +31,9 @@ public abstract class BuildExceptionBase : Exception { } // This is needed to allow opting back in to BinaryFormatter serialization +#if NET8_0_OR_GREATER + [Obsolete(DiagnosticId = "SYSLIB0051")] +#endif private protected BuildExceptionBase(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/Framework/InternalErrorException.cs b/src/Framework/InternalErrorException.cs index 4aef7c049e..e024e3f67a 100644 --- a/src/Framework/InternalErrorException.cs +++ b/src/Framework/InternalErrorException.cs @@ -75,6 +75,9 @@ namespace Microsoft.Build.Framework /// Private constructor used for (de)serialization. The constructor is private as this class is sealed /// If we ever add new members to this class, we'll need to update this. /// +#if NET8_0_OR_GREATER + [Obsolete(DiagnosticId = "SYSLIB0051")] +#endif private InternalErrorException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/Framework/LoggerException.cs b/src/Framework/LoggerException.cs index a671142368..05e457d90e 100644 --- a/src/Framework/LoggerException.cs +++ b/src/Framework/LoggerException.cs @@ -82,6 +82,9 @@ namespace Microsoft.Build.Framework /// /// Serialization info /// Streaming context +#if NET8_0_OR_GREATER + [Obsolete(DiagnosticId = "SYSLIB0051")] +#endif protected LoggerException(SerializationInfo info, StreamingContext context) : base(info, context) { @@ -97,6 +100,9 @@ namespace Microsoft.Build.Framework /// Streaming context #if FEATURE_SECURITY_PERMISSIONS [SecurityPermissionAttribute(SecurityAction.Demand, SerializationFormatter = true)] +#endif +#if NET8_0_OR_GREATER + [Obsolete(DiagnosticId = "SYSLIB0051")] #endif public override void GetObjectData(SerializationInfo info, StreamingContext context) { @@ -121,7 +127,7 @@ namespace Microsoft.Build.Framework helpKeyword = state[nameof(helpKeyword)]; } - #endregion +#endregion #region Properties diff --git a/src/MSBuild/CommandLineSwitchException.cs b/src/MSBuild/CommandLineSwitchException.cs index 50cca72257..364fce6da5 100644 --- a/src/MSBuild/CommandLineSwitchException.cs +++ b/src/MSBuild/CommandLineSwitchException.cs @@ -46,6 +46,9 @@ namespace Microsoft.Build.CommandLine /// /// Serialization constructor /// +#if NET8_0_OR_GREATER + [Obsolete(DiagnosticId = "SYSLIB0051")] +#endif private CommandLineSwitchException( SerializationInfo info, StreamingContext context) : @@ -94,6 +97,9 @@ namespace Microsoft.Build.CommandLine /// #if FEATURE_SECURITY_PERMISSIONS [SecurityPermissionAttribute(SecurityAction.Demand, SerializationFormatter = true)] +#endif +#if NET8_0_OR_GREATER + [Obsolete(DiagnosticId = "SYSLIB0051")] #endif public override void GetObjectData(SerializationInfo info, StreamingContext context) { diff --git a/src/MSBuild/InitializationException.cs b/src/MSBuild/InitializationException.cs index ff5a5e21ad..fea748158a 100644 --- a/src/MSBuild/InitializationException.cs +++ b/src/MSBuild/InitializationException.cs @@ -51,6 +51,9 @@ namespace Microsoft.Build.CommandLine /// /// Serialization constructor /// +#if NET8_0_OR_GREATER + [Obsolete(DiagnosticId = "SYSLIB0051")] +#endif private InitializationException( SerializationInfo info, StreamingContext context) : @@ -87,6 +90,9 @@ namespace Microsoft.Build.CommandLine /// #if FEATURE_SECURITY_PERMISSIONS [SecurityPermissionAttribute(SecurityAction.Demand, SerializationFormatter = true)] +#endif +#if NET8_0_OR_GREATER + [Obsolete(DiagnosticId = "SYSLIB0051")] #endif public override void GetObjectData(SerializationInfo info, StreamingContext context) { diff --git a/src/MSBuild/OutOfProcTaskHostNode.cs b/src/MSBuild/OutOfProcTaskHostNode.cs index f1f7c3b7ff..7afa80f780 100644 --- a/src/MSBuild/OutOfProcTaskHostNode.cs +++ b/src/MSBuild/OutOfProcTaskHostNode.cs @@ -1146,7 +1146,9 @@ namespace Microsoft.Build.CommandLine { if (_nodeEndpoint?.LinkStatus == LinkStatus.Active) { +#pragma warning disable SYSLIB0050 if (!e.GetType().GetTypeInfo().IsSerializable) +#pragma warning disable SYSLIB0050 { // log a warning and bail. This will end up re-calling SendBuildEvent, but we know for a fact // that the warning that we constructed is serializable, so everything should be good. diff --git a/src/StringTools.UnitTests/StringTools.UnitTests.net35.csproj b/src/StringTools.UnitTests/StringTools.UnitTests.net35.csproj index 0c10b4d1f0..6b8d8eb14f 100644 --- a/src/StringTools.UnitTests/StringTools.UnitTests.net35.csproj +++ b/src/StringTools.UnitTests/StringTools.UnitTests.net35.csproj @@ -18,8 +18,6 @@ - - diff --git a/src/Tasks/AppConfig/AppConfigException.cs b/src/Tasks/AppConfig/AppConfigException.cs index 82caefb8fc..b059713b9d 100644 --- a/src/Tasks/AppConfig/AppConfigException.cs +++ b/src/Tasks/AppConfig/AppConfigException.cs @@ -66,6 +66,9 @@ namespace Microsoft.Build.Tasks /// /// Construct the exception. /// +#if NET8_0_OR_GREATER + [Obsolete(DiagnosticId = "SYSLIB0051")] +#endif protected AppConfigException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/Tasks/AssemblyDependency/BadImageReferenceException.cs b/src/Tasks/AssemblyDependency/BadImageReferenceException.cs index 8a9cadcc29..a656771729 100644 --- a/src/Tasks/AssemblyDependency/BadImageReferenceException.cs +++ b/src/Tasks/AssemblyDependency/BadImageReferenceException.cs @@ -25,6 +25,9 @@ namespace Microsoft.Build.Tasks /// /// Construct /// +#if NET8_0_OR_GREATER + [Obsolete(DiagnosticId = "SYSLIB0051")] +#endif private BadImageReferenceException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/Tasks/AssemblyDependency/DependencyResolutionException.cs b/src/Tasks/AssemblyDependency/DependencyResolutionException.cs index 402e499998..2e174dadc3 100644 --- a/src/Tasks/AssemblyDependency/DependencyResolutionException.cs +++ b/src/Tasks/AssemblyDependency/DependencyResolutionException.cs @@ -25,6 +25,9 @@ namespace Microsoft.Build.Tasks /// /// Construct /// +#if NET8_0_OR_GREATER + [Obsolete(DiagnosticId = "SYSLIB0051")] +#endif private DependencyResolutionException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/Tasks/AssemblyDependency/InvalidReferenceAssemblyNameException.cs b/src/Tasks/AssemblyDependency/InvalidReferenceAssemblyNameException.cs index 42838f8dc2..55287a9684 100644 --- a/src/Tasks/AssemblyDependency/InvalidReferenceAssemblyNameException.cs +++ b/src/Tasks/AssemblyDependency/InvalidReferenceAssemblyNameException.cs @@ -26,6 +26,9 @@ namespace Microsoft.Build.Tasks /// /// Construct /// +#if NET8_0_OR_GREATER + [Obsolete(DiagnosticId = "SYSLIB0051")] +#endif private InvalidReferenceAssemblyNameException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/Tasks/AssemblyDependency/ReferenceResolutionException.cs b/src/Tasks/AssemblyDependency/ReferenceResolutionException.cs index 621d883489..c924e806f0 100644 --- a/src/Tasks/AssemblyDependency/ReferenceResolutionException.cs +++ b/src/Tasks/AssemblyDependency/ReferenceResolutionException.cs @@ -25,6 +25,9 @@ namespace Microsoft.Build.Tasks /// /// Implement required constructors for serialization /// +#if NET8_0_OR_GREATER + [Obsolete(DiagnosticId = "SYSLIB0051")] +#endif private ReferenceResolutionException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/Tasks/CompatibilitySuppressions.xml b/src/Tasks/CompatibilitySuppressions.xml index be7948e489..498513b70b 100644 --- a/src/Tasks/CompatibilitySuppressions.xml +++ b/src/Tasks/CompatibilitySuppressions.xml @@ -2,7 +2,7 @@ - @@ -12,6 +12,15 @@ ref/net472/Microsoft.Build.Tasks.Core.dll + + + CP1002 + System.Security.Cryptography, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ref/net7.0/Microsoft.Build.Tasks.Core.dll + ref/netstandard2.0/Microsoft.Build.Tasks.Core.dll + true + + + PKV006 net7.0 diff --git a/src/Tasks/GenerateResource.cs b/src/Tasks/GenerateResource.cs index 6ff6c0a5df..535e0a3dd2 100644 --- a/src/Tasks/GenerateResource.cs +++ b/src/Tasks/GenerateResource.cs @@ -3942,6 +3942,9 @@ namespace Microsoft.Build.Tasks private int lineNumber; private int column; +#if NET8_0_OR_GREATER + [Obsolete(DiagnosticId = "SYSLIB0051")] +#endif private TextFileException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/Tasks/InvalidParameterValueException.cs b/src/Tasks/InvalidParameterValueException.cs index cfa9c9f52d..ad9c727d1b 100644 --- a/src/Tasks/InvalidParameterValueException.cs +++ b/src/Tasks/InvalidParameterValueException.cs @@ -38,6 +38,9 @@ namespace Microsoft.Build.Tasks /// /// Constructor /// +#if NET8_0_OR_GREATER + [Obsolete(DiagnosticId = "SYSLIB0051")] +#endif private InvalidParameterValueException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/Tasks/ResourceHandling/InputFormatNotSupportedException.cs b/src/Tasks/ResourceHandling/InputFormatNotSupportedException.cs index a6b797a7d9..f82fb7c775 100644 --- a/src/Tasks/ResourceHandling/InputFormatNotSupportedException.cs +++ b/src/Tasks/ResourceHandling/InputFormatNotSupportedException.cs @@ -23,6 +23,9 @@ namespace Microsoft.Build.Tasks.ResourceHandling { } +#if NET8_0_OR_GREATER + [Obsolete(DiagnosticId = "SYSLIB0051")] +#endif protected InputFormatNotSupportedException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/Tasks/ResourceHandling/MSBuildResXException.cs b/src/Tasks/ResourceHandling/MSBuildResXException.cs index ce6d5b589c..6ef3b33e88 100644 --- a/src/Tasks/ResourceHandling/MSBuildResXException.cs +++ b/src/Tasks/ResourceHandling/MSBuildResXException.cs @@ -23,6 +23,9 @@ namespace Microsoft.Build.Tasks.ResourceHandling { } +#if NET8_0_OR_GREATER + [Obsolete(DiagnosticId = "SYSLIB0051")] +#endif protected MSBuildResXException(SerializationInfo info, StreamingContext context) : base(info, context) { } diff --git a/src/Tasks/ResourceHandling/PreserializedResourceWriterRequiredException.cs b/src/Tasks/ResourceHandling/PreserializedResourceWriterRequiredException.cs index d72a71f17b..5cfea71ab5 100644 --- a/src/Tasks/ResourceHandling/PreserializedResourceWriterRequiredException.cs +++ b/src/Tasks/ResourceHandling/PreserializedResourceWriterRequiredException.cs @@ -13,6 +13,9 @@ namespace Microsoft.Build.Tasks.ResourceHandling { public PreserializedResourceWriterRequiredException() { } +#if NET8_0_OR_GREATER + [Obsolete(DiagnosticId = "SYSLIB0051")] +#endif private PreserializedResourceWriterRequiredException(SerializationInfo info, StreamingContext context) : base(info, context) { } } diff --git a/src/Utilities/CompatibilitySuppressions.xml b/src/Utilities/CompatibilitySuppressions.xml index 1c5e56d19a..bb15e1e6c3 100644 --- a/src/Utilities/CompatibilitySuppressions.xml +++ b/src/Utilities/CompatibilitySuppressions.xml @@ -1,6 +1,14 @@  + + + CP1002 + System.Runtime, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ref/net7.0/Microsoft.Build.Utilities.Core.dll + ref/netstandard2.0/Microsoft.Build.Utilities.Core.dll + true + + PKV006 net7.0 diff --git a/src/Xunit.NetCore.Extensions/DotNetOnlyFactAttribute.cs b/src/Xunit.NetCore.Extensions/DotNetOnlyFactAttribute.cs deleted file mode 100644 index b1b0fb8baa..0000000000 --- a/src/Xunit.NetCore.Extensions/DotNetOnlyFactAttribute.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Xunit.NetCore.Extensions -{ - /// - /// This test should be run only on .NET (or .NET Core). - /// - public class DotNetOnlyFactAttribute : FactAttribute - { - /// - /// Initializes a new instance of the class. - /// - /// The additional message that is appended to skip reason, when test is skipped. - public DotNetOnlyFactAttribute(string? additionalMessage = null) - { - if (!CustomXunitAttributesUtilities.IsBuiltAgainstDotNet) - { - this.Skip = "This test only runs on .NET.".AppendAdditionalMessage(additionalMessage); - } - } - } -} diff --git a/src/Xunit.NetCore.Extensions/DotNetOnlyTheoryAttribute.cs b/src/Xunit.NetCore.Extensions/DotNetOnlyTheoryAttribute.cs deleted file mode 100644 index b6ee768534..0000000000 --- a/src/Xunit.NetCore.Extensions/DotNetOnlyTheoryAttribute.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -namespace Xunit.NetCore.Extensions -{ - /// - /// This test should be run only on .NET (or .NET Core). - /// - public class DotNetOnlyTheoryAttribute : TheoryAttribute - { - /// - /// Initializes a new instance of the class. - /// - /// The additional message that is appended to skip reason, when test is skipped. - public DotNetOnlyTheoryAttribute(string? additionalMessage = null) - { - if (!CustomXunitAttributesUtilities.IsBuiltAgainstDotNet) - { - this.Skip = "This test only runs on .NET.".AppendAdditionalMessage(additionalMessage); - } - } - } -} diff --git a/src/Xunit.NetCore.Extensions/UnixOnlyFactAttribute.cs b/src/Xunit.NetCore.Extensions/UnixOnlyFactAttribute.cs deleted file mode 100644 index f3878ef0de..0000000000 --- a/src/Xunit.NetCore.Extensions/UnixOnlyFactAttribute.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Runtime.InteropServices; - -namespace Xunit.NetCore.Extensions -{ - /// - /// This test should be run only on Unix (Linux, OSX platforms). - /// - public class UnixOnlyFactAttribute : FactAttribute - { - /// - /// Initializes a new instance of the class. - /// - /// The additional message that is appended to skip reason, when test is skipped. - public UnixOnlyFactAttribute(string? additionalMessage = null) - { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - this.Skip = "This test requires Unix to run.".AppendAdditionalMessage(additionalMessage); - } - } - } -} diff --git a/src/Xunit.NetCore.Extensions/UnixOnlyTheoryAttribute.cs b/src/Xunit.NetCore.Extensions/UnixOnlyTheoryAttribute.cs deleted file mode 100644 index f0a1769882..0000000000 --- a/src/Xunit.NetCore.Extensions/UnixOnlyTheoryAttribute.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Runtime.InteropServices; - -namespace Xunit.NetCore.Extensions -{ - /// - /// This test should be run only on Unix (Linux, OSX platforms). - /// - public class UnixOnlyTheoryAttribute : TheoryAttribute - { - /// - /// Initializes a new instance of the class. - /// - /// The additional message that is appended to skip reason, when test is skipped. - public UnixOnlyTheoryAttribute(string? additionalMessage = null) - { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - this.Skip = "This test requires Unix to run.".AppendAdditionalMessage(additionalMessage); - } - } - } -} diff --git a/src/Xunit.NetCore.Extensions/WindowsFullFrameworkOnlyFactAttribute.cs b/src/Xunit.NetCore.Extensions/WindowsFullFrameworkOnlyFactAttribute.cs deleted file mode 100644 index 4caa40a319..0000000000 --- a/src/Xunit.NetCore.Extensions/WindowsFullFrameworkOnlyFactAttribute.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Runtime.InteropServices; - -namespace Xunit.NetCore.Extensions -{ - /// - /// This test should be run only on Windows on full .NET Framework. - /// - public class WindowsFullFrameworkOnlyFactAttribute : FactAttribute - { - /// - /// Initializes a new instance of the class. - /// - /// The additional message that is appended to skip reason, when test is skipped. - public WindowsFullFrameworkOnlyFactAttribute(string? additionalMessage = null) - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - this.Skip = "This test only runs on Windows on full framework.".AppendAdditionalMessage(additionalMessage); - return; - } - if (!CustomXunitAttributesUtilities.IsBuiltAgainstNetFramework) - { - this.Skip = "This test only runs on full framework.".AppendAdditionalMessage(additionalMessage); - } - } - } -} diff --git a/src/Xunit.NetCore.Extensions/WindowsFullFrameworkOnlyTheoryAttribute.cs b/src/Xunit.NetCore.Extensions/WindowsFullFrameworkOnlyTheoryAttribute.cs deleted file mode 100644 index 952bf0d725..0000000000 --- a/src/Xunit.NetCore.Extensions/WindowsFullFrameworkOnlyTheoryAttribute.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Runtime.InteropServices; - -namespace Xunit.NetCore.Extensions -{ - /// - /// This test should be run only on Windows on full .NET Framework. - /// - public class WindowsFullFrameworkOnlyTheoryAttribute : TheoryAttribute - { - /// - /// Initializes a new instance of the class. - /// Creates the attribute. - /// - /// The additional message that is appended to skip reason, when test is skipped. - public WindowsFullFrameworkOnlyTheoryAttribute(string? additionalMessage = null) - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - this.Skip = "This test only runs on Windows on full framework.".AppendAdditionalMessage(additionalMessage); - return; - } - if (!CustomXunitAttributesUtilities.IsBuiltAgainstNetFramework) - { - this.Skip = "This test only runs on full framework.".AppendAdditionalMessage(additionalMessage); - } - } - } -} diff --git a/src/Xunit.NetCore.Extensions/WindowsOnlyFactAttribute.cs b/src/Xunit.NetCore.Extensions/WindowsOnlyFactAttribute.cs deleted file mode 100644 index 72f2378ad0..0000000000 --- a/src/Xunit.NetCore.Extensions/WindowsOnlyFactAttribute.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Runtime.InteropServices; - -namespace Xunit.NetCore.Extensions -{ - /// - /// This test should be run only on Windows. - /// - public class WindowsOnlyFactAttribute : FactAttribute - { - /// - /// Initializes a new instance of the class. - /// - /// The additional message that is appended to skip reason, when test is skipped. - public WindowsOnlyFactAttribute(string? additionalMessage = null) - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - this.Skip = "This test requires Windows to run.".AppendAdditionalMessage(additionalMessage); - } - } - } -} diff --git a/src/Xunit.NetCore.Extensions/WindowsOnlyTheoryAttribute.cs b/src/Xunit.NetCore.Extensions/WindowsOnlyTheoryAttribute.cs deleted file mode 100644 index dfc2be0b22..0000000000 --- a/src/Xunit.NetCore.Extensions/WindowsOnlyTheoryAttribute.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Runtime.InteropServices; - -namespace Xunit.NetCore.Extensions -{ - /// - /// This test should be run only on Windows. - /// - public class WindowsOnlyTheoryAttribute : TheoryAttribute - { - /// - /// Initializes a new instance of the class. - /// - /// The additional message that is appended to skip reason, when test is skipped. - public WindowsOnlyTheoryAttribute(string? additionalMessage = null) - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - this.Skip = "This test requires Windows to run.".AppendAdditionalMessage(additionalMessage); - } - } - } -} diff --git a/src/Xunit.NetCore.Extensions/Xunit.NetCore.Extensions.csproj b/src/Xunit.NetCore.Extensions/Xunit.NetCore.Extensions.csproj index 6bc9b9cbc4..01d47500a3 100644 --- a/src/Xunit.NetCore.Extensions/Xunit.NetCore.Extensions.csproj +++ b/src/Xunit.NetCore.Extensions/Xunit.NetCore.Extensions.csproj @@ -7,6 +7,8 @@ false - + + - \ No newline at end of file +