Azure / azure-sdk-for-net

This repository is for active development of the Azure SDK for .NET. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/dotnet/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-net.
MIT License
5.17k stars 4.54k forks source link

[BUG] .NET Native Gatekeeper: ArrayBackedPropertyBag has an explicit default constructor which is unsupported #43500

Open bostelk opened 2 months ago

bostelk commented 2 months ago

Library name and version

Azure.Core.dll 1.3800.24.12602

Describe the bug

In my UWP application, when "static analysis for .NET Native" is enabled, the build will fail. The .net native compiler when run, returns a non-successful exit code 1. If I review the .NET Native Gatekeeper output I see that there's an error message related to Azure.Core.ArrayBackedPropertyBag. I'm not sure how harmful this error is because the application will still run when the option is disabled.

It is not clear that this error is causing the build to be unsuccessful but it's the only error message I can find when I run "ilc.exe --gatekeeper ". For the time being, the static analysis option can be disabled to get a successful build.

The error Azure.Core : Gatekeeper error GK0018 : GK0018 Value type 'Azure.Core.ArrayBackedPropertyBag' has an explicit default constructor which is unsupported. Use an initialization function instead.

Expected behavior

The build is successful when static analysis is enabled.

Actual behavior

A build error is raised and the build fails.

Reproduction Steps

You could run "ilc.exe --gatekeeper " with an appropriate gkargs file. Or create a new UWP project and reference Azure. You should check "Compile with .NET Native tool chain" and "Enable static analysis for .NET Native" options. I can try to get a minimal project together later this week.

Environment

Microsoft Visual Studio Community 2022 Version 17.6.4 VisualStudio.17.Release/17.6.4+33815.320 Microsoft .NET Framework Version 4.8.09032

runtime.win10-x64.microsoft.net.native.compiler 2.2.10-rel-29722-00

github-actions[bot] commented 2 months ago

Thank you for your feedback. Tagging and routing to the team member best able to assist.

annelo-msft commented 2 months ago

I can try to get a minimal project together later this week.

Yes, this would be helpful to have to ensure when we create a repro that we are replicating the precise issue you're seeing. If it is also easy to share a little more about how your UWP app is using Azure.Core (what types is it referencing, e.g.?), that would be helpful context as well. If you also have a representative gkargs file you're willing to share, that would be helpful as well. Many thanks!

github-actions[bot] commented 2 months ago

Hi @bostelk. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.

bostelk commented 2 months ago

Hi Anne,

Thank you for the super fast response! Here's a minimal UWP project to reproduce the issue: GateKeeper.zip. I created a empty HttpMessage to instantiate the affected type. I can zip up an ilc workspace if that's helpful.

premiaware commented 1 month ago

I have same issue with Azure.Storage.Blobs version 12.20.0

MSBUILD : error : ILT0038: 'Azure.Core.ArrayBackedPropertyBag`2' is a value type with a default constructor. Value types with default constructors are not currently supported. Consider using an explicit initialization function instead

if I roolback Azure.Storage.Blobs to version 12.19.1 all working fine !!!!