diff --git a/build/scripts/tests.sh b/build/scripts/tests.sh index df831f097da72d39d0c0e7ea412333682ca0461a..78c8f49fa54d62db930c90b8c50d6517e9af4cf9 100755 --- a/build/scripts/tests.sh +++ b/build/scripts/tests.sh @@ -69,7 +69,7 @@ do echo Running "${runtime} ${file_name[@]}" if [[ "${runtime}" == "dotnet" ]]; then runner="dotnet exec --depsfile ${deps_json} --runtimeconfig ${runtimeconfig_json}" - if [[ "${file_name[@]}" == *'Roslyn.Compilers.CSharp.Emit.UnitTests.dll' ]] + if [[ "${file_name[@]}" == *'Roslyn.Compilers.CSharp.Emit.UnitTests.dll' ]] || [[ "${file_name[@]}" == *'Roslyn.Compilers.VisualBasic.Symbol.UnitTests.dll' ]] then echo "Skipping ${file_name[@]}" continue diff --git a/src/Compilers/Test/Utilities/VisualBasic/BasicTestBase.vb b/src/Compilers/Test/Utilities/VisualBasic/BasicTestBase.vb index cb963e5c2f3a6eeabca78dc32a0a99a3f9c0a10f..625c34c04f921f7afec4b9e47c3b254209778485 100644 --- a/src/Compilers/Test/Utilities/VisualBasic/BasicTestBase.vb +++ b/src/Compilers/Test/Utilities/VisualBasic/BasicTestBase.vb @@ -1,27 +1,15 @@ ' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. Imports System.Collections.Immutable -Imports System.Linq -Imports System.Xml.Linq Imports Microsoft.CodeAnalysis.CodeGen Imports Microsoft.CodeAnalysis.Emit Imports Microsoft.CodeAnalysis.Test.Utilities -Imports Microsoft.CodeAnalysis.Text Imports Roslyn.Test.Utilities Imports Xunit Public MustInherit Class BasicTestBase Inherits CommonTestBase - Protected Overloads Function GetCompilationForEmit( - source As IEnumerable(Of String), - additionalRefs() As MetadataReference, - options As VisualBasicCompilationOptions, - parseOptions As VisualBasicParseOptions - ) As VisualBasicCompilation - Return DirectCast(MyClass.GetCompilationForEmit(source, additionalRefs, options, parseOptions), VisualBasicCompilation) - End Function - Public Function XCDataToString(Optional data As XCData = Nothing) As String Return data?.Value.Replace(vbLf, Environment.NewLine) End Function @@ -203,45 +191,6 @@ Public MustInherit Class BasicTestBase verify) End Function - Friend Shadows Function CompileAndVerify( - source As String, - allReferences As IEnumerable(Of MetadataReference), - Optional expectedOutput As String = Nothing, - Optional expectedReturnCode As Integer? = Nothing, - Optional args As String() = Nothing, - Optional dependencies As IEnumerable(Of ModuleData) = Nothing, - Optional sourceSymbolValidator As Action(Of ModuleSymbol) = Nothing, - Optional validator As Action(Of PEAssembly) = Nothing, - Optional symbolValidator As Action(Of ModuleSymbol) = Nothing, - Optional expectedSignatures As SignatureDescription() = Nothing, - Optional options As VisualBasicCompilationOptions = Nothing, - Optional parseOptions As VisualBasicParseOptions = Nothing, - Optional emitOptions As EmitOptions = Nothing, - Optional assemblyName As String = Nothing, - Optional verify As Verification = Verification.Passes - ) As CompilationVerifier - - If options Is Nothing Then - options = If(expectedOutput Is Nothing, TestOptions.ReleaseDll, TestOptions.ReleaseExe) - End If - - Dim compilation = CreateEmptyCompilation(source, allReferences, options, parseOptions, assemblyName) - - Return MyBase.CompileAndVerifyCommon( - compilation, - Nothing, - dependencies, - Translate(sourceSymbolValidator), - validator, - Translate(symbolValidator), - expectedSignatures, - expectedOutput, - expectedReturnCode, - args, - emitOptions, - verify) - End Function - Friend Shadows Function CompileAndVerifyOnWin8Only( source As XElement, allReferences As IEnumerable(Of MetadataReference), @@ -333,6 +282,45 @@ Public MustInherit Class BasicTestBase useLatestFramework:=useLatestFramework) End Function + Friend Shadows Function CompileAndVerifyEx( + source As BasicTestSource, + Optional references As IEnumerable(Of MetadataReference) = Nothing, + Optional expectedOutput As String = Nothing, + Optional expectedReturnCode As Integer? = Nothing, + Optional args As String() = Nothing, + Optional dependencies As IEnumerable(Of ModuleData) = Nothing, + Optional sourceSymbolValidator As Action(Of ModuleSymbol) = Nothing, + Optional validator As Action(Of PEAssembly) = Nothing, + Optional symbolValidator As Action(Of ModuleSymbol) = Nothing, + Optional expectedSignatures As SignatureDescription() = Nothing, + Optional options As VisualBasicCompilationOptions = Nothing, + Optional parseOptions As VisualBasicParseOptions = Nothing, + Optional emitOptions As EmitOptions = Nothing, + Optional assemblyName As String = Nothing, + Optional verify As Verification = Verification.Passes, + Optional targetFramework As TargetFramework = TargetFramework.StandardAndVBRuntime + ) As CompilationVerifier + + If options Is Nothing Then + options = If(expectedOutput Is Nothing, TestOptions.ReleaseDll, TestOptions.ReleaseExe) + End If + + Dim compilation = CreateCompilation(source, references, options, parseOptions, targetFramework, assemblyName) + Return MyBase.CompileAndVerifyCommon( + compilation, + Nothing, + dependencies, + Translate(sourceSymbolValidator), + validator, + Translate(symbolValidator), + expectedSignatures, + expectedOutput, + expectedReturnCode, + args, + emitOptions, + verify) + End Function + ''' ''' Compile sources and adds a custom reference using a custom IL ''' diff --git a/src/Compilers/VisualBasic/Test/Emit/Emit/DynamicAnalysis/DynamicInstrumentationTests.vb b/src/Compilers/VisualBasic/Test/Emit/Emit/DynamicAnalysis/DynamicInstrumentationTests.vb index a7502f3e4e16ee7437f4a975a662caebf79e9fc9..55abf49b92b1a2aad62e9749170ecc02913ff332 100644 --- a/src/Compilers/VisualBasic/Test/Emit/Emit/DynamicAnalysis/DynamicInstrumentationTests.vb +++ b/src/Compilers/VisualBasic/Test/Emit/Emit/DynamicAnalysis/DynamicInstrumentationTests.vb @@ -7,6 +7,7 @@ Imports Microsoft.CodeAnalysis.Test.Utilities Imports Microsoft.CodeAnalysis.Test.Utilities.VBInstrumentationChecker Imports Microsoft.CodeAnalysis.VisualBasic Imports Microsoft.CodeAnalysis.VisualBasic.UnitTests +Imports Roslyn.Test.Utilities Namespace Microsoft.CodeAnalysis.VisualBasic.DynamicAnalysis.UnitTests @@ -2825,11 +2826,12 @@ True End Function Private Overloads Function CompileAndVerify(source As String, Optional expectedOutput As String = Nothing, Optional options As VisualBasicCompilationOptions = Nothing) As CompilationVerifier - Return CompileAndVerify(source, + Return CompileAndVerifyEx(source, LatestVbReferences, expectedOutput, options:=If(options, TestOptions.ReleaseExe).WithDeterministic(True), - emitOptions:=EmitOptions.Default.WithInstrumentationKinds(ImmutableArray.Create(InstrumentationKind.TestCoverage))) + emitOptions:=EmitOptions.Default.WithInstrumentationKinds(ImmutableArray.Create(InstrumentationKind.TestCoverage)), + targetFramework:=TargetFramework.Empty) End Function End Class End Namespace diff --git a/src/Compilers/VisualBasic/Test/Emit/PDB/PDBAsyncTests.vb b/src/Compilers/VisualBasic/Test/Emit/PDB/PDBAsyncTests.vb index 7a2981f7f10a18a63d2cc72330c5a341b553de07..49a3b05a3bccb14bda3637a821fb9f38b71f5192 100644 --- a/src/Compilers/VisualBasic/Test/Emit/PDB/PDBAsyncTests.vb +++ b/src/Compilers/VisualBasic/Test/Emit/PDB/PDBAsyncTests.vb @@ -977,7 +977,7 @@ Class C End Try End Function End Class" - Dim v = CompileAndVerify(src, LatestVbReferences, options:=TestOptions.DebugDll) + Dim v = CompileAndVerifyEx(src, references:=LatestVbReferences, options:=TestOptions.DebugDll, targetFramework:=TargetFramework.Empty) v.VerifyPdb("C+VB$StateMachine_1_M.MoveNext", diff --git a/src/Compilers/VisualBasic/Test/Symbol/BasicCompilerSymbolTest.vbproj b/src/Compilers/VisualBasic/Test/Symbol/BasicCompilerSymbolTest.vbproj index 790385a2ee16fbab4b3d46ddc10f9649a8a9a604..c16e9de2e65f2432fe9e6fa1c809d75b0717dfe3 100644 --- a/src/Compilers/VisualBasic/Test/Symbol/BasicCompilerSymbolTest.vbproj +++ b/src/Compilers/VisualBasic/Test/Symbol/BasicCompilerSymbolTest.vbproj @@ -7,9 +7,8 @@ AnyCPU Library Roslyn.Compilers.VisualBasic.Symbol.UnitTests - net46 - $(RoslynDesktopRuntimeIdentifier) - UnitTest + $(RoslynPortableTargetFrameworks) + UnitTestPortable @@ -24,10 +23,6 @@ - - - - diff --git a/src/Compilers/VisualBasic/Test/Symbol/DocumentationComments/DocCommentTests.vb b/src/Compilers/VisualBasic/Test/Symbol/DocumentationComments/DocCommentTests.vb index eedc7898e26e0241757915819528950f20d5a613..766a51734ed5717f8de880d7cc9dd11cfc4444b6 100644 --- a/src/Compilers/VisualBasic/Test/Symbol/DocumentationComments/DocCommentTests.vb +++ b/src/Compilers/VisualBasic/Test/Symbol/DocumentationComments/DocCommentTests.vb @@ -1943,7 +1943,7 @@ AssemblyName ) End Sub - + Public Sub IllegalXmlInDocComment() CompileCheckDiagnosticsAndXmlDocument( @@ -1993,7 +1993,7 @@ AssemblyName ) End Sub - + Public Sub IllegalXmlInDocComment_Schema() CompileCheckDiagnosticsAndXmlDocument( diff --git a/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/AnonymousTypes/AnonymousTypesEmittedSymbolsTests.vb b/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/AnonymousTypes/AnonymousTypesEmittedSymbolsTests.vb index ad9d5b5103e447f7d96e61084070cc7b58c4aaeb..ecb34247e6aea2386c1fcdc708cb07093e9a49d5 100644 --- a/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/AnonymousTypes/AnonymousTypesEmittedSymbolsTests.vb +++ b/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/AnonymousTypes/AnonymousTypesEmittedSymbolsTests.vb @@ -736,7 +736,8 @@ End Module #End Region - + + Public Sub MultipleNetmodulesWithAnonymousTypes() Dim compilationDef1 = diff --git a/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/Metadata/PE/NoPia.vb b/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/Metadata/PE/NoPia.vb index c9b00e22b6f397232f164e7216b13804ad269f3e..26132235301557bd765576fceda6ab0130816606 100644 --- a/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/Metadata/PE/NoPia.vb +++ b/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/Metadata/PE/NoPia.vb @@ -1015,7 +1015,8 @@ End interface GC.KeepAlive(tc7) End Sub - + + Public Sub Bug16689_1() Dim ilSource = ) End Sub - + + Public Sub Bug16689_3() Dim i3Def = diff --git a/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/Metadata/PE/PEParameterSymbolTests.vb b/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/Metadata/PE/PEParameterSymbolTests.vb index 54a283c2ad2741af5596fb86b03f9e4c082029e9..706d70c0b824a9335fa890fc05c68f481994ddb0 100644 --- a/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/Metadata/PE/PEParameterSymbolTests.vb +++ b/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/Metadata/PE/PEParameterSymbolTests.vb @@ -1,5 +1,5 @@ ' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - +#If NET46 Then Imports System.Reflection Imports Roslyn.Test.Utilities Imports Roslyn.Test.Utilities.Desktop @@ -55,4 +55,4 @@ BC30274: Parameter 'Param' of 'Sub M(Param As Object, Param As Object)' already End Class End Namespace - +#End if diff --git a/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/Source/ComClassTests.vb b/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/Source/ComClassTests.vb index e6f430efde6513cfee5dd340befbe1cd03b6d3bc..a8273107930ba25c898f79de62029ff9fbd5cbd5 100644 --- a/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/Source/ComClassTests.vb +++ b/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/Source/ComClassTests.vb @@ -9,7 +9,6 @@ Imports Microsoft.CodeAnalysis.Test.Utilities Imports Microsoft.CodeAnalysis.VisualBasic.Symbols Imports Microsoft.CodeAnalysis.VisualBasic.Symbols.Metadata.PE Imports Roslyn.Test.Utilities -Imports Roslyn.Test.Utilities.Desktop Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests @@ -166,7 +165,13 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests End If If p.HasExplicitDefaultValue Then - result.Add(<%= p.ExplicitDefaultValue %>) + Dim value = p.ExplicitDefaultValue + If TypeOf value Is Date Then + ' The default display of DateTime is different between Desktop and CoreClr hence + ' we need to normalize the value here. + value = (CDate(value)).ToString("yyyy-MM-ddTHH:mm:ss") + End If + result.Add(<%= value %>) End If ' TODO (tomat): add MarshallingInformation diff --git a/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/Source/FieldTests.vb b/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/Source/FieldTests.vb index a014ee1d7ca2e6daed8a85ce47988708aba210b2..d7a402392ccd2175f2f23fa90036e9790334d858 100644 --- a/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/Source/FieldTests.vb +++ b/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/Source/FieldTests.vb @@ -451,7 +451,7 @@ End Class]]>, ''' - + Public Sub RTSpecialName() Dim compilation = CompilationUtils.CreateCompilationWithMscorlib40AndVBRuntime( diff --git a/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/Source/GroupClassTests.vb b/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/Source/GroupClassTests.vb index b3277dc834c0437368daa7e1acd9dfe7643fcc30..0195a9ccf477890358b4b830664a67b358363295 100644 --- a/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/Source/GroupClassTests.vb +++ b/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/Source/GroupClassTests.vb @@ -3457,7 +3457,7 @@ End Class CompileAndVerify(compilation).VerifyDiagnostics() End Sub - + Public Sub Is_IsNot() Dim compilationDef = @@ -3544,7 +3544,7 @@ True ]]>).VerifyDiagnostics() End Sub - + Public Sub BackingFieldToHaveEditorBrowsableNeverAttribute() Dim compilationDef = @@ -3595,7 +3595,7 @@ End Module Dim verifier = CompileAndVerify(compilation, expectedOutput:="1 Never").VerifyDiagnostics() End Sub - + Public Sub Using001() Dim compilationDef = diff --git a/src/Test/Utilities/Portable/Assert/ConditionalFactAttribute.cs b/src/Test/Utilities/Portable/Assert/ConditionalFactAttribute.cs index 8e36c48cdcf285e2ab127bbb6a6a4802dc2726ac..fca98beb6e80ba0915fdfce6cf61b6ac6ecb157e 100644 --- a/src/Test/Utilities/Portable/Assert/ConditionalFactAttribute.cs +++ b/src/Test/Utilities/Portable/Assert/ConditionalFactAttribute.cs @@ -11,6 +11,16 @@ namespace Roslyn.Test.Utilities { + /// + /// Container for common skip reasons. Secondary benefit allows us to use find all ref to + /// discover the set of tests affected by a particular scenario. + /// + public static class ConditionalSkipReason + { + public const string NoPiaNeedsDesktop = "NoPia is only supported on desktop"; + public const string NetModulesNeedDesktop = "Net Modules are only supported on desktop"; + } + public class ConditionalFactAttribute : FactAttribute { public ConditionalFactAttribute(params Type[] skipConditions) @@ -103,4 +113,10 @@ public class NoIOperationValidation : ExecutionCondition public override bool ShouldSkip => !CompilationExtensions.EnableVerifyIOperation; public override string SkipReason => "Test not supported in TEST_IOPERATION_INTERFACE"; } + + public class OSVersionWin8 : ExecutionCondition + { + public override bool ShouldSkip => !OSVersion.IsWin8; + public override string SkipReason => "Window Version is not at least Win8 (build:9200)"; + } } diff --git a/src/Test/Utilities/Portable/Compilation/RuntimeUtilities.cs b/src/Test/Utilities/Portable/Compilation/RuntimeUtilities.cs index 8030cd1c1cd1815fa58f8316da1ed8657cab7fe4..0f73a752dab17d616db0d106bdf59828bf6aaf5f 100644 --- a/src/Test/Utilities/Portable/Compilation/RuntimeUtilities.cs +++ b/src/Test/Utilities/Portable/Compilation/RuntimeUtilities.cs @@ -38,7 +38,7 @@ internal static IRuntimeEnvironmentFactory GetRuntimeEnvironmentFactory() #elif NETCOREAPP2_0 return new Roslyn.Test.Utilities.CoreClr.CoreCLRRuntimeEnvironmentFactory(); #elif NETSTANDARD1_3 - throw new NotSupportedException(); + throw new PlatformNotSupportedException(); #else #error Unsupported configuration #endif @@ -61,7 +61,7 @@ internal static string GetAssemblyLocation(Type type) #if NET46 || NETCOREAPP2_0 return type.GetTypeInfo().Assembly.Location; #elif NETSTANDARD1_3 - throw new NotSupportedException(); + throw new PlatformNotSupportedException(); #else #error Unsupported configuration #endif diff --git a/src/Test/Utilities/Portable/Platform/Custom/OSVersion.cs b/src/Test/Utilities/Portable/Platform/Custom/OSVersion.cs index 7f3592c186499b16140025bfae6834daf1e94753..2b1c93a4653e92ea7b79cb0fb424c3aa3520635c 100644 --- a/src/Test/Utilities/Portable/Platform/Custom/OSVersion.cs +++ b/src/Test/Utilities/Portable/Platform/Custom/OSVersion.cs @@ -15,7 +15,7 @@ public static class OSVersion #if NET46 || NETCOREAPP2_0 System.Environment.OSVersion.Version.Build >= 9200; #else - throw new InvalidOperationException(); + throw new PlatformNotSupportedException(); #endif } } diff --git a/src/Test/Utilities/Portable/Platform/Desktop/ConditionalFactAttribute.cs b/src/Test/Utilities/Portable/Platform/Desktop/ConditionalFactAttribute.cs index 3785fcdaef817514309756ff9f8b9339fa4a3f49..e0462a2e945f05b09ff39d53a0062cdb1b9b9cb9 100644 --- a/src/Test/Utilities/Portable/Platform/Desktop/ConditionalFactAttribute.cs +++ b/src/Test/Utilities/Portable/Platform/Desktop/ConditionalFactAttribute.cs @@ -59,25 +59,6 @@ public override bool ShouldSkip public override string SkipReason { get { return "Test currently not supported on Framework 4.5"; } } } - - public class OSVersionWin8 : ExecutionCondition - { - public override bool ShouldSkip - { - get - { - return !OSVersion.IsWin8; - } - } - - public override string SkipReason - { - get - { - return "Window Version is not Win8 (build:9200)"; - } - } - } } #endif