| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System; |
| | | 5 | | using System.Runtime.CompilerServices; |
| | | 6 | | using System.Runtime.InteropServices; |
| | | 7 | | |
| | | 8 | | namespace Xunit; |
| | | 9 | | |
| | | 10 | | public class NetCoreOnlyFactAttribute : FactAttribute |
| | | 11 | | { |
| | | 12 | | public NetCoreOnlyFactAttribute( |
| | | 13 | | [CallerFilePath] string sourceFilePath = null, |
| | | 14 | | [CallerLineNumber] int sourceLineNumber = -1) |
| | | 15 | | : base(sourceFilePath, sourceLineNumber) |
| | | 16 | | { |
| | | 17 | | if (Environment.Version.Major < 6) |
| | | 18 | | { |
| | | 19 | | Skip = nameof(NetCoreOnlyFactAttribute); |
| | | 20 | | } |
| | | 21 | | } |
| | | 22 | | } |
| | | 23 | | |
| | | 24 | | public class WindowsOnlyFactAttribute : FactAttribute |
| | | 25 | | { |
| | | 26 | | public WindowsOnlyFactAttribute( |
| | | 27 | | [CallerFilePath] string sourceFilePath = null, |
| | | 28 | | [CallerLineNumber] int sourceLineNumber = -1) |
| | | 29 | | : base(sourceFilePath, sourceLineNumber) |
| | | 30 | | { |
| | | 31 | | if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) |
| | | 32 | | { |
| | | 33 | | Skip = nameof(WindowsOnlyFactAttribute); |
| | | 34 | | } |
| | | 35 | | } |
| | | 36 | | } |
| | | 37 | | |
| | | 38 | | public class LinuxOnlyFactAttribute : FactAttribute |
| | | 39 | | { |
| | | 40 | | public LinuxOnlyFactAttribute( |
| | | 41 | | [CallerFilePath] string sourceFilePath = null, |
| | | 42 | | [CallerLineNumber] int sourceLineNumber = -1) |
| | | 43 | | : base(sourceFilePath, sourceLineNumber) |
| | | 44 | | { |
| | | 45 | | if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) |
| | | 46 | | { |
| | | 47 | | Skip = nameof(LinuxOnlyFactAttribute); |
| | | 48 | | } |
| | | 49 | | } |
| | | 50 | | } |
| | | 51 | | |
| | | 52 | | public class WindowsOnlyTheoryAttribute : TheoryAttribute |
| | | 53 | | { |
| | | 54 | | public WindowsOnlyTheoryAttribute( |
| | | 55 | | [CallerFilePath] string sourceFilePath = null, |
| | | 56 | | [CallerLineNumber] int sourceLineNumber = -1) |
| | | 57 | | : base(sourceFilePath, sourceLineNumber) |
| | | 58 | | { |
| | | 59 | | if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) |
| | | 60 | | { |
| | | 61 | | Skip = nameof(WindowsOnlyTheoryAttribute); |
| | | 62 | | } |
| | | 63 | | } |
| | | 64 | | } |
| | | 65 | | |
| | | 66 | | public class WindowsNetCoreOnlyFactAttribute : FactAttribute |
| | | 67 | | { |
| | | 68 | | public WindowsNetCoreOnlyFactAttribute( |
| | | 69 | | [CallerFilePath] string sourceFilePath = null, |
| | | 70 | | [CallerLineNumber] int sourceLineNumber = -1) |
| | 0 | 71 | | : base(sourceFilePath, sourceLineNumber) |
| | | 72 | | { |
| | 0 | 73 | | if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) |
| | 0 | 74 | | || Environment.Version.Major < 6) |
| | | 75 | | { |
| | 0 | 76 | | Skip = nameof(WindowsNetCoreOnlyFactAttribute); |
| | | 77 | | } |
| | 0 | 78 | | } |
| | | 79 | | } |
| | | 80 | | |
| | | 81 | | public class WindowsNetCoreOnlyTheoryAttribute : TheoryAttribute |
| | | 82 | | { |
| | | 83 | | public WindowsNetCoreOnlyTheoryAttribute( |
| | | 84 | | [CallerFilePath] string sourceFilePath = null, |
| | | 85 | | [CallerLineNumber] int sourceLineNumber = -1) |
| | | 86 | | : base(sourceFilePath, sourceLineNumber) |
| | | 87 | | { |
| | | 88 | | if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) |
| | | 89 | | || Environment.Version.Major < 6) |
| | | 90 | | { |
| | | 91 | | Skip = nameof(WindowsNetCoreOnlyTheoryAttribute); |
| | | 92 | | } |
| | | 93 | | } |
| | | 94 | | } |
| | | 95 | | |
| | | 96 | | public class LinuxWhenCIOnlyFactAttribute : FactAttribute |
| | | 97 | | { |
| | | 98 | | public LinuxWhenCIOnlyFactAttribute( |
| | | 99 | | [CallerFilePath] string sourceFilePath = null, |
| | | 100 | | [CallerLineNumber] int sourceLineNumber = -1) |
| | | 101 | | : base(sourceFilePath, sourceLineNumber) |
| | | 102 | | { |
| | | 103 | | if (Environment.GetEnvironmentVariable("CI") == "true") |
| | | 104 | | { |
| | | 105 | | if (!RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) |
| | | 106 | | { |
| | | 107 | | Skip = nameof(LinuxWhenCIOnlyFactAttribute); |
| | | 108 | | } |
| | | 109 | | } |
| | | 110 | | } |
| | | 111 | | } |
| | | 112 | | |
| | | 113 | | public class LinuxWhenCIOnlyTheoryAttribute : TheoryAttribute |
| | | 114 | | { |
| | | 115 | | public LinuxWhenCIOnlyTheoryAttribute( |
| | | 116 | | [CallerFilePath] string sourceFilePath = null, |
| | | 117 | | [CallerLineNumber] int sourceLineNumber = -1) |
| | | 118 | | : base(sourceFilePath, sourceLineNumber) |
| | | 119 | | { |
| | | 120 | | if (Environment.GetEnvironmentVariable("CI") == "true") |
| | | 121 | | { |
| | | 122 | | if (!RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) |
| | | 123 | | { |
| | | 124 | | Skip = nameof(LinuxWhenCIOnlyFactAttribute); |
| | | 125 | | } |
| | | 126 | | } |
| | | 127 | | } |
| | | 128 | | } |
| | | 129 | | |
| | | 130 | | public class SkipOnGeneratedOperationInvokerFactAttribute : FactAttribute |
| | | 131 | | { |
| | | 132 | | public SkipOnGeneratedOperationInvokerFactAttribute( |
| | | 133 | | [CallerFilePath] string sourceFilePath = null, |
| | | 134 | | [CallerLineNumber] int sourceLineNumber = -1) |
| | | 135 | | : base(sourceFilePath, sourceLineNumber) |
| | | 136 | | { |
| | | 137 | | if (AppContext.TryGetSwitch("CoreWCF.Dispatcher.UseGeneratedOperationInvokers", out bool value) && value) |
| | | 138 | | { |
| | | 139 | | Skip = "Class-based service contracts are not supported by generated OperationInvoker"; |
| | | 140 | | } |
| | | 141 | | } |
| | | 142 | | } |
| | | 143 | | |
| | | 144 | | public class SkipOnGeneratedOperationInvokerTheoryAttribute : TheoryAttribute |
| | | 145 | | { |
| | | 146 | | public SkipOnGeneratedOperationInvokerTheoryAttribute( |
| | | 147 | | [CallerFilePath] string sourceFilePath = null, |
| | | 148 | | [CallerLineNumber] int sourceLineNumber = -1) |
| | | 149 | | : base(sourceFilePath, sourceLineNumber) |
| | | 150 | | { |
| | | 151 | | if (AppContext.TryGetSwitch("CoreWCF.Dispatcher.UseGeneratedOperationInvokers", out bool value) && value) |
| | | 152 | | { |
| | | 153 | | Skip = "Class-based service contracts are not supported by generated OperationInvoker"; |
| | | 154 | | } |
| | | 155 | | } |
| | | 156 | | } |