Skip to content

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

Closed

Description

@JamesNK

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

Activity

  1. ghost added
    untriaged
    on Nov 15, 2022
  2. MichalStrehovsky commented on Nov 15, 2022

    @MichalStrehovsky
    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.

  3. MichalStrehovsky commented on Nov 15, 2022

    @MichalStrehovsky
    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.

  4. added this to the 7.0.x milestone on Nov 22, 2022
  5. removed
    untriaged
    on Nov 22, 2022
  6. MichalStrehovsky commented on Jan 11, 2023

    @MichalStrehovsky
    Member

    This will be fixed in 7.0.3 (#78532).

  7. ghost locked as resolved and limited conversation to collaborators on Feb 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status
      No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions