Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/Compiler/CodeGen/IlxGenSupport.fs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ let GetDynamicallyAccessedMemberTypes (g: TcGlobals) =

ILType.Value(mkILNonGenericTySpec (tref))

let GetDynamicDependencyAttribute (g: TcGlobals) memberTypes ilType =
let GetDynamicDependencyAttribute (g: TcGlobals) memberTypes (ilType: ILType) =
let tref = g.attrib_DynamicDependencyAttribute.TypeRef

g.TryEmbedILType(
Expand All @@ -214,7 +214,12 @@ let GetDynamicDependencyAttribute (g: TcGlobals) memberTypes ilType =
let typIlMemberTypes =
ILType.Value(mkILNonGenericTySpec (g.enum_DynamicallyAccessedMemberTypes.TypeRef))

mkILCustomAttribute (tref, [ typIlMemberTypes; g.ilg.typ_Type ], [ ILAttribElem.Int32 memberTypes; ILAttribElem.Type(Some ilType) ], [])
mkILCustomAttribute (
tref,
[ typIlMemberTypes; g.ilg.typ_Type ],
[ ILAttribElem.Int32 memberTypes; ILAttribElem.TypeRef(Some ilType.TypeRef) ],
[]
)

/// Generate "modreq([mscorlib]System.Runtime.InteropServices.InAttribute)" on inref types.
let GenReadOnlyModReqIfNecessary (g: TcGlobals) ty ilTy =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,4 +339,8 @@ module Basic =
|> verifyCompile
|> shouldSucceed


[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"EnsureValidCustomAttributeBlob.fs"|])>]
let ``EnsureValidCustomAttributeBlob_fs`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
open System
open System.Reflection
open FSharp.Collections

let attributes = typeof<List<int>>.GetConstructor(BindingFlags.NonPublic ||| BindingFlags.Instance, Unchecked.defaultof<Binder>, Type.EmptyTypes, [||]).GetCustomAttributes()
for a in attributes do Console.WriteLine(a.ToString())
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@
!a item2) cil managed
{
.custom instance void System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes,
class [runtime]System.Type) = ( 01 00 60 06 00 00 43 43 6F 6D 70 61 72 65 30 37
class [runtime]System.Type) = ( 01 00 60 06 00 00 3D 43 6F 6D 70 61 72 65 30 37
2B 43 6F 6D 70 61 72 65 4D 69 63 72 6F 50 65 72
66 41 6E 64 43 6F 64 65 47 65 6E 65 72 61 74 69
6F 6E 54 65 73 74 73 2B 47 65 6E 65 72 69 63 4B
65 79 60 31 5B 5B 21 30 5D 5D 00 00 )
65 79 60 31 00 00 )
.custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@
!a item2) cil managed
{
.custom instance void [runtime]System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype [runtime]System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes,
class [runtime]System.Type) = ( 01 00 60 06 00 00 43 43 6F 6D 70 61 72 65 30 37
class [runtime]System.Type) = ( 01 00 60 06 00 00 3D 43 6F 6D 70 61 72 65 30 37
2B 43 6F 6D 70 61 72 65 4D 69 63 72 6F 50 65 72
66 41 6E 64 43 6F 64 65 47 65 6E 65 72 61 74 69
6F 6E 54 65 73 74 73 2B 47 65 6E 65 72 69 63 4B
65 79 60 31 5B 5B 21 30 5D 5D 00 00 )
65 79 60 31 00 00 )
.custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@
!a item2) cil managed
{
.custom instance void System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes,
class [runtime]System.Type) = ( 01 00 60 06 00 00 41 45 71 75 61 6C 73 30 36 2B
class [runtime]System.Type) = ( 01 00 60 06 00 00 3B 45 71 75 61 6C 73 30 36 2B
45 71 75 61 6C 73 4D 69 63 72 6F 50 65 72 66 41
6E 64 43 6F 64 65 47 65 6E 65 72 61 74 69 6F 6E
54 65 73 74 73 2B 47 65 6E 65 72 69 63 4B 65 79
60 31 5B 5B 21 30 5D 5D 00 00 )
60 31 00 00 )
.custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@
!a item2) cil managed
{
.custom instance void [runtime]System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype [runtime]System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes,
class [runtime]System.Type) = ( 01 00 60 06 00 00 41 45 71 75 61 6C 73 30 36 2B
class [runtime]System.Type) = ( 01 00 60 06 00 00 3B 45 71 75 61 6C 73 30 36 2B
45 71 75 61 6C 73 4D 69 63 72 6F 50 65 72 66 41
6E 64 43 6F 64 65 47 65 6E 65 72 61 74 69 6F 6E
54 65 73 74 73 2B 47 65 6E 65 72 69 63 4B 65 79
60 31 5B 5B 21 30 5D 5D 00 00 )
60 31 00 00 )
.custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,10 @@
!a item2) cil managed
{
.custom instance void System.Diagnostics.CodeAnalysis.DynamicDependencyAttribute::.ctor(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes,
class [runtime]System.Type) = ( 01 00 60 06 00 00 3D 48 61 73 68 30 39 2B 48 61
class [runtime]System.Type) = ( 01 00 60 06 00 00 37 48 61 73 68 30 39 2B 48 61
73 68 4D 69 63 72 6F 50 65 72 66 41 6E 64 43 6F
64 65 47 65 6E 65 72 61 74 69 6F 6E 54 65 73 74
73 2B 47 65 6E 65 72 69 63 4B 65 79 60 31 5B 5B
21 30 5D 5D 00 00 )
73 2B 47 65 6E 65 72 69 63 4B 65 79 60 31 00 00 )
.custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.custom instance void [runtime]System.Diagnostics.DebuggerNonUserCodeAttribute::.ctor() = ( 01 00 00 00 )

Expand Down
Loading