diff options
author | Jiyoung Yun <jy910.yun@samsung.com> | 2016-11-23 19:09:09 +0900 |
---|---|---|
committer | Jiyoung Yun <jy910.yun@samsung.com> | 2016-11-23 19:09:09 +0900 |
commit | 4b4aad7217d3292650e77eec2cf4c198ea9c3b4b (patch) | |
tree | 98110734c91668dfdbb126fcc0e15ddbd93738ca /tests/src/baseservices/exceptions/regressions/V1/SEH | |
parent | fa45f57ed55137c75ac870356a1b8f76c84b229c (diff) | |
download | coreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.tar.gz coreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.tar.bz2 coreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.zip |
Imported Upstream version 1.1.0upstream/1.1.0
Diffstat (limited to 'tests/src/baseservices/exceptions/regressions/V1/SEH')
49 files changed, 3780 insertions, 0 deletions
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..700fd91d5c --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/COOL/finally.csproj @@ -0,0 +1,44 @@ +<?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> + <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/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..21c3b2effd --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/COOL/rethrow.csproj @@ -0,0 +1,44 @@ +<?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> + <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..33193a8a95 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/ExternalException.csproj @@ -0,0 +1,44 @@ +<?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> + <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..63483b96b5 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/HandlerException.csproj @@ -0,0 +1,44 @@ +<?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> + <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..9b4caf3a6e --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/MultipleException.csproj @@ -0,0 +1,44 @@ +<?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> + <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..9cc92f0cf9 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/NestedEx1.csproj @@ -0,0 +1,44 @@ +<?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> + <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..f5b6b4f10f --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/NestedEx2.csproj @@ -0,0 +1,44 @@ +<?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> + <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..0f4693fcc2 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/NestedException.csproj @@ -0,0 +1,44 @@ +<?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> + <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..f51b9220f4 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/NormalException.csproj @@ -0,0 +1,44 @@ +<?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> + <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..2926c27f10 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/RecursiveException.csproj @@ -0,0 +1,44 @@ +<?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> + <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..28d4c7f6dd --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/TryCatch.csproj @@ -0,0 +1,44 @@ +<?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> + <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..a785878dd3 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/TryCatchFinally.csproj @@ -0,0 +1,44 @@ +<?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> + <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..b1f6eb6a73 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/Unmanaged.h @@ -0,0 +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. + +#include <stdio.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..c5346713a2 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/UnmanagedToManaged.csproj @@ -0,0 +1,47 @@ +<?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> + <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..c5bbae0c9c --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/UserException.csproj @@ -0,0 +1,44 @@ +<?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> + <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..a49b9acc02 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/VJ/UserExceptionThread.csproj @@ -0,0 +1,44 @@ +<?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> + <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/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..80c2e088a6 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/Except.ilproj @@ -0,0 +1,42 @@ +<?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> + <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..a0a5b26d49 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/FiltCatch.ilproj @@ -0,0 +1,42 @@ +<?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> + <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..576d6e6b71 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/FiltFallThru.ilproj @@ -0,0 +1,42 @@ +<?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> + <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..6abe96b182 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/Filter.ilproj @@ -0,0 +1,42 @@ +<?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> + <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..f1ba3e7e27 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/Finally.ilproj @@ -0,0 +1,42 @@ +<?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> + <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..3c49c3bbe2 --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/NestedExcept.ilproj @@ -0,0 +1,42 @@ +<?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> + <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..4ad4bf0aed --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/asm/NestedFilt.ilproj @@ -0,0 +1,42 @@ +<?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> + <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/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..37859e566e --- /dev/null +++ b/tests/src/baseservices/exceptions/regressions/V1/SEH/coverage/Exceptions.csproj @@ -0,0 +1,44 @@ +<?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> + <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 |