diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 9b97a25..e0a5975 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -2,7 +2,7 @@ 1.9.0-pre2 - 6.8.0 + 6.8.1 diff --git a/src/InlineIL.Tests/InlineIL.Tests.csproj b/src/InlineIL.Tests/InlineIL.Tests.csproj index 373d54b..0b5d5ac 100644 --- a/src/InlineIL.Tests/InlineIL.Tests.csproj +++ b/src/InlineIL.Tests/InlineIL.Tests.csproj @@ -13,10 +13,10 @@ - + - - + + diff --git a/src/InlineIL.Tests/Support/DebugTestAttribute.cs b/src/InlineIL.Tests/Support/DebugTestAttribute.cs deleted file mode 100644 index 2413172..0000000 --- a/src/InlineIL.Tests/Support/DebugTestAttribute.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System.Diagnostics; -using Xunit; - -namespace InlineIL.Tests.Support; - -public class DebugTestAttribute : FactAttribute -{ - public override string? Skip - { - get - { - if (base.Skip != null) - return base.Skip; - - if (!Debugger.IsAttached) - return "Debug test"; - - return null; - } - set => base.Skip = value; - } -} diff --git a/src/InlineIL.Tests/Support/Facts.cs b/src/InlineIL.Tests/Support/Facts.cs new file mode 100644 index 0000000..30cb396 --- /dev/null +++ b/src/InlineIL.Tests/Support/Facts.cs @@ -0,0 +1,51 @@ +using System; +using System.Diagnostics; +using System.Reflection; +using System.Runtime.InteropServices; +using Xunit; + +namespace InlineIL.Tests.Support; + +public abstract class SkippableFactAttribute : FactAttribute +{ + public sealed override string? Skip + { + get => base.Skip ?? GetSkipMessage(); + set => base.Skip = value; + } + + protected abstract string? GetSkipMessage(); +} + +public class DebugTestAttribute : SkippableFactAttribute +{ + protected override string? GetSkipMessage() + => Debugger.IsAttached ? null : "Debug test"; +} + +public class ReleaseFactAttribute : SkippableFactAttribute +{ + private readonly Type _typeFromAssembly; + + public ReleaseFactAttribute(Type typeFromAssembly) + => _typeFromAssembly = typeFromAssembly; + + protected override string? GetSkipMessage() + { + if (((_typeFromAssembly.Assembly.GetCustomAttribute()?.DebuggingFlags ?? DebuggableAttribute.DebuggingModes.Default) & DebuggableAttribute.DebuggingModes.DisableOptimizations) != 0) + return "Inconclusive in debug builds"; + + return null; + } +} + +public class VarargFactAttribute : SkippableFactAttribute +{ + protected override string? GetSkipMessage() + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) || RuntimeInformation.ProcessArchitecture is not (Architecture.X86 or Architecture.X64)) + return "Varargs are not supported on this platform"; + + return null; + } +} diff --git a/src/InlineIL.Tests/Support/ReleaseFactAttribute.cs b/src/InlineIL.Tests/Support/ReleaseFactAttribute.cs deleted file mode 100644 index f8847e7..0000000 --- a/src/InlineIL.Tests/Support/ReleaseFactAttribute.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Diagnostics; -using System.Reflection; -using Xunit; - -namespace InlineIL.Tests.Support; - -public class ReleaseFactAttribute : FactAttribute -{ - private readonly Type _typeFromAssembly; - - public ReleaseFactAttribute(Type typeFromAssembly) - { - _typeFromAssembly = typeFromAssembly; - } - - public override string? Skip - { - get - { - if (base.Skip != null) - return base.Skip; - - if (((_typeFromAssembly.Assembly.GetCustomAttribute()?.DebuggingFlags ?? DebuggableAttribute.DebuggingModes.Default) & DebuggableAttribute.DebuggingModes.DisableOptimizations) != 0) - return "Inconclusive in debug builds"; - - return null; - } - set => base.Skip = value; - } -} diff --git a/src/InlineIL.Tests/Weaving/MethodRefTests.cs b/src/InlineIL.Tests/Weaving/MethodRefTests.cs index 961bdc8..0ad2fda 100644 --- a/src/InlineIL.Tests/Weaving/MethodRefTests.cs +++ b/src/InlineIL.Tests/Weaving/MethodRefTests.cs @@ -1,7 +1,6 @@ using System; using System.Diagnostics.CodeAnalysis; using System.Reflection; -using System.Runtime.InteropServices; using System.Text; using InlineIL.Tests.Common; using InlineIL.Tests.Support; @@ -421,16 +420,6 @@ public void should_call_conversion_operators() result.ShouldEqual([1, 2, 3, 4, 5, 6, 101, 102, 1, 3, 102]); } - [Fact] - public void should_call_vararg_method() - { - if (NetStandard || !RuntimeInformation.IsOSPlatform(OSPlatform.Windows) || RuntimeInformation.ProcessArchitecture is not (Architecture.X86 or Architecture.X64)) - return; - - var result = (int[])GetInstance().CallVarArgMethod(); - result.ShouldEqual([1, 2, 3, 0, 0]); - } - [Fact] public void should_report_generic_args_on_normal_method() { @@ -676,11 +665,26 @@ public void should_call_generic_method_of_forwarded_type() var result = (IEnumerable)GetInstance().CallGenericMethodOfForwardedType(); result.ShouldEqual(["Hello", "Hello"]); } + + [VarargFact] + public void should_call_vararg_method() + { + var result = (int[])GetInstance().CallVarArgMethod(); + result.ShouldEqual([1, 2, 3, 0, 0]); + } } #endif #if NETFRAMEWORK -public class MethodRefTestsFramework : MethodRefTestsBase; +public class MethodRefTestsFramework : MethodRefTestsBase +{ + [VarargFact] + public void should_call_vararg_method() + { + var result = (int[])GetInstance().CallVarArgMethod(); + result.ShouldEqual([1, 2, 3, 0, 0]); + } +} #endif [UsedImplicitly]