Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public static unsafe IntPtr AllocateTypeAssociatedMemory(Type type, int size)
ArgumentOutOfRangeException.ThrowIfNegative(size);

// We don't support unloading; the memory will never be freed.
return (IntPtr)NativeMemory.Alloc((uint)size);
return (IntPtr)NativeMemory.AllocZeroed((uint)size);
}

public static void PrepareDelegate(Delegate d)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
<EnableLibraryImportGenerator>true</EnableLibraryImportGenerator>
<!-- These tests pull the attributes from Ancillary.Interop, so we don't need to include the attribute sources in this assembly. -->
<IncludeLibraryImportGeneratorSources>false</IncludeLibraryImportGeneratorSources>
<!-- suppress warning when referencing architecture specific NativeExports.csproj -->
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
<ReferencesNativeExports>true</ReferencesNativeExports>
</PropertyGroup>

<ItemGroup>
<Compile Include="$(CommonPath)DisableRuntimeMarshalling.cs" Link="Common\DisableRuntimeMarshalling.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\gen\ComInterfaceGenerator\ComInterfaceGenerator.csproj" ReferenceOutputAssembly="false" OutputItemType="Analyzer" />
<ProjectReference Include="..\Ancillary.Interop\Ancillary.Interop.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project>
<PropertyGroup Condition="'$(ReferencesNativeExports)' == 'true'">
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
<IlcExportUnmanagedEntrypoints>true</IlcExportUnmanagedEntrypoints>
</PropertyGroup>
<!-- Expose unmanaged entry points from NativeExports -->
<ItemGroup Condition="'$(ReferencesNativeExports)' == 'true'">
<UnmanagedEntryPointsAssembly Include="Microsoft.Interop.Tests.NativeExports" />
<DirectPInvoke Include="Microsoft.Interop.Tests.NativeExportsNE" />
</ItemGroup>
<Import Project="$([MSBuild]::GetPathOfFileAbove(Directory.Build.targets, $(MSBuildThisFileDirectory)..))" />
</Project>
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<EnableLibraryImportGenerator>true</EnableLibraryImportGenerator>
<IncludeLibraryImportGeneratorSources>false</IncludeLibraryImportGeneratorSources>
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
<ReferencesNativeExports>true</ReferencesNativeExports>
</PropertyGroup>

<ItemGroup>
<Compile Include="$(CommonPath)DisableRuntimeMarshalling.cs"
Link="Common\DisableRuntimeMarshalling.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Ancillary.Interop\Ancillary.Interop.csproj" />
<ProjectReference Include="..\TestAssets\NativeExports\NativeExports.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,12 @@ public static void AllocateTypeAssociatedMemoryInvalidArguments()

[Fact]
[SkipOnMono("Not presently implemented on Mono")]
public static void AllocateTypeAssociatedMemoryValidArguments()
public static unsafe void AllocateTypeAssociatedMemoryValidArguments()
{
IntPtr memory = RuntimeHelpers.AllocateTypeAssociatedMemory(typeof(RuntimeHelpersTests), 32);
Assert.NotEqual(memory, IntPtr.Zero);
// Validate that the memory is zeroed out
Assert.True(new Span<byte>((void*)memory, 32).SequenceEqual(new byte[32]));
}

[StructLayoutAttribute(LayoutKind.Sequential)]
Expand Down
6 changes: 0 additions & 6 deletions src/libraries/tests.proj
Original file line number Diff line number Diff line change
Expand Up @@ -453,12 +453,6 @@
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Runtime.InteropServices.JavaScript\tests\JSImportGenerator.UnitTest\JSImportGenerator.Unit.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)Microsoft.Extensions.Configuration.Binder\tests\SourceGenerationTests\Microsoft.Extensions.Configuration.Binder.SourceGeneration.Tests.csproj" />

<!-- Depends on DNNE. Not particularly interesting because it tests marshalling-less p/invoke only. Low priority -->
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Runtime.InteropServices\tests\LibraryImportGenerator.Tests\LibraryImportGenerator.Tests.csproj" />

<!-- Depends on DNNE -->
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.Runtime.InteropServices\tests\ComInterfaceGenerator.Tests\ComInterfaceGenerator.Tests.csproj" />

<!-- Many test failures due to trimming and MakeGeneric. XmlSerializer is not currently supported with NativeAOT. Low priority -->
<ProjectExclusions Include="$(MSBuildThisFileDirectory)Microsoft.XmlSerializer.Generator\tests\Microsoft.XmlSerializer.Generator.Tests.csproj" />
<ProjectExclusions Include="$(MSBuildThisFileDirectory)System.ServiceModel.Syndication\tests\System.ServiceModel.Syndication.Tests.csproj" />
Expand Down