diff --git a/tests/common/ConfigurationXUnit.cs b/tests/common/ConfigurationXUnit.cs index d1555af04e69..73e59dee9b6d 100644 --- a/tests/common/ConfigurationXUnit.cs +++ b/tests/common/ConfigurationXUnit.cs @@ -47,11 +47,38 @@ public override IEnumerable GetData (MethodInfo testMethod) } } + [AttributeUsage (AttributeTargets.Method, AllowMultiple = true, Inherited = true)] + public sealed class AllSupportedPlatformsAttribute : DataAttribute { + + readonly object [] dataValues; + + public AllSupportedPlatformsAttribute (params object [] parameters) + { + dataValues = parameters; + } + + public override IEnumerable GetData (MethodInfo testMethod) + { + return Configuration. + GetIncludedPlatforms (true). + Select (platform => dataValues.Prepend (platform).ToArray ()); + } + } + public partial class Configuration { static string TestAssemblyDirectory { get { return Assembly.GetExecutingAssembly ().Location; } } + + public static bool IsEnabled (ApplePlatform platform) + => platform switch { + ApplePlatform.iOS => include_ios, + ApplePlatform.TVOS => include_tvos, + ApplePlatform.MacCatalyst => include_maccatalyst, + ApplePlatform.MacOSX => include_mac, + _ => false + }; } } diff --git a/tests/rgen/Microsoft.Macios.Generator.Tests/BindingSourceGeneratorGeneratorTests.cs b/tests/rgen/Microsoft.Macios.Generator.Tests/BindingSourceGeneratorGeneratorTests.cs index f22b7e0a4f40..418e5d629454 100644 --- a/tests/rgen/Microsoft.Macios.Generator.Tests/BindingSourceGeneratorGeneratorTests.cs +++ b/tests/rgen/Microsoft.Macios.Generator.Tests/BindingSourceGeneratorGeneratorTests.cs @@ -37,10 +37,7 @@ public partial class AVAudioPcmBuffer "; [Theory] - [PlatformInlineData (ApplePlatform.iOS, usingImportInput, usingImportOutput)] - [PlatformInlineData (ApplePlatform.TVOS, usingImportInput, usingImportOutput)] - [PlatformInlineData (ApplePlatform.MacOSX, usingImportInput, usingImportOutput)] - [PlatformInlineData (ApplePlatform.MacCatalyst, usingImportInput, usingImportOutput)] + [AllSupportedPlatforms (usingImportInput, usingImportOutput)] public void CorrectUsingImports (ApplePlatform platform, string input, string expectedOutput) { // We need to create a compilation with the required source code. diff --git a/tests/rgen/Microsoft.Macios.Generator.Tests/Extensions/BaseTypeDeclarationSyntaxExtensionsTests.cs b/tests/rgen/Microsoft.Macios.Generator.Tests/Extensions/BaseTypeDeclarationSyntaxExtensionsTests.cs index 69b5b2473cc3..a1f1cbf59b24 100644 --- a/tests/rgen/Microsoft.Macios.Generator.Tests/Extensions/BaseTypeDeclarationSyntaxExtensionsTests.cs +++ b/tests/rgen/Microsoft.Macios.Generator.Tests/Extensions/BaseTypeDeclarationSyntaxExtensionsTests.cs @@ -24,10 +24,7 @@ T GetDeclaration (ApplePlatform platform, string inputText) where T : BaseTyp } [Theory] - [PlatformInlineData (ApplePlatform.iOS)] - [PlatformInlineData (ApplePlatform.TVOS)] - [PlatformInlineData (ApplePlatform.MacCatalyst)] - [PlatformInlineData (ApplePlatform.MacOSX)] + [AllSupportedPlatforms] public void GetFullyQualifiedIdentifierFileScopedNamespace (ApplePlatform platform) { const string inputText = @" @@ -40,10 +37,7 @@ public class Foo { } [Theory] - [PlatformInlineData (ApplePlatform.iOS)] - [PlatformInlineData (ApplePlatform.TVOS)] - [PlatformInlineData (ApplePlatform.MacCatalyst)] - [PlatformInlineData (ApplePlatform.MacOSX)] + [AllSupportedPlatforms] public void GetFullyQualifiedIdentifierFileScopedNamespaceNestedClass (ApplePlatform platform) { const string inputText = @" @@ -58,10 +52,7 @@ public enum Bar { } [Theory] - [PlatformInlineData (ApplePlatform.iOS)] - [PlatformInlineData (ApplePlatform.TVOS)] - [PlatformInlineData (ApplePlatform.MacCatalyst)] - [PlatformInlineData (ApplePlatform.MacOSX)] + [AllSupportedPlatforms] public void GetFullyQualifiedIdentifierNamespaceDeclaration (ApplePlatform platform) { const string inputText = @" @@ -75,10 +66,7 @@ public class Foo { } [Theory] - [PlatformInlineData (ApplePlatform.iOS)] - [PlatformInlineData (ApplePlatform.TVOS)] - [PlatformInlineData (ApplePlatform.MacCatalyst)] - [PlatformInlineData (ApplePlatform.MacOSX)] + [AllSupportedPlatforms] public void GetFullyQualifiedIdentifierMultipleNamespaceDeclaration (ApplePlatform platform) { const string inputText = @" @@ -94,10 +82,7 @@ public class Bar {} } [Theory] - [PlatformInlineData (ApplePlatform.iOS)] - [PlatformInlineData (ApplePlatform.TVOS)] - [PlatformInlineData (ApplePlatform.MacCatalyst)] - [PlatformInlineData (ApplePlatform.MacOSX)] + [AllSupportedPlatforms] public void GetFullyQualifiedIdentifierNestedNamespaceDeclaration (ApplePlatform platform) { const string inputText = @" @@ -112,10 +97,7 @@ public class Test {} } [Theory] - [PlatformInlineData (ApplePlatform.iOS)] - [PlatformInlineData (ApplePlatform.TVOS)] - [PlatformInlineData (ApplePlatform.MacCatalyst)] - [PlatformInlineData (ApplePlatform.MacOSX)] + [AllSupportedPlatforms] public void GetFullyQualifiedIdentifierNamespaceDeclarationNestedClass (ApplePlatform platform) { const string inputText = @" diff --git a/tests/rgen/Microsoft.Macios.Generator.Tests/Extensions/MemberDeclarationSyntaxExtensionsTests.cs b/tests/rgen/Microsoft.Macios.Generator.Tests/Extensions/MemberDeclarationSyntaxExtensionsTests.cs index f77c4cb613c2..8ffe02f04a77 100644 --- a/tests/rgen/Microsoft.Macios.Generator.Tests/Extensions/MemberDeclarationSyntaxExtensionsTests.cs +++ b/tests/rgen/Microsoft.Macios.Generator.Tests/Extensions/MemberDeclarationSyntaxExtensionsTests.cs @@ -9,10 +9,7 @@ namespace Microsoft.Macios.Generator.Tests.Extensions; public class MemberDeclarationSyntaxExtensionsTests : BaseGeneratorTestClass { [Theory] - [PlatformInlineData (ApplePlatform.iOS)] - [PlatformInlineData (ApplePlatform.TVOS)] - [PlatformInlineData (ApplePlatform.MacOSX)] - [PlatformInlineData (ApplePlatform.MacCatalyst)] + [AllSupportedPlatforms] public void GetAttributeCodeChanges (ApplePlatform platform) { var attrsText = @" @@ -99,10 +96,7 @@ public interface IInterface { } [Theory] - [PlatformInlineData (ApplePlatform.iOS)] - [PlatformInlineData (ApplePlatform.TVOS)] - [PlatformInlineData (ApplePlatform.MacOSX)] - [PlatformInlineData (ApplePlatform.MacCatalyst)] + [AllSupportedPlatforms] public void GetAttributeCodeChangesSameAttrDiffText (ApplePlatform platform) { const string inputText = @" @@ -144,10 +138,7 @@ public void SayGoodbye () { } [Theory] - [PlatformInlineData (ApplePlatform.iOS)] - [PlatformInlineData (ApplePlatform.TVOS)] - [PlatformInlineData (ApplePlatform.MacOSX)] - [PlatformInlineData (ApplePlatform.MacCatalyst)] + [AllSupportedPlatforms] public void GetAttributeCodeChangesTypeOf (ApplePlatform platform) {