Skip to content

Compilation error: ApiCompat shows Trim analysis error for IEnumerableConverterFactoryHelpers #42902

Closed

Description

@vcsjones

Building master currently is giving me a compilation error.

Steps to reproduce:

  1. Check out master (bisect shows this was introduced in 994dca6)
  2. Run ./build.sh -rc release -s clr+libs

Eventually, the ApiCompat step fails:

/code/personal/dotnet/runtime/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Collection/IEnumerableConverterFactoryHelpers.cs(179,17): Trim analysis error IL2075: System.Text.Json.Serialization.IEnumerableConverterFactoryHelpers.GetImmutableDictionaryCreateRangeMethod(Type,Type,Type): The requirements declared via the 'DynamicallyAccessedMembersAttribute' on the return value of method 'System.Text.Json.Serialization.IEnumerableConverterFactoryHelpers.GetImmutableDictionaryConstructingType(Type)' don't match those on the implicit 'this' parameter of method 'System.Type.GetMethods()'. The source value must declare at least the same requirements as those declared on the target location it's assigned to [/code/personal/dotnet/runtime/src/libraries/src.proj]

and

code/personal/dotnet/runtime/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Collection/IEnumerableConverterFactoryHelpers.cs(187,25): Trim analysis error IL2060: System.Text.Json.Serialization.IEnumerableConverterFactoryHelpers.GetImmutableDictionaryCreateRangeMethod(Type,Type,Type): Call to System.Reflection.MethodInfo.MakeGenericMethod(Type[]) can not be statically analyzed. It's not possible to guarantee the availability of requirements of the generic method. [/code/personal/dotnet/runtime/src/libraries/src.proj]

Occurs on Ubuntu 20.04.

/cc @layomia

Activity

  1. removed
    untriagedNew issue has not been triaged by the area owner
    on Sep 30, 2020
  2. self-assigned this
    on Sep 30, 2020
  3. added this to the 6.0.0 milestone on Sep 30, 2020
  4. layomia commented on Sep 30, 2020

    @layomia
    Contributor

    It isn't ApiCompat that fails here. It is the new ILLinkTrimSharedFramework linker analysis target introduced in #40691. Local output:

    ApiCompat ->
    D:\repos\dotnet_runtime\src\libraries\System.Text.Json\src\System\Text\Json\Serialization\Converters\Collection\IEnumerableConverterFactoryHelpers.cs(179,17): Trim analysis error IL2075: System.Text.Json.Serialization.IEnumerableConverterFactoryHelpers.GetImmutableDictionaryCreateRangeMethod(Type,Type,Type): The requirements declared via the 'DynamicallyAccessedMembersAttribute' on the return value of method 'System.Text.Json.Serialization.IEnumerableConverterFactoryHelpers.GetImmutableDictionaryConstructingType(Type)' don't match those on the implicit 'this' parameter of method 'System.Type.GetMethods()'. The source value must declare at least the same requirements as those declared on the target location it's assigned to [D:\repos\dotnet_runtime\src\libraries\src.proj]
    D:\repos\dotnet_runtime\src\libraries\System.Text.Json\src\System\Text\Json\Serialization\Converters\Collection\IEnumerableConverterFactoryHelpers.cs(187,25): Trim analysis error IL2060: System.Text.Json.Serialization.IEnumerableConverterFactoryHelpers.GetImmutableDictionaryCreateRangeMethod(Type,Type,Type): Call to `System.Reflection.MethodInfo.MakeGenericMethod(Type[])` can not be statically analyzed. It's not possible to guarantee the availability of requirements of the generic method. [D:\repos\dotnet_runtime\src\libraries\src.proj]
      externals ->
      Microsoft.NETCore.Targets -> D:\repos\dotnet_runtime\artifacts\packages\Debug\Shipping\Microsoft.NETCore.Targets.6.0.0-dev.nupkg
      Microsoft.NETCore.Platforms -> D:\repos\dotnet_runtime\artifacts\packages\Debug\Shipping\Microsoft.NETCore.Platforms.6.0.0-dev.nupkg
      Microsoft.Extensions.Internal.Transport -> D:\repos\dotnet_runtime\artifacts\packages\Debug\NonShipping\Microsoft.Extensions.Internal.Transport.6.0.0-dev.nupkg
      runincontext -> D:\repos\dotnet_runtime\artifacts\bin\coreclr\Windows_NT.x64.Release\runincontext.dll
      ILCompiler.Reflection.ReadyToRun -> D:\repos\dotnet_runtime\artifacts\bin\coreclr\Windows_NT.x64.Release\ILCompiler.Reflection.ReadyToRun.dll
      R2RTest -> D:\repos\dotnet_runtime\artifacts\bin\coreclr\Windows_NT.x64.Release\R2RTest\R2RTest.dll
      R2RDump -> D:\repos\dotnet_runtime\artifacts\bin\coreclr\Windows_NT.x64.Release\R2RDump\R2RDump.dll
      dotnet-pgo -> D:\repos\dotnet_runtime\artifacts\bin\coreclr\Windows_NT.x64.Release\dotnet-pgo\dotnet-pgo.dll
    
    Build FAILED.
    
    D:\repos\dotnet_runtime\src\libraries\System.Text.Json\src\System\Text\Json\Serialization\Converters\Collection\IEnumerableConverterFactoryHelpers.cs(179,17): Trim analysis error IL2075: System.Text.Json.Serialization.IEnumerableConverterFactoryHelpers.GetImmutableDictionaryCreateRangeMethod(Type,Type,Type): The requirements declared via the 'DynamicallyAccessedMembersAttribute' on the return value of method 'System.Text.Json.Serialization.IEnumerableConverterFactoryHelpers.GetImmutableDictionaryConstructingType(Type)' don't match those on the implicit 'this' parameter of method 'System.Type.GetMethods()'. The source value must declare at least the same requirements as those declared on the target location it's assigned to [D:\repos\dotnet_runtime\src\libraries\src.proj]
    D:\repos\dotnet_runtime\src\libraries\System.Text.Json\src\System\Text\Json\Serialization\Converters\Collection\IEnumerableConverterFactoryHelpers.cs(187,25): Trim analysis error IL2060: System.Text.Json.Serialization.IEnumerableConverterFactoryHelpers.GetImmutableDictionaryCreateRangeMethod(Type,Type,Type): Call to `System.Reflection.MethodInfo.MakeGenericMethod(Type[])` can not be statically analyzed. It's not possible to guarantee the availability of requirements of the generic method. [D:\repos\dotnet_runtime\src\libraries\src.proj]
        0 Warning(s)
        2 Error(s)
    
    Time Elapsed 00:10:26.05
    Build failed.
    Some builds failed:
            Configuration: Debug, Architecture: x64
    

    I'll make a PR to add some extra logging to avoid this confusion in the future.


    It looks like the warning suppressions (this, and this) for the GetImmutableDictionaryCreateRangeMethod method need to be updated following #42835 which added a Type parameter. Making a PR now.

  5. vcsjones commented on Sep 30, 2020

    @vcsjones
    MemberAuthor

    Ah, my apologies, I read the build output wrong.

  6. added
    blocking-clean-ciBlocking PR or rolling runs of 'runtime' or 'runtime-extra-platforms'
    on Sep 30, 2020
  7. stephentoub commented on Sep 30, 2020

    @stephentoub
    Member

    How did this get merged when it breaks CI? Was it a case of two PRs getting merged independently/concurrently that together resulted in errors?

  8. layomia commented on Sep 30, 2020

    @layomia
    Contributor

    Yes, it was a case of two PRs getting merged independently that caused the errors. The changes from the first PR #42835 (that cause linker warnings when not suppressed) were not picked up by the CI system in the second PR #40691 (which makes such warnings visible).

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions