diff options
author | Rahul Kumar <rahku@microsoft.com> | 2016-03-02 14:36:15 -0800 |
---|---|---|
committer | Rahul Kumar <rahku@microsoft.com> | 2016-03-09 17:49:53 -0800 |
commit | 7d81c5359b5083ef4b08ebc3b3ebd8b8764fe418 (patch) | |
tree | 8cb3683c256d0c29e8d2f0586dcd4cac7bb0eed3 | |
parent | b1b881989aff677980de55a1134e4834f836011b (diff) | |
download | coreclr-7d81c5359b5083ef4b08ebc3b3ebd8b8764fe418.tar.gz coreclr-7d81c5359b5083ef4b08ebc3b3ebd8b8764fe418.tar.bz2 coreclr-7d81c5359b5083ef4b08ebc3b3ebd8b8764fe418.zip |
Port EH tests.
154 files changed, 11817 insertions, 91 deletions
diff --git a/tests/src/baseservices/exceptions/AccessViolationException/AVException01.cs b/tests/src/baseservices/exceptions/AccessViolationException/AVException01.cs new file mode 100644 index 0000000000..cc94cd0ea2 --- /dev/null +++ b/tests/src/baseservices/exceptions/AccessViolationException/AVException01.cs @@ -0,0 +1,35 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +public class test +{ + private object _state = null; + private static test _obj = null; + + public static int Main() + { + int ret = 0; + try + { + try + { + Object text = _obj._state; + } + catch (NullReferenceException) + { + ret = 100; + } + } + catch (Exception ex) + { + Console.WriteLine("Invalid read = {0} (should be NullRef)",ex.GetType()); + ret = 10; + } + Console.WriteLine(100 == ret ? "Test Passed" : "Test Failed"); + return ret; + } +} + diff --git a/tests/src/baseservices/exceptions/AccessViolationException/AVException01.csproj b/tests/src/baseservices/exceptions/AccessViolationException/AVException01.csproj new file mode 100644 index 0000000000..45abd10178 --- /dev/null +++ b/tests/src/baseservices/exceptions/AccessViolationException/AVException01.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="AVException01.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/AccessViolationException/AVException02.cs b/tests/src/baseservices/exceptions/AccessViolationException/AVException02.cs new file mode 100644 index 0000000000..92ccf1d397 --- /dev/null +++ b/tests/src/baseservices/exceptions/AccessViolationException/AVException02.cs @@ -0,0 +1,36 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +using System; +public class test +{ +#pragma warning disable 414 + private object _state = null; +#pragma warning restore 414 + private static test _obj = null; + + public static int Main() + { + int ret = 0; + try + { + try + { + + _obj._state = null; + + } + catch (NullReferenceException) + { + ret = 100; + } + } + catch (Exception ex) + { + Console.WriteLine("Invalid write (assigning null) = {0} (should be NullRef)",ex.GetType()); + ret = 10; + } + Console.WriteLine(100 == ret ? "Test Passed" : "Test Failed"); + return ret; + } +} diff --git a/tests/src/baseservices/exceptions/AccessViolationException/AVException02.csproj b/tests/src/baseservices/exceptions/AccessViolationException/AVException02.csproj new file mode 100644 index 0000000000..45abd10178 --- /dev/null +++ b/tests/src/baseservices/exceptions/AccessViolationException/AVException02.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="AVException01.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/AccessViolationException/AVException03.cs b/tests/src/baseservices/exceptions/AccessViolationException/AVException03.cs new file mode 100644 index 0000000000..6b5841a8ad --- /dev/null +++ b/tests/src/baseservices/exceptions/AccessViolationException/AVException03.cs @@ -0,0 +1,35 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +public class test +{ + private object _state = null; + private static test _obj = null; + + public static int Main() + { + int ret = 0; + Object temp = new Object(); + try + { + try + { + _obj._state = temp; + } + catch (NullReferenceException) + { + ret = 100; + } + } + catch (Exception ex) + { + Console.WriteLine("Invalid write (assigning an object) = {0} (should be NullRef)",ex.GetType()); + ret = 10; + } + Console.WriteLine(100 == ret ? "Test Passed" : "Test Failed"); + return ret; + } +} diff --git a/tests/src/baseservices/exceptions/AccessViolationException/AVException03.csproj b/tests/src/baseservices/exceptions/AccessViolationException/AVException03.csproj new file mode 100644 index 0000000000..5853068603 --- /dev/null +++ b/tests/src/baseservices/exceptions/AccessViolationException/AVException03.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="AVException03.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/AccessViolationException/app.config b/tests/src/baseservices/exceptions/AccessViolationException/app.config new file mode 100644 index 0000000000..62803f5972 --- /dev/null +++ b/tests/src/baseservices/exceptions/AccessViolationException/app.config @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<configuration> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + </assemblyBinding> + </runtime> +</configuration>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/AccessViolationException/project.json b/tests/src/baseservices/exceptions/AccessViolationException/project.json new file mode 100644 index 0000000000..1a9690222b --- /dev/null +++ b/tests/src/baseservices/exceptions/AccessViolationException/project.json @@ -0,0 +1,34 @@ +{ + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816", + "System.Collections": "4.0.10", + "System.Collections.NonGeneric": "4.0.1-beta-23302", + "System.Collections.Specialized": "4.0.1-beta-23302", + "System.ComponentModel": "4.0.1-beta-23302", + "System.Console": "4.0.0-beta-23302", + "System.Diagnostics.Process": "4.0.0-beta-23302", + "System.Globalization": "4.0.10", + "System.Globalization.Calendars": "4.0.0", + "System.IO": "4.0.10", + "System.IO.FileSystem": "4.0.0", + "System.IO.FileSystem.Primitives": "4.0.0", + "System.Linq": "4.0.1-beta-23302", + "System.Linq.Queryable": "4.0.1-beta-23302", + "System.Reflection": "4.0.10", + "System.Reflection.Primitives": "4.0.0", + "System.Runtime": "4.0.20", + "System.Runtime.Extensions": "4.0.10", + "System.Runtime.Handles": "4.0.0", + "System.Runtime.InteropServices": "4.0.20", + "System.Runtime.Loader": "4.0.0-beta-23302", + "System.Text.Encoding": "4.0.10", + "System.Threading": "4.0.10", + "System.Xml.ReaderWriter": "4.0.11-beta-23302", + "System.Xml.XDocument": "4.0.11-beta-23302", + "System.Xml.XmlDocument": "4.0.1-beta-23302", + "System.Xml.XmlSerializer": "4.0.11-beta-23302" + }, + "frameworks": { + "dnxcore50": {} + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/StackTracePreserve/StackTracePreserveTests.cs b/tests/src/baseservices/exceptions/StackTracePreserve/StackTracePreserveTests.cs new file mode 100644 index 0000000000..37b86fe516 --- /dev/null +++ b/tests/src/baseservices/exceptions/StackTracePreserve/StackTracePreserveTests.cs @@ -0,0 +1,530 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +using System; +using System.Threading; +using System.Runtime.ExceptionServices; +using System.IO; +using System.Security; + +class InactiveForeignException +{ + private static ExceptionDispatchInfo s_EDI = null; + private static int iPassed = 0, iFailed = 0; + + private static Exception GetInnerException() + { + try + { + throw new ArgumentNullException("InnerException"); + } + catch (ArgumentNullException ex) + { + return ex; + } + } + + private static void ThrowEntryPointInner() + { + Console.Write("Throwing exception from spawned thread"); + Console.WriteLine("..."); + throw new Exception("E1"); + } + + private static void ThrowEntryPoint() + { + if (s_EDI == null) + { + try + { + ThrowEntryPointInner(); + } + catch(Exception ex) + { + Console.WriteLine("Caught exception with message: {0}", ex.Message); + s_EDI = ExceptionDispatchInfo.Capture(ex); + } + } + else + { + Console.WriteLine("s_Exception is not null!"); + s_EDI = null; + } + } + + + private static bool Scenario1() + { + s_EDI = null; + + Console.WriteLine("\nScenario1"); + Thread t1 = new Thread(new ThreadStart(ThrowEntryPoint)); + t1.Start(); + t1.Join(); + + bool fPassed = false; + if (s_EDI == null) + { + Console.WriteLine("s_EDI shouldn't be null!"); + goto exit; + } + + // ThrowAndCatch the exception + try + { + s_EDI.Throw(); + } + catch(Exception ex) + { + string stackTrace = ex.StackTrace; + if (stackTrace.IndexOf("ThrowEntryPoint") == -1) + { + Console.WriteLine("FAILED - unable to find expected stackTrace"); + } + else + { + Console.WriteLine("Caught: {0}", ex.ToString()); + Console.WriteLine("Passed"); + fPassed = true; + } + } +exit: + Console.WriteLine(""); + return fPassed; + } + + private static void Scenario2Helper() + { + try + { + s_EDI.Throw(); + } + catch(Exception) + { + Console.WriteLine("Rethrowing caught exception.."); + throw; + } + } + + + private static bool Scenario2(bool fShouldLetGoUnhandled) + { + s_EDI = null; + + Console.WriteLine("\nScenario2"); + Thread t1 = new Thread(new ThreadStart(ThrowEntryPoint)); + t1.Start(); + t1.Join(); + + bool fPassed = false; + if (s_EDI == null) + { + Console.WriteLine("s_EDI shouldn't be null!"); + goto exit; + } + + if (!fShouldLetGoUnhandled) + { + // ThrowRethrowAndCatch the exception + try + { + Scenario2Helper(); + } + catch(Exception ex) + { + string stackTrace = ex.StackTrace; + if ((stackTrace.IndexOf("ThrowEntryPoint") == -1) || + (stackTrace.IndexOf("Scenario2Helper") == -1)) + { + Console.WriteLine("FAILED - unable to find expected stackTrace"); + } + else + { + Console.WriteLine("Caught: {0}", ex.ToString()); + Console.WriteLine("Passed"); + fPassed = true; + } + } + } + else + { + // ThrowRethrowAndUnhandled exception + Scenario2Helper(); + } +exit: + Console.WriteLine(""); + return fPassed; + } + + private static void Scenario3Helper() + { + ExceptionDispatchInfo edi = null; + + try + { + Scenario2Helper(); + } + catch (Exception exInner) + { + Console.WriteLine("Creating new ExceptionDispatchInfo in Scenario3Helper..."); + edi = ExceptionDispatchInfo.Capture(exInner); + } + + edi.Throw(); + } + + private static bool Scenario3() + { + s_EDI = null; + + Console.WriteLine("\nScenario3"); + Thread t1 = new Thread(new ThreadStart(ThrowEntryPoint2)); + t1.Start(); + t1.Join(); + + bool fPassed = false; + if (s_EDI == null) + { + Console.WriteLine("s_EDI shouldn't be null!"); + goto exit; + } + + // ThrowRethrowCatchCreateNewEDIAndThrow the exception - for multiple preservations + try + { + Scenario3Helper(); + } + catch (Exception ex) + { + string stackTrace = ex.StackTrace; + if ((stackTrace.IndexOf("ThrowEntryPoint") == -1) || + (stackTrace.IndexOf("Scenario2Helper") == -1) || + (stackTrace.IndexOf("Scenario3Helper") == -1)) + { + Console.WriteLine("FAILED - unable to find expected stackTrace"); + } + else + { + Console.WriteLine("Caught: {0}", ex.ToString()); + Console.WriteLine("Passed"); + fPassed = true; + } + } + exit: + Console.WriteLine(""); + return fPassed; + } + + private static void ThrowEntryPointNestedHelper() + { + if (s_EDI == null) + { + try + { + ThrowEntryPointInner(); + } + catch (Exception ex) + { + Console.WriteLine("Caught exception with message: {0}", ex.Message); + s_EDI = ExceptionDispatchInfo.Capture(ex); + } + + // This will preserve the original throw stacktrace and + // commence a new one. + s_EDI.Throw(); + } + else + { + Console.WriteLine("s_Exception is not null!"); + s_EDI = null; + } + } + + private static void ThrowEntryPoint2() + { + if (s_EDI == null) + { + try + { + ThrowEntryPointNestedHelper(); + } + catch (Exception ex) + { + Console.WriteLine("Caught: {0}", ex.ToString()); + } + } + else + { + Console.WriteLine("s_Exception is not null!"); + s_EDI = null; + } + } + + + private static bool Scenario4() + { + s_EDI = null; + + Console.WriteLine("\nScenario4"); + Thread t1 = new Thread(new ThreadStart(ThrowEntryPoint2)); + t1.Start(); + t1.Join(); + + bool fPassed = false; + if (s_EDI == null) + { + Console.WriteLine("s_EDI shouldn't be null!"); + goto exit; + } + + // ThrowCatchCreateEDI_ThrowEDICatch the exception on T1 + // ThrowEDI on T2. + // + // We shouldn't see frames post ThrowEDI on T1 when we ThrowEDI on T2. + try + { + s_EDI.Throw(); + } + catch (Exception ex) + { + string stackTrace = ex.StackTrace; + if ((stackTrace.IndexOf("ThrowEntryPointNestedHelper") == -1) || + (stackTrace.IndexOf("Scenario4") == -1) || + (stackTrace.IndexOf("ThrowEntryPoint2") != -1)) + + { + Console.WriteLine("FAILED - unable to find expected stackTrace"); + } + else + { + Console.WriteLine("Caught: {0}", ex.ToString()); + Console.WriteLine("Passed"); + fPassed = true; + } + } + exit: + Console.WriteLine(""); + return fPassed; + } + + + // Use EDI to throw exception during EH dispatch on the same + // thread for the same exception instance. + private static bool Scenario5() + { + bool fPassed = false; + ExceptionDispatchInfo edi = null; + + Console.WriteLine("\nScenario5"); + + try + { + try + { + ThrowEntryPointInner(); + } + catch(Exception ex) + { + edi = ExceptionDispatchInfo.Capture(ex); + edi.Throw(); + } + } + catch(Exception exOuter) + { + string stackTrace = exOuter.StackTrace; + if ((stackTrace.IndexOf("ThrowEntryPointInner") == -1) || + (stackTrace.IndexOf("Scenario5") == -1)) + + { + Console.WriteLine("FAILED - unable to find expected stackTrace"); + } + else + { + Console.WriteLine("Caught: {0}", exOuter.ToString()); + Console.WriteLine("Passed"); + fPassed = true; + } + } + + return fPassed; + } + + // Use EDI to throw an unthrown exception. + private static bool Scenario6() + { + bool fPassed = false; + ExceptionDispatchInfo edi = null; + + Console.WriteLine("\nScenario6"); + + try + { + edi = ExceptionDispatchInfo.Capture(new Exception("Unthrown exception")); + edi.Throw(); + } + catch(Exception exOuter) + { + string stackTrace = exOuter.StackTrace; + if ((stackTrace.IndexOf("Scenario6") == -1)) + + { + Console.WriteLine("FAILED - unable to find expected stackTrace"); + } + else + { + Console.WriteLine("Caught: {0}", exOuter.ToString()); + Console.WriteLine("Passed"); + fPassed = true; + } + } + + return fPassed; + } + + // Scenario 7 - Attempt to create EDI using a null reference throws + // ArgumentNullException. + private static bool Scenario7() + { + bool fPassed = false; + Console.WriteLine("\nScenario7"); + + try{ + try{ + ExceptionDispatchInfo edi = ExceptionDispatchInfo.Capture(null); + } + catch(ArgumentNullException) + { + fPassed = true; + } + } + catch(Exception) + { + } + + Console.WriteLine("{0}", (fPassed)?"Passed":"Failed"); + + return fPassed; + } + + + private static void Scenario9HelperInner() + { + try + { + Console.WriteLine("Throwing from Scenario9Helper..."); + s_EDI.Throw(); + } + finally + { + ; + } + } + + private static void Scenario9Helper() + { + try + { + Scenario9HelperInner(); + } + catch (Exception) + { + Console.WriteLine("Rethrowing..."); + throw; + } + } + + private static bool Scenario9() + { + s_EDI = null; + + Console.WriteLine("\nScenario9"); + Thread t1 = new Thread(new ThreadStart(ThrowEntryPoint)); + t1.Start(); + t1.Join(); + + bool fPassed = false; + if (s_EDI == null) + { + Console.WriteLine("s_EDI shouldn't be null!"); + goto exit; + } + + string s1 = null, s2 = null; + try + { + Scenario9Helper(); + } + catch (Exception ex) + { + s1 = ex.ToString(); + } + + try + { + Console.WriteLine("Triggering 2nd Throw..."); + s_EDI.Throw(); + } + catch (Exception ex) + { + s2 = ex.ToString(); + } + + // S1 should have Scenario9HelperInner, Scenario9Helper and Scenario9 frames, in addition to the original frames. + // S2 should have Scenario9 frame, in addition to the original frames. + if ((s1.IndexOf("Scenario9HelperInner") == -1) || (s1.IndexOf("Scenario9Helper") == -1) || + (s2.IndexOf("Scenario9HelperInner") != -1) || (s2.IndexOf("Scenario9Helper") != -1)) + { + Console.WriteLine("S1: {0}\n", s1); + Console.WriteLine("S2: {0}", s2); + Console.WriteLine("FAILED"); + + } + else + { + Console.WriteLine("S1: {0}\n", s1); + Console.WriteLine("S2: {0}", s2); + Console.WriteLine("Passed"); + fPassed = true; + } + + exit: + Console.WriteLine(""); + return fPassed; + } + + private static void ProcessStatus(bool fPassed) + { + if (fPassed) + iPassed++; + else + iFailed++; + + } + + + public static int Main(string[] args) + { + iPassed = iFailed = 0; + + + ProcessStatus(Scenario1()); + ProcessStatus(Scenario2(false)); + ProcessStatus(Scenario3()); + ProcessStatus(Scenario4()); + ProcessStatus(Scenario5()); + ProcessStatus(Scenario6()); + ProcessStatus(Scenario7()); + ProcessStatus(Scenario9()); + + + + // This is the unhandled exception case + //ProcessStatus(Scenario2(true)); + + + Console.WriteLine("\nPassed: {0}\nFailed: {1}", iPassed, iFailed); + + return ((iFailed == 0) && (iPassed > 0))?100:99; + + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/StackTracePreserve/StackTracePreserveTests.csproj b/tests/src/baseservices/exceptions/StackTracePreserve/StackTracePreserveTests.csproj new file mode 100644 index 0000000000..157b64236e --- /dev/null +++ b/tests/src/baseservices/exceptions/StackTracePreserve/StackTracePreserveTests.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="StackTracePreserveTests.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/StackTracePreserve/app.config b/tests/src/baseservices/exceptions/StackTracePreserve/app.config new file mode 100644 index 0000000000..62803f5972 --- /dev/null +++ b/tests/src/baseservices/exceptions/StackTracePreserve/app.config @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<configuration> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + </assemblyBinding> + </runtime> +</configuration>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/StackTracePreserve/project.json b/tests/src/baseservices/exceptions/StackTracePreserve/project.json new file mode 100644 index 0000000000..1a9690222b --- /dev/null +++ b/tests/src/baseservices/exceptions/StackTracePreserve/project.json @@ -0,0 +1,34 @@ +{ + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816", + "System.Collections": "4.0.10", + "System.Collections.NonGeneric": "4.0.1-beta-23302", + "System.Collections.Specialized": "4.0.1-beta-23302", + "System.ComponentModel": "4.0.1-beta-23302", + "System.Console": "4.0.0-beta-23302", + "System.Diagnostics.Process": "4.0.0-beta-23302", + "System.Globalization": "4.0.10", + "System.Globalization.Calendars": "4.0.0", + "System.IO": "4.0.10", + "System.IO.FileSystem": "4.0.0", + "System.IO.FileSystem.Primitives": "4.0.0", + "System.Linq": "4.0.1-beta-23302", + "System.Linq.Queryable": "4.0.1-beta-23302", + "System.Reflection": "4.0.10", + "System.Reflection.Primitives": "4.0.0", + "System.Runtime": "4.0.20", + "System.Runtime.Extensions": "4.0.10", + "System.Runtime.Handles": "4.0.0", + "System.Runtime.InteropServices": "4.0.20", + "System.Runtime.Loader": "4.0.0-beta-23302", + "System.Text.Encoding": "4.0.10", + "System.Threading": "4.0.10", + "System.Xml.ReaderWriter": "4.0.11-beta-23302", + "System.Xml.XDocument": "4.0.11-beta-23302", + "System.Xml.XmlDocument": "4.0.1-beta-23302", + "System.Xml.XmlSerializer": "4.0.11-beta-23302" + }, + "frameworks": { + "dnxcore50": {} + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/generics/GenericExceptions.cs b/tests/src/baseservices/exceptions/generics/GenericExceptions.cs new file mode 100644 index 0000000000..371732d09d --- /dev/null +++ b/tests/src/baseservices/exceptions/generics/GenericExceptions.cs @@ -0,0 +1,334 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Globalization; +using System.IO; + +class MyException : Exception +{ +} + +public class Help +{ + public static Exception s_exceptionToThrow; + public static bool s_matchingException; + + public static Object s_object = new object(); +} + +public class A<T> where T : Exception +{ + + public void InstanceFunctionWithFewArgs() + { + try + { + throw Help.s_exceptionToThrow; + } + catch (T match) + { + if (!Help.s_matchingException) + throw new Exception("This should not have been caught here", match); + + Console.WriteLine("Caught matching " + match.GetType()); + } + catch(Exception mismatch) + { + if (Help.s_matchingException) + throw new Exception("Should have been caught above", mismatch); + + Console.WriteLine("Expected mismatch " + mismatch.GetType()); + } + } + + public void InstanceFunctionWithManyArgs(int i, int j, int k, object o) + { + try + { + throw Help.s_exceptionToThrow; + } + catch (T match) + { + if (!Help.s_matchingException) + throw new Exception("This should not have been caught here", match); + + Console.WriteLine("Caught matching " + match.GetType()); + } + catch(Exception mismatch) + { + if (Help.s_matchingException) + throw new Exception("Should have been caught above", mismatch); + + Console.WriteLine("Expected mismatch " + mismatch.GetType()); + } + } + + public static void StaticFunctionWithFewArgs() + { + try + { + throw Help.s_exceptionToThrow; + } + catch (T match) + { + if (!Help.s_matchingException) + throw new Exception("This should not have been caught here", match); + + Console.WriteLine("Caught matching " + match.GetType()); + } + catch(Exception mismatch) + { + if (Help.s_matchingException) + throw new Exception("Should have been caught above", mismatch); + + Console.WriteLine("Expected mismatch " + mismatch.GetType()); + } } + + public static void StaticFunctionWithManyArgs(int i, int j, int k, object o) + { + try + { + throw Help.s_exceptionToThrow; + } + catch (T match) + { + if (!Help.s_matchingException) + throw new Exception("This should not have been caught here", match); + + Console.WriteLine("Caught matching " + match.GetType()); + } + catch(Exception mismatch) + { + if (Help.s_matchingException) + throw new Exception("Should have been caught above", mismatch); + + Console.WriteLine("Expected mismatch " + mismatch.GetType()); + } + } + + public static void GenericFunctionWithFewArgs<X>() where X : Exception + { + try + { + throw Help.s_exceptionToThrow; + } + catch (X match) + { + if (!Help.s_matchingException) + throw new Exception("This should not have been caught here", match); + + Console.WriteLine("Caught matching " + match.GetType()); + } + catch(Exception mismatch) + { + if (Help.s_matchingException) + throw new Exception("Should have been caught above", mismatch); + + Console.WriteLine("Expected mismatch " + mismatch.GetType()); + } + } + + public static void GenericFunctionWithManyArgs<X>(int i, int j, int k, object o) where X : Exception + { + try + { + throw Help.s_exceptionToThrow; + } + catch (X match) + { + if (!Help.s_matchingException) + throw new Exception("This should not have been caught here", match); + + Console.WriteLine("Caught matching " + match.GetType()); + } + catch(Exception mismatch) + { + if (Help.s_matchingException) + throw new Exception("Should have been caught above", mismatch); + + Console.WriteLine("Expected mismatch " + mismatch.GetType()); + } + } +} + +public struct Struct<T> where T : Exception +{ + + public void StructInstanceFunctionWithFewArgs() + { + try + { + throw Help.s_exceptionToThrow; + } + catch (T match) + { + if (!Help.s_matchingException) + throw new Exception("This should not have been caught here", match); + + Console.WriteLine("Caught matching " + match.GetType()); + } + catch(Exception mismatch) + { + if (Help.s_matchingException) + throw new Exception("Should have been caught above", mismatch); + + Console.WriteLine("Expected mismatch " + mismatch.GetType()); + } + } + + public void StructInstanceFunctionWithManyArgs(int i, int j, int k, object o) + { + try + { + throw Help.s_exceptionToThrow; + } + catch (T match) + { + if (!Help.s_matchingException) + throw new Exception("This should not have been caught here", match); + + Console.WriteLine("Caught matching " + match.GetType()); + } + catch(Exception mismatch) + { + if (Help.s_matchingException) + throw new Exception("Should have been caught above", mismatch); + + Console.WriteLine("Expected mismatch " + mismatch.GetType()); + } + } +} + +public class GenericExceptions +{ + public static void InstanceFunctionWithFewArgs() + { + Help.s_matchingException = true; + Help.s_exceptionToThrow = new MyException(); + (new A<Exception>()).InstanceFunctionWithFewArgs(); + (new A<MyException>()).InstanceFunctionWithFewArgs(); + + Help.s_matchingException = false; + Help.s_exceptionToThrow = new Exception(); + (new A<MyException>()).InstanceFunctionWithFewArgs(); + } + + public static void InstanceFunctionWithManyArgs() + { + Help.s_matchingException = true; + Help.s_exceptionToThrow = new MyException(); + (new A<Exception>()).InstanceFunctionWithManyArgs(1, 2, 3, Help.s_object); + (new A<MyException>()).InstanceFunctionWithManyArgs(1, 2, 3, Help.s_object); + + Help.s_matchingException = false; + Help.s_exceptionToThrow = new Exception(); + (new A<MyException>()).InstanceFunctionWithManyArgs(1, 2, 3, Help.s_object); + } + + public static void StaticFunctionWithFewArgs() + { + Help.s_matchingException = true; + Help.s_exceptionToThrow = new MyException(); + A<Exception>.StaticFunctionWithFewArgs(); + A<MyException>.StaticFunctionWithFewArgs(); + + Help.s_matchingException = false; + Help.s_exceptionToThrow = new Exception(); + A<MyException>.StaticFunctionWithFewArgs(); + } + + public static void StaticFunctionWithManyArgs() + { + Help.s_matchingException = true; + Help.s_exceptionToThrow = new MyException(); + A<Exception>.StaticFunctionWithManyArgs(1, 2, 3, Help.s_object); + A<MyException>.StaticFunctionWithManyArgs(1, 2, 3, Help.s_object); + + Help.s_matchingException = false; + Help.s_exceptionToThrow = new Exception(); + A<MyException>.StaticFunctionWithManyArgs(1, 2, 3, Help.s_object); + } + + public static void GenericFunctionWithFewArgs() + { + Help.s_matchingException = true; + Help.s_exceptionToThrow = new MyException(); + A<DivideByZeroException>.GenericFunctionWithFewArgs<Exception>(); + A<DivideByZeroException>.GenericFunctionWithFewArgs<MyException>(); + + Help.s_matchingException = false; + Help.s_exceptionToThrow = new Exception(); + A<DivideByZeroException>.GenericFunctionWithFewArgs<MyException>(); + } + + public static void GenericFunctionWithManyArgs() + { + Help.s_matchingException = true; + Help.s_exceptionToThrow = new MyException(); + A<DivideByZeroException>.GenericFunctionWithManyArgs<Exception>(1, 2, 3, Help.s_object); + A<DivideByZeroException>.GenericFunctionWithManyArgs<MyException>(1, 2, 3, Help.s_object); + + Help.s_matchingException = false; + Help.s_exceptionToThrow = new Exception(); + A<DivideByZeroException>.GenericFunctionWithManyArgs<MyException>(1, 2, 3, Help.s_object); + } + + public static void StructInstanceFunctionWithFewArgs() + { + Help.s_matchingException = true; + Help.s_exceptionToThrow = new MyException(); + (new Struct<Exception>()).StructInstanceFunctionWithFewArgs(); + (new Struct<MyException>()).StructInstanceFunctionWithFewArgs(); + + Help.s_matchingException = false; + Help.s_exceptionToThrow = new Exception(); + (new Struct<MyException>()).StructInstanceFunctionWithFewArgs(); + } + + public static void StructInstanceFunctionWithManyArgs() + { + Help.s_matchingException = true; + Help.s_exceptionToThrow = new MyException(); + (new Struct<Exception>()).StructInstanceFunctionWithManyArgs(1, 2, 3, Help.s_object); + (new Struct<MyException>()).StructInstanceFunctionWithManyArgs(1, 2, 3, Help.s_object); + + Help.s_matchingException = false; + Help.s_exceptionToThrow = new Exception(); + (new Struct<MyException>()).StructInstanceFunctionWithManyArgs(1, 2, 3, Help.s_object); + } + + [System.Runtime.CompilerServices.MethodImpl( + System.Runtime.CompilerServices.MethodImplOptions.NoInlining)] + public static int Main() + { + try + { + Console.WriteLine("This test checks that we can catch generic exceptions."); + Console.WriteLine("All exceptions should be handled by the test itself"); + + InstanceFunctionWithFewArgs(); + InstanceFunctionWithManyArgs(); + + StaticFunctionWithFewArgs(); + StaticFunctionWithManyArgs(); + + GenericFunctionWithFewArgs(); + GenericFunctionWithManyArgs(); + + StructInstanceFunctionWithFewArgs(); + StructInstanceFunctionWithManyArgs(); + + } + catch(Exception) + { + Console.WriteLine("Test Failed"); + return -1; + } + + Console.WriteLine("Test Passed"); + return 100; + } + +} diff --git a/tests/src/baseservices/exceptions/generics/GenericExceptions.csproj b/tests/src/baseservices/exceptions/generics/GenericExceptions.csproj new file mode 100644 index 0000000000..5d70494be7 --- /dev/null +++ b/tests/src/baseservices/exceptions/generics/GenericExceptions.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="genericexceptions.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/generics/try-fault-struct01.il b/tests/src/baseservices/exceptions/generics/try-fault-struct01.il index 511a2e88c6..fac44bff48 100644 --- a/tests/src/baseservices/exceptions/generics/try-fault-struct01.il +++ b/tests/src/baseservices/exceptions/generics/try-fault-struct01.il @@ -1,3 +1,6 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. // Microsoft (R) .NET Framework IL Disassembler. Version 1.2.2211.0 // Copyright (C) Microsoft Corporation 1998-2002. All rights reserved. @@ -5,12 +8,11 @@ // Metadata version: v1.1.2211 -.assembly extern mscorlib +.assembly extern legacy library mscorlib {} +.assembly extern System.Console { - .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. - .hash = (32 83 18 13 53 59 D7 A6 73 07 31 5C FB 07 BE AC // 2...SY..s.1\.... - 80 11 4E 4D ) // ..NM - .ver 1:2:3300:0 + .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) + .ver 4:0:0:0 } .assembly 'try-finally01' { @@ -316,7 +318,7 @@ IL_001f: box [mscorlib]System.Int32 IL_0024: call string [mscorlib]System.String::Concat(object, object) - IL_0029: call void [mscorlib]System.Console::WriteLine(string) + IL_0029: call void [System.Console]System.Console::WriteLine(string) IL_002e: ret } // end of method Test::Eval @@ -729,12 +731,12 @@ IL_03e2: ldsfld bool Test::result IL_03e7: brfalse.s IL_03f8 IL_03e9: ldstr "Test Passed" - IL_03ee: call void [mscorlib]System.Console::WriteLine(string) + IL_03ee: call void [System.Console]System.Console::WriteLine(string) IL_03f3: ldc.i4.s 100 IL_03f5: stloc.0 IL_03f6: br.s IL_0406 IL_03f8: ldstr "Test Failed" - IL_03fd: call void [mscorlib]System.Console::WriteLine(string) + IL_03fd: call void [System.Console]System.Console::WriteLine(string) IL_0402: ldc.i4.1 IL_0403: stloc.0 IL_0404: br.s IL_0406 diff --git a/tests/src/baseservices/exceptions/generics/try-fault-struct01.ilproj b/tests/src/baseservices/exceptions/generics/try-fault-struct01.ilproj new file mode 100644 index 0000000000..1c79689a92 --- /dev/null +++ b/tests/src/baseservices/exceptions/generics/try-fault-struct01.ilproj @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <AssemblyName>$(MSBuildProjectName)</AssemblyName> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <PropertyGroup> + + </PropertyGroup> + <ItemGroup> + <Compile Include="try-fault-struct01.il" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/generics/try-fault-struct02.il b/tests/src/baseservices/exceptions/generics/try-fault-struct02.il index 6b1e105f8f..d57f3bd26e 100644 --- a/tests/src/baseservices/exceptions/generics/try-fault-struct02.il +++ b/tests/src/baseservices/exceptions/generics/try-fault-struct02.il @@ -1,3 +1,6 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. // Microsoft (R) .NET Framework IL Disassembler. Version 1.2.2211.0 // Copyright (C) Microsoft Corporation 1998-2002. All rights reserved. @@ -5,12 +8,11 @@ // Metadata version: v1.1.2211 -.assembly extern mscorlib +.assembly extern legacy library mscorlib {} +.assembly extern System.Console { - .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. - .hash = (32 83 18 13 53 59 D7 A6 73 07 31 5C FB 07 BE AC // 2...SY..s.1\.... - 80 11 4E 4D ) // ..NM - .ver 1:2:3300:0 + .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) + .ver 4:0:0:0 } .assembly 'try-finally01' { @@ -317,7 +319,7 @@ IL_001f: box [mscorlib]System.Int32 IL_0024: call string [mscorlib]System.String::Concat(object, object) - IL_0029: call void [mscorlib]System.Console::WriteLine(string) + IL_0029: call void [System.Console]System.Console::WriteLine(string) IL_002e: ret } // end of method Test::Eval @@ -730,12 +732,12 @@ IL_03e2: ldsfld bool Test::result IL_03e7: brfalse.s IL_03f8 IL_03e9: ldstr "Test Passed" - IL_03ee: call void [mscorlib]System.Console::WriteLine(string) + IL_03ee: call void [System.Console]System.Console::WriteLine(string) IL_03f3: ldc.i4.s 100 IL_03f5: stloc.0 IL_03f6: br.s IL_0406 IL_03f8: ldstr "Test Failed" - IL_03fd: call void [mscorlib]System.Console::WriteLine(string) + IL_03fd: call void [System.Console]System.Console::WriteLine(string) IL_0402: ldc.i4.1 IL_0403: stloc.0 IL_0404: br.s IL_0406 diff --git a/tests/src/baseservices/exceptions/generics/try-fault-struct02.ilproj b/tests/src/baseservices/exceptions/generics/try-fault-struct02.ilproj new file mode 100644 index 0000000000..72d7c6a72f --- /dev/null +++ b/tests/src/baseservices/exceptions/generics/try-fault-struct02.ilproj @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <AssemblyName>$(MSBuildProjectName)</AssemblyName> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <PropertyGroup> + + </PropertyGroup> + <ItemGroup> + <Compile Include="try-fault-struct02.il" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/generics/try-fault-struct03.il b/tests/src/baseservices/exceptions/generics/try-fault-struct03.il index 8bbdfcb0bc..9f9d662dfc 100644 --- a/tests/src/baseservices/exceptions/generics/try-fault-struct03.il +++ b/tests/src/baseservices/exceptions/generics/try-fault-struct03.il @@ -1,3 +1,6 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. // Microsoft (R) .NET Framework IL Disassembler. Version 1.2.2211.0 // Copyright (C) Microsoft Corporation 1998-2002. All rights reserved. @@ -5,12 +8,11 @@ // Metadata version: v1.1.2211 -.assembly extern mscorlib +.assembly extern legacy library mscorlib {} +.assembly extern System.Console { - .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. - .hash = (32 83 18 13 53 59 D7 A6 73 07 31 5C FB 07 BE AC // 2...SY..s.1\.... - 80 11 4E 4D ) // ..NM - .ver 1:2:3300:0 + .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) + .ver 4:0:0:0 } .assembly 'try-fault-struct03' { @@ -318,7 +320,7 @@ IL_001f: box [mscorlib]System.Int32 IL_0024: call string [mscorlib]System.String::Concat(object, object) - IL_0029: call void [mscorlib]System.Console::WriteLine(string) + IL_0029: call void [System.Console]System.Console::WriteLine(string) IL_002e: ret } // end of method Test::Eval @@ -731,12 +733,12 @@ IL_03e2: ldsfld bool Test::result IL_03e7: brfalse.s IL_03f8 IL_03e9: ldstr "Test Passed" - IL_03ee: call void [mscorlib]System.Console::WriteLine(string) + IL_03ee: call void [System.Console]System.Console::WriteLine(string) IL_03f3: ldc.i4.s 100 IL_03f5: stloc.0 IL_03f6: br.s IL_0406 IL_03f8: ldstr "Test Failed" - IL_03fd: call void [mscorlib]System.Console::WriteLine(string) + IL_03fd: call void [System.Console]System.Console::WriteLine(string) IL_0402: ldc.i4.1 IL_0403: stloc.0 IL_0404: br.s IL_0406 diff --git a/tests/src/baseservices/exceptions/generics/try-fault-struct03.ilproj b/tests/src/baseservices/exceptions/generics/try-fault-struct03.ilproj new file mode 100644 index 0000000000..94c3b156a9 --- /dev/null +++ b/tests/src/baseservices/exceptions/generics/try-fault-struct03.ilproj @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <AssemblyName>$(MSBuildProjectName)</AssemblyName> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <PropertyGroup> + + </PropertyGroup> + <ItemGroup> + <Compile Include="try-fault-struct03.il" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/generics/try-fault01.il b/tests/src/baseservices/exceptions/generics/try-fault01.il index d3227ac683..8572fcd159 100644 --- a/tests/src/baseservices/exceptions/generics/try-fault01.il +++ b/tests/src/baseservices/exceptions/generics/try-fault01.il @@ -1,3 +1,6 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. // Microsoft (R) .NET Framework IL Disassembler. Version 1.2.2211.0 // Copyright (C) Microsoft Corporation 1998-2002. All rights reserved. @@ -5,12 +8,11 @@ // Metadata version: v1.1.2211 -.assembly extern mscorlib +.assembly extern legacy library mscorlib {} +.assembly extern System.Console { - .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. - .hash = (32 83 18 13 53 59 D7 A6 73 07 31 5C FB 07 BE AC // 2...SY..s.1\.... - 80 11 4E 4D ) // ..NM - .ver 1:2:3300:0 + .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) + .ver 4:0:0:0 } .assembly 'try-finally01' { @@ -327,7 +329,7 @@ IL_001f: box [mscorlib]System.Int32 IL_0024: call string [mscorlib]System.String::Concat(object, object) - IL_0029: call void [mscorlib]System.Console::WriteLine(string) + IL_0029: call void [System.Console]System.Console::WriteLine(string) IL_002e: ret } // end of method Test::Eval @@ -491,13 +493,13 @@ IL_022b: brfalse.s IL_023c IL_022d: ldstr "Test Passed" - IL_0232: call void [mscorlib]System.Console::WriteLine(string) + IL_0232: call void [System.Console]System.Console::WriteLine(string) IL_0237: ldc.i4.s 100 IL_0239: stloc.0 IL_023a: br.s IL_024a IL_023c: ldstr "Test Failed" - IL_0241: call void [mscorlib]System.Console::WriteLine(string) + IL_0241: call void [System.Console]System.Console::WriteLine(string) IL_0246: ldc.i4.1 IL_0247: stloc.0 IL_0248: br.s IL_024a diff --git a/tests/src/baseservices/exceptions/generics/try-fault01.ilproj b/tests/src/baseservices/exceptions/generics/try-fault01.ilproj new file mode 100644 index 0000000000..349b9cb27f --- /dev/null +++ b/tests/src/baseservices/exceptions/generics/try-fault01.ilproj @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <AssemblyName>$(MSBuildProjectName)</AssemblyName> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <PropertyGroup> + + </PropertyGroup> + <ItemGroup> + <Compile Include="try-fault01.il" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/generics/try-fault02.il b/tests/src/baseservices/exceptions/generics/try-fault02.il index 3206680941..96323ffb5b 100644 --- a/tests/src/baseservices/exceptions/generics/try-fault02.il +++ b/tests/src/baseservices/exceptions/generics/try-fault02.il @@ -1,3 +1,6 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. // Microsoft (R) .NET Framework IL Disassembler. Version 1.2.2211.0 // Copyright (C) Microsoft Corporation 1998-2002. All rights reserved. @@ -5,12 +8,11 @@ // Metadata version: v1.1.2211 -.assembly extern mscorlib +.assembly extern legacy library mscorlib {} +.assembly extern System.Console { - .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. - .hash = (32 83 18 13 53 59 D7 A6 73 07 31 5C FB 07 BE AC // 2...SY..s.1\.... - 80 11 4E 4D ) // ..NM - .ver 1:2:3300:0 + .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) + .ver 4:0:0:0 } .assembly 'try-finally01' { @@ -327,7 +329,7 @@ IL_001f: box [mscorlib]System.Int32 IL_0024: call string [mscorlib]System.String::Concat(object, object) - IL_0029: call void [mscorlib]System.Console::WriteLine(string) + IL_0029: call void [System.Console]System.Console::WriteLine(string) IL_002e: ret } // end of method Test::Eval @@ -491,13 +493,13 @@ IL_022b: brfalse.s IL_023c IL_022d: ldstr "Test Passed" - IL_0232: call void [mscorlib]System.Console::WriteLine(string) + IL_0232: call void [System.Console]System.Console::WriteLine(string) IL_0237: ldc.i4.s 100 IL_0239: stloc.0 IL_023a: br.s IL_024a IL_023c: ldstr "Test Failed" - IL_0241: call void [mscorlib]System.Console::WriteLine(string) + IL_0241: call void [System.Console]System.Console::WriteLine(string) IL_0246: ldc.i4.1 IL_0247: stloc.0 IL_0248: br.s IL_024a diff --git a/tests/src/baseservices/exceptions/generics/try-fault02.ilproj b/tests/src/baseservices/exceptions/generics/try-fault02.ilproj new file mode 100644 index 0000000000..344b0bec7b --- /dev/null +++ b/tests/src/baseservices/exceptions/generics/try-fault02.ilproj @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <AssemblyName>$(MSBuildProjectName)</AssemblyName> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <PropertyGroup> + + </PropertyGroup> + <ItemGroup> + <Compile Include="try-fault02.il" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/generics/try-fault03.il b/tests/src/baseservices/exceptions/generics/try-fault03.il index 657d5ac2d0..53b05dc532 100644 --- a/tests/src/baseservices/exceptions/generics/try-fault03.il +++ b/tests/src/baseservices/exceptions/generics/try-fault03.il @@ -1,3 +1,6 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. // Microsoft (R) .NET Framework IL Disassembler. Version 1.2.2211.0 // Copyright (C) Microsoft Corporation 1998-2002. All rights reserved. @@ -5,12 +8,11 @@ // Metadata version: v1.1.2211 -.assembly extern mscorlib +.assembly extern legacy library mscorlib {} +.assembly extern System.Console { - .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. - .hash = (32 83 18 13 53 59 D7 A6 73 07 31 5C FB 07 BE AC // 2...SY..s.1\.... - 80 11 4E 4D ) // ..NM - .ver 1:2:3300:0 + .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) + .ver 4:0:0:0 } .assembly 'try-finally03' { @@ -328,7 +330,7 @@ IL_001f: box [mscorlib]System.Int32 IL_0024: call string [mscorlib]System.String::Concat(object, object) - IL_0029: call void [mscorlib]System.Console::WriteLine(string) + IL_0029: call void [System.Console]System.Console::WriteLine(string) IL_002e: ret } // end of method Test::Eval @@ -492,13 +494,13 @@ IL_022b: brfalse.s IL_023c IL_022d: ldstr "Test Passed" - IL_0232: call void [mscorlib]System.Console::WriteLine(string) + IL_0232: call void [System.Console]System.Console::WriteLine(string) IL_0237: ldc.i4.s 100 IL_0239: stloc.0 IL_023a: br.s IL_024a IL_023c: ldstr "Test Failed" - IL_0241: call void [mscorlib]System.Console::WriteLine(string) + IL_0241: call void [System.Console]System.Console::WriteLine(string) IL_0246: ldc.i4.1 IL_0247: stloc.0 IL_0248: br.s IL_024a diff --git a/tests/src/baseservices/exceptions/generics/try-fault03.ilproj b/tests/src/baseservices/exceptions/generics/try-fault03.ilproj new file mode 100644 index 0000000000..ff18d00e19 --- /dev/null +++ b/tests/src/baseservices/exceptions/generics/try-fault03.ilproj @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <AssemblyName>$(MSBuildProjectName)</AssemblyName> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <PropertyGroup> + + </PropertyGroup> + <ItemGroup> + <Compile Include="try-fault03.il" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/generics/try-filter-finally01.il b/tests/src/baseservices/exceptions/generics/try-filter-finally01.il index 95d79be719..5b45064d77 100644 --- a/tests/src/baseservices/exceptions/generics/try-filter-finally01.il +++ b/tests/src/baseservices/exceptions/generics/try-filter-finally01.il @@ -1,3 +1,6 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. // Microsoft (R) .NET Framework IL Disassembler. Version 1.2.2211.0 // Copyright (C) Microsoft Corporation 1998-2002. All rights reserved. @@ -5,12 +8,11 @@ // Metadata version: v1.1.2211 -.assembly extern mscorlib +.assembly extern legacy library mscorlib {} +.assembly extern System.Console { - .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. - .hash = (32 83 18 13 53 59 D7 A6 73 07 31 5C FB 07 BE AC // 2...SY..s.1\.... - 80 11 4E 4D ) // ..NM - .ver 1:2:3300:0 + .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) + .ver 4:0:0:0 } .assembly 'try-catch01' { @@ -347,7 +349,7 @@ IL_001f: box [mscorlib]System.Int32 IL_0024: call string [mscorlib]System.String::Concat(object, object) - IL_0029: call void [mscorlib]System.Console::WriteLine(string) + IL_0029: call void [System.Console]System.Console::WriteLine(string) IL_002e: ret } // end of method Test::Eval @@ -511,13 +513,13 @@ IL_022b: brfalse.s IL_023c IL_022d: ldstr "Test Passed" - IL_0232: call void [mscorlib]System.Console::WriteLine(string) + IL_0232: call void [System.Console]System.Console::WriteLine(string) IL_0237: ldc.i4.s 100 IL_0239: stloc.0 IL_023a: br.s IL_024a IL_023c: ldstr "Test Failed" - IL_0241: call void [mscorlib]System.Console::WriteLine(string) + IL_0241: call void [System.Console]System.Console::WriteLine(string) IL_0246: ldc.i4.1 IL_0247: stloc.0 IL_0248: br.s IL_024a diff --git a/tests/src/baseservices/exceptions/generics/try-filter-finally01.ilproj b/tests/src/baseservices/exceptions/generics/try-filter-finally01.ilproj new file mode 100644 index 0000000000..595ca4860b --- /dev/null +++ b/tests/src/baseservices/exceptions/generics/try-filter-finally01.ilproj @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <AssemblyName>$(MSBuildProjectName)</AssemblyName> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <PropertyGroup> + + </PropertyGroup> + <ItemGroup> + <Compile Include="try-filter-finally01.il" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/generics/try-filter-finally02.il b/tests/src/baseservices/exceptions/generics/try-filter-finally02.il index 5c09ac7ad9..3fe83f7a9d 100644 --- a/tests/src/baseservices/exceptions/generics/try-filter-finally02.il +++ b/tests/src/baseservices/exceptions/generics/try-filter-finally02.il @@ -1,3 +1,6 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. // Microsoft (R) .NET Framework IL Disassembler. Version 1.2.2211.0 // Copyright (C) Microsoft Corporation 1998-2002. All rights reserved. @@ -5,12 +8,11 @@ // Metadata version: v1.1.2211 -.assembly extern mscorlib +.assembly extern legacy library mscorlib {} +.assembly extern System.Console { - .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. - .hash = (32 83 18 13 53 59 D7 A6 73 07 31 5C FB 07 BE AC // 2...SY..s.1\.... - 80 11 4E 4D ) // ..NM - .ver 1:2:3300:0 + .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) + .ver 4:0:0:0 } .assembly 'try-catch01' { @@ -357,7 +359,7 @@ IL_001f: box [mscorlib]System.Int32 IL_0024: call string [mscorlib]System.String::Concat(object, object) - IL_0029: call void [mscorlib]System.Console::WriteLine(string) + IL_0029: call void [System.Console]System.Console::WriteLine(string) IL_002e: ret } // end of method Test::Eval @@ -521,13 +523,13 @@ IL_022b: brfalse.s IL_023c IL_022d: ldstr "Test Passed" - IL_0232: call void [mscorlib]System.Console::WriteLine(string) + IL_0232: call void [System.Console]System.Console::WriteLine(string) IL_0237: ldc.i4.s 100 IL_0239: stloc.0 IL_023a: br.s IL_024a IL_023c: ldstr "Test Failed" - IL_0241: call void [mscorlib]System.Console::WriteLine(string) + IL_0241: call void [System.Console]System.Console::WriteLine(string) IL_0246: ldc.i4.1 IL_0247: stloc.0 IL_0248: br.s IL_024a diff --git a/tests/src/baseservices/exceptions/generics/try-filter-finally02.ilproj b/tests/src/baseservices/exceptions/generics/try-filter-finally02.ilproj new file mode 100644 index 0000000000..5eef87ca28 --- /dev/null +++ b/tests/src/baseservices/exceptions/generics/try-filter-finally02.ilproj @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <AssemblyName>$(MSBuildProjectName)</AssemblyName> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <PropertyGroup> + + </PropertyGroup> + <ItemGroup> + <Compile Include="try-filter-finally02.il" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/generics/try-filter-struct02.il b/tests/src/baseservices/exceptions/generics/try-filter-struct02.il index a42b7fb17b..6398a01623 100644 --- a/tests/src/baseservices/exceptions/generics/try-filter-struct02.il +++ b/tests/src/baseservices/exceptions/generics/try-filter-struct02.il @@ -1,3 +1,6 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. // Microsoft (R) .NET Framework IL Disassembler. Version 1.2.2211.0 // Copyright (C) Microsoft Corporation 1998-2002. All rights reserved. @@ -5,12 +8,11 @@ // Metadata version: v1.1.2211 -.assembly extern mscorlib +.assembly extern legacy library mscorlib {} +.assembly extern System.Console { - .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. - .hash = (32 83 18 13 53 59 D7 A6 73 07 31 5C FB 07 BE AC // 2...SY..s.1\.... - 80 11 4E 4D ) // ..NM - .ver 1:2:3300:0 + .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) + .ver 4:0:0:0 } .assembly 'try-catch01' { @@ -329,7 +331,7 @@ IL_001f: box [mscorlib]System.Int32 IL_0024: call string [mscorlib]System.String::Concat(object, object) - IL_0029: call void [mscorlib]System.Console::WriteLine(string) + IL_0029: call void [System.Console]System.Console::WriteLine(string) IL_002e: ret } // end of method Test::Eval @@ -742,12 +744,12 @@ IL_03e2: ldsfld bool Test::result IL_03e7: brfalse.s IL_03f8 IL_03e9: ldstr "Test Passed" - IL_03ee: call void [mscorlib]System.Console::WriteLine(string) + IL_03ee: call void [System.Console]System.Console::WriteLine(string) IL_03f3: ldc.i4.s 100 IL_03f5: stloc.0 IL_03f6: br.s IL_0406 IL_03f8: ldstr "Test Failed" - IL_03fd: call void [mscorlib]System.Console::WriteLine(string) + IL_03fd: call void [System.Console]System.Console::WriteLine(string) IL_0402: ldc.i4.1 IL_0403: stloc.0 IL_0404: br.s IL_0406 diff --git a/tests/src/baseservices/exceptions/generics/try-filter-struct02.ilproj b/tests/src/baseservices/exceptions/generics/try-filter-struct02.ilproj new file mode 100644 index 0000000000..4508a88144 --- /dev/null +++ b/tests/src/baseservices/exceptions/generics/try-filter-struct02.ilproj @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <AssemblyName>$(MSBuildProjectName)</AssemblyName> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <PropertyGroup> + + </PropertyGroup> + <ItemGroup> + <Compile Include="try-filter-struct02.il" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/generics/try-filter02.il b/tests/src/baseservices/exceptions/generics/try-filter02.il new file mode 100644 index 0000000000..79ebba877d --- /dev/null +++ b/tests/src/baseservices/exceptions/generics/try-filter02.il @@ -0,0 +1,554 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +// Microsoft (R) .NET Framework IL Disassembler. Version 1.2.2211.0 +// Copyright (C) Microsoft Corporation 1998-2002. All rights reserved. + + + +// Metadata version: v1.1.2211 +.assembly extern legacy library mscorlib {} +.assembly extern System.Console +{ + .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) + .ver 4:0:0:0 +} +.assembly 'try-catch01' +{ + + // --- The following custom attribute is added automatically, do not uncomment ------- + // .custom instance void [mscorlib]System.Diagnostics.DebuggableAttribute::.ctor(bool, + // bool) = ( 01 00 00 01 00 00 ) + + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module 'try-catch01.exe' +// MVID: {76712D77-A992-40B1-9AD0-E58BD9DA334B} +.imagebase 0x00400000 +.subsystem 0x00000003 +.file alignment 512 +.corflags 0x00000001 +// Image base: 0x02DB0000 + +// =============== CLASS MEMBERS DECLARATION =================== + +.class public sequential ansi sealed beforefieldinit ValX0 + extends [mscorlib]System.ValueType +{ + .pack 0 + .size 1 +} // end of class ValX0 + +.class public sequential ansi sealed beforefieldinit ValY0 + extends [mscorlib]System.ValueType +{ + .pack 0 + .size 1 +} // end of class ValY0 + +.class public sequential ansi sealed beforefieldinit ValX1<([mscorlib]System.Object) T> + extends [mscorlib]System.ValueType +{ + .pack 0 + .size 1 +} // end of class ValX1 + +.class public sequential ansi sealed beforefieldinit ValY1<([mscorlib]System.Object) T> + extends [mscorlib]System.ValueType +{ + .pack 0 + .size 1 +} // end of class ValY1 + +.class public sequential ansi sealed beforefieldinit ValX2<([mscorlib]System.Object) T,([mscorlib]System.Object) U> + extends [mscorlib]System.ValueType +{ + .pack 0 + .size 1 +} // end of class ValX2 + +.class public sequential ansi sealed beforefieldinit ValY2<([mscorlib]System.Object) T,([mscorlib]System.Object) U> + extends [mscorlib]System.ValueType +{ + .pack 0 + .size 1 +} // end of class ValY2 + +.class public sequential ansi sealed beforefieldinit ValX3<([mscorlib]System.Object) T,([mscorlib]System.Object) U,([mscorlib]System.Object) V> + extends [mscorlib]System.ValueType +{ + .pack 0 + .size 1 +} // end of class ValX3 + +.class public sequential ansi sealed beforefieldinit ValY3<([mscorlib]System.Object) T,([mscorlib]System.Object) U,([mscorlib]System.Object) V> + extends [mscorlib]System.ValueType +{ + .pack 0 + .size 1 +} // end of class ValY3 + +.class public auto ansi beforefieldinit RefX0 + extends [mscorlib]System.Object +{ + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method RefX0::.ctor + +} // end of class RefX0 + +.class public auto ansi beforefieldinit RefY0 + extends [mscorlib]System.Object +{ + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method RefY0::.ctor + +} // end of class RefY0 + +.class public auto ansi beforefieldinit RefX1<([mscorlib]System.Object) T> + extends [mscorlib]System.Object +{ + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method RefX1::.ctor + +} // end of class RefX1 + +.class public auto ansi beforefieldinit RefY1<([mscorlib]System.Object) T> + extends [mscorlib]System.Object +{ + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method RefY1::.ctor + +} // end of class RefY1 + +.class public auto ansi beforefieldinit RefX2<([mscorlib]System.Object) T,([mscorlib]System.Object) U> + extends [mscorlib]System.Object +{ + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method RefX2::.ctor + +} // end of class RefX2 + +.class public auto ansi beforefieldinit RefY2<([mscorlib]System.Object) T,([mscorlib]System.Object) U> + extends [mscorlib]System.Object +{ + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method RefY2::.ctor + +} // end of class RefY2 + +.class public auto ansi beforefieldinit RefX3<([mscorlib]System.Object) T,([mscorlib]System.Object) U,([mscorlib]System.Object) V> + extends [mscorlib]System.Object +{ + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method RefX3::.ctor + +} // end of class RefX3 + +.class public auto ansi beforefieldinit RefY3<([mscorlib]System.Object) T,([mscorlib]System.Object) U,([mscorlib]System.Object) V> + extends [mscorlib]System.Object +{ + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method RefY3::.ctor + +} // end of class RefY3 + +.class public auto ansi beforefieldinit GenException<([mscorlib]System.Object) T> + extends [mscorlib]System.Exception +{ + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Exception::.ctor() + IL_0006: ret + } // end of method GenException::.ctor + +} // end of class GenException + +.class public auto ansi beforefieldinit Gen<([mscorlib]System.Object) T> + extends [mscorlib]System.Object +{ + .method public hidebysig instance void + InternalExceptionTest(bool throwException) cil managed + { + // Code size 54 (0x36) + .maxstack 2 + .locals init (string V_0, + class [mscorlib]System.Exception V_1, + bool V_2) + IL_0000: ldtoken class GenException<!0> + IL_0005: call class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle) + IL_000a: callvirt instance string [mscorlib]System.Type::ToString() + IL_000f: stloc.0 + .try + { + ldc.i4.1 + stloc.2 + IL_0010: ldarg.1 + IL_0011: brfalse.s IL_0019 + + IL_0013: newobj instance void class GenException<!0>::.ctor() + IL_0018: throw + + IL_0019: ldarg.1 + IL_001a: brfalse.s IL_0022 + + IL_001c: ldc.i4.0 + IL_001d: call void Test::Eval(bool) + IL_0022: leave.s Exit + + } // end .try + filter + { + stloc.1 + ldloc.1 + isinst class GenException<!0> + ldnull + cgt.un + call void Test::Eval(bool) + ldc.i4.0 + endfilter + } + { + pop + ldc.i4.0 + stloc.2 + leave Exit + } + Exit: + ldloc.2 + call void Test::Eval(bool) + ret + } // end of method Gen::InternalExceptionTest + + .method public hidebysig instance void ExceptionTest(bool throwException) cil managed +{ + // Code size 28 (0x1c) + .maxstack 2 + .try + { + IL_0000: ldarg.0 + IL_0001: ldarg.1 + IL_0002: call instance void class Gen<!0>::InternalExceptionTest(bool) + IL_0007: ldarg.1 + IL_0008: ldc.i4.0 + IL_0009: ceq + IL_000b: call void Test::Eval(bool) + IL_0010: leave.s IL_001b + } // end .try + catch [mscorlib]System.Object + { + IL_0012: pop + IL_0013: ldarg.1 + IL_0014: call void Test::Eval(bool) + IL_0019: leave.s IL_001b + } // end handler + IL_001b: ret +} // end of method Gen::ExceptionTest + + + + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method Gen::.ctor + +} // end of class Gen + +.class public auto ansi beforefieldinit Test + extends [mscorlib]System.Object +{ + .field public static int32 counter + .field public static bool result + .method public hidebysig static void Eval(bool exp) cil managed + { + // Code size 47 (0x2f) + .maxstack 8 + IL_0000: ldsfld int32 Test::counter + IL_0005: ldc.i4.1 + IL_0006: add + IL_0007: stsfld int32 Test::counter + IL_000c: ldarg.0 + IL_000d: brtrue.s IL_002e + + IL_000f: ldarg.0 + IL_0010: stsfld bool Test::result + IL_0015: ldstr "Test Failed at location: " + IL_001a: ldsfld int32 Test::counter + IL_001f: box [mscorlib]System.Int32 + IL_0024: call string [mscorlib]System.String::Concat(object, + object) + IL_0029: call void [System.Console]System.Console::WriteLine(string) + IL_002e: ret + } // end of method Test::Eval + + .method public hidebysig static int32 Main() cil managed + { + .entrypoint + // Code size 588 (0x24c) + .maxstack 2 + .locals init (int32 V_0) + IL_0000: newobj instance void class Gen<int32>::.ctor() + IL_0005: ldc.i4.1 + IL_0006: call instance void class Gen<int32>::ExceptionTest(bool) + IL_000b: newobj instance void class Gen<float64>::.ctor() + IL_0010: ldc.i4.1 + IL_0011: call instance void class Gen<float64>::ExceptionTest(bool) + IL_0016: newobj instance void class Gen<string>::.ctor() + IL_001b: ldc.i4.1 + IL_001c: call instance void class Gen<string>::ExceptionTest(bool) + IL_0021: newobj instance void class Gen<object>::.ctor() + IL_0026: ldc.i4.1 + IL_0027: call instance void class Gen<object>::ExceptionTest(bool) + IL_002c: newobj instance void class Gen<valuetype [mscorlib]System.Guid>::.ctor() + IL_0031: ldc.i4.1 + IL_0032: call instance void class Gen<valuetype [mscorlib]System.Guid>::ExceptionTest(bool) + IL_0037: newobj instance void class Gen<int32[]>::.ctor() + IL_003c: ldc.i4.1 + IL_003d: call instance void class Gen<int32[]>::ExceptionTest(bool) + IL_0042: newobj instance void class Gen<float64[0...,0...]>::.ctor() + IL_0047: ldc.i4.1 + IL_0048: call instance void class Gen<float64[0...,0...]>::ExceptionTest(bool) + IL_004d: newobj instance void class Gen<string[][][]>::.ctor() + IL_0052: ldc.i4.1 + IL_0053: call instance void class Gen<string[][][]>::ExceptionTest(bool) + IL_0058: newobj instance void class Gen<object[0...,0...,0...,0...]>::.ctor() + IL_005d: ldc.i4.1 + IL_005e: call instance void class Gen<object[0...,0...,0...,0...]>::ExceptionTest(bool) + IL_0063: newobj instance void class Gen<valuetype [mscorlib]System.Guid[][0...,0...,0...,0...][]>::.ctor() + IL_0068: ldc.i4.1 + IL_0069: call instance void class Gen<valuetype [mscorlib]System.Guid[][0...,0...,0...,0...][]>::ExceptionTest(bool) + IL_006e: newobj instance void class Gen<class RefX1<int32>[]>::.ctor() + IL_0073: ldc.i4.1 + IL_0074: call instance void class Gen<class RefX1<int32>[]>::ExceptionTest(bool) + IL_0079: newobj instance void class Gen<class RefX1<float64>[0...,0...]>::.ctor() + IL_007e: ldc.i4.1 + IL_007f: call instance void class Gen<class RefX1<float64>[0...,0...]>::ExceptionTest(bool) + IL_0084: newobj instance void class Gen<class RefX1<string>[][][]>::.ctor() + IL_0089: ldc.i4.1 + IL_008a: call instance void class Gen<class RefX1<string>[][][]>::ExceptionTest(bool) + IL_008f: newobj instance void class Gen<class RefX1<object>[0...,0...,0...,0...]>::.ctor() + IL_0094: ldc.i4.1 + IL_0095: call instance void class Gen<class RefX1<object>[0...,0...,0...,0...]>::ExceptionTest(bool) + IL_009a: newobj instance void class Gen<class RefX1<valuetype [mscorlib]System.Guid>[][0...,0...,0...,0...][]>::.ctor() + IL_009f: ldc.i4.1 + IL_00a0: call instance void class Gen<class RefX1<valuetype [mscorlib]System.Guid>[][0...,0...,0...,0...][]>::ExceptionTest(bool) + IL_00a5: newobj instance void class Gen<class RefX2<int32,int32>[]>::.ctor() + IL_00aa: ldc.i4.1 + IL_00ab: call instance void class Gen<class RefX2<int32,int32>[]>::ExceptionTest(bool) + IL_00b0: newobj instance void class Gen<class RefX2<float64,float64>[0...,0...]>::.ctor() + IL_00b5: ldc.i4.1 + IL_00b6: call instance void class Gen<class RefX2<float64,float64>[0...,0...]>::ExceptionTest(bool) + IL_00bb: newobj instance void class Gen<class RefX2<string,string>[][][]>::.ctor() + IL_00c0: ldc.i4.1 + IL_00c1: call instance void class Gen<class RefX2<string,string>[][][]>::ExceptionTest(bool) + IL_00c6: newobj instance void class Gen<class RefX2<object,object>[0...,0...,0...,0...]>::.ctor() + IL_00cb: ldc.i4.1 + IL_00cc: call instance void class Gen<class RefX2<object,object>[0...,0...,0...,0...]>::ExceptionTest(bool) + IL_00d1: newobj instance void class Gen<class RefX2<valuetype [mscorlib]System.Guid,valuetype [mscorlib]System.Guid>[][0...,0...,0...,0...][]>::.ctor() + IL_00d6: ldc.i4.1 + IL_00d7: call instance void class Gen<class RefX2<valuetype [mscorlib]System.Guid,valuetype [mscorlib]System.Guid>[][0...,0...,0...,0...][]>::ExceptionTest(bool) + IL_00dc: newobj instance void class Gen<valuetype ValX1<int32>[]>::.ctor() + IL_00e1: ldc.i4.1 + IL_00e2: call instance void class Gen<valuetype ValX1<int32>[]>::ExceptionTest(bool) + IL_00e7: newobj instance void class Gen<valuetype ValX1<float64>[0...,0...]>::.ctor() + IL_00ec: ldc.i4.1 + IL_00ed: call instance void class Gen<valuetype ValX1<float64>[0...,0...]>::ExceptionTest(bool) + IL_00f2: newobj instance void class Gen<valuetype ValX1<string>[][][]>::.ctor() + IL_00f7: ldc.i4.1 + IL_00f8: call instance void class Gen<valuetype ValX1<string>[][][]>::ExceptionTest(bool) + IL_00fd: newobj instance void class Gen<valuetype ValX1<object>[0...,0...,0...,0...]>::.ctor() + IL_0102: ldc.i4.1 + IL_0103: call instance void class Gen<valuetype ValX1<object>[0...,0...,0...,0...]>::ExceptionTest(bool) + IL_0108: newobj instance void class Gen<valuetype ValX1<valuetype [mscorlib]System.Guid>[][0...,0...,0...,0...][]>::.ctor() + IL_010d: ldc.i4.1 + IL_010e: call instance void class Gen<valuetype ValX1<valuetype [mscorlib]System.Guid>[][0...,0...,0...,0...][]>::ExceptionTest(bool) + IL_0113: newobj instance void class Gen<valuetype ValX2<int32,int32>[]>::.ctor() + IL_0118: ldc.i4.1 + IL_0119: call instance void class Gen<valuetype ValX2<int32,int32>[]>::ExceptionTest(bool) + IL_011e: newobj instance void class Gen<valuetype ValX2<float64,float64>[0...,0...]>::.ctor() + IL_0123: ldc.i4.1 + IL_0124: call instance void class Gen<valuetype ValX2<float64,float64>[0...,0...]>::ExceptionTest(bool) + IL_0129: newobj instance void class Gen<valuetype ValX2<string,string>[][][]>::.ctor() + IL_012e: ldc.i4.1 + IL_012f: call instance void class Gen<valuetype ValX2<string,string>[][][]>::ExceptionTest(bool) + IL_0134: newobj instance void class Gen<valuetype ValX2<object,object>[0...,0...,0...,0...]>::.ctor() + IL_0139: ldc.i4.1 + IL_013a: call instance void class Gen<valuetype ValX2<object,object>[0...,0...,0...,0...]>::ExceptionTest(bool) + IL_013f: newobj instance void class Gen<valuetype ValX2<valuetype [mscorlib]System.Guid,valuetype [mscorlib]System.Guid>[][0...,0...,0...,0...][]>::.ctor() + IL_0144: ldc.i4.1 + IL_0145: call instance void class Gen<valuetype ValX2<valuetype [mscorlib]System.Guid,valuetype [mscorlib]System.Guid>[][0...,0...,0...,0...][]>::ExceptionTest(bool) + IL_014a: newobj instance void class Gen<class RefX1<int32>>::.ctor() + IL_014f: ldc.i4.1 + IL_0150: call instance void class Gen<class RefX1<int32>>::ExceptionTest(bool) + IL_0155: newobj instance void class Gen<class RefX1<valuetype ValX1<int32>>>::.ctor() + IL_015a: ldc.i4.1 + IL_015b: call instance void class Gen<class RefX1<valuetype ValX1<int32>>>::ExceptionTest(bool) + IL_0160: newobj instance void class Gen<class RefX2<int32,string>>::.ctor() + IL_0165: ldc.i4.1 + IL_0166: call instance void class Gen<class RefX2<int32,string>>::ExceptionTest(bool) + IL_016b: newobj instance void class Gen<class RefX3<int32,string,valuetype [mscorlib]System.Guid>>::.ctor() + IL_0170: ldc.i4.1 + IL_0171: call instance void class Gen<class RefX3<int32,string,valuetype [mscorlib]System.Guid>>::ExceptionTest(bool) + IL_0176: newobj instance void class Gen<class RefX1<class RefX1<int32>>>::.ctor() + IL_017b: ldc.i4.1 + IL_017c: call instance void class Gen<class RefX1<class RefX1<int32>>>::ExceptionTest(bool) + IL_0181: newobj instance void class Gen<class RefX1<class RefX1<class RefX1<string>>>>::.ctor() + IL_0186: ldc.i4.1 + IL_0187: call instance void class Gen<class RefX1<class RefX1<class RefX1<string>>>>::ExceptionTest(bool) + IL_018c: newobj instance void class Gen<class RefX1<class RefX1<class RefX1<class RefX1<valuetype [mscorlib]System.Guid>>>>>::.ctor() + IL_0191: ldc.i4.1 + IL_0192: call instance void class Gen<class RefX1<class RefX1<class RefX1<class RefX1<valuetype [mscorlib]System.Guid>>>>>::ExceptionTest(bool) + IL_0197: newobj instance void class Gen<class RefX1<class RefX2<int32,string>>>::.ctor() + IL_019c: ldc.i4.1 + IL_019d: call instance void class Gen<class RefX1<class RefX2<int32,string>>>::ExceptionTest(bool) + IL_01a2: newobj instance void class Gen<class RefX2<class RefX2<class RefX1<int32>,class RefX3<int32,string,class RefX1<class RefX2<int32,string>>>>,class RefX2<class RefX1<int32>,class RefX3<int32,string,class RefX1<class RefX2<int32,string>>>>>>::.ctor() + IL_01a7: ldc.i4.1 + IL_01a8: call instance void class Gen<class RefX2<class RefX2<class RefX1<int32>,class RefX3<int32,string,class RefX1<class RefX2<int32,string>>>>,class RefX2<class RefX1<int32>,class RefX3<int32,string,class RefX1<class RefX2<int32,string>>>>>>::ExceptionTest(bool) + IL_01ad: newobj instance void class Gen<class RefX3<class RefX1<int32[0...,0...,0...,0...][]>,class RefX2<object[][][0...,0...,0...,0...],valuetype [mscorlib]System.Guid[][][]>,class RefX3<float64[0...,0...,0...,0...,0...,0...,0...,0...,0...,0...,0...],valuetype [mscorlib]System.Guid[][][][0...,0...,0...,0...,0...][0...,0...,0...,0...,0...][][][],string[][][][][][][][][][][]>>>::.ctor() + IL_01b2: ldc.i4.1 + IL_01b3: call instance void class Gen<class RefX3<class RefX1<int32[0...,0...,0...,0...][]>,class RefX2<object[][][0...,0...,0...,0...],valuetype [mscorlib]System.Guid[][][]>,class RefX3<float64[0...,0...,0...,0...,0...,0...,0...,0...,0...,0...,0...],valuetype [mscorlib]System.Guid[][][][0...,0...,0...,0...,0...][0...,0...,0...,0...,0...][][][],string[][][][][][][][][][][]>>>::ExceptionTest(bool) + IL_01b8: newobj instance void class Gen<valuetype ValX1<int32>>::.ctor() + IL_01bd: ldc.i4.1 + IL_01be: call instance void class Gen<valuetype ValX1<int32>>::ExceptionTest(bool) + IL_01c3: newobj instance void class Gen<valuetype ValX1<class RefX1<int32>>>::.ctor() + IL_01c8: ldc.i4.1 + IL_01c9: call instance void class Gen<valuetype ValX1<class RefX1<int32>>>::ExceptionTest(bool) + IL_01ce: newobj instance void class Gen<valuetype ValX2<int32,string>>::.ctor() + IL_01d3: ldc.i4.1 + IL_01d4: call instance void class Gen<valuetype ValX2<int32,string>>::ExceptionTest(bool) + IL_01d9: newobj instance void class Gen<valuetype ValX3<int32,string,valuetype [mscorlib]System.Guid>>::.ctor() + IL_01de: ldc.i4.1 + IL_01df: call instance void class Gen<valuetype ValX3<int32,string,valuetype [mscorlib]System.Guid>>::ExceptionTest(bool) + IL_01e4: newobj instance void class Gen<valuetype ValX1<valuetype ValX1<int32>>>::.ctor() + IL_01e9: ldc.i4.1 + IL_01ea: call instance void class Gen<valuetype ValX1<valuetype ValX1<int32>>>::ExceptionTest(bool) + IL_01ef: newobj instance void class Gen<valuetype ValX1<valuetype ValX1<valuetype ValX1<string>>>>::.ctor() + IL_01f4: ldc.i4.1 + IL_01f5: call instance void class Gen<valuetype ValX1<valuetype ValX1<valuetype ValX1<string>>>>::ExceptionTest(bool) + IL_01fa: newobj instance void class Gen<valuetype ValX1<valuetype ValX1<valuetype ValX1<valuetype ValX1<valuetype [mscorlib]System.Guid>>>>>::.ctor() + IL_01ff: ldc.i4.1 + IL_0200: call instance void class Gen<valuetype ValX1<valuetype ValX1<valuetype ValX1<valuetype ValX1<valuetype [mscorlib]System.Guid>>>>>::ExceptionTest(bool) + IL_0205: newobj instance void class Gen<valuetype ValX1<valuetype ValX2<int32,string>>>::.ctor() + IL_020a: ldc.i4.1 + IL_020b: call instance void class Gen<valuetype ValX1<valuetype ValX2<int32,string>>>::ExceptionTest(bool) + IL_0210: newobj instance void class Gen<valuetype ValX2<valuetype ValX2<valuetype ValX1<int32>,valuetype ValX3<int32,string,valuetype ValX1<valuetype ValX2<int32,string>>>>,valuetype ValX2<valuetype ValX1<int32>,valuetype ValX3<int32,string,valuetype ValX1<valuetype ValX2<int32,string>>>>>>::.ctor() + IL_0215: ldc.i4.1 + IL_0216: call instance void class Gen<valuetype ValX2<valuetype ValX2<valuetype ValX1<int32>,valuetype ValX3<int32,string,valuetype ValX1<valuetype ValX2<int32,string>>>>,valuetype ValX2<valuetype ValX1<int32>,valuetype ValX3<int32,string,valuetype ValX1<valuetype ValX2<int32,string>>>>>>::ExceptionTest(bool) + IL_021b: newobj instance void class Gen<valuetype ValX3<valuetype ValX1<int32[0...,0...,0...,0...][]>,valuetype ValX2<object[][][0...,0...,0...,0...],valuetype [mscorlib]System.Guid[][][]>,valuetype ValX3<float64[0...,0...,0...,0...,0...,0...,0...,0...,0...,0...,0...],valuetype [mscorlib]System.Guid[][][][0...,0...,0...,0...,0...][0...,0...,0...,0...,0...][][][],string[][][][][][][][][][][]>>>::.ctor() + IL_0220: ldc.i4.1 + IL_0221: call instance void class Gen<valuetype ValX3<valuetype ValX1<int32[0...,0...,0...,0...][]>,valuetype ValX2<object[][][0...,0...,0...,0...],valuetype [mscorlib]System.Guid[][][]>,valuetype ValX3<float64[0...,0...,0...,0...,0...,0...,0...,0...,0...,0...,0...],valuetype [mscorlib]System.Guid[][][][0...,0...,0...,0...,0...][0...,0...,0...,0...,0...][][][],string[][][][][][][][][][][]>>>::ExceptionTest(bool) + IL_0226: ldsfld bool Test::result + IL_022b: brfalse.s IL_023c + + IL_022d: ldstr "Test Passed" + IL_0232: call void [System.Console]System.Console::WriteLine(string) + IL_0237: ldc.i4.s 100 + IL_0239: stloc.0 + IL_023a: br.s IL_024a + + IL_023c: ldstr "Test Failed" + IL_0241: call void [System.Console]System.Console::WriteLine(string) + IL_0246: ldc.i4.1 + IL_0247: stloc.0 + IL_0248: br.s IL_024a + + IL_024a: ldloc.0 + IL_024b: ret + } // end of method Test::Main + + .method private hidebysig specialname rtspecialname static + void .cctor() cil managed + { + // Code size 13 (0xd) + .maxstack 8 + IL_0000: ldc.i4.0 + IL_0001: stsfld int32 Test::counter + IL_0006: ldc.i4.1 + IL_0007: stsfld bool Test::result + IL_000c: ret + } // end of method Test::.cctor + + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 7 (0x7) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [mscorlib]System.Object::.ctor() + IL_0006: ret + } // end of method Test::.ctor + +} // end of class Test + + +// ============================================================= + + +//*********** DISASSEMBLY COMPLETE *********************** +// WARNING: Created Win32 resource file try-filter01.res diff --git a/tests/src/baseservices/exceptions/generics/try-filter02.ilproj b/tests/src/baseservices/exceptions/generics/try-filter02.ilproj new file mode 100644 index 0000000000..056a491ae3 --- /dev/null +++ b/tests/src/baseservices/exceptions/generics/try-filter02.ilproj @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <AssemblyName>$(MSBuildProjectName)</AssemblyName> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <PropertyGroup> + + </PropertyGroup> + <ItemGroup> + <Compile Include="try-filter02.il" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/Dev11/147911/CMakeLists.txt b/tests/src/baseservices/exceptions/regressions/Dev11/147911/CMakeLists.txt new file mode 100644 index 0000000000..1bbbd915d2 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/Dev11/147911/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required (VERSION 2.6) +if(WIN32) +project (fpcw) +include_directories(${INC_PLATFORM_DIR}) + +# add the executable +add_library (fpcw SHARED fpcw.cpp) + +# add the install targets +install (TARGETS fpcw DESTINATION bin) +endif() diff --git a/tests/src/baseservices/exceptions/regressions/Dev11/147911/app.config b/tests/src/baseservices/exceptions/regressions/Dev11/147911/app.config new file mode 100644 index 0000000000..62803f5972 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/Dev11/147911/app.config @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<configuration> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + </assemblyBinding> + </runtime> +</configuration>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/Dev11/147911/fpcw.cpp b/tests/src/baseservices/exceptions/regressions/Dev11/147911/fpcw.cpp new file mode 100644 index 0000000000..2e22bf8f4f --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/Dev11/147911/fpcw.cpp @@ -0,0 +1,203 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + + +// FPCW.cpp : Defines the exported functions for the DLL application. +// + +#include "fpcw.h" +#include <stdio.h> +#include <float.h> + +LONG WINAPI ExcepFilter(struct _EXCEPTION_POINTERS *pExp) +{ + printf( "In ExcepFilter \n" ); + + if (pExp->ExceptionRecord->ExceptionCode == 0xc00002b5 || + pExp->ExceptionRecord->ExceptionCode == 0xc00002b4 ) + return EXCEPTION_EXECUTE_HANDLER; + else + return EXCEPTION_CONTINUE_SEARCH; +} + + +// This is an example of an exported function. +extern "C" FPCW_API int RaiseFPException(void) +{ + unsigned int fpcw; + + // DivByZero + printf("DivByZero: "); + + // Enable all FP exceptions + int err = _controlfp_s(&fpcw, 0, _MCW_EM); + if (err) + { + printf("Error setting FPCW: %d\n", err); + return -1; + } + + __try + { + __try + { + float d = 2.0 - (0.0+2.0); + float f = 2.0/d; + printf("Shouldnt execute!\n"); + return 99; + } + __except((GetExceptionCode()==0xc000008e)?EXCEPTION_EXECUTE_HANDLER:EXCEPTION_CONTINUE_SEARCH) + { + printf("Caught exception!\n"); + + // Clear FPSW else the "waiting" FPU instructions used in _controlfp_s will result in + // FPU raising the exception again. + _clearfp(); + + // Reset FPCW + err = _controlfp_s(&fpcw, 0x1f, _MCW_EM); + if (err) + { + printf("Error setting FPCW: %d\n", err); + return -1; + } + + printf("Passed\n"); + } + } + __except(ExcepFilter(GetExceptionInformation())) + { + printf("Caught exception in Filter!\n"); + + // Clear FPSW else the "waiting" FPU instructions used in _controlfp_s will result in + // FPU raising the exception again. + _clearfp(); + + // Reset FPCW + err = _controlfp_s(&fpcw, 0x1f, _MCW_EM); + if (err) + { + printf("Error setting FPCW: %d\n", err); + return -1; + } + } + + + // Underflow + printf("Underflow: "); + + // Enable all FP exceptions + err = _controlfp_s(&fpcw, 0, _MCW_EM); + if (err) + { + printf("Error setting FPCW: %d\n", err); + return -1; + } + + __try + { + __try + { + double a = 1e-40, b; + float x, y; + y = a; + b = 2.0; + printf("Shouldnt execute!\n"); + return 98; + } + __except((GetExceptionCode()==0xc0000093)?EXCEPTION_EXECUTE_HANDLER:EXCEPTION_CONTINUE_SEARCH) + { + printf("Caught exception!\n"); + + // Clear FPSW else the "waiting" FPU instructions used in _controlfp_s will result in + // FPU raising the exception again. + _clearfp(); + + // Reset FPCW + err = _controlfp_s(&fpcw, 0x1f, _MCW_EM); + if (err) + { + printf("Error setting FPCW: %d\n", err); + return -1; + } + printf("Passed\n"); + } + } + __except(ExcepFilter(GetExceptionInformation())) + { + printf("Caught exception in Filter!\n"); + // Clear FPSW else the "waiting" FPU instructions used in _controlfp_s will result in + // FPU raising the exception again. + _clearfp(); + + // Reset FPCW + err = _controlfp_s(&fpcw, 0x1f, _MCW_EM); + if (err) + { + printf("Error setting FPCW: %d\n", err); + return -1; + } + } + + // Overflow + printf("Overflow: "); + + // Enable all FP exceptions + err = _controlfp_s(&fpcw, 0, _MCW_EM); + if (err) + { + printf("Error setting FPCW: %d\n", err); + return -1; + } + + __try + { + __try + { + double a = 1e+40, b; + float x, y; + y = a; + b = 2.0; + printf("Shouldnt execute!\n"); + return 97; + } + __except((GetExceptionCode()==0xc0000091)?EXCEPTION_EXECUTE_HANDLER:EXCEPTION_CONTINUE_SEARCH) + { + printf("Caught exception!\n"); + + // Clear FPSW else the "waiting" FPU instructions used in _controlfp_s will result in + // FPU raising the exception again. + _clearfp(); + + // Reset FPCW + err = _controlfp_s(&fpcw, 0x1f, _MCW_EM); + if (err) + { + printf("Error setting FPCW: %d\n", err); + return -1; + } + printf("Passed\n"); + } + } + __except(ExcepFilter(GetExceptionInformation())) + { + printf("Caught exception in Filter!\n"); + + // Clear FPSW else the "waiting" FPU instructions used in _controlfp_s will result in + // FPU raising the exception again. + _clearfp(); + + // Reset FPCW + err = _controlfp_s(&fpcw, 0x1f, _MCW_EM); + if (err) + { + printf("Error setting FPCW: %d\n", err); + return -1; + } + } + + + return 100; +} + diff --git a/tests/src/baseservices/exceptions/regressions/Dev11/147911/fpcw.h b/tests/src/baseservices/exceptions/regressions/Dev11/147911/fpcw.h new file mode 100644 index 0000000000..e0990567de --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/Dev11/147911/fpcw.h @@ -0,0 +1,19 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +// The following ifdef block is the standard way of creating macros which make exporting +// from a DLL simpler. All files within this DLL are compiled with the FPCW_EXPORTS +// symbol defined on the command line. This symbol should not be defined on any project +// that uses this DLL. This way any other project whose source files include this file see +// FPCW_API functions as being imported from a DLL, whereas this DLL sees symbols +// defined with this macro as being exported. +#define FPCW_API __declspec(dllexport) + +extern "C" FPCW_API int RaiseFPException(void); + +#pragma once + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +// Windows Header Files: +#include <windows.h>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/Dev11/147911/project.json b/tests/src/baseservices/exceptions/regressions/Dev11/147911/project.json new file mode 100644 index 0000000000..89527b786c --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/Dev11/147911/project.json @@ -0,0 +1,34 @@ +{ + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816", + "System.Collections": "4.0.10", + "System.Collections.NonGeneric": "4.0.1-beta-23302", + "System.Collections.Specialized": "4.0.1-beta-23302", + "System.ComponentModel": "4.0.1-beta-23302", + "System.Console": "4.0.0-beta-23302", + "System.Diagnostics.Process": "4.0.0-beta-23302", + "System.Globalization": "4.0.10", + "System.Globalization.Calendars": "4.0.0", + "System.IO": "4.0.10", + "System.IO.FileSystem": "4.0.0", + "System.IO.FileSystem.Primitives": "4.0.0", + "System.Linq": "4.0.1-beta-23302", + "System.Linq.Queryable": "4.0.1-beta-23302", + "System.Reflection": "4.0.10", + "System.Reflection.Primitives": "4.0.0", + "System.Runtime": "4.0.20", + "System.Runtime.Extensions": "4.0.10", + "System.Runtime.Handles": "4.0.0", + "System.Runtime.InteropServices": "4.0.20", + "System.Runtime.Loader": "4.0.0-beta-23302", + "System.Text.Encoding": "4.0.10", + "System.Threading": "4.0.10", + "System.Xml.ReaderWriter": "4.0.11-beta-23302", + "System.Xml.XDocument": "4.0.11-beta-23302", + "System.Xml.XmlDocument": "4.0.1-beta-23302", + "System.Xml.XmlSerializer": "4.0.11-beta-23302", + }, + "frameworks": { + "dnxcore50": {} + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/Dev11/147911/test147911.cs b/tests/src/baseservices/exceptions/regressions/Dev11/147911/test147911.cs new file mode 100644 index 0000000000..045f3a1938 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/Dev11/147911/test147911.cs @@ -0,0 +1,20 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Runtime.InteropServices; + + +public class Class1 +{ + [DllImport("fpcw.dll")] + private static extern int RaiseFPException(); + + public static int Main(string[] args) + { + int retVal = RaiseFPException(); + + return ( retVal==100 ) ? 100 : 101; + } +} diff --git a/tests/src/baseservices/exceptions/regressions/Dev11/147911/test147911.csproj b/tests/src/baseservices/exceptions/regressions/Dev11/147911/test147911.csproj new file mode 100644 index 0000000000..d277a0fc15 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/Dev11/147911/test147911.csproj @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="test147911.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="CMakeLists.txt" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/Dev11/154243/app.config b/tests/src/baseservices/exceptions/regressions/Dev11/154243/app.config new file mode 100644 index 0000000000..62803f5972 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/Dev11/154243/app.config @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<configuration> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + </assemblyBinding> + </runtime> +</configuration>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/Dev11/154243/dynamicmethodliveness.cs b/tests/src/baseservices/exceptions/regressions/Dev11/154243/dynamicmethodliveness.cs new file mode 100644 index 0000000000..5592a9c7e7 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/Dev11/154243/dynamicmethodliveness.cs @@ -0,0 +1,99 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +// regression test for Devdiv bug 154243 +// the test passes if we get to Done. +// with the bug present test was getting assert dialog box with message that Consistency check failed: FAILED: state.fFound + +using System; +using System.Threading; +using System.Reflection; +using System.Reflection.Emit; + +public class My { + + static Exception theException = new Exception(); + + static void Thrower() { + for (int j = 0; j <= 100; j++) + { + try { + throw theException; + } + catch { + } + } + } + + static void Dynamizer() { + for (int j = 0; j <= 100; j++) + { + DynamicMethod method = EmitDynamicMethod(typeof(My).GetMethod("Noop")); + ((Action)method.CreateDelegate(typeof(Action)))(); + } + } + + static DynamicMethod EmitDynamicMethod(MethodInfo callee) + { + DynamicMethod method = new DynamicMethod( + "MyMethod", + typeof(void), + new Type[0], + typeof(My).GetTypeInfo().Module); + + ILGenerator il = method.GetILGenerator(); + for (int i = 0; i < 5; i++) + il.Emit(OpCodes.Call, callee); + il.Emit(OpCodes.Ret); + + return method; + } + + public static void ThrowException() { + throw theException; + } + + public static void Noop() { + } + + static void DoStuff() { + DynamicMethod method = EmitDynamicMethod(typeof(My).GetMethod("ThrowException")); + for (int i = 0; i < 20; i++) + method = EmitDynamicMethod(method); + ((Action)method.CreateDelegate(typeof(Action)))(); + } + + static int Main() { + new Thread(Thrower).Start(); + + new Thread(Dynamizer).Start(); + + Thread.Sleep(100); + Console.WriteLine("TestCase Started"); + for (int j=0;j<=100;j++) { + Console.WriteLine("Counter = " + j.ToString()); + try { + try { + + DoStuff(); + } + finally { + Console.WriteLine("Sleeping"); + Thread.Sleep(100); + Console.WriteLine("Running GC"); + GC.Collect(); + Console.WriteLine("Waiting for finalizers..."); + for (int i = 0; i < 10; i++) GC.WaitForPendingFinalizers(); + Console.WriteLine("Running GC"); + GC.Collect(); + } + } + catch (Exception) + { + } + } + Console.WriteLine("Test case Pass"); + return 100; + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/Dev11/154243/dynamicmethodliveness.csproj b/tests/src/baseservices/exceptions/regressions/Dev11/154243/dynamicmethodliveness.csproj new file mode 100644 index 0000000000..5527b3d613 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/Dev11/154243/dynamicmethodliveness.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="dynamicmethodliveness.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/Dev11/154243/project.json b/tests/src/baseservices/exceptions/regressions/Dev11/154243/project.json new file mode 100644 index 0000000000..f257213d94 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/Dev11/154243/project.json @@ -0,0 +1,35 @@ +{ + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816", + "System.Collections": "4.0.10", + "System.Collections.NonGeneric": "4.0.1-beta-23302", + "System.Collections.Specialized": "4.0.1-beta-23302", + "System.ComponentModel": "4.0.1-beta-23302", + "System.Console": "4.0.0-beta-23302", + "System.Diagnostics.Process": "4.0.0-beta-23302", + "System.Globalization": "4.0.10", + "System.Globalization.Calendars": "4.0.0", + "System.IO": "4.0.10", + "System.IO.FileSystem": "4.0.0", + "System.IO.FileSystem.Primitives": "4.0.0", + "System.Linq": "4.0.1-beta-23302", + "System.Linq.Queryable": "4.0.1-beta-23302", + "System.Reflection": "4.0.10", + "System.Reflection.Primitives": "4.0.0", + "System.Runtime": "4.0.20", + "System.Runtime.Extensions": "4.0.10", + "System.Runtime.Handles": "4.0.0", + "System.Runtime.InteropServices": "4.0.20", + "System.Runtime.Loader": "4.0.0-beta-23302", + "System.Text.Encoding": "4.0.10", + "System.Threading": "4.0.10", + "System.Xml.ReaderWriter": "4.0.11-beta-23302", + "System.Xml.XDocument": "4.0.11-beta-23302", + "System.Xml.XmlDocument": "4.0.1-beta-23302", + "System.Xml.XmlSerializer": "4.0.11-beta-23302", + "System.Reflection.Emit.Lightweight": "4.0.0-beta-23302" + }, + "frameworks": { + "dnxcore50": {} + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/COOL/app.config b/tests/src/baseservices/exceptions/regressions/V1/SEH/COOL/app.config new file mode 100644 index 0000000000..62803f5972 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/COOL/app.config @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<configuration> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + </assemblyBinding> + </runtime> +</configuration>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/COOL/finally.cs b/tests/src/baseservices/exceptions/regressions/V1/SEH/COOL/finally.cs new file mode 100644 index 0000000000..1e13b966ba --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/COOL/finally.cs @@ -0,0 +1,40 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Threading; +public class Foo +{ + private static int n=0; + + public static void Bar(){ + int i = 0; + try { + i = i/n ; + } + catch(DivideByZeroException) + {} + finally { n++; + Console.WriteLine("In finally " + i); + } + } + + public static int Main(String[] args) + { + String s = "Done"; + Thread t = new Thread(new ThreadStart(Foo.Bar)); + t.Start(); + //Thread MainThread = Thread.CurrentThread; + Thread.Sleep(1000); + if (n == 2){ + Console.WriteLine("Finally Test failed"); + return 1; + } + else { + Console.WriteLine("Test Passed"); + Console.WriteLine(s); + return 100; + } + } +} diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/COOL/finally.csproj b/tests/src/baseservices/exceptions/regressions/V1/SEH/COOL/finally.csproj new file mode 100644 index 0000000000..25d416a03d --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/COOL/finally.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="finally.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/COOL/project.json b/tests/src/baseservices/exceptions/regressions/V1/SEH/COOL/project.json new file mode 100644 index 0000000000..89527b786c --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/COOL/project.json @@ -0,0 +1,34 @@ +{ + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816", + "System.Collections": "4.0.10", + "System.Collections.NonGeneric": "4.0.1-beta-23302", + "System.Collections.Specialized": "4.0.1-beta-23302", + "System.ComponentModel": "4.0.1-beta-23302", + "System.Console": "4.0.0-beta-23302", + "System.Diagnostics.Process": "4.0.0-beta-23302", + "System.Globalization": "4.0.10", + "System.Globalization.Calendars": "4.0.0", + "System.IO": "4.0.10", + "System.IO.FileSystem": "4.0.0", + "System.IO.FileSystem.Primitives": "4.0.0", + "System.Linq": "4.0.1-beta-23302", + "System.Linq.Queryable": "4.0.1-beta-23302", + "System.Reflection": "4.0.10", + "System.Reflection.Primitives": "4.0.0", + "System.Runtime": "4.0.20", + "System.Runtime.Extensions": "4.0.10", + "System.Runtime.Handles": "4.0.0", + "System.Runtime.InteropServices": "4.0.20", + "System.Runtime.Loader": "4.0.0-beta-23302", + "System.Text.Encoding": "4.0.10", + "System.Threading": "4.0.10", + "System.Xml.ReaderWriter": "4.0.11-beta-23302", + "System.Xml.XDocument": "4.0.11-beta-23302", + "System.Xml.XmlDocument": "4.0.1-beta-23302", + "System.Xml.XmlSerializer": "4.0.11-beta-23302", + }, + "frameworks": { + "dnxcore50": {} + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/COOL/rethrow.cs b/tests/src/baseservices/exceptions/regressions/V1/SEH/COOL/rethrow.cs new file mode 100644 index 0000000000..7ea776fbb6 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/COOL/rethrow.cs @@ -0,0 +1,147 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Threading; + +public class UserException1 : Exception { + int ExceptionId; + + public UserException1() + { + } + + public UserException1(int id){ + ExceptionId = id; + } + +public class UserException2 : UserException1 { + new int ExceptionId; + + public UserException2() + { + } + public UserException2(int id) : base(id) + { + ExceptionId = id; + } + +public class UserException3 : UserException2 { + new int ExceptionId; + + public UserException3() + { + } + + public UserException3(int id) : base(id) + { + ExceptionId = id; + } + +public class UserException4 : UserException3 { + new int ExceptionId; + + public UserException4() + { + } + public UserException4(int id) : base(id) + { + ExceptionId = id; + } + +public class RethrowException { + private int ThreadId; + + public RethrowException(int id){ + ThreadId = id; + } + + + public static int Main(String[] args) { + String s = "Done"; + System.IO.TextWriter t = Console.Out; + Console.SetOut(t); + int retVal = 101; + Thread[] mv_Thread = new Thread[10]; + RethrowException[] he = new RethrowException[12]; + for (int i = 0 ; i < 10 ; i++){ + he[i] = new RethrowException(i); + mv_Thread[i] = new Thread(new ThreadStart(he[i].runtest)); + try { + mv_Thread[i].Start(); + } + catch (Exception ){ + Console.WriteLine("Exception was caught in main"); + } + } + for (int i = 0; i < 10; i++){ + mv_Thread[i].Join(); + } + Console.WriteLine("\n\n Test Passed"); + Console.WriteLine(s); + retVal = 100; + return retVal; + } + + public void runtest(){ + try { + try { + try { + try { + switch (ThreadId % 4){ + case 0: throw new UserException1(ThreadId); + case 1: throw new UserException2(ThreadId); + case 2: throw new UserException3(ThreadId); + case 3: throw new UserException4(ThreadId); + default: + throw new Exception(); + } + + } + catch (UserException4 e){ + lock(this) + { + Console.WriteLine("Exception4 was caught by Thread " + e.ExceptionId ); + throw ; + } + } + } + catch (UserException3 e) { + lock(this) + { + Console.WriteLine("Exception3 was caught by Thread " + e.ExceptionId ); + throw ; + } + + } + } + catch (UserException2 e){ + lock(this) + { + Console.WriteLine("Exception2 was caught by Thread " + e.ExceptionId ); + throw ; + } + } + } + catch (UserException1 e) { + lock(this) + { + Console.WriteLine("Exception1 was caught by Thread " + e.ExceptionId ); + } + } + catch (Exception ){ + lock(this) + { + Console.WriteLine("Exception was caught"); + } + } + + } + +} // REthrow +} //UserException1 +} //UserException2 +} //UserException3 +} //UserException4 + diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/COOL/rethrow.csproj b/tests/src/baseservices/exceptions/regressions/V1/SEH/COOL/rethrow.csproj new file mode 100644 index 0000000000..b09be6fe42 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/COOL/rethrow.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="rethrow.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/CMakeLists.txt b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/CMakeLists.txt new file mode 100644 index 0000000000..fa7315e4c7 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required (VERSION 2.6) +if (WIN32) +project (Unmanaged) +include_directories(${INC_PLATFORM_DIR}) + +# add the executable +add_library (Unmanaged SHARED Unmanaged.cpp) + +# add the install targets +install (TARGETS Unmanaged DESTINATION bin) +endif() diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/ExternalException.cs b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/ExternalException.cs new file mode 100644 index 0000000000..3c56d933dc --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/ExternalException.cs @@ -0,0 +1,86 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Threading; + +class ExternalClass { + ExternalException ee = new ExternalException(); + + public void ThrowException(){ + throw ee; + } + +} + + +public class ExternalException : Exception { + + static int retVal = 100; + + public static int Main(String [] args) { + Thread mv_Thread; + String str = "Done"; + ExternalException ee = new ExternalException(); + for (int i = 0 ; i < 10; i++){ + mv_Thread = new Thread(new ThreadStart(ee.runtest)); + try { + mv_Thread.Start(); + } + catch (Exception ){ + Console.WriteLine("Exception was caught in main"); + } + } + Console.WriteLine(str); + return retVal; + } + + public void runtest(){ + int counter = 0; + //String m_str = "Failed"; + for (int j = 0; j < 100; j++){ + try { + if (j % 2 == 0) + counter = j / (j % 2); + else + recurse(0); + } + catch ( ArithmeticException ) { + counter++; + continue; + } + catch (ExternalException ){ + counter--; + continue; + } + finally { + counter++; + } + } + if (counter == 100){ + lock(this) { + Console.WriteLine( "TryCatch Test Passed" ); + } + } + else{ + lock(this) { + Console.WriteLine( "TryCatch Test Failed" ); + Console.WriteLine(counter); + retVal = -1; + } + } + } + + public void recurse(int counter){ + char [] abc = new char[100]; + if (counter == 100) + (new ExternalClass()).ThrowException(); + else + recurse(++counter); + + } +} + + + diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/ExternalException.csproj b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/ExternalException.csproj new file mode 100644 index 0000000000..4cb4ae4d9e --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/ExternalException.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="ExternalException.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/HandlerException.cs b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/HandlerException.cs new file mode 100644 index 0000000000..9f9547a2cc --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/HandlerException.cs @@ -0,0 +1,123 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +using System; +using System.Threading; +using System.IO; + +class UserException1 : Exception { + public int ExceptionId; + + public UserException1(int id){ + ExceptionId = id; + } +} + +class UserException2 : Exception { + public int ExceptionId; + + public UserException2(int id){ + ExceptionId = id; + } +} + +class UserException3 : Exception { + public int ExceptionId; + + public UserException3(int id){ + ExceptionId = id; + } +} + +class UserException4 : Exception { + public int ExceptionId; + + public UserException4(int id){ + ExceptionId = id; + } +} + + +public class HandlerException { + private int ThreadId; + + public HandlerException(int id){ + ThreadId = id; + } + + + public static int Main(String [] args) { + String s = "Done"; + int retVal = 100; + Thread mv_Thread; + HandlerException [] he = new HandlerException[10]; + for (int i = 0 ; i < 10; i++){ + he[i] = new HandlerException(i); + mv_Thread = new Thread(new ThreadStart(he[i].runtest)); + try { + mv_Thread.Start(); + } + catch (Exception ){ + Console.WriteLine("Exception was caught in main"); + retVal = 0; + } + } + Console.WriteLine(s); + return retVal; + } + + public void runtest(){ + try { + try { + try { + try { + switch (ThreadId){ + case 0: throw new UserException1(ThreadId); + case 1: throw new UserException2(ThreadId); + case 2: throw new UserException3(ThreadId); + case 3: throw new UserException4(ThreadId); + default: + throw new Exception(); + } + + } + catch (UserException1 e){ + lock(this) + { + Console.WriteLine("Exception1 was caught by Thread " + e.ExceptionId ); + } + + throw new UserException2(ThreadId); + } + } + catch (UserException2 e) { + lock(this) + { + Console.WriteLine("Exception2 was caught by Thread " + e.ExceptionId ); + } + throw new UserException3(ThreadId); + } + } + catch (UserException3 e){ + lock(this) + { + Console.WriteLine("Exception3 was caught by Thread " + e.ExceptionId ); + } + throw new UserException4(ThreadId); + } + } + catch (UserException4 e) { + lock(this) + { + Console.WriteLine("Exception4 was caught by Thread " + e.ExceptionId ); + } + } + catch (Exception ){ + lock(this) + { + Console.WriteLine("Exception was caught"); + } + } + } + +} diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/HandlerException.csproj b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/HandlerException.csproj new file mode 100644 index 0000000000..a2b3ac98c4 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/HandlerException.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="HandlerException.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/MultipleException.cs b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/MultipleException.cs new file mode 100644 index 0000000000..3a8706ba1f --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/MultipleException.cs @@ -0,0 +1,61 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +using System; +using System.Threading; +using System.IO; + +class UserException : Exception { + internal int ExceptionId; + + public UserException(int id){ + ExceptionId = id; + } +} + +public class MultipleException { + private int ThreadId; + + public MultipleException(int id){ + ThreadId = id; + } + + + public static int Main(String [] args) { + int retVal = 100; + String s = "Done"; + Thread mv_Thread; + MultipleException [] me = new MultipleException[10]; + for (int i = 0 ; i < 10; i++){ + me[i] = new MultipleException(i); + mv_Thread = new Thread(new ThreadStart(me[i].runtest)); + try { + mv_Thread.Start(); + } + catch (Exception ){ + Console.WriteLine("Exception was caught in main"); + retVal = 0; + } + } + Console.WriteLine(s); + return retVal; + } + + public void runtest(){ + try { + recurse(0); + } + catch (UserException e) { + lock(this){ + Console.WriteLine("The Exception " + e.ExceptionId + " was caught"); + } + } + } + + public void recurse(int counter) { + if (counter == 1000) + throw new UserException( ThreadId ); + else + recurse(++counter); + } +} diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/MultipleException.csproj b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/MultipleException.csproj new file mode 100644 index 0000000000..139ccbbbd8 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/MultipleException.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="MultipleException.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/NestedEx1.cs b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/NestedEx1.cs new file mode 100644 index 0000000000..d659706540 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/NestedEx1.cs @@ -0,0 +1,126 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Security; + +class TestClass { + + static int iExitCode; + + void TestMain() + { + int caught = 0; + int fincount = 0; + + try { + throw new ArgumentException(); +// Console.WriteLine("Exception not thrown."); +// iExitCode = 1; + } + catch (ArithmeticException ) { + Console.WriteLine("Caught wrong exception."); + iExitCode = 2; + } + catch (ArgumentException ) { + caught ++; + try { + throw new SecurityException(); +// Console.WriteLine("Exception not thrown."); +// iExitCode = 1; + } + catch (SecurityException ) { + caught ++; + } + catch (Exception ) { + Console.WriteLine("Didn't catch specific exception."); + iExitCode = 3; + } + finally { + try{ + throw new NullReferenceException(); +// Console.WriteLine("Exception Not Thrown in Finally"); + } + catch(NullReferenceException e){ + Console.WriteLine(e.StackTrace); + caught++; + } + catch(Exception ){ + Console.WriteLine("Correct Exception not caught"); + } + finally + { + GC.Collect(); + fincount++; + } + + fincount ++; + } + } + catch (Exception ) { + Console.WriteLine("Didn't catch specific exception."); + iExitCode = 3; + } + finally { + GC.Collect(); + fincount ++; + } + + try { + try { + throw new NullReferenceException(); +// Console.WriteLine("Exception not thrown."); +// iExitCode = 1; + } + catch (NullReferenceException ) { + caught ++; + throw new OutOfMemoryException(); +// Console.WriteLine("Exception not thrown."); +// iExitCode = 1; + } + catch (Exception ) { + Console.WriteLine("Didn't catch specific exception."); + iExitCode = 3; + } + finally { + GC.Collect(); + fincount ++; + } + } + catch (OutOfMemoryException ) { + caught ++; + } + finally { + GC.Collect(); + fincount ++; + } + + if (caught != 5) { + Console.WriteLine("Didn't catch enough exceptions."); + iExitCode = 4; + } + if (fincount != 5) { + Console.WriteLine("Didn't execute enough finallys."); + iExitCode = 5; + } + } + + public static int Main(String [] args) + { + int retVal = 100; + String str = "Done"; + (new TestClass()).TestMain(); + if (iExitCode == 0) { + Console.WriteLine("Test Passed."); + } else { + Console.WriteLine("Test FAILED."); + retVal = iExitCode; + } + Console.WriteLine(str); + return retVal; +} + +}; + + diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/NestedEx1.csproj b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/NestedEx1.csproj new file mode 100644 index 0000000000..f0ee177b97 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/NestedEx1.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="NestedEx1.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/NestedEx2.cs b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/NestedEx2.cs new file mode 100644 index 0000000000..d95d8b5dcc --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/NestedEx2.cs @@ -0,0 +1,178 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Security; + +class TestClass { + + static int iExitCode; + + void TestMain() + { + int caught = 0; + int fincount = 0; + + try { + throw new ArgumentException(); +// Console.WriteLine("Exception not thrown."); +// iExitCode = 1; + } + catch (ArithmeticException ) { + Console.WriteLine("Caught wrong exception."); + iExitCode = 2; + } + catch (ArgumentException ) { + caught ++; + try { + try{ + try{ + try{ + try{ + try{ + try{ + try{ + int [] arr = new int[1000]; + throw new SecurityException(); +// Console.WriteLine("Exception not thrown."); +// iExitCode = 1; + } + catch(DivideByZeroException ){ + } + finally + { + double [] s = new double[1]; + } + + } + catch(DivideByZeroException ){ + } + } + catch(DivideByZeroException ){ + } + finally + { + Console.WriteLine("Somewhere in a finally"); + float [] j = new float[99]; + } + + } + catch(DivideByZeroException ){ + } + } + catch(DivideByZeroException ){ + } + } + catch(DivideByZeroException ){ + } + } + catch(DivideByZeroException ){ + } + } + catch(DivideByZeroException ){ + } + catch (SecurityException ) { + caught ++; + } + catch (Exception ) { + Console.WriteLine("Didn't catch specific exception."); + iExitCode = 3; + try{ + Console.WriteLine("Something new"); + } + catch(DivideByZeroException ){ + } + finally{ + Console.WriteLine("Is this ever reached?"); + } + + } + finally { + int [] i = new int[10]; + try{ + throw new NullReferenceException(); +// Console.WriteLine("Exception Not Thrown in Finally"); + } + catch(NullReferenceException e){ + Console.WriteLine(e.StackTrace); + caught++; + } + catch(Exception ){ + Console.WriteLine("Correct Exception not caught"); + } + finally + { + GC.Collect(); + fincount++; + } + + fincount ++; + } + } + catch (Exception ) { + Console.WriteLine("Didn't catch specific exception."); + iExitCode = 3; + } + finally { + GC.Collect(); + fincount ++; + } + + try { + try { + throw new NullReferenceException(); +// Console.WriteLine("Exception not thrown."); +// iExitCode = 1; + } + catch (NullReferenceException ) { + caught ++; + throw new OutOfMemoryException(); +// Console.WriteLine("Exception not thrown."); +// iExitCode = 1; + } + catch (Exception ) { + Console.WriteLine("Didn't catch specific exception."); + iExitCode = 3; + } + finally { + GC.Collect(); + fincount ++; + } + } + catch (OutOfMemoryException ) { + caught ++; + } + finally { + GC.Collect(); + fincount ++; + } + + if (caught != 5) { + Console.WriteLine("Didn't catch enough exceptions."); + iExitCode = 4; + } + if (fincount != 5) { + Console.WriteLine("Didn't execute enough finallys."); + iExitCode = 5; + } + } + + public static int Main(String[] args) + { + int retVal = 100; + String str = "Done"; + (new TestClass()).TestMain(); + if (iExitCode == 0) { + Console.WriteLine("Test Passed."); + } else { + Console.WriteLine("Test FAILED."); + retVal = iExitCode; + } + Console.WriteLine(str); + return retVal; +} + +}; + + diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/NestedEx2.csproj b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/NestedEx2.csproj new file mode 100644 index 0000000000..aa39d00f0d --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/NestedEx2.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="NestedEx2.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/NestedException.cs b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/NestedException.cs new file mode 100644 index 0000000000..c9f04d4d6e --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/NestedException.cs @@ -0,0 +1,114 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Threading; + +class UserException1 : Exception { + public int ExceptionId; + + public UserException1(int id){ + ExceptionId = id; + } +} + +class UserException2 : Exception { + public int ExceptionId; + + public UserException2(int id){ + ExceptionId = id; + } +} + +class UserException3 : Exception { + public int ExceptionId; + + public UserException3(int id){ + ExceptionId = id; + } +} + +class UserException4 : Exception { + public int ExceptionId; + + public UserException4(int id){ + ExceptionId = id; + } +} + + +public class NestedException { + private int ThreadId; + + public NestedException(int id){ + ThreadId = id; + } + + + public static int Main(String []args) { + String s = "Done"; + int retVal = 100; + Thread mv_Thread; + NestedException [] ne = new NestedException[10]; + for (int i = 0 ; i < 10; i++){ + ne[i] = new NestedException(i); + mv_Thread = new Thread(new ThreadStart(ne[i].runtest)); + try { + mv_Thread.Start(); + } + catch (Exception ){ + retVal = 0; + Console.WriteLine("Exception was caught in main"); + } + } + Console.WriteLine(s); + return retVal; + } + + public void runtest(){ + try { + try { + try { + try { + switch (ThreadId){ + case 0: throw new UserException1(ThreadId); + case 1: throw new UserException2(ThreadId); + case 2: throw new UserException3(ThreadId); + case 3: throw new UserException4(ThreadId); + default: + throw new Exception(); + } + + } + catch (UserException1 e){ + lock(this){ + Console.WriteLine("The Exception1 " + e.ExceptionId + " was caught"); + } + } + } + catch (UserException2 e) { + lock(this){ + Console.WriteLine("The Exception2 " + e.ExceptionId + " was caught"); + } + } + } + catch (UserException3 e){ + lock(this){ + Console.WriteLine("The Exception3 " + e.ExceptionId + " was caught"); + } + } + } + catch (UserException4 e) { + lock(this){ + Console.WriteLine("The Exception4 " + e.ExceptionId + " was caught"); + } + } + catch (Exception ){ + lock(this){ + Console.WriteLine("Exception was caught"); + } + } + } + +} diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/NestedException.csproj b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/NestedException.csproj new file mode 100644 index 0000000000..7dafa5ec6d --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/NestedException.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="NestedException.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/NormalException.cs b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/NormalException.cs new file mode 100644 index 0000000000..3ed4a87503 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/NormalException.cs @@ -0,0 +1,202 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +using System; + +class UserException : Exception{ + + public UserException(){ + throw new ArithmeticException(); + } +} + +class ComplexByte { + + byte real = 0 ; + byte imag = 0 ; + + byte getrealpart( ) + { + return real; + } + + byte getimagpart( ) + { + return imag; + } + + int equals( int realparam, int imagparam ) + { + if (real != realparam) + { + return 0; + } + if (imag != imagparam) + { + return 0; + } + return 1; + } + + int equals( ComplexByte cparm ) + { + if (real != cparm.getrealpart()) + { + return 0; + } + if(imag != cparm.getimagpart( )) + { + return 0; + } + return 1; + } + + + void assign( int realparm, int imagparm ) + { + if( ( realparm > 127 ) || ( realparm < -128 ) ) + throw new ArgumentException(); + if( ( imagparm > 127 ) || ( imagparm < -128 ) ) + throw new ArgumentException(); + real = (byte) realparm; + imag = (byte) imagparm; + } + + void assign( ComplexByte cparm ) + { + real = cparm.getrealpart( ); + imag = cparm.getimagpart( ); + } + + public void add( int realparm, int imagparm ) + { + int rtemp, itemp; + + rtemp = real + realparm; + if ( ( rtemp > 127 ) || ( rtemp < -128 ) ) + throw new ArithmeticException(); + itemp = imag + imagparm; + if ( ( itemp > 127 ) || ( itemp < -128 ) ) + throw new ArithmeticException(); + real = (byte)(rtemp); + imag = (byte)(itemp); + } + + void add( ComplexByte cparm ) + { + int rtemp, itemp; + rtemp = real + cparm.getrealpart(); + if ( ( rtemp > 127 ) || ( rtemp < -128 ) ) + throw new ArithmeticException(); + itemp = imag + cparm.getimagpart(); + if ( ( itemp > 127 ) || ( itemp < -128 ) ) + throw new ArithmeticException(); + real = (byte)( rtemp); + imag = (byte)( itemp ); + } + + + void multiply( int realparm, int imagparm ) + { + int rtemp, itemp; + + rtemp = ( real * realparm - imag * imagparm ); + itemp = (real * imagparm + realparm * imag ); + if ( ( rtemp > 127 ) || ( rtemp < -128 ) ) + throw new ArithmeticException(); + if ( ( itemp > 127 ) || ( itemp < -128 ) ) + throw new ArithmeticException(); + real = (byte) rtemp; + imag = (byte) itemp; + } + + void multiply( ComplexByte cparm ) + { + int rtemp, itemp; + + rtemp = (real * cparm.getrealpart( ) - imag * cparm.getimagpart( )); + itemp = (real * cparm.getimagpart( ) + cparm.getrealpart( ) * imag); + + if ( ( rtemp > 127 ) || ( rtemp < -128 ) ) + throw new ArithmeticException(); + if ( ( itemp > 127 ) || ( itemp < -128 ) ) + throw new ArithmeticException(); + real = (byte) rtemp; + imag = (byte) itemp; + } + + public ComplexByte( ) + { + this.real = 0 ; + this.imag = 0 ; + } + + public ComplexByte( int realparm, int imagparm ) + { + if ( ( realparm > 127 ) || ( realparm < -128 ) ) + throw new ArgumentException(); + if ( ( imagparm > 127 ) || ( imagparm < -128 ) ) + throw new ArgumentException(); + real = (byte) realparm; + imag = (byte) imagparm; + } + + public ComplexByte( ComplexByte cparm ) + { + this.real = cparm.getrealpart( ); + this.imag = cparm.getimagpart( ); + } + +} + +public class NormalException { + + public static int Main( String [] args ) + { + String s = "Done"; + int retVal = 100; + int tryflag = 1; + + try { + throw new UserException(); + } + catch (ArithmeticException ){ + Console.WriteLine("AE was caught"); + + } + + try { + ComplexByte c4 = new ComplexByte( 200, -200 ); + } + catch ( ArgumentException ) { + tryflag = 0; // we caught it + Console.WriteLine( "Caught Argument Exception in Test Case 8" ); + } + finally { + if ( tryflag != 0 ) { + retVal = 8; + } + } + + tryflag = 1; + + try { + ComplexByte c4 = new ComplexByte( 100, -100 ); + c4.add( 200, -200 ); + } + catch ( ArithmeticException ) { + tryflag = 0; // we caught it + Console.WriteLine( "Caught Arithmetic Exception in Test Case 9" ); + } + finally { + if ( tryflag != 0 ) { + retVal = 9; + } + } + + + Console.WriteLine(s); + return retVal; + } + +} diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/NormalException.csproj b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/NormalException.csproj new file mode 100644 index 0000000000..c679d67395 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/NormalException.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="NormalException.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/RecursiveException.cs b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/RecursiveException.cs new file mode 100644 index 0000000000..052a48868a --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/RecursiveException.cs @@ -0,0 +1,50 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +using System; +using System.Threading; +using System.IO; + +class UserException : Exception { + +} + +public class RecursiveException { + public static int Main(String [] args) { + String s = "Done"; + int retVal = 100; + Thread mv_Thread; + RecursiveException re = new RecursiveException(); + for (int i = 0 ; i < 10; i++){ + mv_Thread = new Thread(new ThreadStart(re.runtest)); + try { + mv_Thread.Start(); + } + catch (Exception ){ + Console.WriteLine("Exception was caught in main"); + retVal = 0; + } + } + Console.WriteLine(s); + return retVal; + } + + public void runtest(){ + try { + recurse(0); + } + catch (UserException ) { + lock(this) + { + Console.WriteLine("The Exception was caught"); + } + } + } + + public void recurse(int counter) { + if (counter == 1000) + throw new UserException(); + else + recurse(++counter); + } +} diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/RecursiveException.csproj b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/RecursiveException.csproj new file mode 100644 index 0000000000..9f3df59755 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/RecursiveException.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="RecursiveException.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/TryCatch.cs b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/TryCatch.cs new file mode 100644 index 0000000000..3642b9984c --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/TryCatch.cs @@ -0,0 +1,107 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + + +public class TryCatch{ + public static int Main(String [] args) { + int retVal = 100; + int i = 0; + String m_str = ""; + String str = "Done"; + + try { + throw new ArithmeticException(); + } + catch ( ArithmeticException ) { + m_str = m_str + "ArithmeticException\n"; + i++; + } + + try { + throw new DivideByZeroException(); + } + catch ( DivideByZeroException ) { + m_str = m_str + "DivideByZeroException\n"; + i++; + } + + try { + throw new OverflowException(); + } + catch ( OverflowException ) { + m_str = m_str + "OverflowException\n"; + i++; + } + + try { + throw new ArgumentException(); + } + catch ( ArgumentException ) { + m_str = m_str + "ArgumentException\n"; + i++; + } + + try { + throw new ArrayTypeMismatchException(); + } + catch ( ArrayTypeMismatchException ) { + m_str = m_str + "ArrayTypeMismatchException\n"; + i++; + } + + try { + throw new MemberAccessException(); + } + catch ( MemberAccessException ) { + m_str = m_str + "AccessException\n"; + i++; + } + + try { + throw new FieldAccessException(); + } + catch ( FieldAccessException ) { + m_str = m_str + "FieldAccessException\n"; + i++; + } + + try { + throw new MissingFieldException(); + } + catch ( MissingFieldException ) { + m_str = m_str + "MissingFieldException\n"; + i++; + } + + try { + throw new MethodAccessException(); + } + catch ( MethodAccessException ) { + m_str = m_str + "MethodAccessException\n"; + i++; + } + + try { + throw new MissingMethodException(); + } + catch ( MissingMethodException ) { + m_str = m_str + "MissingMethodException\n"; + i++; + } + + Console.WriteLine( m_str ); + if (i == 10){ + Console.WriteLine("Test Passed"); + } + else { + Console.WriteLine("Test Failed"); + retVal = 1; + } + Console.WriteLine(str); + return retVal; + + } +} diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/TryCatch.csproj b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/TryCatch.csproj new file mode 100644 index 0000000000..ebf33c408a --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/TryCatch.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="TryCatch.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/TryCatchFinally.cs b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/TryCatchFinally.cs new file mode 100644 index 0000000000..bc25b16814 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/TryCatchFinally.cs @@ -0,0 +1,31 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + + +public class TryCatchFinally{ + public static int Main(String [] args) { + int i = 1; + String m_str = "Failed"; + String str = "Done"; + + try { + throw new ArithmeticException(); + } + catch ( ArithmeticException ) { + m_str = "Passed Catch"; + i = 1; + } + finally { + m_str = m_str + " and Passed Finally"; + i = 100; + } + + Console.WriteLine( "TryCatch Test " + m_str ); + Console.WriteLine(str); + return i; + + } +} diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/TryCatchFinally.csproj b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/TryCatchFinally.csproj new file mode 100644 index 0000000000..5a284d34e8 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/TryCatchFinally.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="TryCatchFinally.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/Unmanaged.cpp b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/Unmanaged.cpp new file mode 100644 index 0000000000..8f5b97cbad --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/Unmanaged.cpp @@ -0,0 +1,26 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +#include "Unmanaged.h" + +BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) +{ + /* No Need to do anything here -- for now */ + return TRUE; +} + + +EXPORT VOID UnmanagedCode( int iGiven ) +{ + int i; + + printf("[unmanaged code] software divide by zero:\n"); + RaiseException( EXCEPTION_INT_DIVIDE_BY_ZERO, 0, 0, 0); + + + printf("[unmanaged code] hardware divide by zero:\n"); + i = 5 / iGiven; + + printf("[unmanaged code] ... and survived? %i\n",i); +} diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/Unmanaged.h b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/Unmanaged.h new file mode 100644 index 0000000000..043fbdd2d3 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/Unmanaged.h @@ -0,0 +1,10 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +#include <iostream> +#include <WCTYPE.H> +#include <windows.h> + +#define EXPORT extern "C" __declspec(dllexport) + diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/UnmanagedToManaged.cs b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/UnmanagedToManaged.cs new file mode 100644 index 0000000000..d5f9222328 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/UnmanagedToManaged.cs @@ -0,0 +1,34 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +using System; +using System.Runtime.InteropServices; + +public class UnmanagedToManaged { + + ///** @dll.import("Unmanaged.dll")*/ + [System.Runtime.InteropServices.DllImport("unmanaged.dll")] + public static extern void UnmanagedCode( int i) ; + + public static int Main(String []args){ + String s = "Done"; + int retVal = 0; + try { + Console.WriteLine("Calling unmanaged code..."); + UnmanagedCode(0); + Console.WriteLine("...Returned from unmanaged code"); + } + catch (DivideByZeroException ) + { + Console.WriteLine("Caught a div-by-zero exception."); + retVal = 100; + } + catch (Exception ) + { + Console.WriteLine("Caught a general exception"); + } + Console.WriteLine(s); + return retVal; + } + +} diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/UnmanagedToManaged.csproj b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/UnmanagedToManaged.csproj new file mode 100644 index 0000000000..851989cd42 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/UnmanagedToManaged.csproj @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="UnmanagedToManaged.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="CMakeLists.txt" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/UserException.cs b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/UserException.cs new file mode 100644 index 0000000000..b8aa396609 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/UserException.cs @@ -0,0 +1,42 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +using System; +using System.Threading; + +public class UserException : Exception { + public static int Main(String [] args) { + int counter = 0; + String str = "Done"; + + for (int j = 0; j < 100; j++){ + try { + if (j % 2 == 0) + counter = j / (j % 2); + else + throw new UserException(); + } + catch ( UserException ) { + counter++; + continue; + } + catch (ArithmeticException ){ + counter--; + continue; + } + catch (Exception ){} + finally { + counter++; + } + } + if (counter == 100){ + Console.WriteLine( "TryCatch Test Passed" ); + return 100; + } + else{ + Console.WriteLine( "TryCatch Test Failed" ); + return 1; + } + Console.WriteLine(str); + } +} diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/UserException.csproj b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/UserException.csproj new file mode 100644 index 0000000000..909f141b45 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/UserException.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="UserException.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/UserExceptionThread.cs b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/UserExceptionThread.cs new file mode 100644 index 0000000000..020f80b375 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/UserExceptionThread.cs @@ -0,0 +1,59 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +using System; +using System.Threading; +using System.IO; + +public class UserExceptionThread : Exception { + static int retVal = 100; + + public static int Main(String []args) { + Thread mv_Thread; + String str = "Done"; + UserExceptionThread ue = new UserExceptionThread(); + for (int i = 0 ; i < 10; i++){ + mv_Thread = new Thread(new ThreadStart(ue.runtest)); + try { + mv_Thread.Start(); + } + catch (Exception ){ + Console.WriteLine("Exception was caught in main"); + } + } + Console.WriteLine(str); + return retVal; + } + + public void runtest(){ + int counter = 0; + for (int j = 0; j < 100; j++){ + try { + if (j % 2 == 0) + counter = j / (j % 2); + else + throw new UserExceptionThread(); + } + catch ( UserExceptionThread ) { + counter++; + continue; + } + catch (ArithmeticException ){ + counter--; + continue; + } + finally { + counter++; + } + } + if (counter == 100){ + lock(this){ + Console.WriteLine( "TryCatch Test Passed" ); + } + } + else{ + Console.WriteLine( "TryCatch Test Failed" ); + retVal = 1; + } + } +} diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/UserExceptionThread.csproj b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/UserExceptionThread.csproj new file mode 100644 index 0000000000..db31b5c3d4 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/UserExceptionThread.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="UserExceptionThread.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/app.config b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/app.config new file mode 100644 index 0000000000..62803f5972 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/app.config @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<configuration> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + </assemblyBinding> + </runtime> +</configuration>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/project.json b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/project.json new file mode 100644 index 0000000000..89527b786c --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/project.json @@ -0,0 +1,34 @@ +{ + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816", + "System.Collections": "4.0.10", + "System.Collections.NonGeneric": "4.0.1-beta-23302", + "System.Collections.Specialized": "4.0.1-beta-23302", + "System.ComponentModel": "4.0.1-beta-23302", + "System.Console": "4.0.0-beta-23302", + "System.Diagnostics.Process": "4.0.0-beta-23302", + "System.Globalization": "4.0.10", + "System.Globalization.Calendars": "4.0.0", + "System.IO": "4.0.10", + "System.IO.FileSystem": "4.0.0", + "System.IO.FileSystem.Primitives": "4.0.0", + "System.Linq": "4.0.1-beta-23302", + "System.Linq.Queryable": "4.0.1-beta-23302", + "System.Reflection": "4.0.10", + "System.Reflection.Primitives": "4.0.0", + "System.Runtime": "4.0.20", + "System.Runtime.Extensions": "4.0.10", + "System.Runtime.Handles": "4.0.0", + "System.Runtime.InteropServices": "4.0.20", + "System.Runtime.Loader": "4.0.0-beta-23302", + "System.Text.Encoding": "4.0.10", + "System.Threading": "4.0.10", + "System.Xml.ReaderWriter": "4.0.11-beta-23302", + "System.Xml.XDocument": "4.0.11-beta-23302", + "System.Xml.XmlDocument": "4.0.1-beta-23302", + "System.Xml.XmlSerializer": "4.0.11-beta-23302", + }, + "frameworks": { + "dnxcore50": {} + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/Except.il b/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/Except.il new file mode 100644 index 0000000000..1e481a350d --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/Except.il @@ -0,0 +1,99 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +// +// Except.asm +// Revised 4.01.99 by t-joecl +// Revised 7.01.99 by manishg +// Basic exception handling test case. +// +.assembly extern legacy library mscorlib{} +.assembly extern System.Console +{ + .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) + .ver 4:0:0:0 +} + +.assembly Except.exe{ + //This byte field requests that this assembly not be verified at run time and corresponds to this C# declaration: + //[assembly:System.Security.Permissions.SecurityPermissionAttribute( [mscorlib]System.Security.Permissions.SecurityAction.RequestMinimum, Flags=System.Security.Permissions.SecurityPermissionFlag.SkipVerification )] + .permission reqmin ['mscorlib']System.Security.Permissions.SecurityPermissionAttribute ( "SkipVerification" = true ) +} + +.class Except { + +// global for storing return value - defaults to 0 for success + + +// .data iResult = int32(0x00000000) +.field static int32 iResult + +// Execution starts here + +.method static int32 main(class [mscorlib]System.String[]) { +.locals (string) +.entrypoint +.maxstack 2 + + ldstr "Done" + stloc.0 + +try_start: + ldc.i4 0xFFFFFF80 + ldc.i4 0x0 + div + pop + leave ENDOFTEST +try_end: + // Error case 4 - exception _not thrown + ldstr "Error case 4 - exception _not thrown" + + + call void [System.Console]System.Console::WriteLine(class System.String) + + ldc.i4 0x4 + stsfld int32 Except::iResult + br ENDOFTEST + //leave ENDOFTEST +handler1: + isinst [mscorlib]System.ArithmeticException + brfalse error_case1 + leave ENDOFTEST +error_case1: + // Error case 1 - aHandler failure: trapped the wrong exception + ldstr "Error case 1 - aHandler failure: trapped the wrong exception" + + + call void [System.Console]System.Console::WriteLine(class System.String) + ldc.i4 0x1 + stsfld int32 Except::iResult + leave ENDOFTEST +end_handler1: + + +.try try_start to try_end catch [mscorlib]System.ArithmeticException handler handler1 to end_handler1 + +ENDOFTEST: + ldsfld int32 Except::iResult + ldc.i4 0 + ceq + brfalse RETFAIL + ldstr "Test succeeded (returning 100)." + + + call void [System.Console]System.Console::WriteLine(class System.String) + ldc.i4 0x64 + br RETEND +RETFAIL: + ldstr "Test FAILED." + + + call void [System.Console]System.Console::WriteLine(class System.String) + ldsfld int32 Except::iResult +RETEND: + ldloc.0 + call void [System.Console]System.Console::WriteLine(string) + ret + +} +} diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/Except.ilproj b/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/Except.ilproj new file mode 100644 index 0000000000..1f4b7ebbb1 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/Except.ilproj @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <AssemblyName>$(MSBuildProjectName)</AssemblyName> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <PropertyGroup> + + </PropertyGroup> + <ItemGroup> + <Compile Include="Except.il" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/FiltCatch.il b/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/FiltCatch.il new file mode 100644 index 0000000000..f248a93fb7 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/FiltCatch.il @@ -0,0 +1,109 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +// +// FiltCatch.asm +// Revised 4.01.99 by t-joecl +// +// Apply filters that do trap an exception; make sure it doesn't get out +// to an outer .exception aHandler. +// +.assembly extern legacy library mscorlib{} +.assembly extern System.Console +{ + .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) + .ver 4:0:0:0 +} + +.assembly FiltCatch.exe{ + //This byte field requests that this assembly not be verified at run time and corresponds to this C# declaration: + //[assembly:System.Security.Permissions.SecurityPermissionAttribute( [mscorlib]System.Security.Permissions.SecurityAction.RequestMinimum, Flags=System.Security.Permissions.SecurityPermissionFlag.SkipVerification )] + .permission reqmin ['mscorlib']System.Security.Permissions.SecurityPermissionAttribute ( "SkipVerification" = true )} + +.class FiltCatch { + +// global for storing return value - defaults to 0 for success + + +// .data iResult = int32(0x00000000) +.field static int32 iResult + +// Execution starts here + +.method static int32 main(class [mscorlib]System.String[]) { +.locals(string) +.entrypoint +.maxstack 2 + + ldstr "Done" + stloc.0 + +.try{ + newobj instance void [mscorlib]System.ArithmeticException::.ctor() + throw +try_end: + // Error case 4 - exception _not thrown + ldstr "Error case 4 - exception _not thrown" + call void [System.Console]System.Console::WriteLine(class System.String) + ldc.i4 0x4 + stsfld int32 FiltCatch::iResult + //br ENDOFTEST + leave ENDOFTEST +} + +// aFilter one exception that won't be encountered; +// let it fall through. + +filter{ + isinst [mscorlib]System.OutOfMemoryException + brfalse OOMcontinue + + // Error case 2 - aFilter failure: filtered the wrong exception + ldstr "Error case 2 - aFilter failure: filtered the wrong exception" + call void [System.Console]System.Console::WriteLine(class System.String) + ldc.i4 0x2 + stsfld int32 FiltCatch::iResult + ldnull + br OOMendfilter +OOMcontinue: + ldnull +OOMendfilter: +AEfilter: + isinst [mscorlib]System.ArithmeticException + brfalse AEcontinue + ldc.i4 0x00000001 + br AEendfilter +AEcontinue: + ldc.i4 0x00000001 + br AEendfilter +AEendfilter: + endfilter +} +{ + pop + leave ENDOFTEST +ENDOOMFILThandler: +} + +ENDOFTEST: + ldsfld int32 FiltCatch::iResult + ldc.i4 0 + ceq + brfalse RETFAIL + ldstr "Test succeeded (returning 100)." + + call void [System.Console]System.Console::WriteLine(class System.String) + ldc.i4 0x64 + br RETEND +RETFAIL: + ldstr "Test FAILED." + call void [System.Console]System.Console::WriteLine(class System.String) + ldsfld int32 FiltCatch::iResult +RETEND: + ldloc.0 + call void [System.Console]System.Console::WriteLine(class System.String) + ret + +} +} diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/FiltCatch.ilproj b/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/FiltCatch.ilproj new file mode 100644 index 0000000000..772ef1f3e8 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/FiltCatch.ilproj @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <AssemblyName>$(MSBuildProjectName)</AssemblyName> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <PropertyGroup> + + </PropertyGroup> + <ItemGroup> + <Compile Include="FiltCatch.il" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/FiltFallThru.il b/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/FiltFallThru.il new file mode 100644 index 0000000000..4168fcd40b --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/FiltFallThru.il @@ -0,0 +1,170 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +// +// FiltFallThru.asm +// Revised 4.01.99 by t-joecl +// +// Apply filters that don't trap an exception, then catch it in an +// outer .exception aHandler. +// +.assembly extern legacy library mscorlib{} +.assembly extern System.Console +{ + .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) + .ver 4:0:0:0 +} + +.assembly FiltFallThru{ +//This byte field requests that this assembly not be verified at run time and corresponds to this C# declaration: + //[assembly:System.Security.Permissions.SecurityPermissionAttribute( [mscorlib]System.Security.Permissions.SecurityAction.RequestMinimum, Flags=System.Security.Permissions.SecurityPermissionFlag.SkipVerification )] + .permission reqmin ['mscorlib']System.Security.Permissions.SecurityPermissionAttribute ( "SkipVerification" = true )} + +.class FiltFallThru { + +// global for storing return value - defaults to 0 for success + + +// .data iResult = int32(0x00000000) +.field static int32 iResult + +// Execution starts here + +.method static int32 main(class [mscorlib]System.String[]) { +.locals(string) +.entrypoint +.maxstack 2 + + ldstr "Done" + stloc.0 +.try{ + .try{ + try_start: + newobj instance void [mscorlib]System.Security.SecurityException::.ctor() + throw + try_end: + // Error case 4 - exception _not thrown + ldstr "Error case 4 - exception _not thrown" + + + call void [System.Console]System.Console::WriteLine(class System.String) + ldc.i4 0x4 + stsfld int32 FiltFallThru::iResult + leave ENDOFTEST + } + + // aFilter two exceptions that won't be encountered; + // let them fall through. + filter{ + OOMfilter: + isinst [mscorlib]System.OutOfMemoryException + leave OOMcontinue + + // Error case 2 - aFilter failure: filtered the wrong exception + ldstr "Error case 2 - aFilter failure: filtered the wrong exception" + + + call void [System.Console]System.Console::WriteLine(class System.String) + ldc.i4 0x2 + stsfld int32 FiltFallThru::iResult + ldnull + leave OOMendfilter + OOMcontinue: + ldnull + OOMendfilter: + + AEfilter: + isinst [mscorlib]System.ArithmeticException + leave AEcontinue + + // Error case 2 - aFilter failure: filtered the wrong exception + ldstr "Error case 2 - aFilter failure: filtered the wrong exception" + + + call void [System.Console]System.Console::WriteLine(class System.String) + ldc.i4 0x2 + stsfld int32 FiltFallThru::iResult + ldc.i4 0x00000001 + leave AEendfilter + AEcontinue: + ldc.i4 0x00000000 + AEendfilter: + endfilter + } + { + FILThandler: + pop + // isinst System.ArithmeticException + // brfalse FILTcontinue + // br FILTcontinue + FILTcontinue: + // Error case 3 - running aHandler for the wrong aFilter + ldstr "Error case 3 - running aHandler for the wrong aFilter" + + + call void [System.Console]System.Console::WriteLine(class System.String) + ldc.i4 0x3 + stsfld int32 FiltFallThru::iResult + leave ENDFILThandler + ENDFILThandler: + leave ENDOFTEST + + FILThandler1: + pop + // isinst System.ArithmeticException + // brfalse FILTcontinue1 + // br FILTcontinue1 + FILTcontinue1: + // Error case 3 - running aHandler for the wrong aFilter + ldstr "Error case 3 - running aHandler for the wrong aFilter" + call void [System.Console]System.Console::WriteLine(class System.String) + ldc.i4 0x3 + stsfld int32 FiltFallThru::iResult + leave ENDFILThandler1 + ENDFILThandler1: + leave ENDOFTEST + } +} + +catch [mscorlib]System.Security.SecurityException{ +SEChandler: + isinst [mscorlib]System.Security.SecurityException + brfalse handler_fail + br end_handler + +handler_fail: + // Error case 1 - aHandler failure: trapped the wrong exception + ldc.i4 0x1 + stsfld int32 FiltFallThru::iResult + ldstr "Error case 1 - aHandler failure: trapped the wrong exception" + + + call void [System.Console]System.Console::WriteLine(class System.String) +end_handler: + leave ENDOFTEST +} +ENDOFTEST: + ldsfld int32 FiltFallThru::iResult + ldc.i4 0 + ceq + brfalse RETFAIL + ldstr "Test succeeded (returning 100)." + + + call void [System.Console]System.Console::WriteLine(class System.String) + ldc.i4 0x64 + br RETEND +RETFAIL: + ldstr "Test FAILED." + + + call void [System.Console]System.Console::WriteLine(class System.String) + ldsfld int32 FiltFallThru::iResult +RETEND: + ldloc.0 + call void [System.Console]System.Console::WriteLine(class System.String) + ret + +} +} diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/FiltFallThru.ilproj b/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/FiltFallThru.ilproj new file mode 100644 index 0000000000..b48b3cc5c7 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/FiltFallThru.ilproj @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <AssemblyName>$(MSBuildProjectName)</AssemblyName> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <PropertyGroup> + + </PropertyGroup> + <ItemGroup> + <Compile Include="FiltFallThru.il" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/Filter.il b/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/Filter.il new file mode 100644 index 0000000000..6f98b9e53b --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/Filter.il @@ -0,0 +1,102 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +// +// Filter.asm +// Revised 4.01.99 by t-joecl +// +// Basic aFilter test case. +// +.assembly extern legacy library mscorlib{} +.assembly extern System.Console +{ + .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) + .ver 4:0:0:0 +} + +.assembly Filter.exe{} + + +.class Filter { + +// global for storing return value - defaults to 0 for success + + +// .data iResult = int32(0x00000000) +.field static int32 iResult + +// Execution starts here + +.method static int32 main(class [mscorlib]System.String[]) { +.locals(string) +.entrypoint +.maxstack 2 + + ldstr "Done" + stloc.0 + +.try{ +try_start: + newobj instance void [mscorlib]System.Security.SecurityException::.ctor() + throw +try_end: + // Error case 4 - exception _not thrown + ldstr "Error case 4 - exception _not thrown" + + + call void [System.Console]System.Console::WriteLine(class System.String) + ldc.i4 0x4 + stsfld int32 Filter::iResult + leave ENDOFTEST +} +filter{ +filter1: + isinst [mscorlib]System.Security.SecurityException + brfalse continue1 + ldc.i4 0x00000001 + br endfilter1 +continue1: + ldc.i4 0x00000000 +endfilter1: + endfilter +} +{ +handler1: + isinst [mscorlib]System.Security.SecurityException + brfalse handler_fail1 + br end_handler1 +handler_fail1: + // Error case 3 - running aHandler for the wrong aFilter + ldstr "Error case 3 - running aHandler for the wrong aFilter" + + + call void [System.Console]System.Console::WriteLine(class System.String) + ldc.i4 0x1 + stsfld int32 Filter::iResult +end_handler1: + leave ENDOFTEST +} +ENDOFTEST: + ldsfld int32 Filter::iResult + ldc.i4 0 + ceq + brfalse RETFAIL + ldstr "Test succeeded (returning 100)." + + + call void [System.Console]System.Console::WriteLine(class System.String) + ldc.i4 0x64 + br RETEND +RETFAIL: + ldstr "Test FAILED." + + + call void [System.Console]System.Console::WriteLine(class System.String) + ldsfld int32 Filter::iResult +RETEND: + ldloc.0 + call void [System.Console]System.Console::WriteLine(class System.String) + ret + +} +} diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/Filter.ilproj b/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/Filter.ilproj new file mode 100644 index 0000000000..6ef6d919b8 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/Filter.ilproj @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <AssemblyName>$(MSBuildProjectName)</AssemblyName> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <PropertyGroup> + + </PropertyGroup> + <ItemGroup> + <Compile Include="filter.il" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/Finally.il b/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/Finally.il new file mode 100644 index 0000000000..06d1338a8c --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/Finally.il @@ -0,0 +1,127 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +// +// Finally.asm +// Revised 4.01.99 by t-joecl +// +// Exercises finally exception syntax. +// +.assembly extern legacy library mscorlib{} +.assembly extern System.Console +{ + .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) + .ver 4:0:0:0 +} + +.assembly Finally.exe{ +//This byte field requests that this assembly not be verified at run time and corresponds to this C# declaration: + //[assembly:System.Security.Permissions.SecurityPermissionAttribute( [mscorlib]System.Security.Permissions.SecurityAction.RequestMinimum, Flags=System.Security.Permissions.SecurityPermissionFlag.SkipVerification )] + .permission reqmin ['mscorlib']System.Security.Permissions.SecurityPermissionAttribute ( "SkipVerification" = true )} + + +.class Finally { +.field static int32 iResult +.field static int32 finally_flag + +// global for storing return value - defaults to 0 for success +//iResult: +// i4 0x00000000 +//finally_flag: +// i4 0x00000000 + +//clinit +.method static void .cctor() { +.maxstack 1 + ldc.i4 0 + stsfld int32 Finally::iResult + ldc.i4 0 + stsfld int32 Finally::finally_flag + ret +} + +// Execution starts here + +.method static int32 main(class [mscorlib]System.String[]) { +.locals(string) +.entrypoint +.maxstack 2 + + ldstr "Done" + stloc.0 + +try_start: + newobj instance void [mscorlib]System.ArithmeticException::.ctor() + throw +try_end: + // Error case 4 - exception _not thrown + ldstr "Error case 4 - exception _not thrown" + + + call void [System.Console]System.Console::WriteLine(class System.String) + ldc.i4 0x4 + stsfld int32 Finally::iResult + leave ENDOFTEST + +handler1: + isinst [mscorlib]System.ArithmeticException + brfalse handler_continue1 + leave end_handler1 +handler_continue1: + // Error case 1 - aHandler failure: trapped the wrong exception + ldstr "Error case 1 - aHandler failure: trapped the wrong exception" + + + call void [System.Console]System.Console::WriteLine(class System.String) + ldc.i4 0x1 + stsfld int32 Finally::iResult +end_handler1: + leave ENDOFhandler1 +ENDOFhandler1: + leave ENDOFTEST + +finally1: + ldstr "Successfully called the finally block." + call void [System.Console]System.Console::WriteLine(class System.String) + ldc.i4 0x1 + stsfld int32 Finally::finally_flag + endfinally +ENDOFFinally: + +.try try_start to try_end catch [mscorlib]System.ArithmeticException handler handler1 to ENDOFhandler1 +.try try_start to finally1 finally handler finally1 to ENDOFFinally + +ENDOFTEST: + ldsfld int32 Finally::finally_flag + ldc.i4 1 + ceq + brfalse FINALLYFAIL + + ldsfld int32 Finally::iResult + ldc.i4 0 + ceq + brfalse RETFAIL + ldstr "Test succeeded (returning 100)." + + + call void [System.Console]System.Console::WriteLine(class System.String) + ldc.i4 0x64 + br RETEND +FINALLYFAIL: + ldstr "Error case 2 - finally _not called" + + + call void [System.Console]System.Console::WriteLine(class System.String) +RETFAIL: + ldstr "Test FAILED." + + + call void [System.Console]System.Console::WriteLine(class System.String) + ldsfld int32 Finally::iResult +RETEND: + ldloc.0 + call void [System.Console]System.Console::WriteLine(class System.String) + ret + +} +} diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/Finally.ilproj b/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/Finally.ilproj new file mode 100644 index 0000000000..cac81ca4b2 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/Finally.ilproj @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <AssemblyName>$(MSBuildProjectName)</AssemblyName> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <PropertyGroup> + + </PropertyGroup> + <ItemGroup> + <Compile Include="Finally.il" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/NestedExcept.il b/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/NestedExcept.il new file mode 100644 index 0000000000..e6197fd7a1 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/NestedExcept.il @@ -0,0 +1,108 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +// +// NestedExcept.asm +// Revised 4.01.99 by t-joecl +// +// Nested exception test cases. +// +.assembly extern legacy library mscorlib{} +.assembly extern System.Console +{ + .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) + .ver 4:0:0:0 +} + +.assembly NestedExcept.exe{} + +.class NestedExcept { + +// global for storing return value - defaults to 0 for success + + +// .data iResult = int32(0x00000000) +.field static int32 iResult + +// Execution starts here + +.method static int32 main(class [mscorlib]System.String[]) { +.locals(string) +.entrypoint +.maxstack 2 + + ldstr "Done" + stloc.0 + +try_start: + newobj instance void [mscorlib]System.Security.SecurityException::.ctor() + throw +try_end: + // Error case 4 - exception _not thrown + ldstr "Error case 4 - exception _not thrown" + + + call void [System.Console]System.Console::WriteLine(class System.String) + ldc.i4 0x4 + stsfld int32 NestedExcept::iResult + br ENDOFTEST + +handler1: + isinst [mscorlib]System.Security.SecurityException + brfalse error_case1 +// br end_handler1 + leave ENDOFhandler1 +error_case1: + // Error case 1 - aHandler failure: trapped the wrong exception + ldstr "Error case 1 - aHandler failure: trapped the wrong exception" + + + call void [System.Console]System.Console::WriteLine(class System.String) + ldc.i4 0x1 + stsfld int32 NestedExcept::iResult +end_handler1: + leave ENDOFhandler1 +ENDOFhandler1: + br after_handler2 + +handler2: + pop + // Error case 5 - exception propagates beyond first aHandler + ldstr "Error case 5 - exception propagates beyond first aHandler" + + + call void [System.Console]System.Console::WriteLine(class System.String) + ldc.i4 0x5 + stsfld int32 NestedExcept::iResult + leave after_handler2 + +after_handler2: + +.try try_start to try_end catch [mscorlib]System.Security.SecurityException handler handler1 to ENDOFhandler1 +.try try_start to try_end catch [mscorlib]System.Security.SecurityException handler handler2 to after_handler2 + +ENDOFTEST: + ldsfld int32 NestedExcept::iResult + ldc.i4 0 + ceq + brfalse RETFAIL + ldstr "Test succeeded (returning 100)." + + + call void [System.Console]System.Console::WriteLine(class System.String) + ldc.i4 0x64 + br RETEND +RETFAIL: + ldstr "Test FAILED." + + + call void [System.Console]System.Console::WriteLine(class System.String) + ldsfld int32 NestedExcept::iResult +RETEND: + ldloc.0 + call void [System.Console]System.Console::WriteLine(class System.String) + ret + +} +} diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/NestedExcept.ilproj b/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/NestedExcept.ilproj new file mode 100644 index 0000000000..3ac3169103 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/NestedExcept.ilproj @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <AssemblyName>$(MSBuildProjectName)</AssemblyName> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <PropertyGroup> + + </PropertyGroup> + <ItemGroup> + <Compile Include="NestedExcept.il" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/NestedFilt.il b/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/NestedFilt.il new file mode 100644 index 0000000000..ca55a34e92 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/NestedFilt.il @@ -0,0 +1,151 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +// +// NestedFilt.asm +// Revised 4.01.99 by t-joecl +// +// Nests filters that catch the same exception. +// +.assembly extern legacy library mscorlib{} +.assembly extern System.Console +{ + .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) + .ver 4:0:0:0 +} + +.assembly NestedFilt.exe{} + +.class NestedFilt { + +// global for storing return value - defaults to 0 for success + + +// .data iResult = int32(0x00000000) +.field static int32 iResult + +// Execution starts here + +.method static int32 main(class [mscorlib]System.String[]) { +.locals(string) +.entrypoint +.maxstack 3 + + ldstr "Done" + stloc.0 + +try_start: + newobj instance void [mscorlib]System.ArithmeticException::.ctor() + throw +try_end: + // Error case 4 - exception _not thrown + ldstr "Error case 4 - exception _not thrown" + + + call void [System.Console]System.Console::WriteLine(class System.String) + ldc.i4 0x4 + stsfld int32 NestedFilt::iResult + br ENDOFTEST + + +filter1: + isinst [mscorlib]System.ArithmeticException + brfalse continue1 + ldc.i4 0x00000001 + br endfilter1 +continue1: + ldc.i4 0x00000000 + // Error case 2 - aFilter failure: filtered the wrong exception + ldstr "Error case 2 - aFilter failure: filtered the wrong exception" + + + call void [System.Console]System.Console::WriteLine(class System.String) + ldc.i4 0x2 + stsfld int32 NestedFilt::iResult +endfilter1: + endfilter + + +handler1: + isinst [mscorlib]System.ArithmeticException + brfalse handler_continue1 + br end_handler1 +handler_continue1: + // Error case 1 - aHandler failure: trapped the wrong exception + ldstr "Error case 1 - aHandler failure: trapped the wrong exception" + + + call void [System.Console]System.Console::WriteLine(class System.String) + ldc.i4 0x1 + stsfld int32 NestedFilt::iResult +end_handler1: + leave ENDOFhandler1 +ENDOFhandler1: + br after_handler2 + +filter2: + isinst [mscorlib]System.ArithmeticException + brfalse continue2 + ldc.i4 0x00000001 + br endfilter2 +continue2: + ldc.i4 0x00000000 + // Error case 2 - aFilter failure: filtered the wrong exception + ldstr "Error case 2 - aFilter failure: filtered the wrong exception" + + + call void [System.Console]System.Console::WriteLine(class System.String) + ldc.i4 0x2 + stsfld int32 NestedFilt::iResult +endfilter2: + // Error case 5 - exception propagates beyond first aFilter + ldstr "Error case 5 - exception propagates beyond first aFilter" + + + call void [System.Console]System.Console::WriteLine(class System.String) + ldc.i4 0x5 + stsfld int32 NestedFilt::iResult + endfilter + +handler2: + pop + // Error case 5 - exception propagates beyond first aFilter + ldstr "Error case 5 - exception propagates beyond first aFilter" + + + call void [System.Console]System.Console::WriteLine(class System.String) + ldc.i4 0x5 + stsfld int32 NestedFilt::iResult + leave ENDOFhandler2 + +ENDOFhandler2: + +.try try_start to try_end filter filter1 handler handler1 to ENDOFhandler1 +.try try_start to try_end filter filter2 handler handler2 to ENDOFhandler2 + +after_handler2: + +ENDOFTEST: + ldsfld int32 NestedFilt::iResult + ldc.i4 0 + ceq + brfalse RETFAIL + ldstr "Test succeeded (returning 100)." + + + call void [System.Console]System.Console::WriteLine(class System.String) + ldc.i4 0x64 + br RETEND +RETFAIL: + ldstr "Test FAILED." + + + call void [System.Console]System.Console::WriteLine(class System.String) + ldsfld int32 NestedFilt::iResult +RETEND: + ldloc.0 + call void [System.Console]System.Console::WriteLine(class System.String) + ret + +} +} diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/NestedFilt.ilproj b/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/NestedFilt.ilproj new file mode 100644 index 0000000000..de01d3cf1b --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/NestedFilt.ilproj @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <AssemblyName>$(MSBuildProjectName)</AssemblyName> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <PropertyGroup> + + </PropertyGroup> + <ItemGroup> + <Compile Include="NestedFilt.il" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/app.config b/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/app.config new file mode 100644 index 0000000000..62803f5972 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/app.config @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<configuration> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + </assemblyBinding> + </runtime> +</configuration>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/coverage/Exceptions.cs b/tests/src/baseservices/exceptions/regressions/V1/SEH/coverage/Exceptions.cs new file mode 100644 index 0000000000..b4418ecdf3 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/coverage/Exceptions.cs @@ -0,0 +1,467 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.IO; +using System.Reflection; +using System.Resources; +using System.Runtime.InteropServices; +using System.Security; +using System.Threading; + +class MightyExceptor +{ + static int Result = 100; + + public static int Main(String[] Args) + { + try + { + Console.WriteLine("Throwing ArgumentException.."); + throw new ArgumentException("Invalid Argument", "Paramzi", new Exception()); + } + catch(ArgumentException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + Console.WriteLine("Extra Exception Info: {0}", e.ParamName); + } + + try + { + Console.WriteLine("Throwing ArgumentOutOfRangeException.."); + throw new ArgumentOutOfRangeException("Arguement Name", 1, "Arguement Shame"); + + } + catch(ArgumentOutOfRangeException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + Console.WriteLine("Extra Exception Info: {0}", e.ActualValue); + } + + try + { + Console.WriteLine("Throwing BadImageFormatException.."); + throw new BadImageFormatException("I'm bad, I'm bad..", "YouKnowMe.txt"); + + } + catch(BadImageFormatException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + Console.WriteLine("Extra Exception Info: {0}", e.FileName); + } + + try + { + Console.WriteLine("Throwing another BadImageFormatException.."); + throw new BadImageFormatException("This is a really bad image..", "BadFile.exe", new Exception()); + + } + catch(BadImageFormatException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + Console.WriteLine("Extra Exception Info: {0}", e.FileName); + } + + try + { + Console.WriteLine("Throwing more BadImageFormatExceptions.."); + throw new BadImageFormatException("Yup, it's bad alright", new Exception()); + + } + catch(BadImageFormatException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + Console.WriteLine("Extra Exception Info: {0}", e.FileName); + } + + try + { + Console.WriteLine("Throwing DllNotFoundException.."); + throw new DllNotFoundException("Where is my DLL?"); + + } + catch(DllNotFoundException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + } + + try + { + Console.WriteLine("Throwing another DllNotFoundException.."); + throw new DllNotFoundException("The DLL is unavailable, please try again later.", new Exception()); + + } + catch(DllNotFoundException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + } + + try + { + Console.WriteLine("Throwing DirectoryNotFoundException.."); + throw new DirectoryNotFoundException("You've been had, the folder is gone.", new Exception()); + + } + catch(DirectoryNotFoundException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + } + + try + { + Console.WriteLine("Throwing EndOfStreamException.."); + throw new EndOfStreamException("The Stream is finished.", new Exception()); + + } + catch(EndOfStreamException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + } + + try + { + Console.WriteLine("Throwing FileLoadException.."); + throw new FileLoadException("Zis is a mesage..", "File1.abc", new Exception()); + + } + catch(FileLoadException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + Console.WriteLine("Extra Exception Info: {0}", e.FileName); + } + + try + { + Console.WriteLine("Throwing another FileLoadException.."); + throw new FileLoadException("Nice try.."); + + } + catch(FileLoadException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + Console.WriteLine("Extra Exception Info: {0}", e.FileName); + } + + try + { + Console.WriteLine("Throwing yet another FileLoadException.."); + throw new FileLoadException("Keep trying..", new Exception()); + + } + catch(FileLoadException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + Console.WriteLine("Extra Exception Info: {0}", e.FileName); + } + + try + { + Console.WriteLine("Throwing more FileLoadExceptions.."); + throw new FileLoadException("Zis is a mesage..", "File1.abc"); + + } + catch(FileLoadException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + Console.WriteLine("Extra Exception Info: {0}", e.FileName); + } + + try + { + Console.WriteLine("Throwing FileNotFoundException.."); + throw new FileNotFoundException("What file are you talking about?", "Windows.exe", new Exception()); + + } + catch(FileNotFoundException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + Console.WriteLine("Extra Exception Info: {0}", e.FileName); + } + + try + { + Console.WriteLine("Throwing another FileNotFoundException.."); + throw new FileNotFoundException("Raiders of the lost file?", new Exception()); + + } + catch(FileNotFoundException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + Console.WriteLine("Extra Exception Info: {0}", e.FileName); + } + + try + { + Console.WriteLine("Throwing PathTooLongException.."); + throw new PathTooLongException("Slow down, boy!", new Exception()); + + } + catch(PathTooLongException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + } + + try + { + Console.WriteLine("Throwing InvalidProgramException.."); + throw new InvalidProgramException("Le Programe est invaleed.", new Exception()); + + } + catch(InvalidProgramException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + } + + try + { + Console.WriteLine("Throwing another InvalidProgramException.."); + throw new InvalidProgramException("This program is invalid, parental guidance is advised."); + + } + catch(InvalidProgramException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + } + + try + { + Console.WriteLine("Throwing MissingFieldException.."); + throw new MissingFieldException("Where's the field, kid?", new Exception()); + + } + catch(MissingFieldException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + } + + try + { + Console.WriteLine("Throwing MissingMemberException.."); + throw new MissingMemberException("Classy"); + + } + catch(MissingMemberException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + } + + try + { + Console.WriteLine("Throwing NotImplementedException.."); + throw new NotImplementedException("What are you talking about?", new Exception()); + + } + catch(NotImplementedException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + } + + try + { + Console.WriteLine("Throwing ObjectDisposedException.."); + throw new ObjectDisposedException("Bad Object!"); + + } + catch(ObjectDisposedException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + } + + try + { + Console.WriteLine("Throwing another ObjectDisposedException.."); + throw new ObjectDisposedException(""); + + } + catch(ObjectDisposedException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + } + + try + { + Console.WriteLine("Throwing AmbiguousMatchException.."); + throw new AmbiguousMatchException("Humpty Dumpty sat on a wall..", new Exception()); + + } + catch(AmbiguousMatchException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + } + + try + { + Console.WriteLine("Throwing ReflectionTypeLoadException.."); + Type[] Typo = new Type[1]; + Exception[] Excepto = new Exception[1]; + throw new ReflectionTypeLoadException(Typo, Excepto, "Ya Zahrat al-mada'in."); + + } + catch(ReflectionTypeLoadException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + Console.WriteLine("Extra Exception Info: {0}", e.Types); + Console.WriteLine("Extra Exception Info: {0}", e.LoaderExceptions); + } + + try + { + Console.WriteLine("Throwing TargetParameterCountException.."); + throw new TargetParameterCountException("Then you shall DIE AGAIN!!", new Exception()); + + } + catch(TargetParameterCountException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + } + + try + { + Console.WriteLine("Throwing MissingManifestResourceException.."); + throw new MissingManifestResourceException("No deaders today but walkin' ones, looks like!", new Exception()); + + } + catch(MissingManifestResourceException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + } + + try + { + Console.WriteLine("Throwing COMException.."); + throw new COMException("A Space FOLD??!!", new Exception()); + + } + catch(COMException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + } + + try + { + Console.WriteLine("Throwing InvalidComObjectException.."); + throw new InvalidComObjectException("At this altitude, it's IMPOSSIBLE!!", new Exception()); + + } + catch(InvalidComObjectException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + } + + try + { + Console.WriteLine("Throwing InvalidOleVariantTypeException.."); + throw new InvalidOleVariantTypeException("It may be impossible but they did it!", new Exception()); + + } + catch(InvalidOleVariantTypeException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + } + + try + { + Console.WriteLine("Throwing MarshalDirectiveException.."); + throw new MarshalDirectiveException("You point, I punch!"); + + } + catch(MarshalDirectiveException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + } + + try + { + Console.WriteLine("Throwing another MarshalDirectiveException.."); + throw new MarshalDirectiveException("Minsc and Boo stand ready!", new Exception()); + + } + catch(MarshalDirectiveException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + } + + try + { + Console.WriteLine("Throwing SEHException.."); + throw new SEHException("Full plate and packing steel!"); + + } + catch(SEHException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + Console.WriteLine("Extra Exception Info: {0}", e.CanResume()); + } + + try + { + Console.WriteLine("Throwing another SEHException.."); + throw new SEHException("A den of STINKIN' EVIL! Cover your nose Boo, we'll leave no crevice untouched!!", new Exception()); + + } + catch(SEHException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + Console.WriteLine("Extra Exception Info: {0}", e.CanResume()); + } + + try + { + Console.WriteLine("Throwing SafeArrayRankMismatchException.."); + throw new SafeArrayRankMismatchException("Evil around every corner.. Careful not to step in any!"); + + } + catch(SafeArrayRankMismatchException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + } + + try + { + Console.WriteLine("Throwing another SafeArrayRankMismatchException.."); + throw new SafeArrayRankMismatchException("Cities always teem with evil and decay.. Let's give it a good shake and see what falls out!!", new Exception()); + + } + catch(SafeArrayRankMismatchException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + } + + try + { + Console.WriteLine("Throwing SafeArrayTypeMismatchException.."); + throw new SafeArrayTypeMismatchException("Aww, we are all heroes, you and Boo and I, hamsters and rangers everywhere.. REJOICE!!", new Exception()); + + } + catch(SafeArrayTypeMismatchException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + } + + try + { + Console.WriteLine("Throwing VerificationException.."); + throw new VerificationException("Butts will be liberally kicked when I get out!!", new Exception()); + + } + catch(VerificationException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + } + + try + { + Console.WriteLine("Throwing TypeInitializationException.."); + throw new TypeInitializationException("TheUnknownType", new Exception()); + + } + catch(TypeInitializationException e) + { + Console.WriteLine("Caught the exception: {0}", e.Message); + Console.WriteLine("Extra Exception Info: {0}", e.TypeName); + } + + return Result; + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/coverage/Exceptions.csproj b/tests/src/baseservices/exceptions/regressions/V1/SEH/coverage/Exceptions.csproj new file mode 100644 index 0000000000..d1a3640b49 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/coverage/Exceptions.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="exceptions.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/coverage/app.config b/tests/src/baseservices/exceptions/regressions/V1/SEH/coverage/app.config new file mode 100644 index 0000000000..62803f5972 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/coverage/app.config @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<configuration> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + </assemblyBinding> + </runtime> +</configuration>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/V1/SEH/coverage/project.json b/tests/src/baseservices/exceptions/regressions/V1/SEH/coverage/project.json new file mode 100644 index 0000000000..89527b786c --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/coverage/project.json @@ -0,0 +1,34 @@ +{ + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816", + "System.Collections": "4.0.10", + "System.Collections.NonGeneric": "4.0.1-beta-23302", + "System.Collections.Specialized": "4.0.1-beta-23302", + "System.ComponentModel": "4.0.1-beta-23302", + "System.Console": "4.0.0-beta-23302", + "System.Diagnostics.Process": "4.0.0-beta-23302", + "System.Globalization": "4.0.10", + "System.Globalization.Calendars": "4.0.0", + "System.IO": "4.0.10", + "System.IO.FileSystem": "4.0.0", + "System.IO.FileSystem.Primitives": "4.0.0", + "System.Linq": "4.0.1-beta-23302", + "System.Linq.Queryable": "4.0.1-beta-23302", + "System.Reflection": "4.0.10", + "System.Reflection.Primitives": "4.0.0", + "System.Runtime": "4.0.20", + "System.Runtime.Extensions": "4.0.10", + "System.Runtime.Handles": "4.0.0", + "System.Runtime.InteropServices": "4.0.20", + "System.Runtime.Loader": "4.0.0-beta-23302", + "System.Text.Encoding": "4.0.10", + "System.Threading": "4.0.10", + "System.Xml.ReaderWriter": "4.0.11-beta-23302", + "System.Xml.XDocument": "4.0.11-beta-23302", + "System.Xml.XmlDocument": "4.0.1-beta-23302", + "System.Xml.XmlSerializer": "4.0.11-beta-23302", + }, + "frameworks": { + "dnxcore50": {} + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/v1.0/15266.il b/tests/src/baseservices/exceptions/regressions/v1.0/15266.il new file mode 100644 index 0000000000..8fe4cd5954 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/v1.0/15266.il @@ -0,0 +1,73 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +// rethrow out of finally +// expect throw System.Security.VerificationException + +.assembly extern legacy library mscorlib {} +.assembly extern System.Console +{ + .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) + .ver 4:0:0:0 +} +.assembly b15266 {} +.module b15266.exe + +.class private auto ansi beforefieldinit test + extends [mscorlib]System.Object +{ + .method public static int32 Main() cil managed + { + .entrypoint + + .try + { + call void test::test2() + ldstr "Fail 0" + call void [System.Console]System.Console::WriteLine(string) + + leave FAIL + } + + catch [mscorlib]System.InvalidCastException + { + pop + ldstr "Pass" + call void [System.Console]System.Console::WriteLine(string) + leave PASS + } + catch [mscorlib]System.DivideByZeroException + { + pop + ldstr "Fail 2" + call void [System.Console]System.Console::WriteLine(string) + leave FAIL + } + + +FAIL: + ldc.i4 42 + br END +PASS: + ldc.i4 100 +END: + ret + } + +.method public hidebysig static void test2() cil managed + { + .try + { + newobj instance void [mscorlib]System.DivideByZeroException::.ctor() + throw + } + finally + { + newobj instance void [mscorlib]System.InvalidCastException::.ctor() + throw + } + ret + } + +} diff --git a/tests/src/baseservices/exceptions/regressions/v1.0/15266.ilproj b/tests/src/baseservices/exceptions/regressions/v1.0/15266.ilproj new file mode 100644 index 0000000000..82105917f0 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/v1.0/15266.ilproj @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <AssemblyName>$(MSBuildProjectName)</AssemblyName> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <PropertyGroup> + + </PropertyGroup> + <ItemGroup> + <Compile Include="15266.il" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/v1.0/19896.cs b/tests/src/baseservices/exceptions/regressions/v1.0/19896.cs new file mode 100644 index 0000000000..c6e6e62365 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/v1.0/19896.cs @@ -0,0 +1,34 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +using System; + +public class b19896 +{ + public static int Main(string[] args) + { + int retVal = 200; + + try + { + try + { + throw new Exception(); + } + catch + { + Type.GetType("System.Foo", true); + } + } + + catch(System.TypeLoadException) + { + Console.WriteLine("TEST PASSED"); + retVal = 100; + } + + return retVal; + } +} + +//EOF
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/v1.0/19896.csproj b/tests/src/baseservices/exceptions/regressions/v1.0/19896.csproj new file mode 100644 index 0000000000..21c7115fd9 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/v1.0/19896.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="19896.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/v1.0/app.config b/tests/src/baseservices/exceptions/regressions/v1.0/app.config new file mode 100644 index 0000000000..62803f5972 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/v1.0/app.config @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<configuration> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + </assemblyBinding> + </runtime> +</configuration>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/v1.0/project.json b/tests/src/baseservices/exceptions/regressions/v1.0/project.json new file mode 100644 index 0000000000..1a9690222b --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/v1.0/project.json @@ -0,0 +1,34 @@ +{ + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816", + "System.Collections": "4.0.10", + "System.Collections.NonGeneric": "4.0.1-beta-23302", + "System.Collections.Specialized": "4.0.1-beta-23302", + "System.ComponentModel": "4.0.1-beta-23302", + "System.Console": "4.0.0-beta-23302", + "System.Diagnostics.Process": "4.0.0-beta-23302", + "System.Globalization": "4.0.10", + "System.Globalization.Calendars": "4.0.0", + "System.IO": "4.0.10", + "System.IO.FileSystem": "4.0.0", + "System.IO.FileSystem.Primitives": "4.0.0", + "System.Linq": "4.0.1-beta-23302", + "System.Linq.Queryable": "4.0.1-beta-23302", + "System.Reflection": "4.0.10", + "System.Reflection.Primitives": "4.0.0", + "System.Runtime": "4.0.20", + "System.Runtime.Extensions": "4.0.10", + "System.Runtime.Handles": "4.0.0", + "System.Runtime.InteropServices": "4.0.20", + "System.Runtime.Loader": "4.0.0-beta-23302", + "System.Text.Encoding": "4.0.10", + "System.Threading": "4.0.10", + "System.Xml.ReaderWriter": "4.0.11-beta-23302", + "System.Xml.XDocument": "4.0.11-beta-23302", + "System.Xml.XmlDocument": "4.0.1-beta-23302", + "System.Xml.XmlSerializer": "4.0.11-beta-23302" + }, + "frameworks": { + "dnxcore50": {} + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/v4.0/640474/other.csproj b/tests/src/baseservices/exceptions/regressions/v4.0/640474/other.csproj index 91989b90ff..2a0d112e7a 100644 --- a/tests/src/baseservices/exceptions/regressions/v4.0/640474/other.csproj +++ b/tests/src/baseservices/exceptions/regressions/v4.0/640474/other.csproj @@ -30,7 +30,7 @@ </ItemGroup> <ItemGroup> <!-- Add Compile Object Here --> - <Compile Include="other2.cs" /> + <Compile Include="other1.cs" /> </ItemGroup> <ItemGroup> <None Include="app.config" /> diff --git a/tests/src/baseservices/exceptions/regressions/v4.0/640474/other2.cs b/tests/src/baseservices/exceptions/regressions/v4.0/640474/other1.cs index 15e648da04..3443e1cca3 100644 --- a/tests/src/baseservices/exceptions/regressions/v4.0/640474/other2.cs +++ b/tests/src/baseservices/exceptions/regressions/v4.0/640474/other1.cs @@ -1,11 +1,9 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. + using System; -#pragma warning disable 0169 -class Other { - static int field; +public class Other { + public static int field; } - -#pragma warning restore 0169 diff --git a/tests/src/baseservices/exceptions/regressions/v4.0/640474/test640474.cs b/tests/src/baseservices/exceptions/regressions/v4.0/640474/test640474.cs new file mode 100644 index 0000000000..90a558d7de --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/v4.0/640474/test640474.cs @@ -0,0 +1,63 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Runtime.CompilerServices; +using System.Reflection; + +public class My +{ + + static void bar() + { + Other.field = 123; + } + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + static void foo(bool f) + { + if (f) + bar(); + } + + public static void Worker() + { + try + { + throw new Exception("Hello world"); + } + finally + { + foo(false); + } + } + + public static int Main() + { + try + { + typeof(My).GetMethod("Worker").Invoke(null, null); + + Console.WriteLine("FAILED: No exception thrown."); + return 102; + } + catch (TargetInvocationException e) + { + Exception inner = e.GetBaseException(); + Console.WriteLine(inner); + + if (inner.Message == "Hello world") + { + Console.WriteLine("PASSED: Caught expected exception"); + return 100; + } + else + { + Console.WriteLine("FAILED: Wrong exception thrown. Expected: Exception with message 'Hello world'. Actual: " + inner.Message); + return 101; + } + } + } + +} diff --git a/tests/src/baseservices/exceptions/regressions/v4.0/640474/test640474.csproj b/tests/src/baseservices/exceptions/regressions/v4.0/640474/test640474.csproj new file mode 100644 index 0000000000..ddaf5144d1 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/v4.0/640474/test640474.csproj @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="test640474.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + <ProjectReference Include="other.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/whidbeyM3.2/151232.cs b/tests/src/baseservices/exceptions/regressions/whidbeyM3.2/151232.cs new file mode 100644 index 0000000000..8daf378d51 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/whidbeyM3.2/151232.cs @@ -0,0 +1,47 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +using System; + +public class E<T> : Exception { + T fld; + public E(T x) { fld = x; } + public T Get() { return fld; } + public void Show() { Console.WriteLine("E<" + typeof(T) + ">(" + fld + ")"); } +} + + +public class D { + // Fifth test: polymorphic catch in shared code in a generic method + public static int Test5<T>(bool str,int x) { + if (x < 100) + if (str) throw new E<string>(x.ToString()); + else throw new E<object>(x.ToString()); + else + try { + Test5<T>(str,x-7); + } + catch (E<T> ei) { ei.Show(); } + catch (Exception e) { + Console.WriteLine("Not caught: "+e.GetType().ToString()); + return -1; + } + return 100; + } + +} + +public class M { + public static int Main() { + M test = new M(); + return test.Run(); + } + public int Run(){ + int val = D.Test5<string>(true,129); + if (val == 100) + val = D.Test5<object>(false,128); + else + D.Test5<object>(false,128); + return val; + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/whidbeyM3.2/151232.csproj b/tests/src/baseservices/exceptions/regressions/whidbeyM3.2/151232.csproj new file mode 100644 index 0000000000..97387964b5 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/whidbeyM3.2/151232.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="151232.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/whidbeyM3.2/app.config b/tests/src/baseservices/exceptions/regressions/whidbeyM3.2/app.config new file mode 100644 index 0000000000..62803f5972 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/whidbeyM3.2/app.config @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<configuration> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.20.0" newVersion="4.0.20.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Text.Encoding" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.IO" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + <dependentAssembly> + <assemblyIdentity name="System.Reflection" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-4.0.10.0" newVersion="4.0.10.0" /> + </dependentAssembly> + </assemblyBinding> + </runtime> +</configuration>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/regressions/whidbeyM3.2/project.json b/tests/src/baseservices/exceptions/regressions/whidbeyM3.2/project.json new file mode 100644 index 0000000000..1a9690222b --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/whidbeyM3.2/project.json @@ -0,0 +1,34 @@ +{ + "dependencies": { + "Microsoft.NETCore.Platforms": "1.0.1-rc2-23816", + "System.Collections": "4.0.10", + "System.Collections.NonGeneric": "4.0.1-beta-23302", + "System.Collections.Specialized": "4.0.1-beta-23302", + "System.ComponentModel": "4.0.1-beta-23302", + "System.Console": "4.0.0-beta-23302", + "System.Diagnostics.Process": "4.0.0-beta-23302", + "System.Globalization": "4.0.10", + "System.Globalization.Calendars": "4.0.0", + "System.IO": "4.0.10", + "System.IO.FileSystem": "4.0.0", + "System.IO.FileSystem.Primitives": "4.0.0", + "System.Linq": "4.0.1-beta-23302", + "System.Linq.Queryable": "4.0.1-beta-23302", + "System.Reflection": "4.0.10", + "System.Reflection.Primitives": "4.0.0", + "System.Runtime": "4.0.20", + "System.Runtime.Extensions": "4.0.10", + "System.Runtime.Handles": "4.0.0", + "System.Runtime.InteropServices": "4.0.20", + "System.Runtime.Loader": "4.0.0-beta-23302", + "System.Text.Encoding": "4.0.10", + "System.Threading": "4.0.10", + "System.Xml.ReaderWriter": "4.0.11-beta-23302", + "System.Xml.XDocument": "4.0.11-beta-23302", + "System.Xml.XmlDocument": "4.0.1-beta-23302", + "System.Xml.XmlSerializer": "4.0.11-beta-23302" + }, + "frameworks": { + "dnxcore50": {} + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/simple/ArrayInit.cs b/tests/src/baseservices/exceptions/simple/ArrayInit.cs new file mode 100644 index 0000000000..3871962560 --- /dev/null +++ b/tests/src/baseservices/exceptions/simple/ArrayInit.cs @@ -0,0 +1,72 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +using System; +using TestLibrary; + +public class ArrayInit { + + public static int Main(string[] args) + { + + ArrayInit ai = new ArrayInit(); + TestFramework.BeginTestCase("Exception thrown in default ctor of a valuetype during Array.Initialize"); + if (ai.RunTests()) + return 100; + else + return 0; + } + + public bool RunTests() + { + bool retVal = true; + retVal &= PosTest1(); + retVal &= PosTest2(); + TestFramework.LogInformation(retVal ? "PASS" : "FAIL"); + return retVal; + } + + public bool PosTest1() + { + TestFramework.BeginScenario("PosTest1: Initialize on vector of value-type, where default ctor throws"); + bool retVal = true; + try + { + VT[] vecVT = new VT[5]; + vecVT.Initialize(); + TestFramework.LogError("001", "Expected exception to be thrown from Initialize"); + retVal = false; + } + catch (NotSupportedException) + { + } + catch (Exception e) + { + TestFramework.LogError("002", "Unexpected exception: " + e.ToString()); + retVal = false; + } + return retVal; + } + + public bool PosTest2() + { + TestFramework.BeginScenario("PosTest2: Initialize on multi-dimensional array of value-type, where default ctor throws"); + bool retVal = true; + try + { + VT[,] arrVT = new VT[5,10]; + arrVT.Initialize(); + TestFramework.LogError("001", "Expected exception to be thrown from Initialize"); + retVal = false; + } + catch (NotSupportedException) + { + } + catch (Exception e) + { + TestFramework.LogError("002", "Unexpected exception: " + e.ToString()); + retVal = false; + } + return retVal; + } +}
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/simple/ArrayInit.csproj b/tests/src/baseservices/exceptions/simple/ArrayInit.csproj new file mode 100644 index 0000000000..7f25b76f76 --- /dev/null +++ b/tests/src/baseservices/exceptions/simple/ArrayInit.csproj @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="ArrayInit.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="VT.ilproj" /> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/simple/HardwareEh.cs b/tests/src/baseservices/exceptions/simple/HardwareEh.cs new file mode 100644 index 0000000000..216c4697cc --- /dev/null +++ b/tests/src/baseservices/exceptions/simple/HardwareEh.cs @@ -0,0 +1,331 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// DataMisalignment +// NullRef (generic, nullable, object) +// Divide by zero (integral) +// Overflow (integral) +// Stack overflow +// OOM + +// Array out of bounds (single, multi, jagged) +// Array null ref (single, multi, jagged) + +public class HardwareEh +{ + public const long c_VALUE = 34252; + public delegate bool TestDelegate(); + + public static int Main() + { + HardwareEh e = new HardwareEh(); + + TestLibrary.TestFramework.BeginTestCase("Hardware exceptions: handled"); + + if (e.RunTests()) + { + TestLibrary.TestFramework.EndTestCase(); + TestLibrary.TestFramework.LogInformation("PASS"); + return 100; + } + else + { + TestLibrary.TestFramework.EndTestCase(); + TestLibrary.TestFramework.LogInformation("FAIL"); + return 0; + } + } + + public bool RunTests() + { + bool retVal = true; + + TestLibrary.TestFramework.LogInformation("[Postive]"); + retVal = PosTest1() && retVal; + retVal = PosTest2() && retVal; + retVal = PosTest3() && retVal; + retVal = PosTest4() && retVal; + retVal = PosTest5() && retVal; + retVal = PosTest6() && retVal; + retVal = PosTest7() && retVal; + retVal = PosTest8() && retVal; + retVal = PosTest9() && retVal; +// The current stack overflow behavior is to rip the process +// retVal = PosTest10() && retVal; + retVal = PosTest11() && retVal; + retVal = PosTest12() && retVal; + retVal = PosTest13() && retVal; + retVal = PosTest14() && retVal; + retVal = PosTest15() && retVal; + retVal = PosTest16() && retVal; + retVal = PosTest17() && retVal; + retVal = PosTest18() && retVal; + retVal = PosTest19() && retVal; + retVal = PosTest20() && retVal; + + return retVal; + } + + public bool PosTest1() { return DataMisalign(1, false); } + public bool PosTest2() { return DataMisalign(2, true); } + public bool PosTest3() { return ExceptionTest(3, "NullReference", typeof(NullReferenceException), + delegate() + { + object o = null; + o.ToString(); + return true; + } ); } + public bool PosTest4() { return ExceptionTest(4, "NullReference (generic)", typeof(NullReferenceException), + delegate() + { + List<int> l = null; + l.ToString(); + return true; + } ); } + public bool PosTest5() { return ExceptionTest(5, "NullReference (nullable)", typeof(InvalidOperationException), + delegate() + { + int? i = null; + i.Value.ToString(); + return true; + } ); } + public bool PosTest6() { return ExceptionTest(6, "DivideByZero (int64)", typeof(DivideByZeroException), + delegate() + { + Int64 i = 10; + Int64 j = 0; + Int64 k = i / j; + return true; + } ); } + public bool PosTest7() { return ExceptionTest(7, "DivideByZero (int32)", typeof(DivideByZeroException), + delegate() + { + Int32 i = 10; + Int32 j = 0; + Int32 k = i / j; + return true; + } ); } + public bool PosTest8() { return ExceptionTest(8, "OverflowException (int64)", typeof(OverflowException), new TestDelegate(ILHelper.Int64Overflow) ); } + public bool PosTest9() { return ExceptionTest(9, "OverflowException (int32)", typeof(OverflowException), new TestDelegate(ILHelper.Int32Overflow) ); } +// public bool PosTest10() { return ExceptionTest(10, "StackOverflow", typeof(StackOverflowException), new TestDelegate( GobbleStack )); } + public bool PosTest11() { return ExceptionTest(11, "OutOfMemory", typeof(OutOfMemoryException), + delegate() + { + List<object> list; + list = new List<object>(); + while(true) + { + // allocate memory (86 meg chunks) + list.Add( new byte[8388608]); + } + } ); } + public bool PosTest12() { return ExceptionTest(12, "IndexOutOfRange (single dim [less than])", typeof(IndexOutOfRangeException), + delegate() + { + int[] arr = new int[10]; + int index = -1; + arr[index] = 0; + return true; + } ); } + public bool PosTest13() { return ExceptionTest(13, "IndexOutOfRange (single dim [greater than])", typeof(IndexOutOfRangeException), + delegate() + { + int[] arr = new int[10]; + int index = 11; + arr[index] = 0; + return true; + } ); } + public bool PosTest14() { return ExceptionTest(14, "IndexOutOfRange (multi dim [less than])", typeof(IndexOutOfRangeException), + delegate() + { + int[,] arr = new int[10,10]; + int index = -1; + arr[0,index] = 0; + return true; + } ); } + public bool PosTest15() { return ExceptionTest(15, "IndexOutOfRange (multi dim [greater than])", typeof(IndexOutOfRangeException), + delegate() + { + int[,] arr = new int[10,10]; + int index = 11; + arr[index,0] = 0; + return true; + } ); } + public bool PosTest16() { return ExceptionTest(16, "IndexOutOfRange (jagged [less than])", typeof(IndexOutOfRangeException), + delegate() + { + int[][] arr = new int[10][]; + int index = -1; + arr[0] = new int[10]; + arr[0][index] = 0; + return true; + } ); } + public bool PosTest17() { return ExceptionTest(17, "IndexOutOfRange (jagged [greater than])", typeof(IndexOutOfRangeException), + delegate() + { + int[][] arr = new int[10][]; + int index = 11; + arr[index] = new int[10]; + return true; + } ); } + public bool PosTest18() { return ExceptionTest(18, "NullReference (single dim)", typeof(NullReferenceException), + delegate() + { + int[] arr = null; + int index = 2; + arr[index] = 0; + return true; + } ); } + public bool PosTest19() { return ExceptionTest(19, "NullReference (multi dim)", typeof(NullReferenceException), + delegate() + { + int[,] arr = null; + int index = 2; + arr[index,0] = 0; + return true; + } ); } + public bool PosTest20() { return ExceptionTest(20, "NullReference (jagged)", typeof(NullReferenceException), + delegate() + { + int[][] arr = new int[10][]; + int index = 2; + arr[index][0] = 0; + return true; + } ); } + + public bool DataMisalign(int id, bool getter) + { + bool retVal = true; + long misAlignedField = 0; + MyStruct m; + + TestLibrary.TestFramework.BeginScenario("PosTest"+id+": "+ (getter?"Get":"Set") +" misaligned field expect DataMisalignment Exception (IA64 only)"); + + try + { + m = new MyStruct(); + + if (getter) + { + misAlignedField = m.MisalignedField; + } + else + { + m.MisalignedField = c_VALUE; + } + + if (IsIA64()) + { + TestLibrary.TestFramework.LogError("002", "DataMisalignedException expected"); + retVal = false; + } + + // need to get it to validate that it is right + if (!getter) misAlignedField = m.MisalignedField; + + if (c_VALUE != misAlignedField) + { + TestLibrary.TestFramework.LogError("001", "Incorrect value: Expected("+c_VALUE+") Actual("+misAlignedField+")"); + retVal = false; + } + } + catch (DataMisalignedException e) + { + // expected on IA64 + if (IsIA64()) + { + TestLibrary.TestFramework.LogInformation("Catch DataMisalignedException as expected"); + } + else + { + TestLibrary.TestFramework.LogError("003", "Unexpected exception: " + e); + retVal = false; + } + } + catch (Exception e) + { + TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e); + retVal = false; + } + + return retVal; + } + + public bool ExceptionTest(int id, string msg, Type ehType, TestDelegate d) + { + bool retVal = true; + + TestLibrary.TestFramework.BeginScenario("PosTest"+id+": " + msg); + + try + { + retVal = d(); + + TestLibrary.TestFramework.LogError("10" + id, "Function should have thrown: " + ehType); + retVal = false; + } + catch (Exception e) + { + if (ehType != e.GetType()) + { + TestLibrary.TestFramework.LogError("004", "Unexpected exception: " + e); + retVal = false; + } + } + + return retVal; + } + + public bool IsIA64() + { + return false; + } + + public volatile static int volatileReadWrite = 0; + + [MethodImpl(MethodImplOptions.NoInlining)] + public static bool GobbleStack() + { + #pragma warning disable 0168 + MyStruct s1; + MyStruct s2; + #pragma warning restore 0168 + + return GobbleStack(); + + #pragma warning disable 0162 + // avoid tail call optimizations + volatileReadWrite++; + #pragma warning restore 0162 + } +} + +[StructLayout(LayoutKind.Explicit)] +public class MyStruct +{ + [FieldOffset(1)] + public long MisalignedField = HardwareEh.c_VALUE; +} + +#pragma warning disable 0169 +public struct MyLargeStruct +{ + long l0,l1,l2,l3,l4,l5,l6,l7,l8,l9; + long l10,l11,l12,l13,l14,l15,l16,l17,l18,l19; + long l20,l21,l22,l23,l24,l25,l26,l27,l28,l29; + long l30,l31,l32,l33,l34,l35,l36,l37,l38,l39; + long l40,l41,l42,l43,l44,l45,l46,l47,l48,l49; + double d0,d1,d2,d3,d4,d5,d6,d7,d8,d9; + double d10,d11,d12,d13,d14,d15,d16,d17,d18,d19; + double d20,d21,d22,d23,d24,d25,d26,d27,d28,d29; + double d30,d31,d32,d33,d34,d35,d36,d37,d38,d39; + double d40,d41,d42,d43,d44,d45,d46,d47,d48,d49; +} +#pragma warning restore 0169 diff --git a/tests/src/baseservices/exceptions/simple/HardwareEh.csproj b/tests/src/baseservices/exceptions/simple/HardwareEh.csproj new file mode 100644 index 0000000000..9248446e56 --- /dev/null +++ b/tests/src/baseservices/exceptions/simple/HardwareEh.csproj @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="HardwareEh.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + <ProjectReference Include="ILHelper.ilproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/simple/ILHelper.cs b/tests/src/baseservices/exceptions/simple/ILHelper.cs new file mode 100644 index 0000000000..c243f7dd06 --- /dev/null +++ b/tests/src/baseservices/exceptions/simple/ILHelper.cs @@ -0,0 +1,23 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +public class ILHelper +{ + public static bool Int32Overflow() + { + int i = Int32.MaxValue; + int j = 2; + int k = i + j; + return true; + } + public static bool Int64Overflow() + { + Int64 i = Int64.MaxValue; + Int64 j = 2; + Int64 k = i * j; + return true; + } +} diff --git a/tests/src/baseservices/exceptions/simple/ILHelper.il b/tests/src/baseservices/exceptions/simple/ILHelper.il new file mode 100644 index 0000000000..58752bad24 --- /dev/null +++ b/tests/src/baseservices/exceptions/simple/ILHelper.il @@ -0,0 +1,57 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +.assembly extern mscorlib {} +.assembly ILHelper {} +.module ILHelper.dll + +.class public auto ansi beforefieldinit ILHelper + extends [mscorlib]System.Object +{ + .method public hidebysig static bool Int32Overflow() cil managed + { + .locals init (int32 V_0, + int32 V_1, + int32 V_2) + ldc.i4 0x7fffffff + stloc.0 + ldc.i4.2 + stloc.1 + ldloc.0 + ldloc.1 + // changed to include .ovf + add.ovf + stloc.2 + ldc.i4.1 + ret + } + + .method public hidebysig static bool Int64Overflow() cil managed + { + .locals init (int64 V_0, + int64 V_1, + int64 V_2) + ldc.i8 0x7fffffffffffffff + stloc.0 + ldc.i4.2 + conv.i8 + stloc.1 + ldloc.0 + ldloc.1 + // changed to include .ovf + mul.ovf + stloc.2 + ldc.i4.1 + ret + } + + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + ldarg.0 + call instance void [mscorlib]System.Object::.ctor() + ret + } + +} diff --git a/tests/src/baseservices/exceptions/simple/ILHelper.ilproj b/tests/src/baseservices/exceptions/simple/ILHelper.ilproj new file mode 100644 index 0000000000..3cd6862808 --- /dev/null +++ b/tests/src/baseservices/exceptions/simple/ILHelper.ilproj @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <AssemblyName>$(MSBuildProjectName)</AssemblyName> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <CLRTestKind>SharedLibrary</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <PropertyGroup> + + </PropertyGroup> + <ItemGroup> + <Compile Include="ILHelper.il" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/simple/VT.il b/tests/src/baseservices/exceptions/simple/VT.il new file mode 100644 index 0000000000..0c2c8d6800 --- /dev/null +++ b/tests/src/baseservices/exceptions/simple/VT.il @@ -0,0 +1,67 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +// Microsoft (R) .NET Framework IL Disassembler. Version 2.0.50727.42 +// Copyright (c) Microsoft Corporation. All rights reserved. + + + +// Metadata version: v2.0.50727 +.assembly extern mscorlib +{ + .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. + .ver 2:0:0:0 +} +.assembly VT +{ + .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 ) + .custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx + 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. + .hash algorithm 0x00008004 + .ver 0:0:0:0 +} +.module VT.dll +// MVID: {54DC34D8-2D7D-429C-93F5-6A77ED223377} +.imagebase 0x00400000 +.file alignment 0x00000200 +.stackreserve 0x00100000 +.subsystem 0x0003 // WINDOWS_CUI +.corflags 0x00000001 // ILONLY +// Image base: 0x00E60000 + + +// =============== CLASS MEMBERS DECLARATION =================== + +.class public sequential ansi sealed beforefieldinit VT + extends [mscorlib]System.ValueType +{ + .field public int32 x + .field public float64 y + .field public string z + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 35 (0x23) + .maxstack 8 + IL_0000: nop + IL_0001: ldarg.0 + IL_0002: ldc.i4.2 + IL_0003: stfld int32 VT::x + IL_0008: ldarg.0 + IL_0009: ldc.r8 3.1400000000000001 + IL_0012: stfld float64 VT::y + IL_0017: ldarg.0 + IL_0018: ldstr "England expects that every man will do his duty." + IL_001d: stfld string VT::z + IL_0022: newobj instance void [mscorlib]System.NotSupportedException::.ctor() + IL_0027: throw + } // end of method VT::.ctor + +} // end of class VT + + +// ============================================================= + +// *********** DISASSEMBLY COMPLETE *********************** +// WARNING: Created Win32 resource file VT.res diff --git a/tests/src/baseservices/exceptions/simple/VT.ilproj b/tests/src/baseservices/exceptions/simple/VT.ilproj new file mode 100644 index 0000000000..9bd482e0a8 --- /dev/null +++ b/tests/src/baseservices/exceptions/simple/VT.ilproj @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <AssemblyName>$(MSBuildProjectName)</AssemblyName> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <CLRTestKind>SharedLibrary</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <PropertyGroup> + + </PropertyGroup> + <ItemGroup> + <Compile Include="VT.il" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/simple/fault.il b/tests/src/baseservices/exceptions/simple/fault.il index 98bbb10786..7938f1c3d2 100644 --- a/tests/src/baseservices/exceptions/simple/fault.il +++ b/tests/src/baseservices/exceptions/simple/fault.il @@ -1,10 +1,14 @@ -.assembly extern mscorlib +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +.assembly extern legacy library mscorlib {} +.assembly extern System.Console { - .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) - .ver 2:0:0:0 + .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) + .ver 4:0:0:0 } - .assembly 'fault' {} .class auto ansi Fault @@ -24,7 +28,7 @@ fault_begin: ldstr "in fault block." - call void [mscorlib]System.Console::WriteLine(class [mscorlib]System.String) + call void [System.Console]System.Console::WriteLine(class [mscorlib]System.String) ldloc.0 ldc.i4 1 sub @@ -34,7 +38,7 @@ filter_begin: pop ldstr "in filter." - call void [mscorlib]System.Console::WriteLine(class [mscorlib]System.String) + call void [System.Console]System.Console::WriteLine(class [mscorlib]System.String) ldloc.0 ldc.i4 1 sub @@ -46,10 +50,10 @@ call void [mscorlib]System.GC::Collect() castclass [mscorlib]System.Exception callvirt instance class [mscorlib]System.String [mscorlib]System.Exception::get_Message() - call void [mscorlib]System.Console::WriteLine(class [mscorlib]System.String) + call void [System.Console]System.Console::WriteLine(class [mscorlib]System.String) ldstr "in except block." - call void [mscorlib]System.Console::WriteLine(class [mscorlib]System.String) + call void [System.Console]System.Console::WriteLine(class [mscorlib]System.String) ldloc.0 ldc.i4 1 sub @@ -62,13 +66,13 @@ bne.un.s FAIL ldstr "test passed." - call void [mscorlib]System.Console::WriteLine(class [mscorlib]System.String) + call void [System.Console]System.Console::WriteLine(class [mscorlib]System.String) ldc.i4 0x64 ret FAIL: ldstr "test failed." - call void [mscorlib]System.Console::WriteLine(class [mscorlib]System.String) + call void [System.Console]System.Console::WriteLine(class [mscorlib]System.String) ldloc.0 ret diff --git a/tests/src/baseservices/exceptions/simple/fault.ilproj b/tests/src/baseservices/exceptions/simple/fault.ilproj new file mode 100644 index 0000000000..380a876c96 --- /dev/null +++ b/tests/src/baseservices/exceptions/simple/fault.ilproj @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <AssemblyName>$(MSBuildProjectName)</AssemblyName> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <PropertyGroup> + + </PropertyGroup> + <ItemGroup> + <Compile Include="fault.il" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/simple/finally.csproj b/tests/src/baseservices/exceptions/simple/finally.csproj index 8803b46593..25d416a03d 100644 --- a/tests/src/baseservices/exceptions/simple/finally.csproj +++ b/tests/src/baseservices/exceptions/simple/finally.csproj @@ -41,7 +41,6 @@ </ItemGroup> <ItemGroup> <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> - <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> </ItemGroup> <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> diff --git a/tests/src/baseservices/exceptions/unittests/Baadbaad.cs b/tests/src/baseservices/exceptions/unittests/Baadbaad.cs new file mode 100644 index 0000000000..5fa72012d9 --- /dev/null +++ b/tests/src/baseservices/exceptions/unittests/Baadbaad.cs @@ -0,0 +1,95 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.IO; + +// +// main +// + +public class TestSet +{ + static void CountResults(int testReturnValue, ref int nSuccesses, ref int nFailures) + { + if (100 == testReturnValue) + { + nSuccesses++; + } + else + { + nFailures++; + } + } + + public static int Main() + { + int nSuccesses = 0; + int nFailures = 0; + + CountResults(new BaadbaadTest().Run(), ref nSuccesses, ref nFailures); + + if (0 == nFailures) + { + Console.WriteLine("OVERALL PASS: " + nSuccesses + " tests"); + return 100; + } + else + { + Console.WriteLine("OVERALL FAIL: " + nFailures + " tests failed"); + return 999; + } + } +} + +public class BaadbaadTest +{ + Trace _trace; + public int Run() + { + _trace = new Trace("BaadbaadTest", "1234"); + try + { + DoStuff(); + } + catch (Exception e) + { + Console.WriteLine(e); + _trace.Write("4"); + } + return _trace.Match(); + } + void DoStuff() + { + try + { + try + { + try + { + throw new Exception(); + } + catch (Exception e) + { + Console.WriteLine(e); + _trace.Write("1"); + throw; + } + } + catch (Exception e) + { + Console.WriteLine(e); + _trace.Write("2"); + throw; + } + } + catch (Exception e) + { + Console.WriteLine(e); + _trace.Write("3"); + throw; + } + } +} + diff --git a/tests/src/baseservices/exceptions/unittests/Baadbaad.csproj b/tests/src/baseservices/exceptions/unittests/Baadbaad.csproj new file mode 100644 index 0000000000..c8953ee02c --- /dev/null +++ b/tests/src/baseservices/exceptions/unittests/Baadbaad.csproj @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="baadbaad.cs" /> + <Compile Include="trace.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/unittests/CollidedUnwind.cs b/tests/src/baseservices/exceptions/unittests/CollidedUnwind.cs new file mode 100644 index 0000000000..ea421ae79f --- /dev/null +++ b/tests/src/baseservices/exceptions/unittests/CollidedUnwind.cs @@ -0,0 +1,165 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.IO; + +public class TestSet +{ + static void CountResults(int testReturnValue, ref int nSuccesses, ref int nFailures) + { + if (100 == testReturnValue) + { + nSuccesses++; + } + else + { + nFailures++; + } + } + + public static int Main() + { + int nSuccesses = 0; + int nFailures = 0; + + CountResults(new CollidedUnwindTest().Run(), ref nSuccesses, ref nFailures); + + if (0 == nFailures) + { + Console.WriteLine("OVERALL PASS: " + nSuccesses + " tests"); + return 100; + } + else + { + Console.WriteLine("OVERALL FAIL: " + nFailures + " tests failed"); + return 999; + } + } +} + +public class CollidedUnwindTest +{ + class ExType1 : Exception + { + } + + class ExType2 : Exception + { + } + + Trace _trace; + + public int Run() + { + _trace = new Trace("CollidedUnwindTest", "0123456789ABCDE"); + + try + { + _trace.Write("0"); + Foo(); + } + catch (ExType2 e) + { + Console.WriteLine(e); + _trace.Write("E"); + } + + return _trace.Match(); + } + + void Foo() + { + try + { + _trace.Write("1"); + FnAAA(); + } + catch (ExType1 e) + { + Console.WriteLine(e); + _trace.Write(" BAD "); + } + } + + void FnAAA() + { + try + { + _trace.Write("2"); + FnBBB(); + } + finally + { + _trace.Write("D"); + } + } + + void FnBBB() + { + try + { + _trace.Write("3"); + Bar(); + } + finally + { + _trace.Write("C"); + } + } + + void Bar() + { + try + { + _trace.Write("4"); + FnCCC(); + } + finally + { + _trace.Write("B"); + throw new ExType2(); + } + } + + void FnCCC() + { + try + { + _trace.Write("5"); + FnDDD(); + } + finally + { + _trace.Write("A"); + } + } + + void FnDDD() + { + try + { + _trace.Write("6"); + Fubar(); + } + finally + { + _trace.Write("9"); + } + } + + void Fubar() + { + try + { + _trace.Write("7"); + throw new ExType1(); + } + finally + { + _trace.Write("8"); + } + } +} + diff --git a/tests/src/baseservices/exceptions/unittests/CollidedUnwind.csproj b/tests/src/baseservices/exceptions/unittests/CollidedUnwind.csproj new file mode 100644 index 0000000000..6f4a6ed07b --- /dev/null +++ b/tests/src/baseservices/exceptions/unittests/CollidedUnwind.csproj @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="CollidedUnwind.cs" /> + <Compile Include="trace.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/unittests/EHPatternTests.cs b/tests/src/baseservices/exceptions/unittests/EHPatternTests.cs new file mode 100644 index 0000000000..93c44d7cc0 --- /dev/null +++ b/tests/src/baseservices/exceptions/unittests/EHPatternTests.cs @@ -0,0 +1,1434 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.IO; + +// +// infrastructure +// +public class Trace +{ + public Trace(string tag, string expected) + { + Console.WriteLine("-----------------------------"); + Console.WriteLine(tag); + Console.WriteLine("-----------------------------"); + _expected = expected; + } + + public void Write(string str) + { + _actual += str; + // Console.Write(str); + } + + public void WriteLine(string str) + { + _actual += str; + _actual += "\r\n"; + + // Console.WriteLine(str); + } + + public int Match() + { + // Console.WriteLine(""); + Console.Write(_expected); + if (_actual.Equals(_expected)) + { + Console.WriteLine(": PASS"); + return 100; + } + else + { + Console.WriteLine(": FAIL: _actual='" + _actual + "'"); + Console.WriteLine("_expected='" + _expected + "'"); + return 999; + } + } + + string _actual; + string _expected; +} + +// +// main +// + +public class TestSet +{ + static void CountResults(int testReturnValue, ref int nSuccesses, ref int nFailures) + { + if (100 == testReturnValue) + { + nSuccesses++; + } + else + { + nFailures++; + } + } + + public static int Main() + { + int nSuccesses = 0; + int nFailures = 0; + + // @TODO: SDM: // CountResults(new StackOverflowInLeafFunction().Run(), ref nSuccesses, ref nFailures); + + CountResults(new BaseClassTest().Run(), ref nSuccesses, ref nFailures); + CountResults(new TryCatchInFinallyTest().Run(), ref nSuccesses, ref nFailures); + CountResults(new RecurseTest().Run(), ref nSuccesses, ref nFailures); + CountResults(new ThrowInFinallyNestedInTryTest().Run(), ref nSuccesses, ref nFailures); // FAIL: needs skip to parent code <TODO> investigate </TODO> + CountResults(new GoryManagedPresentTest().Run(), ref nSuccesses, ref nFailures); // FAIL: needs skip to parent code <TODO> investigate </TODO> + CountResults(new InnerFinallyAndCatchTest().Run(), ref nSuccesses, ref nFailures); + CountResults(new InnerFinallyTest().Run(), ref nSuccesses, ref nFailures); + CountResults(new ThrowInFinallyTest().Run(), ref nSuccesses, ref nFailures); + CountResults(new RecursiveRethrow().Run(), ref nSuccesses, ref nFailures); + CountResults(new RecursiveThrowNew().Run(), ref nSuccesses, ref nFailures); + CountResults(new PendingTest().Run(), ref nSuccesses, ref nFailures); + CountResults(new CollidedUnwindTest().Run(), ref nSuccesses, ref nFailures); + CountResults(new BaadbaadTest().Run(), ref nSuccesses, ref nFailures); + CountResults(new GoryNativePastTest().Run(), ref nSuccesses, ref nFailures); + CountResults(new ThrowInCatchTest().Run(), ref nSuccesses, ref nFailures); + CountResults(new StrSwitchFinalTest().Run(), ref nSuccesses, ref nFailures); + CountResults(new RethrowAndFinallysTest().Run(), ref nSuccesses, ref nFailures); + + if (0 == nFailures) + { + Console.WriteLine("OVERALL PASS: " + nSuccesses + " tests"); + return 100; + } + else + { + Console.WriteLine("OVERALL FAIL: " + nFailures + " tests failed"); + return 999; + } + } +} + +// +// tests +// + +public class RecursiveRethrow +{ + Trace _trace; + + public int Run() + { + _trace = new Trace("RecursiveRethrow", "210C0C1C2"); + + try + { + LoveToRecurse(2); + } + catch (Exception e) + { + Console.WriteLine(e); + } + + return _trace.Match(); + } + + + void SeparatorMethod(int i) + { + LoveToRecurse(i); + } + + void LoveToRecurse(int i) + { + try + { + _trace.Write(i.ToString()); + if (0 == i) + { + throw new Exception("RecursionIsFun"); + } + else + { + SeparatorMethod(i - 1); + } + } + catch (Exception e) + { + _trace.Write("C" + i.ToString()); + Console.WriteLine(e); + throw e; + } + } +} + +public class RecursiveThrowNew +{ + Trace _trace; + + public int Run() + { + _trace = new Trace("RecursiveThrowNew", "210C0(eX)C1(e0)C2(e1)CM(e2)"); + + try + { + LoveToRecurse(2); + } + catch (Exception e) + { + _trace.Write("CM(" + e.Message + ")"); + Console.WriteLine(e); + } + + return _trace.Match(); + } + + + void SeparatorMethod(int i) + { + LoveToRecurse(i); + } + + void LoveToRecurse(int i) + { + try + { + _trace.Write(i.ToString()); + if (0 == i) + { + throw new Exception("eX"); + } + else + { + SeparatorMethod(i - 1); + } + } + catch (Exception e) + { + _trace.Write("C" + i.ToString() + "(" + e.Message + ")"); + Console.WriteLine(e); + throw new Exception("e" + i.ToString()); + } + } +} + + +public class BaadbaadTest +{ + Trace _trace; + + public int Run() + { + _trace = new Trace("BaadbaadTest", "1234"); + + try + { + DoStuff(); + } + catch(Exception e) + { + Console.WriteLine(e); + _trace.Write("4"); + } + return _trace.Match(); + } + + void DoStuff() + { + try + { + try + { + try + { + throw new Exception(); + } + catch(Exception e) + { + Console.WriteLine(e); + _trace.Write("1"); + throw; + } + } + catch(Exception e) + { + Console.WriteLine(e); + _trace.Write("2"); + throw; + } + } + catch(Exception e) + { + Console.WriteLine(e); + _trace.Write("3"); + throw; + } + } +} + + +class BaseClassTest +{ + Trace _trace; + + void f2() + { + throw new FileNotFoundException("1"); + } + + void f1() + { + try + { + f2(); + } + catch(FileNotFoundException e) + { + Console.WriteLine(e); + _trace.Write("0" + e.Message); + throw e; + } + catch(IOException e) + { + Console.WriteLine(e); + _trace.Write("!" + e.Message); + throw e; + } + catch(Exception e) + { + Console.WriteLine(e); + _trace.Write("@" + e.Message); + throw e; + } + } + + public int Run() + { + _trace = new Trace("BaseClassTest", "0121"); + + try + { + f1(); + } + catch(Exception e) + { + Console.WriteLine(e); + _trace.Write("2" + e.Message); + } + + return _trace.Match(); + } +} + + + +public class CollidedUnwindTest +{ + class ExType1 : Exception + { + } + + class ExType2 : Exception + { + } + + Trace _trace; + + public int Run() + { + _trace = new Trace("CollidedUnwindTest", "0123456789ABCDE"); + + try + { + _trace.Write("0"); + Foo(); + } + catch (ExType2 e) + { + Console.WriteLine(e); + _trace.Write("E"); + } + + return _trace.Match(); + } + + void Foo() + { + try + { + _trace.Write("1"); + FnAAA(); + } + catch (ExType1 e) + { + Console.WriteLine(e); + _trace.Write(" BAD "); + } + } + + void FnAAA() + { + try + { + _trace.Write("2"); + FnBBB(); + } + finally + { + _trace.Write("D"); + } + } + + void FnBBB() + { + try + { + _trace.Write("3"); + Bar(); + } + finally + { + _trace.Write("C"); + } + } + + void Bar() + { + try + { + _trace.Write("4"); + FnCCC(); + } + finally + { + _trace.Write("B"); + throw new ExType2(); + } + } + + void FnCCC() + { + try + { + _trace.Write("5"); + FnDDD(); + } + finally + { + _trace.Write("A"); + } + } + + void FnDDD() + { + try + { + _trace.Write("6"); + Fubar(); + } + finally + { + _trace.Write("9"); + } + } + + void Fubar() + { + try + { + _trace.Write("7"); + throw new ExType1(); + } + finally + { + _trace.Write("8"); + } + } +} + +public class ThrowInFinallyNestedInTryTest +{ + Trace _trace; + + void MiddleMethod() + { + _trace.Write("2"); + try + { + _trace.Write("3"); + try + { + _trace.Write("4"); + } + finally + { + _trace.Write("5"); + try + { + _trace.Write("6"); + throw new System.ArgumentException(); + } + finally + { + _trace.Write("7"); + } + } + } + finally + { + _trace.Write("8"); + } + } + + public int Run() + { + _trace = new Trace("ThrowInFinallyNestedInTryTest", "0123456789a"); + + _trace.Write("0"); + try + { + _trace.Write("1"); + MiddleMethod(); + } + catch(Exception e) + { + Console.WriteLine(e); + _trace.Write("9"); + } + _trace.Write("a"); + + return _trace.Match(); + } +} + +class ThrowInFinallyTest +{ + Trace _trace; + + void Dumb() + { + _trace.Write("2"); + try + { + _trace.Write("3"); + try + { + _trace.Write("4"); + try + { + _trace.Write("5"); + throw new Exception("A"); + } + finally + { + _trace.Write("6"); + throw new Exception("B"); + } + } + finally + { + _trace.Write("7"); + throw new Exception("C"); + } + } + finally + { + _trace.Write("8"); + } + } + + public int Run() + { + _trace = new Trace("ThrowInFinallyTest", "0123456789Ca"); + + _trace.Write("0"); + try + { + _trace.Write("1"); + Dumb(); + } + catch(Exception e) + { + Console.WriteLine(e); + _trace.Write("9"); + _trace.Write(e.Message); + } + _trace.Write("a"); + return _trace.Match(); + } +} + +class ThrowInCatchTest +{ + Trace _trace; + + public int Run() + { + _trace = new Trace("ThrowInCatchTest", "0123456"); + _trace.Write("0"); + try + { + _trace.Write("1"); + try + { + _trace.Write("2"); + throw new Exception("....."); + } + catch(Exception e) + { + Console.WriteLine(e); + _trace.Write("3"); + throw new Exception("5"); + } + } + catch(Exception e) + { + Console.WriteLine(e); + _trace.Write("4"); + _trace.Write(e.Message); + } + _trace.Write("6"); + return _trace.Match(); + } +} + +class RecurseTest +{ + Trace _trace; + + void DoTest(int level) + { + _trace.Write(level.ToString()); + if (level <= 0) + return; + + try + { + throw new Exception("" + (level - 1)); + } + catch (Exception e) + { + Console.WriteLine(e); + _trace.Write(e.Message); + DoTest(level - 2); + } + } + + public int Run() + { + int n = 8; + string expected = ""; + + // create expected result string + for (int i = n; i >= 0; i--) + { + expected += i.ToString(); + } + + _trace = new Trace("RecurseTest", expected); + + DoTest(n); + + return _trace.Match(); + } +} + +class PendingTest +{ + Trace _trace; + + void f3() + { + throw new Exception(); + } + + void f2() + { + try + { + _trace.Write("1"); + f3(); + } + catch(Exception e) + { + Console.WriteLine(e); + _trace.Write("2"); + throw; + } + } + + void f1() + { + try + { + _trace.Write("0"); + f2(); + } + catch(Exception e) + { + Console.WriteLine(e); + _trace.Write("3"); + throw e; + } + } + + public int Run() + { + _trace = new Trace("PendingTest", "0123401235"); + + try + { + f1(); + } + catch(Exception e) + { + Console.WriteLine(e); + _trace.Write("4"); + } + + try + { + f1(); + } + catch(Exception e) + { + Console.WriteLine(e); + _trace.Write("5"); + } + + return _trace.Match(); + } +} + + +class GoryNativePastTest +{ + Trace _trace; + + void bar() + { + _trace.Write("2"); + throw new Exception("6"); + } + + void foo() + { + _trace.Write("1"); + try + { + bar(); + } + finally + { + _trace.Write("3"); + } + } + + public int Run() + { + _trace = new Trace("GoryNativePastTest", "0123456"); + + _trace.Write("0"); + try + { + try + { + foo(); + } + catch(Exception e) + { + Console.WriteLine(e); + _trace.Write("4"); + throw; + } + } + catch(Exception e) + { + _trace.Write("5"); + _trace.Write(e.Message); + } + return _trace.Match(); + } +} + +class GoryManagedPresentTest +{ + Trace _trace; + + void foo(int dummy) + { + _trace.Write("1"); + try + { + _trace.Write("2"); + try + { + _trace.Write("3"); + if (1234 == dummy) + { + goto MyLabel; + } + _trace.Write("...."); + } + finally + { + _trace.Write("4"); + } + } + finally + { + _trace.Write("5"); + if (1234 == dummy) + { + int i = 0; + int q = 167 / i; + } + } + + _trace.Write("****"); + + MyLabel: + _trace.Write("~~~~"); + } + + public int Run() + { + _trace = new Trace("GoryManagedPresentTest", "0123456"); + try + { + _trace.Write("0"); + foo(1234); + _trace.Write("%%%%"); + } + catch(Exception e) + { + Console.WriteLine(e); + _trace.Write("6"); + } + + return _trace.Match(); + } +} + +class TryCatchInFinallyTest +{ + Trace _trace; + + public int Run() + { + _trace = new Trace("TryCatchInFinallyTest", "0123456"); + + _trace.Write("0"); + try + { + _trace.Write("1"); + } + finally + { + _trace.Write("2"); + try + { + _trace.Write("3"); + throw new InvalidProgramException(); + } + catch(InvalidProgramException e) + { + Console.WriteLine(e); + _trace.Write("4"); + } + _trace.Write("5"); + } + _trace.Write("6"); + + return _trace.Match(); + } +} + +class StrSwitchFinalTest +{ + Trace _trace; + static string _expected; + + static StrSwitchFinalTest() + { + // Create test writer object to hold expected output + System.IO.StringWriter expectedOut = new System.IO.StringWriter(); + + // Write expected output to string writer object + expectedOut.WriteLine("s == one"); + expectedOut.WriteLine("In inner finally"); + expectedOut.WriteLine("In outer finally\r\n"); + expectedOut.WriteLine("s == two"); + expectedOut.WriteLine("After two"); + expectedOut.WriteLine("In inner finally"); + expectedOut.WriteLine("In outer finally\r\n"); + expectedOut.WriteLine("s == three"); + expectedOut.WriteLine("After three"); + expectedOut.WriteLine("Ok"); + expectedOut.WriteLine("After after three"); + expectedOut.WriteLine("In inner finally"); + expectedOut.WriteLine("Caught an exception\r\n"); + expectedOut.WriteLine("Ok\r\n"); + expectedOut.WriteLine("In outer finally\r\n"); + + expectedOut.WriteLine("In four's finally"); + expectedOut.WriteLine("In inner finally"); + expectedOut.WriteLine("Caught an exception\r\n"); + + expectedOut.WriteLine("Ok\r\n"); + + expectedOut.WriteLine("In outer finally\r\n"); + + expectedOut.WriteLine("s == five"); + expectedOut.WriteLine("Five's finally 0"); + expectedOut.WriteLine("Five's finally 1"); + expectedOut.WriteLine("Five's finally 2"); + expectedOut.WriteLine("In inner finally"); + expectedOut.WriteLine("In outer finally\r\n"); + + expectedOut.WriteLine("Greater than five"); + expectedOut.WriteLine("in six's finally"); + expectedOut.WriteLine("In inner finally"); + expectedOut.WriteLine("In outer finally\r\n"); + + _expected = expectedOut.ToString(); + } + + public int Run() + { + _trace = new Trace("StrSwitchFinalTest", _expected); + + string[] s = {"one", "two", "three", "four", "five", "six"}; + + for(int i = 0; i < s.Length; i++) + { + + beginloop: + try + { + try + { + try + { + switch(s[i]) + { + case "one": + try + { + _trace.WriteLine("s == one"); + } + catch + { + _trace.WriteLine("Exception at one"); + } + break; + case "two": + try + { + _trace.WriteLine("s == two"); + } + finally + { + _trace.WriteLine("After two"); + } + break; + case "three": + try + { + try + { + _trace.WriteLine("s == three"); + } + catch(System.Exception e) + { + _trace.WriteLine(e.ToString()); + goto continueloop; + } + } + finally + { + _trace.WriteLine("After three"); + try + { + switch(s[s.Length-1]) + { + case "six": + _trace.WriteLine("Ok"); + _trace.WriteLine(s[s.Length]); + goto label2; + default: + try + { + _trace.WriteLine("Ack"); + goto label; + } + catch + { + _trace.WriteLine("I don't think so ..."); + } + break; + } + label: + _trace.WriteLine("Unreached"); + throw new Exception(); + } + finally + { + _trace.WriteLine("After after three"); + } + label2: + _trace.WriteLine("Unreached"); + + } + goto continueloop; + + case "four": + try + { + try + { + _trace.WriteLine("s == " + s[s.Length]); + try + { + } + finally + { + _trace.WriteLine("Unreached"); + } + } + catch (Exception e) + { + goto test; + rethrowex: + throw; + test: + if (e is System.ArithmeticException) + { + + try + { + _trace.WriteLine("unreached "); + goto finishfour; + } + finally + { + _trace.WriteLine("also unreached"); + } + } + else + { + goto rethrowex; + } + } + } + finally + { + _trace.WriteLine("In four's finally"); + } + finishfour: + break; + case "five": + try + { + try + { + try + { + + _trace.WriteLine("s == five"); + } + finally + { + _trace.WriteLine("Five's finally 0"); + } + } + catch (Exception) + { + _trace.WriteLine("Unreached"); + } + finally + { + _trace.WriteLine("Five's finally 1"); + } + break; + } + finally + { + _trace.WriteLine("Five's finally 2"); + } + default: + try + { + _trace.WriteLine("Greater than five"); + goto finish; + } + finally + { + _trace.WriteLine("in six's finally"); + + } + + }; + continue; + } + finally + { + _trace.WriteLine("In inner finally"); + } + } + catch (Exception e) + { + _trace.WriteLine("Caught an exception\r\n"); + + switch(s[i]) + { + case "three": + if (e is System.IndexOutOfRangeException) + { + _trace.WriteLine("Ok\r\n"); + i++; + goto beginloop; + } + _trace.WriteLine("Unreached\r\n"); + break; + case "four": + if (e is System.IndexOutOfRangeException) + { + _trace.WriteLine("Ok\r\n"); + i++; + goto beginloop; + } + _trace.WriteLine("Unreached\r\n"); + break; + default: + _trace.WriteLine("****** Unreached"); + goto continueloop; + } + + } + + _trace.WriteLine("Unreached"); + } + finally + { + _trace.WriteLine("In outer finally\r\n"); + } + + continueloop: + _trace.WriteLine("Continuing"); + + } + finish: + + return _trace.Match();; + } +} + + +public class RethrowAndFinallysTest +{ + Trace _trace; + + public int Run() + { + _trace = new Trace("RethrowAndFinallysTest", "abcdefF3ED2CB1A[done]"); + try + { + _trace.Write("a"); + try + { + _trace.Write("b"); + try + { + _trace.Write("c"); + try + { + _trace.Write("d"); + try + { + _trace.Write("e"); + try + { + _trace.Write("f"); + throw new Exception("ex1"); + } + finally + { + _trace.Write("F"); + } + } + catch(Exception e) + { + Console.WriteLine(e); + _trace.Write("3"); + throw; + } + finally + { + _trace.Write("E"); + } + } + finally + { + _trace.Write("D"); + } + } + catch(Exception e) + { + Console.WriteLine(e); + _trace.Write("2"); + throw; + } + finally + { + _trace.Write("C"); + } + } + finally + { + _trace.Write("B"); + } + } + catch(Exception e) + { + Console.WriteLine(e); + _trace.Write("1"); + } + finally + { + _trace.Write("A"); + } + + _trace.Write("[done]"); + + return _trace.Match(); + } +} + + + +class InnerFinallyTest +{ + Trace _trace; + + public InnerFinallyTest() + { + // Create test writer object to hold expected output + System.IO.StringWriter expectedOut = new System.IO.StringWriter(); + + // Write expected output to string writer object + expectedOut.WriteLine(" try 1"); + expectedOut.WriteLine("\t try 1.1"); + expectedOut.WriteLine("\t finally 1.1"); + expectedOut.WriteLine("\t\t try 1.1.1"); + expectedOut.WriteLine("\t\t Throwing an exception here!"); + expectedOut.WriteLine("\t\t finally 1.1.1"); + expectedOut.WriteLine(" catch 1"); + expectedOut.WriteLine(" finally 1"); + + _trace = new Trace("InnerFinallyTest", expectedOut.ToString()); + } + + public int Run() + { + int x = 7, y = 0, z; + + try + { + _trace.WriteLine(" try 1"); + try + { + _trace.WriteLine("\t try 1.1"); + } + finally + { + _trace.WriteLine("\t finally 1.1"); + try + { + _trace.WriteLine("\t\t try 1.1.1"); + _trace.WriteLine("\t\t Throwing an exception here!"); + z = x / y; + } + finally + { + _trace.WriteLine("\t\t finally 1.1.1"); + } + } + } + catch (Exception) + { + _trace.WriteLine(" catch 1"); + } + finally + { + _trace.WriteLine(" finally 1"); + } + + return _trace.Match(); + } +} + + +class InnerFinallyAndCatchTest +{ + Trace _trace; + + public int Run() + { + _trace = new Trace("InnerFinallyAndCatchTest", "abcdefghijklm13"); + + int x = 7, y = 0, z; + + int count = 0; + + try + { + _trace.Write("a"); + count++; + try + { + _trace.Write("b"); + count++; + } + finally // 1 + { + try + { + _trace.Write("c"); + count++; + } + finally // 2 + { + try + { + try + { + _trace.Write("d"); + count++; + } + finally // 3 + { + _trace.Write("e"); + count++; + try + { + _trace.Write("f"); + count++; + } + finally // 4 + { + _trace.Write("g"); + count++; + z = x / y; + } + _trace.Write("@@"); + count++; + } + } + catch (Exception) // C2 + { + _trace.Write("h"); + count++; + } + _trace.Write("i"); + count++; + } + _trace.Write("j"); + count++; + } + _trace.Write("k"); + count++; + } + catch (Exception) // C1 + { + _trace.Write("!!"); + count++; + } + finally // 0 + { + _trace.Write("l"); + count++; + } + + _trace.Write("m"); + count++; + + _trace.Write(count.ToString()); + + return _trace.Match(); + } +} + + +class StackOverflowInLeafFunction +{ + Trace _trace; + +/* + int LeafFunction(int a, int b) + { + int c; + + try + { + // raise stack overflow + } + catch + { + c = b / a; // this exception will not be able to dispatch + } + + return c; + } +*/ + + unsafe void RecursiveDeath(int depth) + { + string msg = String.Concat("caught at depth:", depth.ToString()); + long* pStuff = stackalloc long[128]; + + for (int i = 0; i < 128; i++) + { + short d = (short)depth; + long dd = (long)d; + + long foo = dd << 48; + foo |= dd << 32; + foo |= dd << 16; + foo |= dd; + + pStuff[i] = foo; + } + + try + { + RecursiveDeath(depth + 1); + } + catch + { + Console.WriteLine(msg); + } + + } + + public int Run() + { + _trace = new Trace("", "123"); + + _trace.Write("1"); + + try + { + RecursiveDeath(0); + } + catch + { + _trace.Write("2"); + } + + _trace.Write("3"); + + return _trace.Match(); + } +} + diff --git a/tests/src/baseservices/exceptions/unittests/EHPatternTests.csproj b/tests/src/baseservices/exceptions/unittests/EHPatternTests.csproj new file mode 100644 index 0000000000..c71abc30b1 --- /dev/null +++ b/tests/src/baseservices/exceptions/unittests/EHPatternTests.csproj @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="EHPatternTests.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/unittests/GoryManagedPresent.cs b/tests/src/baseservices/exceptions/unittests/GoryManagedPresent.cs new file mode 100644 index 0000000000..485d1167e3 --- /dev/null +++ b/tests/src/baseservices/exceptions/unittests/GoryManagedPresent.cs @@ -0,0 +1,100 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.IO; + +public class TestSet +{ + static void CountResults(int testReturnValue, ref int nSuccesses, ref int nFailures) + { + if (100 == testReturnValue) + { + nSuccesses++; + } + else + { + nFailures++; + } + } + + public static int Main() + { + int nSuccesses = 0; + int nFailures = 0; + + CountResults(new GoryManagedPresentTest().Run(), ref nSuccesses, ref nFailures); // FAIL: needs skip to parent code <TODO> investigate </TODO> + + if (0 == nFailures) + { + Console.WriteLine("OVERALL PASS: " + nSuccesses + " tests"); + return 100; + } + else + { + Console.WriteLine("OVERALL FAIL: " + nFailures + " tests failed"); + return 999; + } + } +} + +class GoryManagedPresentTest +{ + Trace _trace; + + void foo(int dummy) + { + _trace.Write("1"); + try + { + _trace.Write("2"); + try + { + _trace.Write("3"); + if (1234 == dummy) + { + goto MyLabel; + } + _trace.Write("...."); + } + finally + { + _trace.Write("4"); + } + } + finally + { + _trace.Write("5"); + if (1234 == dummy) + { + int i = 0; + int q = 167 / i; + } + } + + _trace.Write("****"); + + MyLabel: + _trace.Write("~~~~"); + } + + public int Run() + { + _trace = new Trace("GoryManagedPresentTest", "0123456"); + try + { + _trace.Write("0"); + foo(1234); + _trace.Write("%%%%"); + } + catch(Exception e) + { + Console.WriteLine(e); + _trace.Write("6"); + } + + return _trace.Match(); + } +} + diff --git a/tests/src/baseservices/exceptions/unittests/GoryManagedPresent.csproj b/tests/src/baseservices/exceptions/unittests/GoryManagedPresent.csproj new file mode 100644 index 0000000000..decbe445e7 --- /dev/null +++ b/tests/src/baseservices/exceptions/unittests/GoryManagedPresent.csproj @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="GoryManagedPresent.cs" /> + <Compile Include="trace.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/unittests/GoryNativePast.cs b/tests/src/baseservices/exceptions/unittests/GoryNativePast.cs new file mode 100644 index 0000000000..777d1c7ed6 --- /dev/null +++ b/tests/src/baseservices/exceptions/unittests/GoryNativePast.cs @@ -0,0 +1,91 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.IO; + +public class TestSet +{ + static void CountResults(int testReturnValue, ref int nSuccesses, ref int nFailures) + { + if (100 == testReturnValue) + { + nSuccesses++; + } + else + { + nFailures++; + } + } + + public static int Main() + { + int nSuccesses = 0; + int nFailures = 0; + + CountResults(new GoryNativePastTest().Run(), ref nSuccesses, ref nFailures); + + if (0 == nFailures) + { + Console.WriteLine("OVERALL PASS: " + nSuccesses + " tests"); + return 100; + } + else + { + Console.WriteLine("OVERALL FAIL: " + nFailures + " tests failed"); + return 999; + } + } +} + +class GoryNativePastTest +{ + Trace _trace; + + void bar() + { + _trace.Write("2"); + throw new Exception("6"); + } + + void foo() + { + _trace.Write("1"); + try + { + bar(); + } + finally + { + _trace.Write("3"); + } + } + + public int Run() + { + _trace = new Trace("GoryNativePastTest", "0123456"); + + _trace.Write("0"); + try + { + try + { + foo(); + } + catch(Exception e) + { + Console.WriteLine(e); + _trace.Write("4"); + throw; + } + } + catch(Exception e) + { + _trace.Write("5"); + _trace.Write(e.Message); + } + return _trace.Match(); + } +} + diff --git a/tests/src/baseservices/exceptions/unittests/GoryNativePast.csproj b/tests/src/baseservices/exceptions/unittests/GoryNativePast.csproj new file mode 100644 index 0000000000..3f051b4386 --- /dev/null +++ b/tests/src/baseservices/exceptions/unittests/GoryNativePast.csproj @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="GoryNativePast.cs" /> + <Compile Include="trace.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/unittests/InnerFinallyAndCatch.cs b/tests/src/baseservices/exceptions/unittests/InnerFinallyAndCatch.cs new file mode 100644 index 0000000000..74abe712bc --- /dev/null +++ b/tests/src/baseservices/exceptions/unittests/InnerFinallyAndCatch.cs @@ -0,0 +1,131 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.IO; + +public class TestSet +{ + static void CountResults(int testReturnValue, ref int nSuccesses, ref int nFailures) + { + if (100 == testReturnValue) + { + nSuccesses++; + } + else + { + nFailures++; + } + } + + public static int Main() + { + int nSuccesses = 0; + int nFailures = 0; + + CountResults(new InnerFinallyAndCatchTest().Run(), ref nSuccesses, ref nFailures); + + if (0 == nFailures) + { + Console.WriteLine("OVERALL PASS: " + nSuccesses + " tests"); + return 100; + } + else + { + Console.WriteLine("OVERALL FAIL: " + nFailures + " tests failed"); + return 999; + } + } +} + +class InnerFinallyAndCatchTest +{ + Trace _trace; + + public int Run() + { + _trace = new Trace("InnerFinallyAndCatchTest", "abcdefghijklm13"); + + int x = 7, y = 0, z; + + int count = 0; + + try + { + _trace.Write("a"); + count++; + try + { + _trace.Write("b"); + count++; + } + finally // 1 + { + try + { + _trace.Write("c"); + count++; + } + finally // 2 + { + try + { + try + { + _trace.Write("d"); + count++; + } + finally // 3 + { + _trace.Write("e"); + count++; + try + { + _trace.Write("f"); + count++; + } + finally // 4 + { + _trace.Write("g"); + count++; + z = x / y; + } + _trace.Write("@@"); + count++; + } + } + catch (Exception) // C2 + { + _trace.Write("h"); + count++; + } + _trace.Write("i"); + count++; + } + _trace.Write("j"); + count++; + } + _trace.Write("k"); + count++; + } + catch (Exception) // C1 + { + _trace.Write("!!"); + count++; + } + finally // 0 + { + _trace.Write("l"); + count++; + } + + _trace.Write("m"); + count++; + + _trace.Write(count.ToString()); + + return _trace.Match(); + } +} + diff --git a/tests/src/baseservices/exceptions/unittests/InnerFinallyAndCatch.csproj b/tests/src/baseservices/exceptions/unittests/InnerFinallyAndCatch.csproj new file mode 100644 index 0000000000..ad750ba137 --- /dev/null +++ b/tests/src/baseservices/exceptions/unittests/InnerFinallyAndCatch.csproj @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="InnerFinallyAndCatch.cs" /> + <Compile Include="trace.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/unittests/Pending.cs b/tests/src/baseservices/exceptions/unittests/Pending.cs new file mode 100644 index 0000000000..5307bb078c --- /dev/null +++ b/tests/src/baseservices/exceptions/unittests/Pending.cs @@ -0,0 +1,111 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.IO; + +public class TestSet +{ + static void CountResults(int testReturnValue, ref int nSuccesses, ref int nFailures) + { + if (100 == testReturnValue) + { + nSuccesses++; + } + else + { + nFailures++; + } + } + + public static int Main() + { + int nSuccesses = 0; + int nFailures = 0; + + CountResults(new PendingTest().Run(), ref nSuccesses, ref nFailures); + + if (0 == nFailures) + { + Console.WriteLine("OVERALL PASS: " + nSuccesses + " tests"); + return 100; + } + else + { + Console.WriteLine("OVERALL FAIL: " + nFailures + " tests failed"); + return 999; + } + } +} + + +class PendingTest +{ + Trace _trace; + + void f3() + { + throw new Exception(); + } + + void f2() + { + try + { + _trace.Write("1"); + f3(); + } + catch(Exception e) + { + Console.WriteLine(e); + _trace.Write("2"); + throw; + } + } + + void f1() + { + try + { + _trace.Write("0"); + f2(); + } + catch(Exception e) + { + Console.WriteLine(e); + _trace.Write("3"); + throw e; + } + } + + public int Run() + { + _trace = new Trace("PendingTest", "0123401235"); + + try + { + f1(); + } + catch(Exception e) + { + Console.WriteLine(e); + _trace.Write("4"); + } + + try + { + f1(); + } + catch(Exception e) + { + Console.WriteLine(e); + _trace.Write("5"); + } + + return _trace.Match(); + } +} + + + diff --git a/tests/src/baseservices/exceptions/unittests/Pending.csproj b/tests/src/baseservices/exceptions/unittests/Pending.csproj new file mode 100644 index 0000000000..71ca03138c --- /dev/null +++ b/tests/src/baseservices/exceptions/unittests/Pending.csproj @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="Pending.cs" /> + <Compile Include="trace.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/unittests/Recurse.cs b/tests/src/baseservices/exceptions/unittests/Recurse.cs new file mode 100644 index 0000000000..0c4579ba0c --- /dev/null +++ b/tests/src/baseservices/exceptions/unittests/Recurse.cs @@ -0,0 +1,82 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.IO; + +public class TestSet +{ + static void CountResults(int testReturnValue, ref int nSuccesses, ref int nFailures) + { + if (100 == testReturnValue) + { + nSuccesses++; + } + else + { + nFailures++; + } + } + + public static int Main() + { + int nSuccesses = 0; + int nFailures = 0; + + CountResults(new RecurseTest().Run(), ref nSuccesses, ref nFailures); + + if (0 == nFailures) + { + Console.WriteLine("OVERALL PASS: " + nSuccesses + " tests"); + return 100; + } + else + { + Console.WriteLine("OVERALL FAIL: " + nFailures + " tests failed"); + return 999; + } + } +} + +class RecurseTest +{ + Trace _trace; + + void DoTest(int level) + { + _trace.Write(level.ToString()); + if (level <= 0) + return; + + try + { + throw new Exception("" + (level - 1)); + } + catch (Exception e) + { + Console.WriteLine(e); + _trace.Write(e.Message); + DoTest(level - 2); + } + } + + public int Run() + { + int n = 8; + string expected = ""; + + // create expected result string + for (int i = n; i >= 0; i--) + { + expected += i.ToString(); + } + + _trace = new Trace("RecurseTest", expected); + + DoTest(n); + + return _trace.Match(); + } +} + diff --git a/tests/src/baseservices/exceptions/unittests/Recurse.csproj b/tests/src/baseservices/exceptions/unittests/Recurse.csproj new file mode 100644 index 0000000000..d46656c7a8 --- /dev/null +++ b/tests/src/baseservices/exceptions/unittests/Recurse.csproj @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="Recurse.cs" /> + <Compile Include="trace.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/unittests/RecursiveRethrow.cs b/tests/src/baseservices/exceptions/unittests/RecursiveRethrow.cs new file mode 100644 index 0000000000..5ceb3710f3 --- /dev/null +++ b/tests/src/baseservices/exceptions/unittests/RecursiveRethrow.cs @@ -0,0 +1,91 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.IO; + +public class TestSet +{ + static void CountResults(int testReturnValue, ref int nSuccesses, ref int nFailures) + { + if (100 == testReturnValue) + { + nSuccesses++; + } + else + { + nFailures++; + } + } + + public static int Main() + { + int nSuccesses = 0; + int nFailures = 0; + + CountResults(new RecursiveRethrow().Run(), ref nSuccesses, ref nFailures); + + if (0 == nFailures) + { + Console.WriteLine("OVERALL PASS: " + nSuccesses + " tests"); + return 100; + } + else + { + Console.WriteLine("OVERALL FAIL: " + nFailures + " tests failed"); + return 999; + } + } +} + +public class RecursiveRethrow +{ + Trace _trace; + + public int Run() + { + _trace = new Trace("RecursiveRethrow", "210C0C1C2RecursionIsFun"); + + try + { + LoveToRecurse(2); + } + catch (Exception e) + { + Console.WriteLine(e); + _trace.Write(e.Message); + } + + return _trace.Match(); + } + + + void SeparatorMethod(int i) + { + LoveToRecurse(i); + } + + void LoveToRecurse(int i) + { + try + { + _trace.Write(i.ToString()); + if (0 == i) + { + throw new Exception("RecursionIsFun"); + } + else + { + SeparatorMethod(i - 1); + } + } + catch (Exception e) + { + _trace.Write("C" + i.ToString()); + Console.WriteLine(e); + throw e; + } + } +} + diff --git a/tests/src/baseservices/exceptions/unittests/RecursiveRethrow.csproj b/tests/src/baseservices/exceptions/unittests/RecursiveRethrow.csproj new file mode 100644 index 0000000000..f7e6cdd9a0 --- /dev/null +++ b/tests/src/baseservices/exceptions/unittests/RecursiveRethrow.csproj @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="RecursiveRethrow.cs" /> + <Compile Include="trace.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/unittests/RecursiveThrowNew.cs b/tests/src/baseservices/exceptions/unittests/RecursiveThrowNew.cs new file mode 100644 index 0000000000..b4ae467c5c --- /dev/null +++ b/tests/src/baseservices/exceptions/unittests/RecursiveThrowNew.cs @@ -0,0 +1,92 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.IO; + +public class TestSet +{ + static void CountResults(int testReturnValue, ref int nSuccesses, ref int nFailures) + { + if (100 == testReturnValue) + { + nSuccesses++; + } + else + { + nFailures++; + } + } + + public static int Main() + { + int nSuccesses = 0; + int nFailures = 0; + + CountResults(new RecursiveThrowNew().Run(), ref nSuccesses, ref nFailures); + + if (0 == nFailures) + { + Console.WriteLine("OVERALL PASS: " + nSuccesses + " tests"); + return 100; + } + else + { + Console.WriteLine("OVERALL FAIL: " + nFailures + " tests failed"); + return 999; + } + } +} + +public class RecursiveThrowNew +{ + Trace _trace; + + public int Run() + { + _trace = new Trace("RecursiveThrowNew", "210C0(eX)C1(e0)C2(e1)CM(e2)"); + + try + { + LoveToRecurse(2); + } + catch (Exception e) + { + _trace.Write("CM(" + e.Message + ")"); + Console.WriteLine(e); + } + + return _trace.Match(); + } + + + void SeparatorMethod(int i) + { + LoveToRecurse(i); + } + + void LoveToRecurse(int i) + { + try + { + _trace.Write(i.ToString()); + if (0 == i) + { + throw new Exception("eX"); + } + else + { + SeparatorMethod(i - 1); + } + } + catch (Exception e) + { + _trace.Write("C" + i.ToString() + "(" + e.Message + ")"); + Console.WriteLine(e); + throw new Exception("e" + i.ToString()); + } + } +} + + diff --git a/tests/src/baseservices/exceptions/unittests/RecursiveThrowNew.csproj b/tests/src/baseservices/exceptions/unittests/RecursiveThrowNew.csproj new file mode 100644 index 0000000000..fc5835fc1a --- /dev/null +++ b/tests/src/baseservices/exceptions/unittests/RecursiveThrowNew.csproj @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="RecursiveThrowNew.cs" /> + <Compile Include="trace.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/unittests/StrSwitchFinally.cs b/tests/src/baseservices/exceptions/unittests/StrSwitchFinally.cs new file mode 100644 index 0000000000..d84e8293ef --- /dev/null +++ b/tests/src/baseservices/exceptions/unittests/StrSwitchFinally.cs @@ -0,0 +1,326 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.IO; + +// +// main +// + +public class TestSet +{ + static void CountResults(int testReturnValue, ref int nSuccesses, ref int nFailures) + { + if (100 == testReturnValue) + { + nSuccesses++; + } + else + { + nFailures++; + } + } + + public static int Main() + { + int nSuccesses = 0; + int nFailures = 0; + + CountResults(new StrSwitchFinalTest().Run(), ref nSuccesses, ref nFailures); + + if (0 == nFailures) + { + Console.WriteLine("OVERALL PASS: " + nSuccesses + " tests"); + return 100; + } + else + { + Console.WriteLine("OVERALL FAIL: " + nFailures + " tests failed"); + return 999; + } + } +} + +class StrSwitchFinalTest +{ + Trace _trace; + static string _expected; + + static StrSwitchFinalTest() + { + // Create test writer object to hold expected output + System.IO.StringWriter expectedOut = new System.IO.StringWriter(); + + // Write expected output to string writer object + expectedOut.WriteLine("s == one"); + expectedOut.WriteLine("In inner finally"); + expectedOut.WriteLine("In outer finally\r\n"); + expectedOut.WriteLine("s == two"); + expectedOut.WriteLine("After two"); + expectedOut.WriteLine("In inner finally"); + expectedOut.WriteLine("In outer finally\r\n"); + expectedOut.WriteLine("s == three"); + expectedOut.WriteLine("After three"); + expectedOut.WriteLine("Ok"); + expectedOut.WriteLine("After after three"); + expectedOut.WriteLine("In inner finally"); + expectedOut.WriteLine("Caught an exception\r\n"); + expectedOut.WriteLine("Ok\r\n"); + expectedOut.WriteLine("In outer finally\r\n"); + + expectedOut.WriteLine("In four's finally"); + expectedOut.WriteLine("In inner finally"); + expectedOut.WriteLine("Caught an exception\r\n"); + + expectedOut.WriteLine("Ok\r\n"); + + expectedOut.WriteLine("In outer finally\r\n"); + + expectedOut.WriteLine("s == five"); + expectedOut.WriteLine("Five's finally 0"); + expectedOut.WriteLine("Five's finally 1"); + expectedOut.WriteLine("Five's finally 2"); + expectedOut.WriteLine("In inner finally"); + expectedOut.WriteLine("In outer finally\r\n"); + + expectedOut.WriteLine("Greater than five"); + expectedOut.WriteLine("in six's finally"); + expectedOut.WriteLine("In inner finally"); + expectedOut.WriteLine("In outer finally\r\n"); + + _expected = expectedOut.ToString(); + } + + public int Run() + { + _trace = new Trace("StrSwitchFinalTest", _expected); + + string[] s = {"one", "two", "three", "four", "five", "six"}; + + for(int i = 0; i < s.Length; i++) + { + + beginloop: + try + { + try + { + try + { + switch(s[i]) + { + case "one": + try + { + _trace.WriteLine("s == one"); + } + catch + { + _trace.WriteLine("Exception at one"); + } + break; + case "two": + try + { + _trace.WriteLine("s == two"); + } + finally + { + _trace.WriteLine("After two"); + } + break; + case "three": + try + { + try + { + _trace.WriteLine("s == three"); + } + catch(System.Exception e) + { + _trace.WriteLine(e.ToString()); + goto continueloop; + } + } + finally + { + _trace.WriteLine("After three"); + try + { + switch(s[s.Length-1]) + { + case "six": + _trace.WriteLine("Ok"); + _trace.WriteLine(s[s.Length]); + goto label2; + default: + try + { + _trace.WriteLine("Ack"); + goto label; + } + catch + { + _trace.WriteLine("I don't think so ..."); + } + break; + } + label: + _trace.WriteLine("Unreached"); + throw new Exception(); + } + finally + { + _trace.WriteLine("After after three"); + } + label2: + _trace.WriteLine("Unreached"); + + } + goto continueloop; + + case "four": + try + { + try + { + _trace.WriteLine("s == " + s[s.Length]); + try + { + } + finally + { + _trace.WriteLine("Unreached"); + } + } + catch (Exception e) + { + goto test; + rethrowex: + throw; + test: + if (e is System.ArithmeticException) + { + + try + { + _trace.WriteLine("unreached "); + goto finishfour; + } + finally + { + _trace.WriteLine("also unreached"); + } + } + else + { + goto rethrowex; + } + } + } + finally + { + _trace.WriteLine("In four's finally"); + } + finishfour: + break; + case "five": + try + { + try + { + try + { + + _trace.WriteLine("s == five"); + } + finally + { + _trace.WriteLine("Five's finally 0"); + } + } + catch (Exception) + { + _trace.WriteLine("Unreached"); + } + finally + { + _trace.WriteLine("Five's finally 1"); + } + break; + } + finally + { + _trace.WriteLine("Five's finally 2"); + } + default: + try + { + _trace.WriteLine("Greater than five"); + goto finish; + } + finally + { + _trace.WriteLine("in six's finally"); + + } + + }; + continue; + } + finally + { + _trace.WriteLine("In inner finally"); + } + } + catch (Exception e) + { + _trace.WriteLine("Caught an exception\r\n"); + + switch(s[i]) + { + case "three": + if (e is System.IndexOutOfRangeException) + { + _trace.WriteLine("Ok\r\n"); + i++; + goto beginloop; + } + _trace.WriteLine("Unreached\r\n"); + break; + case "four": + if (e is System.IndexOutOfRangeException) + { + _trace.WriteLine("Ok\r\n"); + i++; + goto beginloop; + } + _trace.WriteLine("Unreached\r\n"); + break; + default: + _trace.WriteLine("****** Unreached"); + goto continueloop; + } + + } + + _trace.WriteLine("Unreached"); + } + finally + { + _trace.WriteLine("In outer finally\r\n"); + } + + continueloop: + _trace.WriteLine("Continuing"); + + } + finish: + + return _trace.Match();; + } +} + + diff --git a/tests/src/baseservices/exceptions/unittests/StrSwitchFinally.csproj b/tests/src/baseservices/exceptions/unittests/StrSwitchFinally.csproj new file mode 100644 index 0000000000..586d3c1dfa --- /dev/null +++ b/tests/src/baseservices/exceptions/unittests/StrSwitchFinally.csproj @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="StrSwitchFinally.cs" /> + <Compile Include="trace.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/baseservices/exceptions/unittests/ThrowInFinallyNestedInTry.cs b/tests/src/baseservices/exceptions/unittests/ThrowInFinallyNestedInTry.cs new file mode 100644 index 0000000000..fda491caa0 --- /dev/null +++ b/tests/src/baseservices/exceptions/unittests/ThrowInFinallyNestedInTry.cs @@ -0,0 +1,101 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.IO; + +// +// main +// + +public class TestSet +{ + static void CountResults(int testReturnValue, ref int nSuccesses, ref int nFailures) + { + if (100 == testReturnValue) + { + nSuccesses++; + } + else + { + nFailures++; + } + } + + public static int Main() + { + int nSuccesses = 0; + int nFailures = 0; + + CountResults(new ThrowInFinallyNestedInTryTest().Run(), ref nSuccesses, ref nFailures); // FAIL: needs skip to parent code <TODO> investigate </TODO> + + if (0 == nFailures) + { + Console.WriteLine("OVERALL PASS: " + nSuccesses + " tests"); + return 100; + } + else + { + Console.WriteLine("OVERALL FAIL: " + nFailures + " tests failed"); + return 999; + } + } +} + +public class ThrowInFinallyNestedInTryTest +{ + Trace _trace; + + void MiddleMethod() + { + _trace.Write("2"); + try + { + _trace.Write("3"); + try + { + _trace.Write("4"); + } + finally + { + _trace.Write("5"); + try + { + _trace.Write("6"); + throw new System.ArgumentException(); + } + finally + { + _trace.Write("7"); + } + } + } + finally + { + _trace.Write("8"); + } + } + + public int Run() + { + _trace = new Trace("ThrowInFinallyNestedInTryTest", "0123456789a"); + + _trace.Write("0"); + try + { + _trace.Write("1"); + MiddleMethod(); + } + catch(Exception e) + { + Console.WriteLine(e); + _trace.Write("9"); + } + _trace.Write("a"); + + return _trace.Match(); + } +} + + diff --git a/tests/src/baseservices/exceptions/unittests/ThrowInFinallyNestedInTry.csproj b/tests/src/baseservices/exceptions/unittests/ThrowInFinallyNestedInTry.csproj new file mode 100644 index 0000000000..84c1ec8baf --- /dev/null +++ b/tests/src/baseservices/exceptions/unittests/ThrowInFinallyNestedInTry.csproj @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid> + <OutputType>Exe</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <FileAlignment>512</FileAlignment> + <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> + <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\11.0\UITestExtensionPackages</ReferencePath> + <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> + <NuGetPackageImportStamp>7a9bfb7d</NuGetPackageImportStamp> + <AllowUnsafeBlocks>true</AllowUnsafeBlocks> + <ReferenceLocalMscorlib>false</ReferenceLocalMscorlib> + <CLRTestKind>BuildAndRun</CLRTestKind> + <CLRTestPriority>1</CLRTestPriority> + </PropertyGroup> + <!-- Default configurations to help VS understand the configurations --> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + </PropertyGroup> + <ItemGroup> + <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> + <Visible>False</Visible> + </CodeAnalysisDependentAssemblyPaths> + </ItemGroup> + <ItemGroup> + <!-- Add Compile Object Here --> + <Compile Include="ThrowInFinallyNestedInTry.cs" /> + <Compile Include="trace.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="app.config" /> + <None Include="project.json" /> + </ItemGroup> + <ItemGroup> + <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="../../../Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" /> + </ItemGroup> + <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> + <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/tests/src/dir.targets b/tests/src/dir.targets index 1903630c13..a792d14768 100644 --- a/tests/src/dir.targets +++ b/tests/src/dir.targets @@ -89,8 +89,8 @@ <ProjectLanguage Condition="'$(MSBuildProjectExtension)' == '.csproj' OR '$(Language)' == 'C#' OR '$(ProjectLanguage)'==''">CSharp</ProjectLanguage> </PropertyGroup> - <!-- TODO (#1122): import this from the ToolsDir once it becomes available --> - <Import Project="$(ProjectDir)src\IL.targets" Condition="'$(ProjectLanguage)' == 'IL'" /> + <!-- TODO (#1122): import this from the ToolsDir once it becomes available --> + <Import Project="$(ProjectDir)src\IL.targets" Condition="'$(ProjectLanguage)' == 'IL' And '$(CLRTestPriority)' <= '$(CLRTestPriorityToBuild)'" /> <Import Project="CLRTest.Execute.targets" /> diff --git a/tests/testsFailingOutsideWindows.txt b/tests/testsFailingOutsideWindows.txt index 7d224e97b9..9ba1534fdd 100644 --- a/tests/testsFailingOutsideWindows.txt +++ b/tests/testsFailingOutsideWindows.txt @@ -1,3 +1,4 @@ +baseservices/exceptions/unittests/EHPatternTests/EHPatternTests.sh baseservices/threading/paramthreadstart/ThreadStartString_1/ThreadStartString_1.sh CoreMangLib/cti/system/multicastdelegate/MulticastDelegateCtor/MulticastDelegateCtor.sh CoreMangLib/cti/system/runtime/interopservices/marshal/MarshalGetLastWin32Error_PSC/MarshalGetLastWin32Error_PSC.sh diff --git a/tests/testsUnsupportedOutsideWindows.txt b/tests/testsUnsupportedOutsideWindows.txt index 76be20d5b2..077ed19817 100644 --- a/tests/testsUnsupportedOutsideWindows.txt +++ b/tests/testsUnsupportedOutsideWindows.txt @@ -1,3 +1,5 @@ +baseservices/exceptions/regressions/V1/SEH/VJ/UnmanagedToManaged/UnmanagedToManaged.sh +baseservices/exceptions/regressions/Dev11/147911/test147911/test147911.sh baseservices/threading/commitstackonlyasneeded/DefaultStackCommit/DefaultStackCommit.sh CoreMangLib/cti/system/byte/ByteToString3/ByteToString3.sh CoreMangLib/cti/system/convert/ConvertToInt32_4/ConvertToInt32_4.sh |