Skip to content

Cannot pass list of DynamicallyAccessedMembers types #27997

Open
@idigra

Description

@idigra

Describe the bug

I'm trying to migrate existing codebase to .NET 7 (rc1).
Some uses to Core libraries that were added DynamicallyAccessedMembers forces me to pass DaynamicallyAccessedMembers attributes over the stack.
Some methods passed Type lists, but due to syntax limitation the DynamicallyAccessedMembers attribute cannot be applied directly on the generic actual argument.

To Reproduce

Pseudo code sample:

        IEnumerable<System.Reflection.PropertyInfo> ConcatenateMembersDemo(IList<Type> types)
        {
            return types.SelectMany(type =>
                type.GetProperties()); // <-- IL2070 here
        }

Exceptions (if any)

Compile error:

Error	IL2070	'this' argument does not satisfy 'DynamicallyAccessedMemberTypes.PublicProperties' in call to 'System.Type.GetProperties()'. The parameter 'type' of method 'lambda expression' does not have matching annotations. The source value must declare at least the same requirements as those declared on the target location it is assigned to.	OleDb.Core	P:\PQExcel2\submodules\PQDesktop\private\Product\Mashup\OleDb\Serialization\DateTimePageReader.cs	54	Active

Further technical details

  • Include the output of dotnet --info
    .NET SDK:
     Version:   7.0.100-rc.1.22431.12
     Commit:    f1cf61e1c0

    Runtime Environment:
     OS Name:     Windows
     OS Version:  10.0.19044
     OS Platform: Windows
     RID:         win10-x64
     Base Path:   C:\Program Files\dotnet\sdk\7.0.100-rc.1.22431.12\

    Host:
      Version:      7.0.0-rc.1.22426.10
      Architecture: x64
      Commit:       06aceb7015

    .NET SDKs installed:
      3.1.423 [C:\Program Files\dotnet\sdk]
      5.0.209 [C:\Program Files\dotnet\sdk]
      5.0.214 [C:\Program Files\dotnet\sdk]
      5.0.406 [C:\Program Files\dotnet\sdk]
      5.0.408 [C:\Program Files\dotnet\sdk]
      6.0.304 [C:\Program Files\dotnet\sdk]
      6.0.400 [C:\Program Files\dotnet\sdk]
      6.0.401 [C:\Program Files\dotnet\sdk]
      7.0.100-preview.7.22377.5 [C:\Program Files\dotnet\sdk]
      7.0.100-rc.1.22431.12 [C:\Program Files\dotnet\sdk]

    .NET runtimes installed:
      Microsoft.AspNetCore.App 3.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
      Microsoft.AspNetCore.App 3.1.29 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
      Microsoft.AspNetCore.App 5.0.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
      Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
      Microsoft.AspNetCore.App 6.0.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
      Microsoft.AspNetCore.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
      Microsoft.AspNetCore.App 7.0.0-preview.7.22376.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
      Microsoft.AspNetCore.App 7.0.0-rc.1.22427.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
      Microsoft.NETCore.App 3.1.23 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      Microsoft.NETCore.App 3.1.29 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      Microsoft.NETCore.App 5.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      Microsoft.NETCore.App 6.0.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      Microsoft.NETCore.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      Microsoft.NETCore.App 7.0.0-preview.7.22375.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      Microsoft.NETCore.App 7.0.0-rc.1.22426.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      Microsoft.WindowsDesktop.App 3.1.23 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
      Microsoft.WindowsDesktop.App 3.1.29 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
      Microsoft.WindowsDesktop.App 5.0.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
      Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
      Microsoft.WindowsDesktop.App 6.0.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
      Microsoft.WindowsDesktop.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
      Microsoft.WindowsDesktop.App 7.0.0-preview.7.22377.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
      Microsoft.WindowsDesktop.App 7.0.0-rc.1.22427.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

    Other architectures found:
      x86   [C:\Program Files (x86)\dotnet]
        registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

    Environment variables:
      Not set

    global.json file:
      Not found

    Learn more:
      https://aka.ms/dotnet/info

    Download .NET:
      https://aka.ms/dotnet/download
  • The IDE (VS / VS Code/ VS4Mac) you're running on, and its version
    17.4.0 Preview 2.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions