diff --git a/.github/workflows/verifyaotcompat.yml b/.github/workflows/verifyaotcompat.yml
index 6a599bb5369..e9beff96d64 100644
--- a/.github/workflows/verifyaotcompat.yml
+++ b/.github/workflows/verifyaotcompat.yml
@@ -11,7 +11,7 @@ jobs:
strategy:
fail-fast: false # ensures the entire test matrix is run, even if one permutation fails
matrix:
- os: [ ubuntu-latest ]
+ os: [ ubuntu-latest, windows-latest ]
version: [ net8.0 ]
runs-on: ${{ matrix.os }}
@@ -24,4 +24,3 @@ jobs:
- name: publish AOT testApp, assert static analysis warning count, and run the app
shell: pwsh
run: .\build\test-aot-compatibility.ps1 ${{ matrix.version }}
-
diff --git a/Directory.Packages.props b/Directory.Packages.props
index cdf796313dc..8d3bc258873 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -28,6 +28,7 @@
-->
+
diff --git a/build/test-aot-compatibility.ps1 b/build/test-aot-compatibility.ps1
index 37483488f50..39d36520346 100644
--- a/build/test-aot-compatibility.ps1
+++ b/build/test-aot-compatibility.ps1
@@ -1,24 +1,35 @@
param([string]$targetNetFramework)
$rootDirectory = Split-Path $PSScriptRoot -Parent
-$publishOutput = dotnet publish $rootDirectory/test/OpenTelemetry.AotCompatibility.TestApp/OpenTelemetry.AotCompatibility.TestApp.csproj -nodeReuse:false /p:UseSharedCompilation=false /p:ExposeExperimentalFeatures=true
+$publishOutput = dotnet publish $rootDirectory/test/OpenTelemetry.AotCompatibility.TestApp/OpenTelemetry.AotCompatibility.TestApp.csproj --framework $targetNetFramework -nodeReuse:false /p:UseSharedCompilation=false /p:ExposeExperimentalFeatures=true
$actualWarningCount = 0
foreach ($line in $($publishOutput -split "`r`n"))
{
- if ($line -like "*analysis warning IL*")
+ if (($line -like "*analysis warning IL*") -or ($line -like "*analysis error IL*"))
{
Write-Host $line
-
$actualWarningCount += 1
}
}
-pushd $rootDirectory/test/OpenTelemetry.AotCompatibility.TestApp/bin/Release/$targetNetFramework/linux-x64
+Write-Host "Actual warning count is:", $actualWarningCount
+$expectedWarningCount = 0
+
+if ($LastExitCode -ne 0)
+{
+ Write-Host "There was an error while publishing AotCompatibility Test App. LastExitCode is:", $LastExitCode
+ Write-Host $publishOutput
+}
+
+$runtime = $IsWindows ? "win-x64" : ($IsMacOS ? "macos-x64" : "linux-x64")
+$app = $IsWindows ? "./OpenTelemetry.AotCompatibility.TestApp.exe" : "./OpenTelemetry.AotCompatibility.TestApp"
+
+Push-Location $rootDirectory/test/OpenTelemetry.AotCompatibility.TestApp/bin/Release/$targetNetFramework/$runtime
Write-Host "Executing test App..."
-./OpenTelemetry.AotCompatibility.TestApp
+$app
Write-Host "Finished executing test App"
if ($LastExitCode -ne 0)
@@ -26,10 +37,7 @@ if ($LastExitCode -ne 0)
Write-Host "There was an error while executing AotCompatibility Test App. LastExitCode is:", $LastExitCode
}
-popd
-
-Write-Host "Actual warning count is:", $actualWarningCount
-$expectedWarningCount = 0
+Pop-Location
$testPassed = 0
if ($actualWarningCount -ne $expectedWarningCount)
diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md
index f4d9f9ffd2d..9f07dab60ed 100644
--- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md
+++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/CHANGELOG.md
@@ -2,6 +2,9 @@
## Unreleased
+* Fix native AoT warnings in `OpenTelemetry.Exporter.OpenTelemetryProtocol`.
+ ([#5520](https://github.com/open-telemetry/opentelemetry-dotnet/pull/5520))
+
## 1.8.0
Released 2024-Apr-02
diff --git a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OpenTelemetry.Exporter.OpenTelemetryProtocol.csproj b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OpenTelemetry.Exporter.OpenTelemetryProtocol.csproj
index 8f89cb12514..c10ab504dd2 100644
--- a/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OpenTelemetry.Exporter.OpenTelemetryProtocol.csproj
+++ b/src/OpenTelemetry.Exporter.OpenTelemetryProtocol/OpenTelemetry.Exporter.OpenTelemetryProtocol.csproj
@@ -8,6 +8,9 @@
disable
BUILDING_INTERNAL_PERSISTENT_STORAGE;$(DefineConstants)
+ true
+
+ $(NoWarn);SYSLIB1100;SYSLIB1101
@@ -19,6 +22,7 @@
+
diff --git a/src/Shared/Options/DelegatingOptionsFactory.cs b/src/Shared/Options/DelegatingOptionsFactory.cs
index 315b38caab2..b76fdc2babc 100644
--- a/src/Shared/Options/DelegatingOptionsFactory.cs
+++ b/src/Shared/Options/DelegatingOptionsFactory.cs
@@ -16,6 +16,9 @@ example of how that works.
#nullable enable
using System.Diagnostics;
+#if NET6_0_OR_GREATER
+using System.Diagnostics.CodeAnalysis;
+#endif
using Microsoft.Extensions.Configuration;
namespace Microsoft.Extensions.Options;
@@ -24,7 +27,11 @@ namespace Microsoft.Extensions.Options;
/// Implementation of .
///
/// The type of options being requested.
+#if NET6_0_OR_GREATER
+internal sealed class DelegatingOptionsFactory<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)] TOptions> :
+#else
internal sealed class DelegatingOptionsFactory :
+#endif
IOptionsFactory
where TOptions : class
{
diff --git a/src/Shared/Options/DelegatingOptionsFactoryServiceCollectionExtensions.cs b/src/Shared/Options/DelegatingOptionsFactoryServiceCollectionExtensions.cs
index 1140478f740..200e3b8c03f 100644
--- a/src/Shared/Options/DelegatingOptionsFactoryServiceCollectionExtensions.cs
+++ b/src/Shared/Options/DelegatingOptionsFactoryServiceCollectionExtensions.cs
@@ -4,6 +4,9 @@
#nullable enable
using System.Diagnostics;
+#if NET6_0_OR_GREATER
+using System.Diagnostics.CodeAnalysis;
+#endif
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
@@ -12,7 +15,11 @@ namespace Microsoft.Extensions.DependencyInjection;
internal static class DelegatingOptionsFactoryServiceCollectionExtensions
{
+#if NET6_0_OR_GREATER
+ public static IServiceCollection RegisterOptionsFactory<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] T>(
+#else
public static IServiceCollection RegisterOptionsFactory(
+#endif
this IServiceCollection services,
Func optionsFactoryFunc)
where T : class
@@ -33,7 +40,11 @@ public static IServiceCollection RegisterOptionsFactory(
return services!;
}
+#if NET6_0_OR_GREATER
+ public static IServiceCollection RegisterOptionsFactory<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] T>(
+#else
public static IServiceCollection RegisterOptionsFactory(
+#endif
this IServiceCollection services,
Func optionsFactoryFunc)
where T : class
diff --git a/test/OpenTelemetry.AotCompatibility.TestApp/OpenTelemetry.AotCompatibility.TestApp.csproj b/test/OpenTelemetry.AotCompatibility.TestApp/OpenTelemetry.AotCompatibility.TestApp.csproj
index bf5db5a04c1..0b7dffb58aa 100644
--- a/test/OpenTelemetry.AotCompatibility.TestApp/OpenTelemetry.AotCompatibility.TestApp.csproj
+++ b/test/OpenTelemetry.AotCompatibility.TestApp/OpenTelemetry.AotCompatibility.TestApp.csproj
@@ -2,7 +2,7 @@
Exe
- $(TargetFrameworksForAotCompatibilityTests)
+ $(TargetFrameworksForAotCompatibilityTests)
true
false
true