Skip to content

NativeAOT IL9702 false positives when publishing shared libraries #609

Closed
@jpovixwm

Description

@jpovixwm

Hello.
Ever since #605 was merged, publishing any shared libraries appears to generate the IL9702 warning.
The issue can be easily reproduced with the NativeLibrary sample:

$ dotnet publish -p:NativeLib=Shared -p:SelfContained=true -r win-x64 -c release
Microsoft (R) Build Engine version 16.8.3+39993bd9d for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  Restored C:\runtimelab\samples\NativeLibrary\NativeLibrary.csproj (in 949 ms).
  NativeLibrary -> C:\runtimelab\samples\NativeLibrary\bin\release\net5.0\win-x64\NativeLibrary.dll
  Generating compatible native code. To optimize for size or speed, visit https://aka.ms/OptimizeCoreRT
/_/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs(1699): AOT analysis warning IL9702: System.Diagnostics.Tracing.EventSource.DecodeObject(Int32,Int32,EventData*&): Marshal.SizeOf was called with an unknown type. It might not be possible to compute the marshalling size at runtime. [C:\runtimelab\samples\NativeLibrary\NativeLibrary.csproj]
     Creating library bin\release\net5.0\win-x64\native\NativeLibrary.lib and object bin\release\net5.0\win-x64\native\NativeLibrary.exp
  NativeLibrary -> C:\runtimelab\samples\NativeLibrary\bin\release\net5.0\win-x64\publish\

The warning is generated even when all of the code in Class1.cs is commented out.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions