class ExplicitLayout
{
+#pragma warning disable 618
[StructLayout(LayoutKind.Explicit, Size = SIZE)]
internal unsafe struct TestStruct
{
[FieldOffset(16), MarshalAs(UnmanagedType.Struct, SizeConst = 16)]
public Guid Guid2;
}
+#pragma warning restore 618
internal class Program
{
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-// This test is a regression test for VSWhidbey 298006
// The struct has an objref and is of odd size.
// The GC requires that all valuetypes containing objrefs be sized to a multiple of sizeof(void*) )== 4).
// Since the size of this struct was 17 we were throwing a TypeLoadException.
using System;
using System.Runtime.InteropServices;
+#pragma warning disable 618
[StructLayout(LayoutKind.Explicit)]
public struct S
{
[FieldOffset(8)] public double d;
[FieldOffset(0), MarshalAs(UnmanagedType.BStr)] public string st;
}
-
-
+#pragma warning restore 618
public class Test
{
- public static void Run()
- {
- S s;
- s.b = true;
- }
-
- public static int Main()
- {
- try
- {
- Run();
-
- Console.WriteLine("PASS");
- return 100;
- }
- catch (TypeLoadException e)
- {
- Console.WriteLine("FAIL: Caught unexpected TypeLoadException: {0}", e.Message);
- return 101;
- }
- catch (Exception e)
- {
- Console.WriteLine("FAIL: Caught unexpected Exception: {0}", e.Message);
- return 101;
- }
- }
+ public static void Run()
+ {
+ S s;
+ s.b = true;
+ }
+
+ public static int Main()
+ {
+ try
+ {
+ Run();
+
+ Console.WriteLine("PASS");
+ return 100;
+ }
+ catch (TypeLoadException e)
+ {
+ Console.WriteLine("FAIL: Caught unexpected TypeLoadException: {0}", e.Message);
+ return 101;
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("FAIL: Caught unexpected Exception: {0}", e.Message);
+ return 101;
+ }
+ }
}
+++ /dev/null
-<?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>Library</OutputType>
- <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
- <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <CLRTestKind>SharedLibrary</CLRTestKind>
- <CLRTestPriority>1</CLRTestPriority>
- </PropertyGroup>
- <!-- Default configurations to help VS understand the configurations -->
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- </PropertyGroup>
- <ItemGroup>
- <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
- <Visible>False</Visible>
- </CodeAnalysisDependentAssemblyPaths>
- </ItemGroup>
- <ItemGroup>
- <!-- Add Compile Object Here -->
- <Compile Include="managedcom.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
+++ /dev/null
-// 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;
-
-[ComVisible(true)]
-[ClassInterface(ClassInterfaceType.AutoDual)]
-[Guid("2A9F41BC-94F4-4889-9F8A-E0290CEF1177")]
-public class Class1COMInterop
-{
- public delegate void Callback();
-
- [DllImport("NativePinvoke", CallingConvention=CallingConvention.StdCall)]
- public static extern void Native2(Callback call);
-
- [DispId(1)]
- public void Managed1()
- {
- Console.WriteLine("Inside Managed1");
- try
- {
- Managed2();
- }
- finally
- {
- try
- {
- throw new ArgumentException();
- }
- catch(ArgumentException e)
- {
- Console.WriteLine("Managed1: Caught Exception: " + e);
- }
- }
- }
-
- public static void Managed2()
- {
- Console.WriteLine("Inside Managed2");
-
- // pinvoke into Native2
- Native2( new Callback(Managed3) );
-
- }
-
- public static void Managed3()
- {
- Console.WriteLine("Inside Managed3()");
- Managed4();
- }
-
- public static void Managed4()
- {
-
- Console.WriteLine("Inside Managed4()");
-
- // Throw IndexOutOfBounds
- int[] IntArray = new int[10];
- IntArray[11] = 5;
- }
-}
\ No newline at end of file
using System.Text;
using System.Runtime.InteropServices;
using System.Threading;
-//using System.Configuration;
namespace StackCommitTest
{
public unsafe class WinApi
{
+#pragma warning disable 618
[DllImport("kernel32.dll")]
public static extern void GetSystemInfo([MarshalAs(UnmanagedType.Struct)] ref SYSTEM_INFO lpSystemInfo);
+#pragma warning restore 618
[StructLayout(LayoutKind.Sequential)]
public struct SYSTEM_INFO