Skip to content
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

.NET Native AOT warnings from System.Net.Http #78367

Closed
JamesNK opened this issue Nov 15, 2022 · 5 comments
Closed

.NET Native AOT warnings from System.Net.Http #78367

JamesNK opened this issue Nov 15, 2022 · 5 comments

Comments

@JamesNK
Copy link
Member

JamesNK commented Nov 15, 2022

Description

Publishing an app with .NET Native AOT results in analysis warnings. Devs have confidence that their app works when no errors remain, so System.Net.Http shouldn't report warnings unless an AOT incompatible API is used from the assembly.

Reproduction Steps

  1. Create a console app
  2. Write code to create an HTTP request with HttpClient
  3. Publish with <PublishAot>true</PublishAot>

Expected behavior

No warning from System.Net.Http.

Actual behavior

I think it might be one error. I enabled this setting to get details: https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/trimming-options?pivots=dotnet-7-0#show-detailed-warnings

/_/src/libraries/System.Net.Http/src/System/Net/Http/DiagnosticsHandler.cs(333): AOT analysis warning IL3050: System.Net.Http.DiagnosticsHandler.Write<T>(DiagnosticSource,St
ring,!!0): Using member 'System.Diagnostics.DiagnosticSource.Write(String,Object)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. Diagn
osticSource may require creating new generic types or methods, which requires creating code at runtime. This may not work when AOT compiling. [C:\Development\Source\grpc-dot
net\examples\Transcoder\Server\Server.csproj]

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Nov 15, 2022
@ghost
Copy link

ghost commented Nov 15, 2022

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

Publishing an app with .NET Native AOT results in analysis warnings. Devs have confidence that their app works when no errors remain, so System.Net.Http shouldn't report warnings unless an AOT incompatible API is used from the assembly.

Reproduction Steps

  1. Create a console app
  2. Write code to create an HTTP request with HttpClient
  3. Publish with <PublishAot>true</PublishAot>

Expected behavior

No warning from System.Net.Http.

Actual behavior

/_/src/libraries/System.Net.Http/src/System/Net/Http/DiagnosticsHandler.cs(333): AOT analysis warning IL3050: System.Net.Http.DiagnosticsHandler.Write<T>(DiagnosticSource,St
ring,!!0): Using member 'System.Diagnostics.DiagnosticSource.Write(String,Object)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. Diagn
osticSource may require creating new generic types or methods, which requires creating code at runtime. This may not work when AOT compiling. [C:\Development\Source\grpc-dot
net\examples\Transcoder\Server\Server.csproj]

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Author: JamesNK
Assignees: -
Labels:

area-System.Net.Http

Milestone: -

@ghost
Copy link

ghost commented Nov 15, 2022

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

Publishing an app with .NET Native AOT results in analysis warnings. Devs have confidence that their app works when no errors remain, so System.Net.Http shouldn't report warnings unless an AOT incompatible API is used from the assembly.

Reproduction Steps

  1. Create a console app
  2. Write code to create an HTTP request with HttpClient
  3. Publish with <PublishAot>true</PublishAot>

Expected behavior

No warning from System.Net.Http.

Actual behavior

I think it might be one error. I enabled this setting to get details: https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/trimming-options?pivots=dotnet-7-0#show-detailed-warnings

/_/src/libraries/System.Net.Http/src/System/Net/Http/DiagnosticsHandler.cs(333): AOT analysis warning IL3050: System.Net.Http.DiagnosticsHandler.Write<T>(DiagnosticSource,St
ring,!!0): Using member 'System.Diagnostics.DiagnosticSource.Write(String,Object)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. Diagn
osticSource may require creating new generic types or methods, which requires creating code at runtime. This may not work when AOT compiling. [C:\Development\Source\grpc-dot
net\examples\Transcoder\Server\Server.csproj]

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Author: JamesNK
Assignees: -
Labels:

untriaged, area-NativeAOT-coreclr

Milestone: -

@MichalStrehovsky
Copy link
Member

The warning is potentially real if one enables EventSource (that we disabled by default in 7.0 for NativeAOT). But without opting in, it's just noise, because this won't throw.

@eerhardt made DiagnosticSource AOT-safe in #76109 and that would make the warning disappear (it shouldn't be warning in 8.0 anymore).

I know I said it probably doesn't meet the 7.0 bar in #76109 (comment) but I didn't consider the warning. The warning is annoying.

I triggered a backport on the PR to see if we can still slam it into the December update.

@MichalStrehovsky
Copy link
Member

Ok, cool the backport failed because the bot cannot comment on the old PR. Fix in arcade: dotnet/arcade#11637

Meanwhile, I submitted #78372 with a cherry-pick to get a headstart on the CI. It's end of the day for me so I'll let the US time zone chase this if it's at all possible to get this in.

@agocke agocke added this to the 7.0.x milestone Nov 22, 2022
@agocke agocke removed the untriaged New issue has not been triaged by the area owner label Nov 22, 2022
@MichalStrehovsky
Copy link
Member

This will be fixed in 7.0.3 (#78532).

@ghost ghost locked as resolved and limited conversation to collaborators Feb 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Archived in project
Development

No branches or pull requests

3 participants