Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Struct with self-referencing ImmutableArray static field causes TypeLoadException #104519

Closed
JakeYallop opened this issue Jul 7, 2024 · 1 comment

Comments

@JakeYallop
Copy link
Contributor

Description

A struct with a static ImmuatableArray field that references the enclosing struct causes a TypeLoadException on start.

Reproduction Steps

sharplab

dotnet new console
Console.WriteLine(new MyStruct());

public struct MyStruct
{
    static ImmutableArray<MyStruct> One;
}

Expected behavior

No error

Actual behavior

Unhandled exception. System.TypeLoadException: Could not load type 'MyStruct' from assembly 'StructRepro, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
   at Program.<Main>$(String[] args)

Regression?

No - reproducible on .NET 8/7/6 as well.

Known Workarounds

No response

Configuration

.NET SDK:
 Version:           9.0.100-preview.5.24307.3
 Commit:            35b2c21ea6
 Workload version:  9.0.100-manifests.6407b7e4
 MSBuild version:   17.11.0-preview-24279-02+b963c24ef

Other information

No response

@JakeYallop JakeYallop changed the title Struct with self-referencing ImmutableArray static field creates TypeLoadException on run Struct with self-referencing ImmutableArray static field causes TypeLoadException Jul 7, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Jul 7, 2024
@JakeYallop JakeYallop changed the title Struct with self-referencing ImmutableArray static field causes TypeLoadException Struct with self-referencing ImmutableArray static field causes TypeLoadException Jul 7, 2024
@JakeYallop
Copy link
Contributor Author

JakeYallop commented Jul 7, 2024

Duplicate of #100077 - completely forgot to check for dupes before opening this!

@JakeYallop JakeYallop closed this as not planned Won't fix, can't repro, duplicate, stale Jul 7, 2024
@dotnet-policy-service dotnet-policy-service bot removed the untriaged New issue has not been triaged by the area owner label Jul 7, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Aug 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant