-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE REQ] Resolve Native AOT Warnings in Azure.Core #35572
Comments
Thank you for filing this, @eerhardt. We'll start to take a look over the next couple of weeks and reach out once we know more. |
Thanks, @jsquire. As I look through some of the warnings from the above steps, I see that the following code uses System.Linq.Expressions: azure-sdk-for-net/sdk/core/Azure.Core/src/Shared/DiagnosticScope.cs Lines 418 to 812 in 30cf933
This is unfortunate because:
Looking at the comment on that code, it appears that this code is working around not being able to reference a newer System.Diagnostics.DiagnosticSource with the necessary APIs. Would it make sense to update to a newer System.Diagnostics.DiagnosticSource version as part of this work? Then the Linq.Expressions usage could be removed? |
@JoshLove-msft would be best able to offer an opinion on whether there's something that we still need in the older package. |
One option (if we really needed to work around this) would be to add a |
On a related note, we should also work on trimming: #24238. The whole assembly doesn't need to be AOT-compatible if we properly annotate what won't work (and people don't use it). |
@eerhardt, one thing we'd like to understand, related to your comment:
This sounds like there is an eventual goal of resolving all of the Native AOT warnings in Azure.Core (although not included in the scope of work represented by this issue). I'd like to understand this better, per @heaths's comment above. Given that non-compliant types can be trimmed, what would be the benefit of 100% AOT-compatibility for Azure.Core? Or conversely, what would we lose by adding new non-compliant types to Azure.Core that would prevent us from eventually reaching this goal? |
My first goal is to get Open Telemetry in an ASP.NET app working with no warnings. Getting the whole The advantage of annotating incompatible APIs is that any callers of the incompatible APIs will get warnings where they call the incompatible API. This is preferred because callers know immediately what they are doing isn’t trim/AOT-compatible, and there is a custom message you can use to explain why it isn’t compatible. When the incompatible code isn't annotated, the dev won't get warnings from their code (at build time). But instead, they will see the warnings at publish-time coming from within the Azure.Core library itself - which they can't fix. |
Duplicate: #38773 |
@m-redding I don't think this is resolved yet. See #39410 |
Library name
Azure.Core
Please describe the feature.
In .NET 8 our goal is to enable a subset of ASP.NET functionality to support publishing with Native AOT. For more information on this goal, see ASP.NET Core updates in .NET 8 Preview 3 - ASP.NET Core support for native AOT and Support publishing ASP.NET Core API apps with Native AOT. This work is being done with a focus on enhancing .NET for "Cloud Native" applications. One important aspect for cloud apps is being able to monitor and diagnose the deployed application. With this in mind, our intent is to enable Open Telemetry support for Native AOT (for Microsoft employees, see the internal work item). Getting the Azure.Monitor.OpenTelemetry.Exporter compatible with AOT is important so those Open Telemetry events can be exported to Azure Monitor.
Azure.Monitor.OpenTelemetry.Exporter
has a dependency onAzure.Core
and parts ofAzure.Core
are not compatible with Native AOT. The best way to prepare a library for Native AOT is following the guidance in:Using that information, we should resolve the Native AOT warnings coming from Azure.Core, starting first with the code used by
Azure.Monitor.OpenTelemetry.Exporter
. To get the Native AOT warnings for the Azure.Core library, you can follow these steps (taken from the above docs):dotnet publish
the following application:Azure.Core
.I have done the above with the current code, and here are the warnings I am seeing from
Azure.Core
:See the above 2 documentation links for more information on these warnings, and how to address them. (Or reach out to me and I will gladly help as well.)
cc @KrzysztofCwalina @jsquire @annelo-msft @pallavit @tg-msft @Yun-Ting
The text was updated successfully, but these errors were encountered: