-
Notifications
You must be signed in to change notification settings - Fork 833
Closed
Labels
Milestone
Description
Describe the bug
Before .NET 7, assembly.GetTypes() returned only types that were defined in my assembly. Now, if the assembly in question is a library and not an executable, it additionally returns System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes and System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute.
This is true as of SDK 7.0.400; I have a vague recollection that it wasn't true of some earlier SDKs in the 7.0 series, but not sure about that.
I'm afraid I have absolutely no idea where this issue should go; dotnet/sdk is my best guess.
To Reproduce
Lib/Library1.fsproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="Thing.fs" />
</ItemGroup>
</Project>
Lib/Thing.fs:
namespace Foo
type Foo = FooApp/Program.fs:
namespace Foo
module Program =
[<EntryPoint>]
let main _ =
typeof<Foo>.Assembly.GetTypes ()
|> Array.iter (fun ty -> System.Console.WriteLine ty.FullName)
0
App/App.fsproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.fs"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Lib\Library1.fsproj" />
</ItemGroup>
</Project>
Running the app gives the following output, demonstrating the problem by its final two lines:
Lib.ThisAssembly
Foo.Foo
<StartupCode$Lib>.$Thing
<StartupCode$Lib>.$Lib.Version
<StartupCode$Lib>.$Lib.AssemblyInfo
<StartupCode$Lib>.$.NETStandard\,Version=v2.0.AssemblyAttributes
System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes
System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute
Further technical details
dotnet --info:
.NET SDK:
Version: 7.0.400
Commit: 73bf45718d
Runtime Environment:
OS Name: Mac OS X
OS Version: 14.0
OS Platform: Darwin
RID: osx-arm64
Base Path: /nix/store/27hjfsgvv7bklnid729j27kifig070lb-dotnet-sdk-7.0.400/sdk/7.0.400/
Host:
Version: 7.0.10
Architecture: arm64
Commit: a6dbb800a4
.NET SDKs installed:
7.0.400 [/nix/store/27hjfsgvv7bklnid729j27kifig070lb-dotnet-sdk-7.0.400/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 7.0.10 [/nix/store/27hjfsgvv7bklnid729j27kifig070lb-dotnet-sdk-7.0.400/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 7.0.10 [/nix/store/27hjfsgvv7bklnid729j27kifig070lb-dotnet-sdk-7.0.400/shared/Microsoft.NETCore.App]
Other architectures found:
None
Environment variables:
Not set
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
No IDE necessary.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done