Skip to content

[Bug] System.Data warnings for .NET 8 WPF assemblies #9459

Description

@rohahn

Describe the bug
Running docfx metadata on a .NET 8 WPF DLL generates a bunch of wrong warnings.
Since we use --warningsAsErrors, this is a blocker for us. :(

The transitive dependency DirectWriteForwarder.dll references assemblies from .NET 8 and .NET Framework. UniversalAssemblyResolver cannot handle this.

To Reproduce

  1. Create a simple WPF assembly with
<TargetFramework>net8.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
  1. Configure docfx.json to process assemblies (the problem does not occur when processing project files)
{
  "metadata": [
    {
      "src": [
        {
          "files": ["artifacts/assemblies/*.dll"],
          "src": "./"
        }
      ],
      "dest": "api"
    }
  ]
}
  1. Execute dotnet docfx metadata .\docfx.json

This results in the following warnings:

dotnet docfx metadata .\docfx.json
                                                                           Using .NET Core SDK 8.0.100
Loading assembly C:/Users/hahn/Projects/DocFxTest/artifacts/assemblies/DocFxWarningTest.dll
warning: Unable to resolve assembly reference System.Data.SqlClient, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
warning: Unable to resolve assembly reference System.Data.Odbc, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
warning: Unable to resolve assembly reference System.Data.OleDb, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
warning: Unable to resolve assembly reference System.IO.Ports, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
warning: Unable to resolve assembly reference System.Runtime.Serialization.Schema, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
warning: Unable to resolve assembly reference System.ServiceModel.Syndication, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
warning: Unable to resolve assembly reference System.ServiceProcess.ServiceController, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Processing DocFxWarningTest
Creating output...


Build succeeded with warning.

    7 warning(s)
    0 error(s)

Expected behavior
There should be no warnings.

Context (please complete the following information):

  • OS: Windows 11
  • Docfx version: 2.74.0+0a19218b660d592013a1d75479f013d69a6c5d71

Additional context
I ran docfx in the debugger and was able to see where the dependency is coming from:

PresentationCore -> DirectWriteForwarder -> System.Data -> System.Data.SqlClient

DirectWriteForwarder is referencing System.Data from .NET Framework (C:\Windows\Microsoft.NET\Framework64\v4.0.30319\System.Data.dll).

image

UniversalAssemblyResolver.FindAssemblyFile in CompilationHelper is resolving C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.0\System.Data.dll instead, which is a reference assembly that only contains forwarded types.

image

Since these references with 0.0.0.0 version cannot be resolved, the warnings are generated.

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