Skip to content

Commit 2dff7cd

Browse files
authored
Dllimport generator build and test fixes (#59658)
1 parent d81945e commit 2dff7cd

File tree

21 files changed

+206
-26
lines changed

21 files changed

+206
-26
lines changed

eng/Versions.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
<XunitPerformanceApiPackageVersion>1.0.0-beta-build0015</XunitPerformanceApiPackageVersion>
145145
<MicrosoftDiagnosticsToolsRuntimeClientVersion>1.0.4-preview6.19326.1</MicrosoftDiagnosticsToolsRuntimeClientVersion>
146146
<MicrosoftDiagnosticsNETCoreClientVersion>0.2.61701</MicrosoftDiagnosticsNETCoreClientVersion>
147-
<DNNEVersion>1.0.23</DNNEVersion>
147+
<DNNEVersion>1.0.26</DNNEVersion>
148148
<!--
149149
These are used as reference assemblies only, so they must not take a ProdCon/source-build
150150
version. Insert "RefOnly" to avoid assignment via PVP.

eng/generators.targets

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333
<ItemGroup Condition="'@(EnabledGenerators)' != ''
3434
and @(EnabledGenerators->AnyHaveMetadataValue('Identity', 'DllImportGenerator'))
3535
and '$(IncludeDllImportGeneratorSources)' == 'true'">
36-
<ProjectReference Include="$(LibrariesProjectRoot)System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
37-
<Compile Include="$(LibrariesProjectRoot)Common/src/System/Runtime/InteropServices/GeneratedDllImportAttribute.cs" />
38-
<Compile Include="$(LibrariesProjectRoot)Common/src/System/Runtime/InteropServices/GeneratedMarshallingAttribute.cs" />
39-
<Compile Include="$(LibrariesProjectRoot)Common/src/System/Runtime/InteropServices/ArrayMarshaller.cs" />
36+
<ProjectReference Include="$(LibrariesProjectRoot)System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
37+
<Compile Include="$(LibrariesProjectRoot)Common\src\System\Runtime\InteropServices\GeneratedDllImportAttribute.cs" />
38+
<Compile Include="$(LibrariesProjectRoot)Common\src\System\Runtime\InteropServices\GeneratedMarshallingAttribute.cs" />
39+
<Compile Include="$(LibrariesProjectRoot)Common\src\System\Runtime\InteropServices\ArrayMarshaller.cs" />
4040
</ItemGroup>
4141

4242
<Target Name="ConfigureGenerators"
@@ -59,7 +59,7 @@
5959
<DefineConstants>$(DefineConstants);DLLIMPORTGENERATOR_INTERNALUNSAFE</DefineConstants>
6060
</PropertyGroup>
6161

62-
<MSBuild Projects="$(LibrariesProjectRoot)System.Runtime.InteropServices/gen/DllImportGenerator/DllImportGenerator.csproj"
62+
<MSBuild Projects="$(LibrariesProjectRoot)System.Runtime.InteropServices\gen\DllImportGenerator\DllImportGenerator.csproj"
6363
RemoveProperties="TargetFramework">
6464
<Output TaskParameter="TargetOutputs" PropertyName="DllImportGeneratorOutputPath" />
6565
</MSBuild>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Output the toolchain information required to create a command line that builds with the right rootfs as XML
2+
3+
set (ADDED_COMPILE_OPTIONS)
4+
if (CMAKE_SCRIPT_MODE_FILE)
5+
# add_compile_options and add_definitions can't be used in scripts,
6+
# so override the implementations to append to a local property
7+
macro(add_compile_options)
8+
list(APPEND ADDED_COMPILE_OPTIONS ${ARGV})
9+
endmacro()
10+
macro(add_definitions)
11+
list(APPEND ADDED_COMPILE_OPTIONS ${ARGV})
12+
endmacro()
13+
endif()
14+
15+
include(${CMAKE_CURRENT_LIST_DIR}/../common/cross/toolchain.cmake)
16+
17+
message("<toolchain-info>")
18+
message("<target-triple>${TOOLCHAIN}</target-triple>")
19+
message("<linker-args>${CMAKE_SHARED_LINKER_FLAGS_INIT}</linker-args>")
20+
message("<compiler-args>${ADDED_COMPILE_OPTIONS}</compiler-args>")
21+
message("</toolchain-info>")

src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CloseHandle.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@ internal static partial class Interop
88
{
99
internal static partial class Kernel32
1010
{
11-
#if DLLIMPORTGENERATOR_ENABLED
12-
[GeneratedDllImport(Libraries.Kernel32, SetLastError = true)]
13-
internal static partial bool CloseHandle(IntPtr handle);
14-
#else
11+
#pragma warning disable DLLIMPORTGENANALYZER015 // Use 'GeneratedDllImportAttribute' instead of 'DllImportAttribute' to generate P/Invoke marshalling code at compile time
12+
// Disabled since CloseHandle is a QCall in some scenarios and DllImportGenerator doesn't support QCalls.
1513
[DllImport(Libraries.Kernel32, SetLastError = true)]
1614
internal static extern bool CloseHandle(IntPtr handle);
17-
#endif
1815
}
1916
}

src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FormatMessage.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,18 @@ internal static partial class Kernel32
1515
private const int FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x00000100;
1616
private const int ERROR_INSUFFICIENT_BUFFER = 0x7A;
1717

18-
#if DLLIMPORTGENERATOR_ENABLED
19-
[GeneratedDllImport(Libraries.Kernel32, EntryPoint = "FormatMessageW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
20-
private static unsafe partial int FormatMessage(
21-
#else
18+
#pragma warning disable DLLIMPORTGENANALYZER015 // Use 'GeneratedDllImportAttribute' instead of 'DllImportAttribute' to generate P/Invoke marshalling code at compile time
19+
// Disabled since FormatMessage is a QCall in some scenarios and DllImportGenerator doesn't support QCalls.
2220
[DllImport(Libraries.Kernel32, EntryPoint = "FormatMessageW", BestFitMapping = true, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
2321
private static extern unsafe int FormatMessage(
24-
#endif
2522
int dwFlags,
2623
IntPtr lpSource,
2724
uint dwMessageId,
2825
int dwLanguageId,
2926
void* lpBuffer,
3027
int nSize,
3128
IntPtr arguments);
29+
#pragma warning restore DLLIMPORTGENANALYZER015
3230

3331
/// <summary>
3432
/// Returns a string message for the specified Win32 error code.

src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFullPathNameW.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ internal static partial class Kernel32
1616
internal static partial uint GetFullPathNameW(
1717
#else
1818
[DllImport(Libraries.Kernel32, BestFitMapping = false, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
19-
internal static extern uint GetFullPathNameW(
2019
#endif
20+
internal static extern uint GetFullPathNameW(
2121
ref char lpFileName,
2222
uint nBufferLength,
2323
ref char lpBuffer,

src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetLongPathNameW.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ internal static partial class Kernel32
1515
internal static partial uint GetLongPathNameW(
1616
#else
1717
[DllImport(Libraries.Kernel32, BestFitMapping = false, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
18-
internal static extern uint GetLongPathNameW(
1918
#endif
19+
internal static extern uint GetLongPathNameW(
2020
ref char lpszShortPath,
2121
ref char lpszLongPath,
2222
uint cchBuffer);
23+
2324
}
2425
}

src/libraries/System.IO.Compression.ZipFile/tests/System.IO.Compression.ZipFile.Tests.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3+
<EnableDllImportGenerator>true</EnableDllImportGenerator>
4+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
35
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser</TargetFrameworks>
46
</PropertyGroup>
57
<ItemGroup>

src/libraries/System.IO.FileSystem/tests/DisabledFileLockingTests/System.IO.FileSystem.DisabledFileLocking.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<PropertyGroup>
33
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
44
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
5+
<EnableDllImportGenerator>true</EnableDllImportGenerator>
56
<!-- file locking can't be disabled on Windows -->
67
<TargetFrameworks>$(NetCoreAppCurrent)-Unix</TargetFrameworks>
78

src/libraries/System.Net.Http/tests/FunctionalTests/System.Net.Http.Functional.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
88
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
99
<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Linux;$(NetCoreAppCurrent)-Browser;$(NetCoreAppCurrent)-OSX</TargetFrameworks>
10+
<EnableDllImportGenerator>true</EnableDllImportGenerator>
1011
</PropertyGroup>
1112

1213
<ItemGroup>

0 commit comments

Comments
 (0)