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

Invalid custom attribute blob on FSharpList..ctor #15140

Closed
MichalStrehovsky opened this issue Apr 25, 2023 · 2 comments · Fixed by #15152
Closed

Invalid custom attribute blob on FSharpList..ctor #15140

MichalStrehovsky opened this issue Apr 25, 2023 · 2 comments · Fixed by #15152

Comments

@MichalStrehovsky
Copy link
Member

MichalStrehovsky commented Apr 25, 2023

The custom attribute blob on FSharpList..ctor is invalid:

.method assembly specialname rtspecialname 
        instance void  .ctor() cil managed
{
  .custom instance void System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes,
                                                                                          class [netstandard]System.Type) = ( 01 00 E0 07 00 00 2F 4D 69 63 72 6F 73 6F 66 74   // ....../Microsoft
                                                                                                                              2E 46 53 68 61 72 70 2E 43 6F 6C 6C 65 63 74 69   // .FSharp.Collecti
                                                                                                                              6F 6E 73 2E 46 53 68 61 72 70 4C 69 73 74 60 31   // ons.FSharpList`1
                                                                                                                              5B 5B 21 30 5D 5D 00 00 )                         // [[!0]]..
  .custom instance void [netstandard]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) 
  .custom instance void [netstandard]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 ) 
  // Code size       7 (0x7)
  .maxstack  8
  IL_0000:  ldarg.0
  IL_0001:  call       instance void [netstandard]System.Object::.ctor()
  IL_0006:  ret
} // end of method FSharpList`1::.ctor

Notice the FSharpList`1[[!0]] part. The intent of the !0 is to represent the first generic argument but that's not something the SerString format supports. See dotnet/runtime#4416 for a spec of the format.

Following C# program throws System.TypeLoadException: 'Could not load type '!0' from assembly 'FSharp.Core, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.' (sorry, I have no clue how to write this in F#):

using System;
using System.Reflection;
using Microsoft.FSharp.Collections;

var attr = typeof(FSharpList<int>).GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, Type.EmptyTypes).GetCustomAttributes();
foreach (var a in attr)
    Console.WriteLine(a);
@eerhardt
Copy link
Member

FYI @KevinRansom

@vzarytovskii
Copy link
Member

vzarytovskii commented Apr 25, 2023

It seems that #15079 broke it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants