Skip to content
Merged
Changes from 1 commit
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
16 changes: 11 additions & 5 deletions src/tests/Interop/COM/ComWrappers/API/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ static void ForceGC()
}
}

[MethodImpl(MethodImplOptions.NoInlining)]
static void ValidateComInterfaceCreation()
{
Console.WriteLine($"Running {nameof(ValidateComInterfaceCreation)}...");
Expand Down Expand Up @@ -156,6 +157,7 @@ static void ValidateComInterfaceCreation()
Assert.Equal(0, count);
}

[MethodImpl(MethodImplOptions.NoInlining)]
static void ValidateComInterfaceCreationRoundTrip()
{
Console.WriteLine($"Running {nameof(ValidateComInterfaceCreationRoundTrip)}...");
Expand Down Expand Up @@ -212,6 +214,7 @@ static IntPtr CreateObjectAndGetComInterface()
// Just because one use of a COM interface returned from GetOrCreateComInterfaceForObject
// hits zero ref count does not mean future calls to GetOrCreateComInterfaceForObject
// should return an unusable object.
[MethodImpl(MethodImplOptions.NoInlining)]
static void ValidateCreatingAComInterfaceForObjectAfterTheFirstIsFree()
{
Console.WriteLine($"Running {nameof(ValidateCreatingAComInterfaceForObjectAfterTheFirstIsFree)}...");
Expand Down Expand Up @@ -247,6 +250,7 @@ unsafe static void CallSetValue(TestComWrappers wrappers, Test testInstance, int
}
}

[MethodImpl(MethodImplOptions.NoInlining)]
static void ValidateFallbackQueryInterface()
{
Console.WriteLine($"Running {nameof(ValidateFallbackQueryInterface)}...");
Expand Down Expand Up @@ -311,25 +315,26 @@ static void ValidateCreateObjectGcBehavior()
IntPtr trackerObjRaw = MockReferenceTrackerRuntime.CreateTrackerObject();

// Create the first native object wrapper and run the GC.
CreateObject();
GC.Collect();
CreateObject(cw, trackerObjRaw);
ForceGC();

// Try to create another wrapper for the same object. The above GC
// may have collected parts of the ComWrapper cache, but this should
// still work.
CreateObject();
CreateObject(cw, trackerObjRaw);
ForceGC();

Marshal.Release(trackerObjRaw);

[MethodImpl(MethodImplOptions.NoInlining)]
void CreateObject()
static void CreateObject(ComWrappers cw, IntPtr trackerObj)
{
var obj = (ITrackerObjectWrapper)cw.GetOrCreateObjectForComInstance(trackerObjRaw, CreateObjectFlags.None);
var obj = (ITrackerObjectWrapper)cw.GetOrCreateObjectForComInstance(trackerObj, CreateObjectFlags.None);
Assert.NotNull(obj);
}
}

[MethodImpl(MethodImplOptions.NoInlining)]
static void ValidateMappingAPIs()
{
Console.WriteLine($"Running {nameof(ValidateMappingAPIs)}...");
Expand Down Expand Up @@ -383,6 +388,7 @@ static void ValidateMappingAPIs()
Marshal.Release(unmanagedObjIUnknown);
}

[MethodImpl(MethodImplOptions.NoInlining)]
static void ValidateWrappersInstanceIsolation()
{
Console.WriteLine($"Running {nameof(ValidateWrappersInstanceIsolation)}...");
Expand Down