Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/coreclr/vm/dllimport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4556,7 +4556,7 @@ static void CreatePInvokeStubAccessMetadata(

(*pNumArgs) = msig.NumFixedArgs();

IMDInternalImport* pInternalImport = pSigDesc->m_pModule->GetMDImport();
IMDInternalImport* pInternalImport = pSigDesc->m_pMetadataModule->GetMDImport();

Comment thread
jkoritzinsky marked this conversation as resolved.
_ASSERTE(!SF_IsHRESULTSwapping(*pdwStubFlags));

Expand Down
3 changes: 2 additions & 1 deletion src/tests/Interop/Interop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<SupportProject Include="$(TestLibraryProjectPath)" />
<SupportProject Include="PInvoke/Miscellaneous/CopyCtor/CopyCtorUtil.ilproj" />
<SupportProject Include="PInvoke/Miscellaneous/MultipleAssembliesWithSamePInvoke/ManagedDll*/*.csproj" />
<SupportProject Include="PInvoke/Varargs/CrossAssembly/VarArgsPInvokeLib/*.csproj" />
<MergedWrapperProjectReference Include="*/**/*.??proj" Exclude="@(SupportProject)" />
<ProjectReference Include="@(SupportProject)" />
</ItemGroup>
Expand Down Expand Up @@ -42,7 +43,7 @@
<Compile Include="PInvoke/SafeHandles/**/*.cs" />
<Compile Include="PInvoke/SetLastError/**/*.cs" />
<Compile Include="PInvoke/SizeParamIndex/**/*.cs" />
<Compile Include="PInvoke/Varargs/**/*.cs" />
<Compile Include="PInvoke/Varargs/**/*.cs" Exclude="PInvoke/Varargs/CrossAssembly/VarArgsPInvokeLib/*.cs" />
<Compile Include="PInvoke/Vector2_3_4/**/*.cs" />

<!-- Reference the CMake projects for the directly-compiled-in tests -->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Text;
using TestLibrary;
using VarArgsPInvokeLib;
using Xunit;

namespace PInvokeTests
{
public class CrossAssemblyVarargsTest
{
[ConditionalFact(typeof(TestLibrary.PlatformDetection), nameof(TestLibrary.PlatformDetection.IsVarArgSupported))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/91388", typeof(TestLibrary.PlatformDetection), nameof(TestLibrary.PlatformDetection.PlatformDoesNotSupportNativeTestAssets))]
public static void TestCrossAssemblyVarArgs()
{
int arg1 = 10;
int arg2 = 20;
double arg3 = 12.5;
string expected = FormattableString.Invariant($"{arg1}, {arg2}, {arg3:F1}");

var builder = new StringBuilder(30);
VarArgsWrapper.TestVarArgs(builder, (IntPtr)30, "%i, %i, %.1f", __arglist(arg1, arg2, arg3));
Assert.Equal(expected, builder.ToString());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Runtime.InteropServices;
using System.Text;

namespace VarArgsPInvokeLib
{
public static class VarArgsWrapper
{
[DllImport("VarargsNative", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern void TestVarArgs(StringBuilder builder, nint bufferSize, string formatString, __arglist);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Library</OutputType>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
</Project>
Loading