From de6660ed4fc2f4f18602ad9131a9c7c3482ed276 Mon Sep 17 00:00:00 2001 From: Kevin Ransom Date: Tue, 11 Apr 2023 14:44:16 -0700 Subject: [PATCH 1/2] Fix attribute embedding determinism --- src/Compiler/CodeGen/IlxGen.fs | 2 +- src/Compiler/TypedTree/TcGlobals.fs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Compiler/CodeGen/IlxGen.fs b/src/Compiler/CodeGen/IlxGen.fs index 62125570cf2..d58bfc90467 100644 --- a/src/Compiler/CodeGen/IlxGen.fs +++ b/src/Compiler/CodeGen/IlxGen.fs @@ -662,7 +662,7 @@ let mkLocalPrivateAttributeWithPropertyConstructors (cenv, name: string, attrPro mkLdfldMethodDef ($"get_{name}", ILMemberAccess.Public, false, ilTy, fieldName, ilType, []) )), (cenv.g.AddMethodGeneratedAttributes( - mkStsfldMethodDef ($"set_{name}", ILMemberAccess.Private, false, ilTy, fieldName, ilType, []) + mkStsfldMethodDef ($"set_{name}", ILMemberAccess.Public, false, ilTy, fieldName, ilType, []) )), (cenv.g.AddPropertyGeneratedAttributes( mkILNonGenericInstanceProperty (name, ilTypeRef, ilType, PropertyAttributes.None, emptyILCustomAttrs) diff --git a/src/Compiler/TypedTree/TcGlobals.fs b/src/Compiler/TypedTree/TcGlobals.fs index 77ba385c520..340c1a1c5e7 100755 --- a/src/Compiler/TypedTree/TcGlobals.fs +++ b/src/Compiler/TypedTree/TcGlobals.fs @@ -9,6 +9,7 @@ module internal FSharp.Compiler.TcGlobals open System.Collections.Concurrent +open System.Linq open System.Diagnostics open Internal.Utilities.Library @@ -1052,7 +1053,7 @@ type TcGlobals( member _.embeddedTypeDefs = embeddedILTypeDefs.Values |> Seq.toList member _.tryRemoveEmbeddedILTypeDefs () = [ - for key in embeddedILTypeDefs.Keys do + for key in embeddedILTypeDefs.Keys.OrderBy(fun k -> k) do match (embeddedILTypeDefs.TryRemove(key)) with | true, ilTypeDef -> yield ilTypeDef | false, _ -> () From 064a662f5ee28bc149307af4e735a4102b8a8303 Mon Sep 17 00:00:00 2001 From: Kevin Ransom Date: Tue, 11 Apr 2023 22:18:29 -0700 Subject: [PATCH 2/2] Moar tests --- .../EmittedIL/GenericComparison/Compare06.fsx.il.net472.bsl | 4 ++-- .../EmittedIL/GenericComparison/Equals05.fsx.il.net472.bsl | 4 ++-- .../EmittedIL/GenericComparison/Hash08.fsx.il.net472.bsl | 4 ++-- .../TestFunctions/TestFunction17.fs.il.net472.release.bsl | 4 ++-- .../TestFunctions/TestFunction24.fs.il.net472.release.bsl | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Compare06.fsx.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Compare06.fsx.il.net472.bsl index 2c11296dbe3..46954760712 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Compare06.fsx.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Compare06.fsx.il.net472.bsl @@ -586,7 +586,7 @@ IL_0006: ret } - .method private hidebysig specialname instance void + .method public hidebysig specialname instance void set_Type(class [runtime]System.Type 'value') cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) @@ -611,7 +611,7 @@ IL_0006: ret } - .method private hidebysig specialname instance void + .method public hidebysig specialname instance void set_MemberType(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes 'value') cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals05.fsx.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals05.fsx.il.net472.bsl index c626341997d..9152d3d106a 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals05.fsx.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Equals05.fsx.il.net472.bsl @@ -588,7 +588,7 @@ IL_0006: ret } - .method private hidebysig specialname instance void + .method public hidebysig specialname instance void set_Type(class [runtime]System.Type 'value') cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) @@ -613,7 +613,7 @@ IL_0006: ret } - .method private hidebysig specialname instance void + .method public hidebysig specialname instance void set_MemberType(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes 'value') cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Hash08.fsx.il.net472.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Hash08.fsx.il.net472.bsl index ce74f3ca8f8..5cdac846b0e 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Hash08.fsx.il.net472.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/GenericComparison/Hash08.fsx.il.net472.bsl @@ -576,7 +576,7 @@ IL_0006: ret } - .method private hidebysig specialname instance void + .method public hidebysig specialname instance void set_Type(class [runtime]System.Type 'value') cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) @@ -601,7 +601,7 @@ IL_0006: ret } - .method private hidebysig specialname instance void + .method public hidebysig specialname instance void set_MemberType(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes 'value') cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction17.fs.il.net472.release.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction17.fs.il.net472.release.bsl index 2798b0c326e..af0bd5de881 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction17.fs.il.net472.release.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction17.fs.il.net472.release.bsl @@ -587,7 +587,7 @@ IL_0006: ret } - .method private hidebysig specialname instance void + .method public hidebysig specialname instance void set_Type(class [runtime]System.Type 'value') cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) @@ -612,7 +612,7 @@ IL_0006: ret } - .method private hidebysig specialname instance void + .method public hidebysig specialname instance void set_MemberType(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes 'value') cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) diff --git a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction24.fs.il.net472.release.bsl b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction24.fs.il.net472.release.bsl index ae1c94ba855..06de9742e3f 100644 --- a/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction24.fs.il.net472.release.bsl +++ b/tests/FSharp.Compiler.ComponentTests/EmittedIL/TestFunctions/TestFunction24.fs.il.net472.release.bsl @@ -888,7 +888,7 @@ IL_0006: ret } - .method private hidebysig specialname instance void + .method public hidebysig specialname instance void set_Type(class [runtime]System.Type 'value') cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) @@ -913,7 +913,7 @@ IL_0006: ret } - .method private hidebysig specialname instance void + .method public hidebysig specialname instance void set_MemberType(valuetype System.Diagnostics.CodeAnalysis.DynamicallyAccessedMemberTypes 'value') cil managed { .custom instance void [runtime]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )