From d2ca8e1422c95aabc797249cef296e41ca2fd14e Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Mon, 25 Oct 2021 20:15:01 -0700 Subject: [PATCH] [DllImportGenerator] Skip unit tests that hit exceptions due to roslyn-sdk#590 (#60848) --- .../AdditionalAttributesOnStub.cs | 14 +-- .../AttributeForwarding.cs | 10 +- .../CompileFails.cs | 4 +- .../DllImportGenerator.UnitTests/Compiles.cs | 18 +-- ...onvertToGeneratedDllImportAnalyzerTests.cs | 10 +- .../ConvertToGeneratedDllImportFixerTests.cs | 14 +-- .../Diagnostics.cs | 20 +-- .../DllImportGenerator.Unit.Tests.csproj | 2 +- .../GeneratedDllImportAnalyzerTests.cs | 14 +-- .../IncrementalGenerationTests.cs | 12 +- .../ManualTypeMarshallingAnalyzerTests.cs | 118 +++++++++--------- .../DllImportGenerator.UnitTests/TestUtils.cs | 15 +++ .../Verifiers/CSharpCodeFixVerifier.cs | 13 ++ 13 files changed, 145 insertions(+), 119 deletions(-) diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/AdditionalAttributesOnStub.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/AdditionalAttributesOnStub.cs index 1e3c0319593b17..df7a1c536a8a93 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/AdditionalAttributesOnStub.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/AdditionalAttributesOnStub.cs @@ -3,11 +3,9 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Testing; -using System; using System.Collections.Generic; using System.Linq; using System.Runtime.CompilerServices; -using System.Text; using System.Threading.Tasks; using Xunit; @@ -15,7 +13,7 @@ namespace DllImportGenerator.UnitTests { public class AdditionalAttributesOnStub { - [Fact] + [ConditionalFact] public async Task SkipLocalsInitAdded() { string source = @" @@ -45,7 +43,7 @@ public Native(S s) { } Assert.Contains(stubMethod.GetAttributes(), attr => attr.AttributeClass!.ToDisplayString() == typeof(SkipLocalsInitAttribute).FullName); } - [Fact] + [ConditionalFact] public async Task SkipLocalsInitNotAddedOnForwardingStub() { string source = @" @@ -72,7 +70,7 @@ public static IEnumerable GetDownlevelTargetFrameworks() yield return new object[] { ReferenceAssemblies.NetFramework.Net48.Default, false }; } - [Theory] + [ConditionalTheory] [MemberData(nameof(GetDownlevelTargetFrameworks))] public async Task SkipLocalsInitOnDownlevelTargetFrameworks(ReferenceAssemblies referenceAssemblies, bool expectSkipLocalsInit) { @@ -122,7 +120,7 @@ public Native(S s) { } } } - [Fact] + [ConditionalFact] public async Task SkipLocalsInitNotAddedWhenDefinedAtModuleLevel() { string source = @" @@ -154,7 +152,7 @@ public Native(S s) { } Assert.DoesNotContain(stubMethod.GetAttributes(), attr => attr.AttributeClass!.ToDisplayString() == typeof(SkipLocalsInitAttribute).FullName); } - [Fact] + [ConditionalFact] public async Task SkipLocalsInitNotAddedWhenDefinedAtClassLevel() { string source = @" @@ -186,7 +184,7 @@ public Native(S s) { } Assert.DoesNotContain(stubMethod.GetAttributes(), attr => attr.AttributeClass!.ToDisplayString() == typeof(SkipLocalsInitAttribute).FullName); } - [Fact] + [ConditionalFact] public async Task SkipLocalsInitNotAddedWhenDefinedOnMethodByUser() { string source = @" diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/AttributeForwarding.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/AttributeForwarding.cs index 0f87246c068e1d..70090ee6dcbc95 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/AttributeForwarding.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/AttributeForwarding.cs @@ -14,7 +14,7 @@ namespace DllImportGenerator.UnitTests { public class AttributeForwarding { - [Theory] + [ConditionalTheory] [InlineData("SuppressGCTransition", "System.Runtime.InteropServices.SuppressGCTransitionAttribute")] [InlineData("UnmanagedCallConv", "System.Runtime.InteropServices.UnmanagedCallConvAttribute")] public async Task KnownParameterlessAttribute(string attributeSourceName, string attributeMetadataName) @@ -54,7 +54,7 @@ public Native(S s) {{ }} attr => SymbolEqualityComparer.Default.Equals(attr.AttributeClass, attributeType)); } - [Fact] + [ConditionalFact] public async Task UnmanagedCallConvAttribute_EmptyCallConvArray() { string source = @" @@ -96,7 +96,7 @@ public Native(S s) { } && attr.NamedArguments[0].Value.Values.Length == 0); } - [Fact] + [ConditionalFact] public async Task UnmanagedCallConvAttribute_SingleCallConvType() { string source = @" @@ -142,7 +142,7 @@ public Native(S s) { } callConvType)); } - [Fact] + [ConditionalFact] public async Task UnmanagedCallConvAttribute_MultipleCallConvTypes() { string source = @" @@ -192,7 +192,7 @@ public Native(S s) { } callConvType2)); } - [Fact] + [ConditionalFact] public async Task OtherAttributeType() { string source = @" diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs index 30895d04149d99..39958354b44136 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/CompileFails.cs @@ -127,7 +127,7 @@ public static IEnumerable CodeSnippetsToCompile() yield return new object[] { CodeSnippets.MutuallyRecursiveSizeParamIndexOnParameter, 4, 0 }; } - [Theory] + [ConditionalTheory] [MemberData(nameof(CodeSnippetsToCompile))] public async Task ValidateSnippets(string source, int expectedGeneratorErrors, int expectedCompilerErrors) { @@ -150,7 +150,7 @@ public static IEnumerable CodeSnippetsToCompile_InvalidCode() yield return new object[] { CodeSnippets.MutuallyRecursiveImplicitlyBlittableStruct, 5, 2 }; } - [Theory] + [ConditionalTheory] [MemberData(nameof(CodeSnippetsToCompile_InvalidCode))] public async Task ValidateSnippets_InvalidCodeGracefulFailure(string source, int expectedGeneratorErrors, int expectedCompilerErrors) { diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs index c44c1141131342..d7d40535d65e8f 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Compiles.cs @@ -269,7 +269,7 @@ public static IEnumerable CodeSnippetsToCompile() yield return new[] { CodeSnippets.CollectionsOfCollectionsStress }; } - [Theory] + [ConditionalTheory] [MemberData(nameof(CodeSnippetsToCompile))] public async Task ValidateSnippets(string source) { @@ -295,7 +295,7 @@ public static IEnumerable CodeSnippetsToCompileWithPreprocessorSymbols yield return new object[] { CodeSnippets.PreprocessorIfAfterAttributeAroundFunctionAdditionalFunctionAfter("Foo"), Array.Empty() }; } - [Theory] + [ConditionalTheory] [MemberData(nameof(CodeSnippetsToCompileWithPreprocessorSymbols))] public async Task ValidateSnippetsWithPreprocessorDefintions(string source, IEnumerable preprocessorSymbols) { @@ -320,7 +320,7 @@ public static IEnumerable CodeSnippetsToCompileWithForwarder() yield return new[] { CodeSnippets.BasicParametersAndModifiers() }; } - [Theory] + [ConditionalTheory] [MemberData(nameof(CodeSnippetsToCompileWithForwarder))] public async Task ValidateSnippetsWithForwarder(string source) { @@ -338,7 +338,7 @@ public async Task ValidateSnippetsWithForwarder(string source) var newCompDiags = newComp.GetDiagnostics(); Assert.Empty(newCompDiags); - // Verify that the forwarder generates the method as a DllImport. + // Verify that the forwarder generates the method as a DllImport. SyntaxTree generatedCode = newComp.SyntaxTrees.Last(); SemanticModel model = newComp.GetSemanticModel(generatedCode); var methods = generatedCode.GetRoot() @@ -357,7 +357,7 @@ public static IEnumerable FullyBlittableSnippetsToCompile() yield return new[] { CodeSnippets.BasicParameterByValue("int") }; } - [Theory] + [ConditionalTheory] [MemberData(nameof(FullyBlittableSnippetsToCompile))] public async Task ValidateSnippetsWithBlittableAutoForwarding(string source) { @@ -374,7 +374,7 @@ public async Task ValidateSnippetsWithBlittableAutoForwarding(string source) var newCompDiags = newComp.GetDiagnostics(); Assert.Empty(newCompDiags); - // Verify that the forwarder generates the method as a DllImport. + // Verify that the forwarder generates the method as a DllImport. SyntaxTree generatedCode = newComp.SyntaxTrees.Last(); SemanticModel model = newComp.GetSemanticModel(generatedCode); var methods = generatedCode.GetRoot() @@ -391,7 +391,7 @@ public static IEnumerable SnippetsWithBlittableTypesButNonBlittableDat yield return new[] { CodeSnippets.PreserveSigFalse() }; } - [Theory] + [ConditionalTheory] [MemberData(nameof(SnippetsWithBlittableTypesButNonBlittableDataToCompile))] public async Task ValidateSnippetsWithBlittableTypesButNonBlittableMetadataDoNotAutoForward(string source) { @@ -429,7 +429,7 @@ public static IEnumerable CodeSnippetsToCompileWithMarshalType() #pragma warning disable xUnit1004 // Test methods should not be skipped. // If we have any new experimental APIs that we are implementing that have not been approved, // we will add new scenarios for this test. - [Theory(Skip = "No current scenarios to test.")] + [ConditionalTheory(Skip = "No current scenarios to test.")] #pragma warning restore [MemberData(nameof(CodeSnippetsToCompileWithMarshalType))] public async Task ValidateSnippetsWithMarshalType(string source) @@ -461,7 +461,7 @@ public static IEnumerable CodeSnippetsToCompileMultipleSources() yield return new object[] { new[] { CodeSnippets.BasicParameterByValue("int[]"), CodeSnippets.BasicParameterWithByRefModifier("ref", "int") } }; } - [Theory] + [ConditionalTheory] [MemberData(nameof(CodeSnippetsToCompileMultipleSources))] public async Task ValidateSnippetsWithMultipleSources(string[] sources) { diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ConvertToGeneratedDllImportAnalyzerTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ConvertToGeneratedDllImportAnalyzerTests.cs index 2329c3d221b77b..8d99a8204f2bb6 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ConvertToGeneratedDllImportAnalyzerTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ConvertToGeneratedDllImportAnalyzerTests.cs @@ -37,7 +37,7 @@ public static IEnumerable NoMarshallingRequiredTypes() => new[] new object[] { typeof(ConsoleKey) }, // enum }; - [Theory] + [ConditionalTheory] [MemberData(nameof(MarshallingRequiredTypes))] [MemberData(nameof(NoMarshallingRequiredTypes))] public async Task TypeRequiresMarshalling_ReportsDiagnostic(Type type) @@ -53,7 +53,7 @@ await VerifyCS.VerifyAnalyzerAsync( .WithArguments("Method_Return")); } - [Theory] + [ConditionalTheory] [MemberData(nameof(MarshallingRequiredTypes))] [MemberData(nameof(NoMarshallingRequiredTypes))] public async Task ByRef_ReportsDiagnostic(Type type) @@ -86,7 +86,7 @@ await VerifyCS.VerifyAnalyzerAsync( .WithArguments("Method_Ref")); } - [Fact] + [ConditionalFact] public async Task PreserveSigFalse_ReportsDiagnostic() { string source = @$" @@ -110,7 +110,7 @@ await VerifyCS.VerifyAnalyzerAsync( .WithArguments("Method2")); } - [Fact] + [ConditionalFact] public async Task SetLastErrorTrue_ReportsDiagnostic() { string source = @$" @@ -134,7 +134,7 @@ await VerifyCS.VerifyAnalyzerAsync( .WithArguments("Method2")); } - [Fact] + [ConditionalFact] public async Task NotDllImport_NoDiagnostic() { string source = @$" diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ConvertToGeneratedDllImportFixerTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ConvertToGeneratedDllImportFixerTests.cs index 15519be05f4a29..c6c61fe1e2c52d 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ConvertToGeneratedDllImportFixerTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ConvertToGeneratedDllImportFixerTests.cs @@ -17,7 +17,7 @@ namespace DllImportGenerator.UnitTests [ActiveIssue("https://github.com/dotnet/runtime/issues/60650", TestRuntimes.Mono)] public class ConvertToGeneratedDllImportFixerTests { - [Theory] + [ConditionalTheory] [InlineData(true)] [InlineData(false)] public async Task Basic(bool usePreprocessorDefines) @@ -56,7 +56,7 @@ await VerifyCS.VerifyCodeFixAsync( usePreprocessorDefines ? WithPreprocessorDefinesKey : NoPreprocessorDefinesKey); } - [Theory] + [ConditionalTheory] [InlineData(true)] [InlineData(false)] public async Task Comments(bool usePreprocessorDefines) @@ -119,7 +119,7 @@ await VerifyCS.VerifyCodeFixAsync( usePreprocessorDefines ? WithPreprocessorDefinesKey : NoPreprocessorDefinesKey); } - [Theory] + [ConditionalTheory] [InlineData(true)] [InlineData(false)] public async Task MultipleAttributes(bool usePreprocessorDefines) @@ -180,7 +180,7 @@ await VerifyCS.VerifyCodeFixAsync( usePreprocessorDefines ? WithPreprocessorDefinesKey : NoPreprocessorDefinesKey); } - [Theory] + [ConditionalTheory] [InlineData(true)] [InlineData(false)] public async Task NamedArguments(bool usePreprocessorDefines) @@ -232,7 +232,7 @@ await VerifyCS.VerifyCodeFixAsync( usePreprocessorDefines ? WithPreprocessorDefinesKey : NoPreprocessorDefinesKey); } - [Theory] + [ConditionalTheory] [InlineData(true)] [InlineData(false)] public async Task RemoveableNamedArguments(bool usePreprocessorDefines) @@ -284,7 +284,7 @@ await VerifyCS.VerifyCodeFixAsync( usePreprocessorDefines ? WithPreprocessorDefinesKey : NoPreprocessorDefinesKey); } - [Theory] + [ConditionalTheory] [InlineData(true)] [InlineData(false)] public async Task ReplaceableExplicitPlatformDefaultCallingConvention(bool usePreprocessorDefines) @@ -322,7 +322,7 @@ await VerifyCS.VerifyCodeFixAsync( usePreprocessorDefines ? WithPreprocessorDefinesKey : NoPreprocessorDefinesKey); } - [Theory] + [ConditionalTheory] [InlineData(CallingConvention.Cdecl, typeof(CallConvCdecl), true)] [InlineData(CallingConvention.Cdecl, typeof(CallConvCdecl), false)] [InlineData(CallingConvention.StdCall, typeof(CallConvStdcall), true)] diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Diagnostics.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Diagnostics.cs index df6da9008696a2..fdeee50748409c 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Diagnostics.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Diagnostics.cs @@ -24,7 +24,7 @@ public enum TargetFramework Net } - [Theory] + [ConditionalTheory] [InlineData(TargetFramework.Framework)] [InlineData(TargetFramework.Core)] [InlineData(TargetFramework.Standard)] @@ -61,7 +61,7 @@ partial class Test Assert.Empty(newCompDiags); } - [Theory] + [ConditionalTheory] [InlineData(TargetFramework.Framework)] [InlineData(TargetFramework.Core)] [InlineData(TargetFramework.Standard)] @@ -85,7 +85,7 @@ partial class Test Assert.Empty(newCompDiags); } - [Fact] + [ConditionalFact] public async Task ParameterTypeNotSupported_ReportsDiagnostic() { string source = @" @@ -123,7 +123,7 @@ partial class Test Assert.Empty(newCompDiags); } - [Fact] + [ConditionalFact] public async Task ReturnTypeNotSupported_ReportsDiagnostic() { string source = @" @@ -161,7 +161,7 @@ partial class Test Assert.Empty(newCompDiags); } - [Fact] + [ConditionalFact] public async Task ParameterTypeNotSupportedWithDetails_ReportsDiagnostic() { string source = @" @@ -189,7 +189,7 @@ partial class Test Assert.Empty(newCompDiags); } - [Fact] + [ConditionalFact] public async Task ReturnTypeNotSupportedWithDetails_ReportsDiagnostic() { string source = @" @@ -220,7 +220,7 @@ partial class Test Assert.Empty(newCompDiags); } - [Fact] + [ConditionalFact] public async Task ParameterConfigurationNotSupported_ReportsDiagnostic() { string source = @" @@ -253,7 +253,7 @@ partial class Test Assert.Empty(newCompDiags); } - [Fact] + [ConditionalFact] public async Task ReturnConfigurationNotSupported_ReportsDiagnostic() { string source = @" @@ -288,7 +288,7 @@ partial class Test Assert.Empty(newCompDiags); } - [Fact] + [ConditionalFact] public async Task MarshalAsUnmanagedTypeNotSupported_ReportsDiagnostic() { string source = @" @@ -328,7 +328,7 @@ partial class Test Assert.Empty(newCompDiags); } - [Fact] + [ConditionalFact] public async Task MarshalAsFieldNotSupported_ReportsDiagnostic() { string source = @" diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.Unit.Tests.csproj b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.Unit.Tests.csproj index 0df9bfb16d1223..0f5e5915be1dd5 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.Unit.Tests.csproj +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/DllImportGenerator.Unit.Tests.csproj @@ -1,4 +1,4 @@ - + $(NetCoreAppCurrent) diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/GeneratedDllImportAnalyzerTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/GeneratedDllImportAnalyzerTests.cs index 5c6856dc895b36..0d54d8ce058ecd 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/GeneratedDllImportAnalyzerTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/GeneratedDllImportAnalyzerTests.cs @@ -12,7 +12,7 @@ namespace DllImportGenerator.UnitTests [ActiveIssue("https://github.com/dotnet/runtime/issues/60650", TestRuntimes.Mono)] public class GeneratedDllImportAnalyzerTests { - [Fact] + [ConditionalFact] public async Task NonPartialMethod_ReportsDiagnostic() { string source = @" @@ -48,7 +48,7 @@ await VerifyCS.VerifyAnalyzerAsync( .WithArguments("ExternMethod2")); } - [Fact] + [ConditionalFact] public async Task NonStaticMethod_ReportsDiagnostic() { string source = @" @@ -80,7 +80,7 @@ await VerifyCS.VerifyAnalyzerAsync( .WithArguments("Method1")); } - [Fact] + [ConditionalFact] public async Task NonPartialNonStaticMethod_ReportsDiagnostic() { string source = @" @@ -116,7 +116,7 @@ await VerifyCS.VerifyAnalyzerAsync( .WithArguments("ExternMethod2")); } - [Fact] + [ConditionalFact] public async Task NotGeneratedDllImport_NoDiagnostic() { string source = @" @@ -130,7 +130,7 @@ public void Method1() { } await VerifyCS.VerifyAnalyzerAsync(source); } - [Fact] + [ConditionalFact] public async Task StaticPartialMethod_NoDiagnostic() { string source = @" @@ -144,7 +144,7 @@ partial class Test await VerifyCS.VerifyAnalyzerAsync(source); } - [Theory] + [ConditionalTheory] [InlineData("class")] [InlineData("struct")] [InlineData("record")] @@ -167,7 +167,7 @@ await VerifyCS.VerifyAnalyzerAsync( .WithArguments("Test")); } - [Theory] + [ConditionalTheory] [InlineData("class")] [InlineData("struct")] [InlineData("record")] diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/IncrementalGenerationTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/IncrementalGenerationTests.cs index 75e5de8f546edd..d14773de2f07f9 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/IncrementalGenerationTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/IncrementalGenerationTests.cs @@ -19,7 +19,7 @@ public class IncrementalGenerationTests public const string RequiresIncrementalSyntaxTreeModifySupport = "The GeneratorDriver treats all SyntaxTree replace operations on a Compilation as an Add/Remove operation instead of a Modify operation" + ", so all cached results based on that input are thrown out. As a result, we cannot validate that unrelated changes within the same SyntaxTree do not cause regeneration."; - [Fact] + [ConditionalFact] public async Task AddingNewUnrelatedType_DoesNotRegenerateSource() { string source = CodeSnippets.BasicParametersAndModifiers(); @@ -44,7 +44,7 @@ public async Task AddingNewUnrelatedType_DoesNotRegenerateSource() } #pragma warning disable xUnit1004 // Test methods should not be skipped. These tests will be updated to use the new incremental work tracking APIs and enabled then. - [Fact(Skip = RequiresIncrementalSyntaxTreeModifySupport)] + [ConditionalFact(Skip = RequiresIncrementalSyntaxTreeModifySupport)] #pragma warning restore public async Task AppendingUnrelatedSource_DoesNotRegenerateSource() { @@ -73,7 +73,7 @@ public async Task AppendingUnrelatedSource_DoesNotRegenerateSource() }); } - [Fact] + [ConditionalFact] public async Task AddingFileWithNewGeneratedDllImport_DoesNotRegenerateOriginalMethod() { string source = CodeSnippets.BasicParametersAndModifiers(); @@ -97,7 +97,7 @@ public async Task AddingFileWithNewGeneratedDllImport_DoesNotRegenerateOriginalM Assert.Equal(1, generator.IncrementalTracker.ExecutedSteps.Count(s => s.Step == IncrementalityTracker.StepName.OutputSourceFile)); } - [Fact] + [ConditionalFact] public async Task ReplacingFileWithNewGeneratedDllImport_DoesNotRegenerateStubsInOtherFiles() { string source = CodeSnippets.BasicParametersAndModifiers(); @@ -121,7 +121,7 @@ public async Task ReplacingFileWithNewGeneratedDllImport_DoesNotRegenerateStubsI Assert.Equal(1, generator.IncrementalTracker.ExecutedSteps.Count(s => s.Step == IncrementalityTracker.StepName.OutputSourceFile)); } - [Fact] + [ConditionalFact] public async Task ChangingMarshallingStrategy_RegeneratesStub() { string stubSource = CodeSnippets.BasicParametersAndModifiers("CustomType"); @@ -170,7 +170,7 @@ public async Task ChangingMarshallingStrategy_RegeneratesStub() } #pragma warning disable xUnit1004 // Test methods should not be skipped. These tests will be updated to use the new incremental work tracking APIs and enabled then. - [Fact(Skip = RequiresIncrementalSyntaxTreeModifySupport)] + [ConditionalFact(Skip = RequiresIncrementalSyntaxTreeModifySupport)] #pragma warning restore public async Task ChangingMarshallingAttributes_SameStrategy_DoesNotRegenerate() { diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ManualTypeMarshallingAnalyzerTests.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ManualTypeMarshallingAnalyzerTests.cs index 028269fee619c5..ba00865d9f3ae2 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ManualTypeMarshallingAnalyzerTests.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/ManualTypeMarshallingAnalyzerTests.cs @@ -59,14 +59,14 @@ struct S } [MemberData(nameof(NonBlittableTypeMarkedBlittable_ReportsDiagnostic_TestData))] - [Theory] + [ConditionalTheory] public async Task NonBlittableTypeMarkedBlittable_ReportsDiagnostic(string source) { var diagnostic = VerifyCS.Diagnostic(BlittableTypeMustBeBlittableRule).WithLocation(0).WithArguments("S"); await VerifyCS.VerifyAnalyzerAsync(source, diagnostic); } - [Fact] + [ConditionalFact] public async Task BlittablePrimitiveFields_MarkedBlittable_NoDiagnostic() { @@ -82,7 +82,7 @@ struct S await VerifyCS.VerifyAnalyzerAsync(source); } - [Fact] + [ConditionalFact] public async Task BlittableEnumFields_MarkedBlittable_NoDiagnostic() { @@ -100,7 +100,7 @@ struct S await VerifyCS.VerifyAnalyzerAsync(source); } - [Fact] + [ConditionalFact] public async Task BlittableStructFields_MarkedBlittable_NoDiagnostic() { string source = @" @@ -121,7 +121,7 @@ struct T await VerifyCS.VerifyAnalyzerAsync(source); } - [Fact] + [ConditionalFact] public async Task NonBlittableFields_MarkedBlittable_ReportDiagnosticOnFieldTypeDefinition() { string source = @" @@ -143,7 +143,7 @@ struct T await VerifyCS.VerifyAnalyzerAsync(source, diagnostic); } - [Fact] + [ConditionalFact] public async Task NonUnmanagedTypeMarkedBlittable_ReportsDiagnosticOnStructType() { string source = @" @@ -165,7 +165,7 @@ await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(BlittableTypeMustBeBlittableRule).WithLocation(0).WithArguments("T")); } - [Fact] + [ConditionalFact] public async Task BlittableTypeWithNonBlittableStaticField_DoesNotReportDiagnostic() { string source = @" @@ -181,7 +181,7 @@ struct S await VerifyCS.VerifyAnalyzerAsync(source); } - [Fact] + [ConditionalFact] public async Task NullNativeType_ReportsDiagnostic() { string source = @" @@ -197,7 +197,7 @@ await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(NativeTypeMustBeNonNullRule).WithLocation(0).WithArguments("S")); } - [Fact] + [ConditionalFact] public async Task NonNamedNativeType_ReportsDiagnostic() { string source = @" @@ -213,7 +213,7 @@ await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(NativeTypeMustHaveRequiredShapeRule).WithLocation(0).WithArguments("int*", "S")); } - [Fact] + [ConditionalFact] public async Task NonBlittableNativeType_ReportsDiagnostic() { string source = @" @@ -240,7 +240,7 @@ await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(NativeTypeMustBeBlittableRule).WithLocation(0).WithArguments("Native", "S")); } - [Fact] + [ConditionalFact] public async Task ClassNativeType_ReportsDiagnostic() { string source = @" @@ -267,7 +267,7 @@ await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(NativeTypeMustHaveRequiredShapeRule).WithLocation(0).WithArguments("Native", "S")); } - [Fact] + [ConditionalFact] public async Task BlittableNativeType_DoesNotReportDiagnostic() { string source = @" @@ -296,7 +296,7 @@ public Native(S s) await VerifyCS.VerifyAnalyzerAsync(source); } - [Fact] + [ConditionalFact] public async Task BlittableNativeWithNonBlittableValueProperty_ReportsDiagnostic() { string source = @" @@ -328,7 +328,7 @@ await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(NativeTypeMustBeBlittableRule).WithLocation(0).WithArguments("string", "S")); } - [Fact] + [ConditionalFact] public async Task NonBlittableNativeTypeWithBlittableValueProperty_DoesNotReportDiagnostic() { string source = @" @@ -358,7 +358,7 @@ public Native(S s) await VerifyCS.VerifyAnalyzerAsync(source); } - [Fact] + [ConditionalFact] public async Task ClassNativeTypeWithValueProperty_ReportsDiagnostic() { string source = @" @@ -389,7 +389,7 @@ await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(NativeTypeMustHaveRequiredShapeRule).WithLocation(0).WithArguments("Native", "S")); } - [Fact] + [ConditionalFact] public async Task NonBlittableGetPinnableReferenceReturnType_ReportsDiagnostic() { string source = @" @@ -422,7 +422,7 @@ await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(GetPinnableReferenceReturnTypeBlittableRule).WithLocation(0)); } - [Fact] + [ConditionalFact] public async Task BlittableGetPinnableReferenceReturnType_DoesNotReportDiagnostic() { string source = @" @@ -454,7 +454,7 @@ public Native(S s) : this() await VerifyCS.VerifyAnalyzerAsync(source); } - [Fact] + [ConditionalFact] public async Task TypeWithGetPinnableReferenceNonPointerReturnType_ReportsDiagnostic() { string source = @" @@ -487,7 +487,7 @@ await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(NativeTypeMustBePointerSizedRule).WithLocation(0).WithArguments("int", "S")); } - [Fact] + [ConditionalFact] public async Task TypeWithGetPinnableReferencePointerReturnType_DoesNotReportDiagnostic() { string source = @" @@ -519,7 +519,7 @@ public Native(S s) : this() await VerifyCS.VerifyAnalyzerAsync(source); } - [Fact] + [ConditionalFact] public async Task TypeWithGetPinnableReferenceByRefReturnType_ReportsDiagnostic() { string source = @" @@ -550,7 +550,7 @@ await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(RefValuePropertyUnsupportedRule).WithLocation(0).WithArguments("Native")); } - [Fact] + [ConditionalFact] public async Task NativeTypeWithGetPinnableReferenceByRefReturnType_ReportsDiagnostic() { string source = @" @@ -581,7 +581,7 @@ await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(RefValuePropertyUnsupportedRule).WithLocation(0).WithArguments("Native")); } - [Fact] + [ConditionalFact] public async Task BlittableValueTypeWithNoFields_DoesNotReportDiagnostic() { string source = @" @@ -596,7 +596,7 @@ struct S await VerifyCS.VerifyAnalyzerAsync(source); } - [Fact] + [ConditionalFact] public async Task NativeTypeWithNoMarshallingMethods_ReportsDiagnostic() { string source = @" @@ -618,7 +618,7 @@ await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(NativeTypeMustHaveRequiredShapeRule).WithLocation(0).WithArguments("Native", "S")); } - [Fact] + [ConditionalFact] public async Task CollectionNativeTypeWithNoMarshallingMethods_ReportsDiagnostic() { string source = @" @@ -640,7 +640,7 @@ await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(CollectionNativeTypeMustHaveRequiredShapeRule).WithLocation(0).WithArguments("Native", "S")); } - [Fact] + [ConditionalFact] public async Task CollectionNativeTypeWithWrongConstructor_ReportsDiagnostic() { string source = @" @@ -668,7 +668,7 @@ await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(CollectionNativeTypeMustHaveRequiredShapeRule).WithLocation(0).WithArguments("Native", "S")); } - [Fact] + [ConditionalFact] public async Task CollectionNativeTypeWithCorrectConstructor_DoesNotReportDiagnostic() { string source = @" @@ -695,7 +695,7 @@ public Native(S s, int nativeElementSize) : this() {} await VerifyCS.VerifyAnalyzerAsync(source); } - [Fact] + [ConditionalFact] public async Task CollectionNativeTypeWithIncorrectStackallocConstructor_ReportsDiagnostic() { string source = @" @@ -725,7 +725,7 @@ await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(CollectionNativeTypeMustHaveRequiredShapeRule).WithLocation(0).WithArguments("Native", "S")); } - [Fact] + [ConditionalFact] public async Task CollectionNativeTypeWithOnlyStackallocConstructor_ReportsDiagnostic() { string source = @" @@ -755,7 +755,7 @@ await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(StackallocMarshallingShouldSupportAllocatingMarshallingFallbackRule).WithLocation(0).WithArguments("Native", "S")); } - [Fact] + [ConditionalFact] public async Task CollectionNativeTypeWithMissingManagedValuesProperty_ReportsDiagnostic() { string source = @" @@ -782,7 +782,7 @@ await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(CollectionNativeTypeMustHaveRequiredShapeRule).WithLocation(0).WithArguments("Native", "S")); } - [Fact] + [ConditionalFact] public async Task CollectionNativeTypeWithMissingNativeValueStorageProperty_ReportsDiagnostic() { string source = @" @@ -809,7 +809,7 @@ await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(CollectionNativeTypeMustHaveRequiredShapeRule).WithLocation(0).WithArguments("Native", "S")); } - [Fact] + [ConditionalFact] public async Task NativeTypeWithOnlyConstructor_DoesNotReportDiagnostic() { string source = @" @@ -831,7 +831,7 @@ public Native(S s) {} await VerifyCS.VerifyAnalyzerAsync(source); } - [Fact] + [ConditionalFact] public async Task NativeTypeWithOnlyToManagedMethod_DoesNotReportDiagnostic() { string source = @" @@ -853,7 +853,7 @@ struct Native await VerifyCS.VerifyAnalyzerAsync(source); } - [Fact] + [ConditionalFact] public async Task NativeTypeWithOnlyStackallocConstructor_ReportsDiagnostic() { string source = @" @@ -878,7 +878,7 @@ await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(StackallocMarshallingShouldSupportAllocatingMarshallingFallbackRule).WithLocation(0).WithArguments("Native")); } - [Fact] + [ConditionalFact] public async Task TypeWithOnlyNativeStackallocConstructorAndGetPinnableReference_ReportsDiagnostics() { string source = @" @@ -906,7 +906,7 @@ await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(GetPinnableReferenceShouldSupportAllocatingMarshallingFallbackRule).WithLocation(0).WithArguments("S", "Native")); } - [Fact] + [ConditionalFact] public async Task NativeTypeWithConstructorAndSetOnlyValueProperty_ReportsDiagnostic() { string source = @" @@ -930,7 +930,7 @@ await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(ValuePropertyMustHaveGetterRule).WithLocation(0).WithArguments("Native")); } - [Fact] + [ConditionalFact] public async Task NativeTypeWithToManagedAndGetOnlyValueProperty_ReportsDiagnostic() { string source = @" @@ -954,7 +954,7 @@ await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(ValuePropertyMustHaveSetterRule).WithLocation(0).WithArguments("Native")); } - [Fact] + [ConditionalFact] public async Task BlittableNativeTypeOnMarshalUsingParameter_DoesNotReportDiagnostic() { string source = @" @@ -989,7 +989,7 @@ static void Foo([MarshalUsing(typeof(Native))] S s) await VerifyCS.VerifyAnalyzerAsync(source); } - [Fact] + [ConditionalFact] public async Task NonBlittableNativeTypeOnMarshalUsingParameter_ReportsDiagnostic() { string source = @" @@ -1023,7 +1023,7 @@ await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(NativeTypeMustBeBlittableRule).WithLocation(0).WithArguments("Native", "S")); } - [Fact] + [ConditionalFact] public async Task NonBlittableNativeTypeOnMarshalUsingParameter_MultipleCompilations_ReportsDiagnostic_WithLocation() { string source1 = @" @@ -1074,7 +1074,7 @@ static void Foo([{|#0:MarshalUsing(typeof(Native))|}] S s) await test.RunAsync(); } - [Fact] + [ConditionalFact] public async Task NonBlittableNativeTypeOnMarshalUsingReturn_ReportsDiagnostic() { string source = @" @@ -1108,7 +1108,7 @@ await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(NativeTypeMustBeBlittableRule).WithLocation(0).WithArguments("Native", "S")); } - [Fact] + [ConditionalFact] public async Task NonBlittableNativeTypeOnMarshalUsingField_ReportsDiagnostic() { string source = @" @@ -1142,7 +1142,7 @@ await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(NativeTypeMustBeBlittableRule).WithLocation(0).WithArguments("Native", "S")); } - [Fact] + [ConditionalFact] public async Task GenericNativeTypeWithValueTypeValueProperty_DoesNotReportDiagnostic() { string source = @" @@ -1169,7 +1169,7 @@ public Native(T s) await VerifyCS.VerifyAnalyzerAsync(source); } - [Fact] + [ConditionalFact] public async Task GenericNativeTypeWithGenericMemberInstantiatedWithBlittable_DoesNotReportDiagnostic() { @@ -1197,7 +1197,7 @@ public Native(S s) await VerifyCS.VerifyAnalyzerAsync(source); } - [Fact] + [ConditionalFact] public async Task UninstantiatedGenericNativeTypeOnNonGeneric_ReportsDiagnostic() { @@ -1225,7 +1225,7 @@ public Native(S s) await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(NativeGenericTypeMustBeClosedOrMatchArityRule).WithLocation(0).WithArguments("Native<>", "S")); } - [Fact] + [ConditionalFact] public async Task UninstantiatedGenericNativeTypeOnGenericWithArityMismatch_ReportsDiagnostic() { string source = @" @@ -1252,7 +1252,7 @@ public Native(S s) await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(NativeGenericTypeMustBeClosedOrMatchArityRule).WithLocation(0).WithArguments("Native<,>", "S")); } - [Fact] + [ConditionalFact] public async Task UninstantiatedGenericNativeTypeOnGenericWithArityMatch_DoesNotReportDiagnostic() { string source = @" @@ -1279,7 +1279,7 @@ public Native(S s) await VerifyCS.VerifyAnalyzerAsync(source); } - [Fact] + [ConditionalFact] public async Task ValueTypeContainingPointerBlittableType_DoesNotReportDiagnostic() { var source = @" @@ -1293,7 +1293,7 @@ unsafe struct S await VerifyCS.VerifyAnalyzerAsync(source); } - [Fact] + [ConditionalFact] public async Task ValueTypeContainingPointerToNonBlittableType_ReportsDiagnostic() { var source = @" @@ -1308,7 +1308,7 @@ await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(BlittableTypeMustBeBlittableRule).WithLocation(0).WithArguments("S")); } - [Fact] + [ConditionalFact] public async Task BlittableValueTypeContainingPointerToSelf_DoesNotReportDiagnostic() { @@ -1324,7 +1324,7 @@ unsafe struct S await VerifyCS.VerifyAnalyzerAsync(source); } - [Fact] + [ConditionalFact] public async Task NonBlittableValueTypeContainingPointerToSelf_ReportsDiagnostic() { var source = @" @@ -1340,7 +1340,7 @@ await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(BlittableTypeMustBeBlittableRule).WithLocation(0).WithArguments("S")); } - [Fact] + [ConditionalFact] public async Task BlittableTypeContainingFunctionPointer_DoesNotReportDiagnostic() { var source = @" @@ -1354,7 +1354,7 @@ unsafe struct S await VerifyCS.VerifyAnalyzerAsync(source); } - [Fact] + [ConditionalFact] public async Task BlittableGenericTypeInBlittableType_DoesNotReportDiagnostic() { var source = @" @@ -1374,7 +1374,7 @@ unsafe struct S await VerifyCS.VerifyAnalyzerAsync(source); } - [Fact] + [ConditionalFact] public async Task NonBlittableGenericTypeInBlittableType_ReportsDiagnostic() { var source = @" @@ -1395,7 +1395,7 @@ await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(BlittableTypeMustBeBlittableRule).WithLocation(0).WithArguments("S")); } - [Fact] + [ConditionalFact] public async Task BlittableGenericTypeTypeParameterReferenceType_ReportsDiagnostic() { var source = @" @@ -1410,7 +1410,7 @@ await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(BlittableTypeMustBeBlittableRule).WithLocation(0).WithArguments("G")); } - [Fact] + [ConditionalFact] public async Task BlittableGenericTypeContainingGenericType_DoesNotReportDiagnostic() { var source = @" @@ -1431,7 +1431,7 @@ struct F await VerifyCS.VerifyAnalyzerAsync(source); } - [Fact] + [ConditionalFact] public async Task BlittableNestedGenericType_DoesNotReportDiagnostic() { var source = @" @@ -1455,7 +1455,7 @@ struct S await VerifyCS.VerifyAnalyzerAsync(source); } - [Fact] + [ConditionalFact] public async Task BlittableNestedGenericTypeWithReferenceTypeGenericParameter_DoesNotReportDiagnostic() { var source = @" @@ -1474,7 +1474,7 @@ await VerifyCS.VerifyAnalyzerAsync(source, VerifyCS.Diagnostic(BlittableTypeMustBeBlittableRule).WithLocation(0).WithArguments("C.G")); } - [Fact] + [ConditionalFact] public async Task BlittableGenericTypeWithReferenceTypeParameterNotUsedInFieldType_DoesNotReportDiagnostic() { var source = @" @@ -1488,7 +1488,7 @@ struct G where U : class await VerifyCS.VerifyAnalyzerAsync(source); } - [Fact] + [ConditionalFact] public async Task NativeTypeWithStackallocConstructorWithoutBufferSize_ReportsDiagnostic() { string source = @" diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs index c0039a7e5b04b2..194b75193e7062 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/TestUtils.cs @@ -5,6 +5,7 @@ using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Testing; +using Microsoft.DotNet.XUnitExtensions; using System; using System.Collections.Generic; using System.Collections.Immutable; @@ -160,6 +161,15 @@ public static GeneratorDriver CreateDriver(Compilation c, AnalyzerConfigOptionsP parseOptions: (CSharpParseOptions)c.SyntaxTrees.First().Options, optionsProvider: options); + // The non-configurable test-packages folder may be incomplete/corrupt. + // - https://github.com/dotnet/roslyn-sdk/issues/487 + // - https://github.com/dotnet/roslyn-sdk/issues/590 + internal static void ThrowSkipExceptionIfPackagingException(Exception e) + { + if (e.GetType().FullName == "NuGet.Packaging.Core.PackagingException") + throw new SkipTestException($"Skipping test due to issue with test-packages ({e.Message}). See https://github.com/dotnet/roslyn-sdk/issues/590."); + } + private static async Task> ResolveReferenceAssemblies(ReferenceAssemblies referenceAssemblies) { try @@ -167,6 +177,11 @@ private static async Task> ResolveReferenceAss ResolveRedirect.Instance.Start(); return await referenceAssemblies.ResolveAsync(LanguageNames.CSharp, CancellationToken.None); } + catch (Exception e) + { + ThrowSkipExceptionIfPackagingException(e); + throw; + } finally { ResolveRedirect.Instance.Stop(); diff --git a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpCodeFixVerifier.cs b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpCodeFixVerifier.cs index 136c88a9cd45d6..cc4d7f183ac95c 100644 --- a/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpCodeFixVerifier.cs +++ b/src/libraries/System.Runtime.InteropServices/tests/DllImportGenerator.UnitTests/Verifiers/CSharpCodeFixVerifier.cs @@ -116,6 +116,19 @@ public Test() protected override ParseOptions CreateParseOptions() => ((CSharpParseOptions)base.CreateParseOptions()).WithPreprocessorSymbols("DLLIMPORTGENERATOR_ENABLED"); + + protected override async Task RunImplAsync(CancellationToken cancellationToken) + { + try + { + await base.RunImplAsync(cancellationToken); + } + catch (System.Exception e) + { + TestUtils.ThrowSkipExceptionIfPackagingException(e); + throw; + } + } } } }