forked from rabbitmq/rabbitmq-dotnet-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Follow up to trimming changes for 6.x
The allows the 6.x library to be used in trimmed and native AOT'd applications without any warnings. Since the 6.x branch doesn't target net6.0+, it only targets netstandard2.0 and net462, the #if NET6_0_OR_GREATER checks don't do anything. To resolve this issue, and copy the trimming attributes into this library following the recommendation at https://devblogs.microsoft.com/dotnet/creating-aot-compatible-libraries/#approach-2-define-the-attributes-internally. This allows the library to apply the attributes without targeting net6.0+. Also moving DebugUtil to the test project - porting rabbitmq#1009 from the main branch. Contributes to rabbitmq#1410 Add AotCompatibility.TestApp Add PS1 to run test app Add AOT test to windows GHA
- Loading branch information
1 parent
55010ab
commit fcbd239
Showing
13 changed files
with
351 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
projects/AotCompatibility.TestApp/AotCompatibility.TestApp.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<!-- When targeting net7.0+, this can be updated to PublishAot. --> | ||
<PublishTrimmed>true</PublishTrimmed> | ||
<TrimmerSingleWarn>false</TrimmerSingleWarn> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<TrimmerRootAssembly Include="RabbitMQ.Client" /> | ||
<TrimmerRootAssembly Update="@(TrimmerRootAssembly)" Path="..\%(Identity)\%(Identity).csproj" /> | ||
<ProjectReference Include="@(TrimmerRootAssembly->'%(Path)')" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// publishing this app ensures all of the code in the referenced | ||
// assemblies are trim/AOT compatible. | ||
|
||
Console.WriteLine("Hello, World!"); |
59 changes: 59 additions & 0 deletions
59
projects/AotCompatibility.TestApp/test-aot-compatibility.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
$DebugPreference = "Continue" | ||
$ErrorActionPreference = 'Stop' | ||
# Set-PSDebug -Strict -Trace 1 | ||
Set-PSDebug -Off | ||
Set-StrictMode -Version 'Latest' -ErrorAction 'Stop' -Verbose | ||
|
||
New-Variable -Name rootDirectory -Option Constant -Value $PSScriptRoot | ||
Write-Host "[INFO] rootDirectory: $rootDirectory" | ||
|
||
$runtime = $IsWindows ? "win-x64" : ($IsMacOS ? "macos-x64" : "linux-x64") | ||
$app = $IsWindows ? "./AotCompatibility.TestApp.exe" : "./AotCompatibility.TestApp" | ||
|
||
$publishOutput = dotnet publish --runtime=$runtime $rootDirectory/AotCompatibility.TestApp.csproj -nodeReuse:false '/p:UseSharedCompilation=false' '/p:Configuration=Release' | ||
|
||
$actualWarningCount = 0 | ||
|
||
foreach ($line in $($publishOutput -split "`r`n")) | ||
{ | ||
if (($line -like "*analysis warning IL*") -or ($line -like "*analysis error IL*")) | ||
{ | ||
Write-Host $line | ||
$actualWarningCount += 1 | ||
} | ||
} | ||
|
||
Write-Host "Actual warning count is:", $actualWarningCount | ||
$expectedWarningCount = 0 | ||
|
||
if ($LastExitCode -ne 0) | ||
{ | ||
Write-Error -ErrorAction Continue -Message "[ERROR] error while publishing AotCompatibility Test App, LastExitCode is $LastExitCode" | ||
Write-Error -ErrorAction Continue -Message $publishOutput | ||
} | ||
|
||
Push-Location "$rootDirectory/bin/Release/net6.0/$runtime" | ||
try | ||
{ | ||
Write-Host "[INFO] executing: $app" | ||
$app | ||
Write-Host "[INFO] finished executing test app" | ||
|
||
if ($LastExitCode -ne 0) | ||
{ | ||
Write-Error -ErrorAction Continue -Message "[ERROR] there was an error while executing AotCompatibility Test App. LastExitCode is: $LastExitCode" | ||
} | ||
} | ||
finally | ||
{ | ||
Pop-Location | ||
} | ||
|
||
$exitCode = 0 | ||
if ($actualWarningCount -ne $expectedWarningCount) | ||
{ | ||
$exitCode = 1 | ||
Write-Error -ErrorAction Continue -Message "Actual warning count: $actualWarningCount is not as expected, which is: $expectedWarningCount" | ||
} | ||
|
||
Exit $exitCode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.